X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Ftimespec.h;h=388ddb83a76120814003276f18966a4f7a904faf;hb=ab624c1a8f744419fdb653b77250153a3563203f;hp=74d5749df60e075bdbec4576691259b6e69372c2;hpb=d60f3b0c6b0f93a601acd1cfd3923f94ca05abb0;p=gnulib.git diff --git a/lib/timespec.h b/lib/timespec.h index 74d5749df..388ddb83a 100644 --- a/lib/timespec.h +++ b/lib/timespec.h @@ -1,6 +1,6 @@ /* timespec -- System time interface - Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2011 Free Software + Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -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 *);