Commit | Line | Data |
---|---|---|
10a4cc63 | 1 | /* systime.h - System-dependent definitions for time manipulations. |
ba318903 | 2 | Copyright (C) 1993-1994, 2002-2014 Free Software Foundation, Inc. |
f469625a JB |
3 | |
4 | This file is part of GNU Emacs. | |
5 | ||
b9b1cc14 | 6 | GNU Emacs is free software: you can redistribute it and/or modify |
f469625a | 7 | it under the terms of the GNU General Public License as published by |
b9b1cc14 GM |
8 | the Free Software Foundation, either version 3 of the License, or |
9 | (at your option) any later version. | |
f469625a JB |
10 | |
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. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
b9b1cc14 | 17 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
f469625a | 18 | |
fb1b041d DL |
19 | #ifndef EMACS_SYSTIME_H |
20 | #define EMACS_SYSTIME_H | |
482fa053 | 21 | |
d35af63c | 22 | #include <timespec.h> |
7b89707c | 23 | |
f162bcc3 | 24 | INLINE_HEADER_BEGIN |
f162bcc3 | 25 | |
89d1bd22 PE |
26 | #ifdef emacs |
27 | # ifdef HAVE_X_WINDOWS | |
28 | # include <X11/X.h> | |
29 | # else | |
08dc5ae6 | 30 | typedef unsigned long Time; |
89d1bd22 | 31 | # endif |
08dc5ae6 PE |
32 | #endif |
33 | ||
71068d78 KH |
34 | /* On some configurations (hpux8.0, X11R4), sys/time.h and X11/Xos.h |
35 | disagree about the name of the guard symbol. */ | |
c810639a | 36 | #ifdef HPUX |
71068d78 KH |
37 | #ifdef _STRUCT_TIMEVAL |
38 | #ifndef __TIMEVAL__ | |
39 | #define __TIMEVAL__ | |
40 | #endif | |
41 | #endif | |
c810639a | 42 | #endif |
696056c2 | 43 | |
696056c2 | 44 | #include <sys/time.h> /* for 'struct timeval' */ |
10a4cc63 | 45 | \f |
43aac990 | 46 | /* Emacs uses struct timespec to represent nonnegative temporal intervals. |
e9a9ae03 | 47 | |
43aac990 PE |
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. */ | |
f469625a | 52 | |
43aac990 | 53 | /* Return an invalid timespec. */ |
00382e8b | 54 | INLINE struct timespec |
43aac990 | 55 | invalid_timespec (void) |
e9a9ae03 | 56 | { |
43aac990 | 57 | return make_timespec (0, -1); |
e9a9ae03 | 58 | } |
f469625a | 59 | |
96c06863 | 60 | /* Return true if TIME is a valid timespec. This currently doesn't worry |
43aac990 PE |
61 | about whether tv_nsec is less than TIMESPEC_RESOLUTION; leap seconds |
62 | might cause a problem if it did. */ | |
96c06863 | 63 | INLINE bool |
43aac990 | 64 | timespec_valid_p (struct timespec t) |
e9a9ae03 | 65 | { |
908589fd | 66 | return t.tv_nsec >= 0; |
e9a9ae03 | 67 | } |
722687f5 | 68 | |
43aac990 | 69 | /* Return current system time. */ |
00382e8b | 70 | INLINE struct timespec |
43aac990 | 71 | current_timespec (void) |
e9a9ae03 | 72 | { |
43aac990 PE |
73 | struct timespec r; |
74 | gettime (&r); | |
75 | return r; | |
e9a9ae03 | 76 | } |
f469625a | 77 | |
d35af63c | 78 | /* defined in sysdep.c */ |
43aac990 PE |
79 | extern int set_file_times (int, const char *, struct timespec, struct timespec); |
80 | extern struct timeval make_timeval (struct timespec) ATTRIBUTE_CONST; | |
c53a6701 | 81 | |
43f15d4a | 82 | /* defined in keyboard.c */ |
43aac990 | 83 | extern void set_waiting_for_input (struct timespec *); |
43f15d4a | 84 | |
fa8459a3 DN |
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. */ | |
88 | #ifdef GCPRO1 | |
d35af63c | 89 | /* defined in editfns.c */ |
43aac990 | 90 | extern Lisp_Object make_lisp_time (struct timespec); |
a08d4ba7 | 91 | extern bool decode_time_components (Lisp_Object, Lisp_Object, Lisp_Object, |
43aac990 PE |
92 | Lisp_Object, struct timespec *, double *); |
93 | extern struct timespec lisp_time_argument (Lisp_Object); | |
fa8459a3 DN |
94 | #endif |
95 | ||
f162bcc3 PE |
96 | INLINE_HEADER_END |
97 | ||
fb1b041d | 98 | #endif /* EMACS_SYSTIME_H */ |