Make sure that the correct struct timespec definition (which the pthreads APIs will need) is known before we define our own.
This commit is contained in:
parent
6b6d7cccac
commit
d4c83e5f46
1 changed files with 11 additions and 4 deletions
15
sim_timer.h
15
sim_timer.h
|
@ -31,21 +31,28 @@
|
|||
#ifndef _SIM_TIMER_H_
|
||||
#define _SIM_TIMER_H_ 0
|
||||
|
||||
/* Pick up a struct timespec definition if it is available */
|
||||
#include <time.h>
|
||||
#if defined(SIM_ASYNCH_IO) || defined(USE_READER_THREAD)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#if defined (__APPLE__)
|
||||
#define HAVE_STRUCT_TIMESPEC 1 /* OSX defined the structure but doesn't tell us */
|
||||
#endif
|
||||
|
||||
#ifndef CLOCK_REALTIME
|
||||
#if !defined(CLOCK_REALTIME)
|
||||
#define CLOCK_REALTIME 1
|
||||
#define NEED_CLOCK_GETTIME 1
|
||||
#ifndef HAVE_STRUCT_TIMESPEC
|
||||
#if !defined(HAVE_STRUCT_TIMESPEC)
|
||||
#define HAVE_STRUCT_TIMESPEC 1
|
||||
#if !defined(_TIMESPEC_DEFINED)
|
||||
#define _TIMESPEC_DEFINED
|
||||
struct timespec {
|
||||
long tv_sec;
|
||||
long tv_nsec;
|
||||
long tv_sec;
|
||||
long tv_nsec;
|
||||
};
|
||||
#endif /* _TIMESPEC_DEFINED */
|
||||
#endif /* HAVE_STRUCT_TIMESPEC */
|
||||
int clock_gettime(int clock_id, struct timespec *tp);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue