time_from_tai.c (409B)
1 /* ISC license. */ 2 3 #include <skalibs/sysdeps.h> 4 #include <skalibs/bsdsnowflake.h> 5 #include <time.h> 6 #include <errno.h> 7 #include <skalibs/uint64.h> 8 #include <skalibs/tai.h> 9 10 int time_from_tai (time_t *u, tai const *t) 11 { 12 uint64_t uu = t->x - TAI_MAGIC ; 13 #if SKALIBS_SIZEOFTIME < 8 14 if ((uu >> 32) && (uu >> 32) != 0xffffffffUL) 15 return (errno = EOVERFLOW, 0) ; 16 #endif 17 *u = (time_t)uu ; 18 return 1 ; 19 }