1 /* systime.h - System-dependent definitions for time manipulations.
2 Copyright (C) 1993-1994, 2002-2015 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 #ifndef EMACS_SYSTIME_H
20 #define EMACS_SYSTIME_H
27 # ifdef HAVE_X_WINDOWS
30 typedef unsigned long Time
;
34 /* On some configurations (hpux8.0, X11R4), sys/time.h and X11/Xos.h
35 disagree about the name of the guard symbol. */
37 #ifdef _STRUCT_TIMEVAL
44 #include <sys/time.h> /* for 'struct timeval' */
46 /* Emacs uses struct timespec to represent nonnegative temporal intervals.
48 WARNING: Since tv_sec might be an unsigned value, do not use struct
49 timespec as a general-purpose data type for adding or subtracting
50 arbitrary time values! When computing A + B or A - B, typically A
51 should be an absolute time since the epoch and B a nonnegative offset. */
53 /* Return an invalid timespec. */
54 INLINE
struct timespec
55 invalid_timespec (void)
57 return make_timespec (0, -1);
60 /* Return true if TIME is a valid timespec. This currently doesn't worry
61 about whether tv_nsec is less than TIMESPEC_RESOLUTION; leap seconds
62 might cause a problem if it did. */
64 timespec_valid_p (struct timespec t
)
66 return t
.tv_nsec
>= 0;
69 /* Return current system time. */
70 INLINE
struct timespec
71 current_timespec (void)
78 /* defined in sysdep.c */
79 extern int set_file_times (int, const char *, struct timespec
, struct timespec
);
80 extern struct timeval
make_timeval (struct timespec
) ATTRIBUTE_CONST
;
82 /* defined in keyboard.c */
83 extern void set_waiting_for_input (struct timespec
*);
85 /* When lisp.h is not included Lisp_Object is not defined (this can
86 happen when this files is used outside the src directory).
87 Use GCPRO1 to determine if lisp.h was included. */
90 /* Emacs uses the integer list (HI LO US PS) to represent the time
91 (HI << LO_TIME_BITS) + LO + US / 1e6 + PS / 1e12. */
92 enum { LO_TIME_BITS
= 16 };
94 /* A Lisp time (HI LO US PS), sans the cons cells. */
101 /* defined in editfns.c */
102 extern Lisp_Object
make_lisp_time (struct timespec
);
103 extern int decode_time_components (Lisp_Object
, Lisp_Object
, Lisp_Object
,
104 Lisp_Object
, struct lisp_time
*, double *);
105 extern struct timespec
lisp_to_timespec (struct lisp_time
);
106 extern struct timespec
lisp_time_argument (Lisp_Object
);
114 # define mktime_z emacs_mktime_z
115 # define timezone_t emacs_timezone_t
116 # define tzalloc emacs_tzalloc
117 # define tzfree emacs_tzfree
118 typedef char const *timezone_t
;
119 INLINE timezone_t
tzalloc (char const *name
) { return name
; }
120 INLINE
void tzfree (timezone_t tz
) { }
125 #endif /* EMACS_SYSTIME_H */