I've noticed some discrepancies in timings in our system, and I'm trying to narrow down what could be causing them.I'm reviewing out time abstraction, and as far as I can determine it's fine.Am I missing anything, and is it portable (besides being constrained to POSIX)?typedef struct timespec Time;static inline Time getTime() {    static struct timespec time;    clock_gettime(CLOCK_MONOTONIC, &time);    return time;}static inline __constant Time timeAdd(Time oldTime, Time time) {    if (time.tv_nsec + oldTime.tv_nsec >= 1E9)        return (Time){            tv_sec: time.tv_sec + oldTime.tv_sec + 1,            tv_nsec: time.tv_nsec + oldTime.tv_nsec - 1E9        };    else        return (Time){            tv_sec: time.tv_sec + oldTime.tv_sec,            tv_nsec: time.tv_nsec + oldTime.tv_nsec        };}static inline __constant Time timeDiff(Time oldTime, Time time) {    if (time.tv_nsec < oldTime.tv_nsec)        return (Time){            tv_sec: time.tv_sec - 1 - oldTime.tv_sec,            tv_nsec: 1E9 + time.tv_nsec - oldTime.tv_nsec        };    else        return (Time){            tv_sec: time.tv_sec - oldTime.tv_sec,            tv_nsec: time.tv_nsec - oldTime.tv_nsec        };}static __always_inline __constant double timeSeconds(Time time) {    return time.tv_sec + time.tv_nsec/1E9;}static inline double timeSince(Time oldTime) {    struct timespec time;    clock_gettime(CLOCK_MONOTONIC, &time);    return timeSeconds(timeDiff(oldTime, time));}
Correctness of calculations with struct timespec
c;datetime;linux