changeset 15330:15ab18909697

* lib/timespec.h (timespec_sign): New inline function.
author Paul Eggert <eggert@cs.ucla.edu>
date Thu, 30 Jun 2011 15:04:56 -0700
parents e121c7cef4a9
children d214a85acda4
files ChangeLog lib/timespec.h
diffstat 2 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2011-06-30  Paul Eggert  <eggert@cs.ucla.edu>
 
+	* lib/timespec.h (timespec_sign): New inline function.
+
 	pselect: new module
 	* lib/sys_select.in.h: Include <signal.h>, for 'sigset_t'.
 	(pselect): New decls.
--- a/lib/timespec.h
+++ b/lib/timespec.h
@@ -57,6 +57,14 @@
           : (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;
+}
+
 void gettime (struct timespec *);
 int settime (struct timespec const *);