10 #ifndef PTHREAD_BARRIER_H_ 11 #define PTHREAD_BARRIER_H_ 16 typedef int pthread_barrierattr_t;
19 pthread_mutex_t mutex;
26 int pthread_barrier_init(pthread_barrier_t *barrier,
const pthread_barrierattr_t *attr,
unsigned int count);
28 int pthread_barrier_destroy(pthread_barrier_t *barrier);
30 int pthread_barrier_wait(pthread_barrier_t *barrier);
32 #endif // PTHREAD_BARRIER_H_ 37 #if !defined(CLOCK_REALTIME) && !defined(CLOCK_MONOTONIC) 39 #define CLOCK_REALTIME 0 40 #define CLOCK_MONOTONIC 6 41 typedef int clockid_t;
44 #include <mach/mach_time.h> 47 inline int clock_gettime( clockid_t clk_id,
struct timespec *ts )
52 if ( CLOCK_REALTIME == clk_id )
55 ret = gettimeofday(&tv, NULL);
56 ts->tv_sec = tv.tv_sec;
57 ts->tv_nsec = tv.tv_usec * 1000;
59 else if ( CLOCK_MONOTONIC == clk_id )
61 const uint64_t t = mach_absolute_time();
62 mach_timebase_info_data_t timebase;
63 mach_timebase_info(&timebase);
64 const uint64_t tdiff = t * timebase.numer / timebase.denom;
65 ts->tv_sec = tdiff / 1000000000;
66 ts->tv_nsec = tdiff % 1000000000;
73 #endif // CLOCK_REALTIME and CLOCK_MONOTONIC unsigned __int64 uint64_t