1 2 3 4 5 6 7 8 9 10
#include <time.h> time_t time(time_t *tloc) { struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); if (tloc) { *tloc = ts.tv_sec; } return ts.tv_sec; }