aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2012-07-14 14:32:01 +0300
committerEli Zaretskii2012-07-14 14:32:01 +0300
commitd9bee43796f52653903d065b51b7a9d3152c271c (patch)
tree029c85a9e970bbe83c52fc4bfa72363a6d0fd67a /src
parent5a1131d937c324c070173482a8d7d47e3b3c79b0 (diff)
downloademacs-d9bee43796f52653903d065b51b7a9d3152c271c.tar.gz
emacs-d9bee43796f52653903d065b51b7a9d3152c271c.zip
Improve commentary in src/systime.h.
Diffstat (limited to 'src')
-rw-r--r--src/systime.h22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/systime.h b/src/systime.h
index 24e9a6f4507..29886248527 100644
--- a/src/systime.h
+++ b/src/systime.h
@@ -41,8 +41,9 @@ typedef unsigned long Time;
41 41
42#include <sys/time.h> /* for 'struct timeval' */ 42#include <sys/time.h> /* for 'struct timeval' */
43 43
44/* The type to use to represent temporal intervals. Its address can be passed 44/* The type to use to represent non-negative temporal intervals. Its
45 as the timeout argument to the pselect system call. */ 45 address can be passed as the timeout argument to the pselect system
46 call. */
46typedef struct timespec EMACS_TIME; 47typedef struct timespec EMACS_TIME;
47 48
48/* Resolution of EMACS_TIME time stamps (in units per second), and log 49/* Resolution of EMACS_TIME time stamps (in units per second), and log
@@ -84,7 +85,13 @@ current_emacs_time (void)
84 85
85/* Return the result of adding A to B, or of subtracting B from A. 86/* Return the result of adding A to B, or of subtracting B from A.
86 On overflow, store an extremal value: ergo, if time_t is unsigned, 87 On overflow, store an extremal value: ergo, if time_t is unsigned,
87 return 0 if the true answer would be negative. */ 88 return 0 if the true answer would be negative.
89
90 WARNING: These are NOT general-purpose macros for adding or
91 subtracting arbitrary time values! They are generally intended to
92 be used with their first argument an absolute time since the epoch
93 and the second argument a non-negative offset. Do NOT use them for
94 anything else. */
88static inline EMACS_TIME 95static inline EMACS_TIME
89add_emacs_time (EMACS_TIME a, EMACS_TIME b) 96add_emacs_time (EMACS_TIME a, EMACS_TIME b)
90{ 97{
@@ -96,7 +103,9 @@ sub_emacs_time (EMACS_TIME a, EMACS_TIME b)
96 return timespec_sub (a, b); 103 return timespec_sub (a, b);
97} 104}
98 105
99/* Return the sign of the valid time stamp TIME, either -1, 0, or 1. */ 106/* Return the sign of the valid time stamp TIME, either -1, 0, or 1.
107 Note: this can only return a negative value if time_t is a signed
108 data type. */
100static inline int 109static inline int
101EMACS_TIME_SIGN (EMACS_TIME t) 110EMACS_TIME_SIGN (EMACS_TIME t)
102{ 111{
@@ -111,8 +120,9 @@ EMACS_TIME_VALID_P (EMACS_TIME t)
111} 120}
112 121
113/* Convert the double D to the greatest EMACS_TIME not greater than D. 122/* Convert the double D to the greatest EMACS_TIME not greater than D.
114 On overflow, return an extremal value. Return the minimum 123 On overflow, return an extremal value; in particular, if time_t is
115 EMACS_TIME if D is not a number. */ 124 an unsigned data type and D is negative, return zero. Return the
125 minimum EMACS_TIME if D is not a number. */
116static inline EMACS_TIME 126static inline EMACS_TIME
117EMACS_TIME_FROM_DOUBLE (double d) 127EMACS_TIME_FROM_DOUBLE (double d)
118{ 128{