X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Ftimespec.h;h=acf815c8dbceb7f5bd27d18553a951600f373a51;hb=83d7371a65a6f805956fb34f0321bff6b4dc7955;hp=74d5749df60e075bdbec4576691259b6e69372c2;hpb=d60f3b0c6b0f93a601acd1cfd3923f94ca05abb0;p=gnulib.git diff --git a/lib/timespec.h b/lib/timespec.h index 74d5749df..acf815c8d 100644 --- a/lib/timespec.h +++ b/lib/timespec.h @@ -57,6 +57,25 @@ timespec_cmp (struct timespec a, struct timespec b) : (int) (a.tv_nsec - b.tv_nsec)); } +/* Return -1, 0, 1, depending on the sign of A. A.tv_nsec must be + nonnegative. */ +static inline int +timespec_sign (struct timespec a) +{ + return a.tv_sec < 0 ? -1 : a.tv_sec || a.tv_nsec; +} + +struct timespec timespec_add (struct timespec, struct timespec); +struct timespec timespec_sub (struct timespec, struct timespec); +struct timespec dtotimespec (double); + +/* Return an approximation to A, of type 'double'. */ +static inline double +timespectod (struct timespec a) +{ + return a.tv_sec + a.tv_nsec / 1e9; +} + void gettime (struct timespec *); int settime (struct timespec const *);