-#define EMACS_TIME_RESOLUTION 1000000000
-#define LOG10_EMACS_TIME_RESOLUTION 9
-
-/* EMACS_SECS (TIME) is an rvalue for the seconds component of TIME.
- EMACS_SECS_ADDR (time) is the address of the seconds component.
- EMACS_SET_SECS (TIME, SECONDS) sets that to SECONDS.
-
- EMACS_NSECS (TIME) is an rvalue for the nanoseconds component of TIME.
- EMACS_SET_NSECS (TIME, NANOSECONDS) sets that to NANOSECONDS.
-
- EMACS_SET_SECS_NSECS (TIME, SECS, NSECS) sets both components of TIME. */
-#define EMACS_SECS(time) ((time).tv_sec + 0)
-#define EMACS_NSECS(time) ((time).tv_nsec + 0)
-#define EMACS_SECS_ADDR(time) (&(time).tv_sec)
-#define EMACS_SET_SECS(time, seconds) ((time).tv_sec = (seconds))
-#define EMACS_SET_NSECS(time, ns) ((time).tv_nsec = (ns))
-#define EMACS_SET_SECS_NSECS(time, s, ns) \
- ((void) (EMACS_SET_SECS (time, s), EMACS_SET_NSECS (time, ns)))
-
-/* Convenience macros for older code that counts microseconds. */
-#define EMACS_SET_USECS(time, us) ((void) EMACS_SET_NSECS (time, (us) * 1000))
-#define EMACS_SET_SECS_USECS(time, secs, usecs) \
- (EMACS_SET_SECS (time, secs), EMACS_SET_USECS (time, usecs))
-
-/* Set TIME to an invalid time stamp. */
-#define EMACS_SET_INVALID_TIME(time) EMACS_SET_SECS_NSECS(time, 0, -1)
-
-/* Set TIME to the current system time. */
-#define EMACS_GET_TIME(time) gettime (&(time))
-
-/* Put into DEST the result of adding SRC1 to SRC2, or of subtracting
- SRC2 from SRC1. On overflow, store an extremal value. */
-#define EMACS_ADD_TIME(dest, src1, src2) ((dest) = timespec_add (src1, src2))
-#define EMACS_SUB_TIME(dest, src1, src2) ((dest) = timespec_sub (src1, src2))
-
-/* Return the sign of the valid time stamp TIME, either -1, 0, or 1. */
-#define EMACS_TIME_SIGN(time) timespec_sign (time)
+enum { EMACS_TIME_RESOLUTION = 1000000000 };
+enum { LOG10_EMACS_TIME_RESOLUTION = 9 };
+
+/* EMACS_SECS (TIME) is the seconds component of TIME.
+ EMACS_NSECS (TIME) is the nanoseconds component of TIME.
+ emacs_secs_addr (PTIME) is the address of *PTIME's seconds component. */
+SYSTIME_INLINE time_t EMACS_SECS (EMACS_TIME t) { return t.tv_sec; }
+SYSTIME_INLINE int EMACS_NSECS (EMACS_TIME t) { return t.tv_nsec; }
+SYSTIME_INLINE time_t *emacs_secs_addr (EMACS_TIME *t) { return &t->tv_sec; }
+
+/* Return an Emacs time with seconds S and nanoseconds NS. */
+SYSTIME_INLINE EMACS_TIME
+make_emacs_time (time_t s, int ns)
+{
+ EMACS_TIME r = { s, ns };
+ return r;
+}
+
+/* Return an invalid Emacs time. */
+SYSTIME_INLINE EMACS_TIME
+invalid_emacs_time (void)
+{
+ EMACS_TIME r = { 0, -1 };
+ return r;
+}
+
+/* Return current system time. */
+SYSTIME_INLINE EMACS_TIME
+current_emacs_time (void)
+{
+ EMACS_TIME r;
+ gettime (&r);
+ return r;
+}
+
+/* Return the result of adding A to B, or of subtracting B from A.
+ On overflow, store an extremal value: ergo, if time_t is unsigned,
+ return 0 if the true answer would be negative.
+
+ WARNING: These are NOT general-purpose macros for adding or
+ subtracting arbitrary time values! They are generally intended to
+ be used with their first argument an absolute time since the epoch
+ and the second argument a non-negative offset. Do NOT use them for
+ anything else. */
+SYSTIME_INLINE EMACS_TIME
+add_emacs_time (EMACS_TIME a, EMACS_TIME b)
+{
+ return timespec_add (a, b);
+}
+SYSTIME_INLINE EMACS_TIME
+sub_emacs_time (EMACS_TIME a, EMACS_TIME b)
+{
+ return timespec_sub (a, b);
+}
+
+/* Return the sign of the valid time stamp TIME, either -1, 0, or 1.
+ Note: this can only return a negative value if time_t is a signed
+ data type. */
+SYSTIME_INLINE int
+EMACS_TIME_SIGN (EMACS_TIME t)
+{
+ return timespec_sign (t);
+}