Fequal_including_properties fix
[bpt/emacs.git] / src / systime.h
... / ...
CommitLineData
1/* systime.h - System-dependent definitions for time manipulations.
2 Copyright (C) 1993-1994, 2002-2014 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
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
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18
19#ifndef EMACS_SYSTIME_H
20#define EMACS_SYSTIME_H
21
22#include <timespec.h>
23
24INLINE_HEADER_BEGIN
25
26#ifdef emacs
27# ifdef HAVE_X_WINDOWS
28# include <X11/X.h>
29# else
30typedef unsigned long Time;
31# endif
32#endif
33
34/* On some configurations (hpux8.0, X11R4), sys/time.h and X11/Xos.h
35 disagree about the name of the guard symbol. */
36#ifdef HPUX
37#ifdef _STRUCT_TIMEVAL
38#ifndef __TIMEVAL__
39#define __TIMEVAL__
40#endif
41#endif
42#endif
43
44#include <sys/time.h> /* for 'struct timeval' */
45\f
46/* Emacs uses struct timespec to represent nonnegative temporal intervals.
47
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. */
52
53/* Return an invalid timespec. */
54INLINE struct timespec
55invalid_timespec (void)
56{
57 return make_timespec (0, -1);
58}
59
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. */
63INLINE bool
64timespec_valid_p (struct timespec t)
65{
66 return t.tv_nsec >= 0;
67}
68
69/* Return current system time. */
70INLINE struct timespec
71current_timespec (void)
72{
73 struct timespec r;
74 gettime (&r);
75 return r;
76}
77
78/* defined in sysdep.c */
79extern int set_file_times (int, const char *, struct timespec, struct timespec);
80extern struct timeval make_timeval (struct timespec) ATTRIBUTE_CONST;
81
82/* defined in keyboard.c */
83extern void set_waiting_for_input (struct timespec *);
84
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
89/* defined in editfns.c */
90extern Lisp_Object make_lisp_time (struct timespec);
91extern bool decode_time_components (Lisp_Object, Lisp_Object, Lisp_Object,
92 Lisp_Object, struct timespec *, double *);
93extern struct timespec lisp_time_argument (Lisp_Object);
94#endif
95
96INLINE_HEADER_END
97
98#endif /* EMACS_SYSTIME_H */