Commit in projects/lcdd/trunk/include/lcdd/util on MAIN | |||
TimerUtil.hh | +20 | 3129 -> 3130 |
- patch for missing clock_gettime() on MacOS
--- projects/lcdd/trunk/include/lcdd/util/TimerUtil.hh 2014-05-19 23:17:26 UTC (rev 3129) +++ projects/lcdd/trunk/include/lcdd/util/TimerUtil.hh 2014-05-20 07:11:11 UTC (rev 3130) @@ -3,6 +3,26 @@
#include <sys/time.h>
+// clock_gettime is not defined on MacOS +#ifdef __MACH__ +#include <mach/mach_time.h> +#define CLOCK_REALTIME 0 +#define CLOCK_MONOTONIC 0 +int clock_gettime(int clk_id, struct timespec *t){ + mach_timebase_info_data_t timebase; + mach_timebase_info(&timebase); + uint64_t time; + time = mach_absolute_time(); + double nseconds = ((double)time * (double)timebase.numer)/((double)timebase.denom); + double seconds = ((double)time * (double)timebase.numer)/((double)timebase.denom * 1e9); + t->tv_sec = seconds; + t->tv_nsec = nseconds; + return 0; +} +#endif + + +
#include <string> #include <map> #include <iostream>
Use REPLY-ALL to reply to list
To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1