8 #if defined(__GNUC__) && defined(__GNUC_MINOR__)
9 #define GCC_VERSION_AT_LEAST(major, minor) \
10 ((__GNUC__ > (major)) || \
11 (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
13 #define GCC_VERSION_AT_LEAST(major, minor) 0
16 #if GCC_VERSION_AT_LEAST(2,95)
17 #define CK_ATTRIBUTE_UNUSED __attribute__ ((unused))
19 #define CK_ATTRIBUTE_UNUSED
22 #if GCC_VERSION_AT_LEAST(2,5)
23 #define CK_ATTRIBUTE_NORETURN __attribute__ ((noreturn))
25 #define CK_ATTRIBUTE_NORETURN
29 * Used for MSVC to create the export attribute
30 * CK_DLL_EXP is defined during the compilation of the library
31 * on the command line.
38 #include <WinSock2.h> /* struct timeval, API used in gettimeofday implementation */
39 #include <io.h> /* read, write */
40 #include <process.h> /* getpid */
44 #include <sys/types.h>
55 /* provides localtime and struct tm */
56 #ifdef HAVE_SYS_TIME_H
58 #endif /* !HAVE_SYS_TIME_H */
61 /* declares fork(), _POSIX_VERSION. according to Autoconf.info,
62 unistd.h defines _POSIX_VERSION if the system is POSIX-compliant,
63 so we will use this as a test for all things uniquely provided by
64 POSIX like sigaction() and fork() */
69 #ifdef HAVE_SYS_WAIT_H
73 /* declares pthread_create and friends */
82 /* replacement functions for broken originals */
84 CK_DLL_EXP unsigned int alarm (unsigned int seconds);
85 #endif /* !HAVE_DECL_ALARM */
87 #if !HAVE_GETPID && HAVE__GETPID
88 #define getpid _getpid
89 #endif /* !HAVE_GETPID && HAVE__GETPID */
91 #if !HAVE_DECL_LOCALTIME_R
92 #if !defined(localtime_r)
93 CK_DLL_EXP struct tm *localtime_r (const time_t * clock, struct tm *result);
95 #endif /* !HAVE_DECL_LOCALTIME_R */
97 #if !HAVE_DECL_STRDUP && !HAVE__STRDUP
98 CK_DLL_EXP char *strdup (const char *str);
99 #elif !HAVE_DECL_STRDUP && HAVE__STRDUP
100 #define strdup _strdup
101 #endif /* !HAVE_DECL_STRDUP && HAVE__STRDUP */
103 #if !HAVE_DECL_STRSIGNAL
104 CK_DLL_EXP char *strsignal (int sig);
105 #endif /* !HAVE_DECL_STRSIGNAL */
108 * On systems where clock_gettime() is not available, or
109 * on systems where some clocks may not be supported, the
110 * definition for CLOCK_MONOTONIC and CLOCK_REALTIME may not
111 * be available. These should define which type of clock
112 * clock_gettime() should use. We define it here if it is
113 * not defined simply so the reimplementation can ignore it.
115 * We set the values of these clocks to some (hopefully)
116 * invalid value, to avoid the case where we define a
117 * clock with a valid value, and unintentionally use
118 * an actual good clock by accident.
120 #ifndef CLOCK_MONOTONIC
121 #define CLOCK_MONOTONIC -1
123 #ifndef CLOCK_REALTIME
124 #define CLOCK_REALTIME -1
129 #ifdef STRUCT_TIMESPEC_DEFINITION_MISSING
131 * The following structure is defined in POSIX 1003.1 for times
132 * specified in seconds and nanoseconds. If it is not defined in
133 * time.g, then we need to define it here
140 #endif /* STRUCT_TIMESPEC_DEFINITION_MISSING */
142 #ifdef STRUCT_ITIMERSPEC_DEFINITION_MISSING
144 * The following structure is defined in POSIX.1b for timer start values and intervals.
145 * If it is not defined in time.h, then we need to define it here.
149 struct timespec it_interval;
150 struct timespec it_value;
152 #endif /* STRUCT_ITIMERSPEC_DEFINITION_MISSING */
155 * Do a simple forward declaration in case the struct is not defined.
156 * In the versions of timer_create in libcompat, sigevent is never
161 #ifndef HAVE_CLOCK_GETTIME
162 CK_DLL_EXP int clock_gettime (clockid_t clk_id, struct timespec *ts);
164 CK_DLL_EXP int timer_create (clockid_t clockid, struct sigevent *sevp,
166 CK_DLL_EXP int timer_settime (timer_t timerid, int flags,
167 const struct itimerspec *new_value, struct itimerspec *old_value);
168 CK_DLL_EXP int timer_delete (timer_t timerid);
169 #endif /* HAVE_LIBRT */
171 /* silence warnings about an empty library */
174 CK_ATTRIBUTE_NORETURN;
176 #endif /* !LIBCOMPAT_H */