Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <time.h>
  2. #include <sys/time.h>
  3.  
  4. #ifdef __MACH__
  5. #include <mach/clock.h>
  6. #include <mach/mach.h>
  7. #endif
  8.  
  9.  
  10.  
  11. struct timespec ts;
  12.  
  13. #ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
  14. clock_serv_t cclock;
  15. mach_timespec_t mts;
  16. host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
  17. clock_get_time(cclock, &mts);
  18. mach_port_deallocate(mach_task_self(), cclock);
  19. ts.tv_sec = mts.tv_sec;
  20. ts.tv_nsec = mts.tv_nsec;
  21.  
  22. #else
  23. clock_gettime(CLOCK_REALTIME, &ts);
  24. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement