Build fix: missing unistd.h include in utils.h
[lttng-tools.git] / tests / utils / utils.h
1 /*
2 * Copyright (C) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #ifndef TEST_UTILS_H
9 #define TEST_UTILS_H
10
11 #include <unistd.h>
12
13 #if defined(__cplusplus)
14 extern "C" {
15 #endif
16
17 #if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
18
19 /*
20 * Version using XSI strerror_r.
21 */
22 #define PERROR_NO_LOGGER(msg, args...) \
23 do { \
24 char _perror_buf[200]; \
25 strerror_r(errno, _perror_buf, sizeof(_perror_buf)); \
26 fprintf(stderr, msg ": %s\n", ##args, _perror_buf); \
27 } while (0);
28 #else
29 /*
30 * Version using GNU strerror_r, for linux with appropriate defines.
31 */
32 #define PERROR_NO_LOGGER(msg, args...) \
33 do { \
34 char *_perror_buf; \
35 char _perror_tmp[200]; \
36 _perror_buf = strerror_r( \
37 errno, _perror_tmp, sizeof(_perror_tmp)); \
38 fprintf(stderr, msg ": %s\n", ##args, _perror_buf); \
39 } while (0);
40 #endif
41
42 int usleep_safe(useconds_t usec);
43 int create_file(const char *path);
44 int wait_on_file(const char *path);
45
46 #if defined(__cplusplus)
47 }
48 #endif
49
50 #endif /* TEST_UTILS_H */
This page took 0.029367 seconds and 4 git commands to generate.