bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] timespec: new convenience constants and function


From: Paul Eggert
Subject: [PATCH] timespec: new convenience constants and function
Date: Tue, 27 Aug 2013 11:08:31 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

* 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  <address@hidden>
+
+       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  <address@hidden>
 
        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

[Prev in Thread] Current Thread [Next in Thread]