A small C library for nanosecond precise, cross platform timestamps
Include nanotime.h to use
#include <nanotime.h>Get current UNIX timestamp as a long double with nanotime precision.
long double timestamp;
if (NANO_UNEXPECTED(nano_time(×tamp)) {
// Error handling
}
printf("Current time: %f\n", timestamp);Get current nanosecond as an unsigned long.
unsigned long sec;
if (NANO_UNEXPECTED(nano_second(&sec)) {
// Error handling
}
printf("Current time: %Ld\n", sec);