1
0

nanoseconds.c 341 B

123456789101112
  1. #include <time.h>
  2. #include "nanoseconds.h"
  3. /* XXX: Y2036 problems; should upgrade to a 128-bit type for this */
  4. /* XXX: nanosecond granularity limits users to 1 terabyte per second */
  5. long long nanoseconds(void)
  6. {
  7. struct timespec t;
  8. if (clock_gettime(CLOCK_REALTIME,&t) != 0) return -1;
  9. return t.tv_sec * 1000000000LL + t.tv_nsec;
  10. }