npth-0.90 build report
Werner Koch
wk at gnupg.org
Sat May 12 10:19:53 CEST 2012
On Fri, 11 May 2012 21:38, lists at openorbit.org said:
> I decided to publish some code I wrote earlier at github. It
> implements clock_gettime for OS X / darwin. I kindly offer it using a
> dual GPL v2 or LGPL v3 or later license. This may be interesting for
Thanks for that offer. However, I already implemented it using
gettimeofday:
int
npth_clock_gettime (struct timespec *ts)
{
#if defined(CLOCK_REALTIME) && HAVE_CLOCK_GETTIME
return clock_gettime (CLOCK_REALTIME, ts);
#elif HAVE_GETTIMEOFDAY
{
struct timeval tv;
if (gettimeofday (&tv, NULL))
return -1;
ts->tv_sec = tv.tv_sec;
ts->tv_nsec = tv.tv_usec * 1000;
return 0;
}
#else
/* FIXME: fall back on time() with seconds resolution. */
# error clock_gettime not available - please provide a fallback.
#endif
}
The gotcha was that HAVE_CLOCK_GETTIME alone was not sufficient, a test
for the CLOCK_REALTIME macro was also required. It would be better to
do the test for CLOCK_REALTIME while testing for clock_gettime, but
well, this was easier.
Salam-Shalom,
Werner
--
Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz.
More information about the Gnupg-devel
mailing list