|
| 1 | +#ifndef LJACK_ASYNC_DEFINES_H |
| 2 | +#define LJACK_ASYNC_DEFINES_H |
| 3 | + |
| 4 | +/* -------------------------------------------------------------------------------------------- */ |
| 5 | + |
| 6 | +#if defined(LJACK_ASYNC_USE_WIN32) \ |
| 7 | + && ( defined(LJACK_ASYNC_USE_STDATOMIC) \ |
| 8 | + || defined(LJACK_ASYNC_USE_GNU)) |
| 9 | + #error "LJACK_ASYNC: Invalid compile flag combination" |
| 10 | +#endif |
| 11 | +#if defined(LJACK_ASYNC_USE_STDATOMIC) \ |
| 12 | + && ( defined(LJACK_ASYNC_USE_WIN32) \ |
| 13 | + || defined(LJACK_ASYNC_USE_GNU)) |
| 14 | + #error "LJACK_ASYNC: Invalid compile flag combination" |
| 15 | +#endif |
| 16 | +#if defined(LJACK_ASYNC_USE_GNU) \ |
| 17 | + && ( defined(LJACK_ASYNC_USE_WIN32) \ |
| 18 | + || defined(LJACK_ASYNC_USE_STDATOMIC)) |
| 19 | + #error "LJACK_ASYNC: Invalid compile flag combination" |
| 20 | +#endif |
| 21 | + |
| 22 | +/* -------------------------------------------------------------------------------------------- */ |
| 23 | + |
| 24 | +#if !defined(LJACK_ASYNC_USE_WIN32) \ |
| 25 | + && !defined(LJACK_ASYNC_USE_STDATOMIC) \ |
| 26 | + && !defined(LJACK_ASYNC_USE_GNU) |
| 27 | + |
| 28 | + #if defined(WIN32) || defined(_WIN32) |
| 29 | + #define LJACK_ASYNC_USE_WIN32 |
| 30 | + #elif defined(__GNUC__) |
| 31 | + #define LJACK_ASYNC_USE_GNU |
| 32 | + #elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__) |
| 33 | + #define LJACK_ASYNC_USE_STDATOMIC |
| 34 | + #else |
| 35 | + #error "LJACK_ASYNC: unknown platform" |
| 36 | + #endif |
| 37 | +#endif |
| 38 | + |
| 39 | +/* -------------------------------------------------------------------------------------------- */ |
| 40 | + |
| 41 | +#if defined(__unix__) || defined(__unix) || (defined (__APPLE__) && defined (__MACH__)) |
| 42 | + #include <unistd.h> |
| 43 | +#endif |
| 44 | + |
| 45 | +#if !defined(LJACK_ASYNC_USE_WINTHREAD) \ |
| 46 | + && !defined(LJACK_ASYNC_USE_PTHREAD) \ |
| 47 | + && !defined(LJACK_ASYNC_USE_STDTHREAD) |
| 48 | + |
| 49 | + #ifdef LJACK_ASYNC_USE_WIN32 |
| 50 | + #define LJACK_ASYNC_USE_WINTHREAD |
| 51 | + #elif _XOPEN_VERSION >= 600 |
| 52 | + #define LJACK_ASYNC_USE_PTHREAD |
| 53 | + #elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__) |
| 54 | + #define LJACK_ASYNC_USE_STDTHREAD |
| 55 | + #else |
| 56 | + #define LJACK_ASYNC_USE_PTHREAD |
| 57 | + #endif |
| 58 | +#endif |
| 59 | + |
| 60 | +/* -------------------------------------------------------------------------------------------- */ |
| 61 | + |
| 62 | +#if defined(LJACK_ASYNC_USE_PTHREAD) |
| 63 | + #ifndef _XOPEN_SOURCE |
| 64 | + #define _XOPEN_SOURCE 600 /* must be defined before any other include */ |
| 65 | + #endif |
| 66 | + #include <errno.h> |
| 67 | + #include <sys/time.h> |
| 68 | + #include <pthread.h> |
| 69 | +#endif |
| 70 | +#if defined(LJACK_ASYNC_USE_WIN32) || defined(LJACK_ASYNC_USE_WINTHREAD) |
| 71 | + #include <windows.h> |
| 72 | +#endif |
| 73 | +#if defined(LJACK_ASYNC_USE_STDATOMIC) |
| 74 | + #include <stdint.h> |
| 75 | + #include <stdatomic.h> |
| 76 | +#endif |
| 77 | +#if defined(LJACK_ASYNC_USE_STDTHREAD) |
| 78 | + #include <sys/time.h> |
| 79 | + #include <threads.h> |
| 80 | +#endif |
| 81 | + |
| 82 | +/* -------------------------------------------------------------------------------------------- */ |
| 83 | + |
| 84 | +#if __STDC_VERSION__ >= 199901L |
| 85 | + #include <stdbool.h> |
| 86 | +#else |
| 87 | + #if !defined(__GNUC__) || defined(__STRICT_ANSI__) |
| 88 | + #define inline |
| 89 | + #endif |
| 90 | + #define bool int |
| 91 | + #define true 1 |
| 92 | + #define false 0 |
| 93 | +#endif |
| 94 | + |
| 95 | +/* -------------------------------------------------------------------------------------------- */ |
| 96 | + |
| 97 | + |
| 98 | +#endif /* LJACK_ASYNC_DEFINES_H */ |
0 commit comments