* lib/timespec.h (TIMESPEC_RESOLUTION, LOG10_TIMESPEC_RESOLUTION):
New constants.
(make_timespec): New function.
---
 ChangeLog      |  7 +++++++
 lib/timespec.h | 17 +++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 31dc201..ccf650b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-08-27  Paul Eggert  <egg...@cs.ucla.edu>
+
+       timespec: new convenience constants and function
+       * lib/timespec.h (TIMESPEC_RESOLUTION, LOG10_TIMESPEC_RESOLUTION):
+       New constants.
+       (make_timespec): New function.
+
 2013-08-26  Simon Josefsson  <si...@josefsson.org>
 
        gc: support HMAC-SHA256 and HMAC-SHA512.
diff --git a/lib/timespec.h b/lib/timespec.h
index d665e6c..c7450ad 100644
--- a/lib/timespec.h
+++ b/lib/timespec.h
@@ -26,6 +26,23 @@ _GL_INLINE_HEADER_BEGIN
 # define _GL_TIMESPEC_INLINE _GL_INLINE
 #endif
 
+/* Resolution of timespec time stamps (in units per second), and log
+   base 10 of the resolution.  */
+
+enum { TIMESPEC_RESOLUTION = 1000000000 };
+enum { LOG10_TIMESPEC_RESOLUTION = 9 };
+
+/* Return a timespec with seconds S and nanoseconds NS.  */
+
+_GL_TIMESPEC_INLINE struct timespec
+make_timespec (time_t s, long int ns)
+{
+  struct timespec r;
+  r.tv_sec = s;
+  r.tv_nsec = ns;
+  return r;
+}
+
 /* Return negative, zero, positive if A < B, A == B, A > B, respectively.
 
    For each time stamp T, this code assumes that either:
-- 
1.7.11.7


Reply via email to