Unify FRAME_window_system_DISPLAY_INFO macros between all ports.
[bpt/emacs.git] / src / systime.h
CommitLineData
10a4cc63 1/* systime.h - System-dependent definitions for time manipulations.
ab422c4d 2 Copyright (C) 1993-1994, 2002-2013 Free Software Foundation, Inc.
f469625a
JB
3
4This file is part of GNU Emacs.
5
b9b1cc14 6GNU Emacs is free software: you can redistribute it and/or modify
f469625a 7it under the terms of the GNU General Public License as published by
b9b1cc14
GM
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
f469625a
JB
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
b9b1cc14 17along 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
PE
24INLINE_HEADER_BEGIN
25#ifndef SYSTIME_INLINE
26# define SYSTIME_INLINE INLINE
27#endif
28
89d1bd22
PE
29#ifdef emacs
30# ifdef HAVE_X_WINDOWS
31# include <X11/X.h>
32# else
08dc5ae6 33typedef unsigned long Time;
89d1bd22 34# endif
08dc5ae6
PE
35#endif
36
71068d78
KH
37/* On some configurations (hpux8.0, X11R4), sys/time.h and X11/Xos.h
38 disagree about the name of the guard symbol. */
c810639a 39#ifdef HPUX
71068d78
KH
40#ifdef _STRUCT_TIMEVAL
41#ifndef __TIMEVAL__
42#define __TIMEVAL__
43#endif
44#endif
c810639a 45#endif
696056c2 46
696056c2 47#include <sys/time.h> /* for 'struct timeval' */
10a4cc63 48\f
43aac990 49/* Emacs uses struct timespec to represent nonnegative temporal intervals.
e9a9ae03 50
43aac990
PE
51 WARNING: Since tv_sec might be an unsigned value, do not use struct
52 timespec as a general-purpose data type for adding or subtracting
53 arbitrary time values! When computing A + B or A - B, typically A
54 should be an absolute time since the epoch and B a nonnegative offset. */
f469625a 55
43aac990
PE
56/* Return an invalid timespec. */
57SYSTIME_INLINE struct timespec
58invalid_timespec (void)
e9a9ae03 59{
43aac990 60 return make_timespec (0, -1);
e9a9ae03 61}
f469625a 62
43aac990
PE
63/* Return 1 if TIME is a valid timespec. This currently doesn't worry
64 about whether tv_nsec is less than TIMESPEC_RESOLUTION; leap seconds
65 might cause a problem if it did. */
f162bcc3 66SYSTIME_INLINE int
43aac990 67timespec_valid_p (struct timespec t)
e9a9ae03 68{
908589fd 69 return t.tv_nsec >= 0;
e9a9ae03 70}
722687f5 71
43aac990
PE
72/* Return current system time. */
73SYSTIME_INLINE struct timespec
74current_timespec (void)
e9a9ae03 75{
43aac990
PE
76 struct timespec r;
77 gettime (&r);
78 return r;
e9a9ae03 79}
f469625a 80
d35af63c 81/* defined in sysdep.c */
43aac990
PE
82extern int set_file_times (int, const char *, struct timespec, struct timespec);
83extern struct timeval make_timeval (struct timespec) ATTRIBUTE_CONST;
c53a6701 84
43f15d4a 85/* defined in keyboard.c */
43aac990 86extern void set_waiting_for_input (struct timespec *);
43f15d4a 87
fa8459a3
DN
88/* When lisp.h is not included Lisp_Object is not defined (this can
89 happen when this files is used outside the src directory).
90 Use GCPRO1 to determine if lisp.h was included. */
91#ifdef GCPRO1
d35af63c 92/* defined in editfns.c */
43aac990 93extern Lisp_Object make_lisp_time (struct timespec);
a08d4ba7 94extern bool decode_time_components (Lisp_Object, Lisp_Object, Lisp_Object,
43aac990
PE
95 Lisp_Object, struct timespec *, double *);
96extern struct timespec lisp_time_argument (Lisp_Object);
fa8459a3
DN
97#endif
98
f162bcc3
PE
99INLINE_HEADER_END
100
fb1b041d 101#endif /* EMACS_SYSTIME_H */