From d4c83e5f46e07619c2bbe7e975f05999d9da7832 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Fri, 13 Jan 2012 15:32:51 -0800 Subject: [PATCH] Make sure that the correct struct timespec definition (which the pthreads APIs will need) is known before we define our own. --- sim_timer.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sim_timer.h b/sim_timer.h index 56896f92..f628b2fd 100644 --- a/sim_timer.h +++ b/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 +#if defined(SIM_ASYNCH_IO) || defined(USE_READER_THREAD) +#include +#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