annotate src/systime.h @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents 677f6a0ee643
children fbbf69b4e8a7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* systime.h - System-dependent definitions for time manipulations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 /* Synched up with: FSF 19.30. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 #ifndef _XEMACS_SYSTIME_H_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 #define _XEMACS_SYSTIME_H_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #ifdef TIME_WITH_SYS_TIME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 #include <sys/time.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include <time.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #ifdef HAVE_SYS_TIME_H
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include <sys/time.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include <time.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 0
diff changeset
37 #if defined(WINDOWSNT) && defined(HAVE_X_WINDOWS)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 0
diff changeset
38 /* Provides gettimeofday etc */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 0
diff changeset
39 #include <X11/Xw32defs.h>
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 0
diff changeset
40 #include <X11/Xos.h>
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 0
diff changeset
41 #endif
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 0
diff changeset
42
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 #ifdef HAVE_UTIME_H
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 # include <utime.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 #ifdef HAVE_TZNAME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 #ifndef tzname /* For SGI. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 extern char *tzname[]; /* RS6000 and others want it this way. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 /* On some configurations (hpux8.0, X11R4), sys/time.h and X11/Xos.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 disagree about the name of the guard symbol. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 #ifdef HPUX
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 #ifdef _STRUCT_TIMEVAL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 #ifndef __TIMEVAL__
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 #define __TIMEVAL__
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 /* EMACS_TIME is the type to use to represent temporal intervals.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 At one point this was 'struct timeval' on some systems, int on others.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 But this is stupid. Other things than select() code like to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 manipulate time values, and so microsecond precision should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 maintained. Separate typedefs and conversion functions are provided
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 for select().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 EMACS_SECS (TIME) is an rvalue for the seconds component of TIME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 EMACS_SET_SECS (TIME, SECONDS) sets that to SECONDS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 EMACS_USECS (TIME) is an rvalue for the microseconds component of TIME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 EMACS_SET_USECS (TIME, MICROSECONDS) sets that to MICROSECONDS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 Note that all times are returned in "normalized" format (i.e. the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 usecs value is in the range 0 <= value < 1000000) and are assumed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 to be passed in in this format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 EMACS_SET_SECS_USECS (TIME, SECS, USECS) sets both components of TIME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 EMACS_GET_TIME (TIME) stores the current system time in TIME, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 should be an lvalue.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 set_file_times (PATH, ATIME, MTIME) changes the last-access and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 last-modification times of the file named PATH to ATIME and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 MTIME, which are EMACS_TIMEs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 EMACS_NORMALIZE_TIME (TIME) coerces TIME into normalized format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 EMACS_ADD_TIME (DEST, SRC1, SRC2) adds SRC1 to SRC2 and stores the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 result in DEST. Either or both may be negative.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 EMACS_SUB_TIME (DEST, SRC1, SRC2) subtracts SRC2 from SRC1 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 stores the result in DEST. Either or both may be negative.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 EMACS_TIME_NEG_P (TIME) is true iff TIME is negative.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 EMACS_TIME_EQUAL (TIME1, TIME2) is true iff TIME1 is the same as TIME2.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 EMACS_TIME_GREATER (TIME1, TIME2) is true iff TIME1 is greater than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 TIME2.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 EMACS_TIME_EQUAL_OR_GREATER (TIME1, TIME2) is true iff TIME1 is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 greater than or equal to TIME2.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 #ifdef HAVE_TIMEVAL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 #define EMACS_SELECT_TIME struct timeval
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 #define EMACS_TIME_TO_SELECT_TIME(time, select_time) ((select_time) = (time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 #else /* not HAVE_TIMEVAL */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 struct timeval
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 long tv_sec; /* seconds */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 long tv_usec; /* microseconds */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 #define EMACS_SELECT_TIME int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 #define EMACS_TIME_TO_SELECT_TIME(time, select_time) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 EMACS_TIME_TO_INT (time, select_time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 #endif /* not HAVE_TIMEVAL */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 #define EMACS_TIME_TO_INT(time, intvar) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 EMACS_TIME tmptime = time; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 if (tmptime.tv_usec > 0) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (intvar) = tmptime.tv_sec + 1; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 else \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (intvar) = tmptime.tv_sec; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 #define EMACS_TIME struct timeval
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 #define EMACS_SECS(time) ((time).tv_sec + 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 #define EMACS_USECS(time) ((time).tv_usec + 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 #define EMACS_SET_SECS(time, seconds) ((time).tv_sec = (seconds))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 #define EMACS_SET_USECS(time, microseconds) ((time).tv_usec = (microseconds))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 #if !defined (HAVE_GETTIMEOFDAY)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 struct timezone;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
144 int gettimeofday (struct timeval *, struct timezone *);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 /* On SVR4, the compiler may complain if given this extra BSD arg. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 #ifdef GETTIMEOFDAY_ONE_ARGUMENT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 # ifdef SOLARIS2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 /* Solaris (at least) omits this prototype. IRIX5 has it and chokes if we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 declare it here. */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
152 int gettimeofday (struct timeval *);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 # endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 /* According to the Xt sources, some NTP daemons on some systems may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 return non-normalized values. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 #define EMACS_GET_TIME(time) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 gettimeofday (&(time)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 EMACS_NORMALIZE_TIME (time); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 #else /* not GETTIMEOFDAY_ONE_ARGUMENT */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 # ifdef SOLARIS2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 /* Solaris doesn't provide any prototype of this unless a bunch of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 crap we don't define are defined. */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
165 int gettimeofday (struct timeval *, void *dummy);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 # endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 #define EMACS_GET_TIME(time) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 struct timezone dummy; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 gettimeofday (&(time), &dummy); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 EMACS_NORMALIZE_TIME (time); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 #endif /* not GETTIMEOFDAY_ONE_ARGUMENT */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 #define EMACS_NORMALIZE_TIME(time) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 while ((time).tv_usec >= 1000000) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (time).tv_usec -= 1000000; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (time).tv_sec++; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 while ((time).tv_usec < 0) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (time).tv_usec += 1000000; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (time).tv_sec--; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 #define EMACS_ADD_TIME(dest, src1, src2) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (dest).tv_sec = (src1).tv_sec + (src2).tv_sec; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (dest).tv_usec = (src1).tv_usec + (src2).tv_usec; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 EMACS_NORMALIZE_TIME (dest); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 #define EMACS_SUB_TIME(dest, src1, src2) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (dest).tv_sec = (src1).tv_sec - (src2).tv_sec; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (dest).tv_usec = (src1).tv_usec - (src2).tv_usec; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 EMACS_NORMALIZE_TIME (dest); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 #define EMACS_TIME_NEG_P(time) ((long)(time).tv_sec < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 #define EMACS_TIME_EQUAL(time1, time2) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ((time1).tv_sec == (time2).tv_sec && \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (time1).tv_usec == (time2).tv_usec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 #define EMACS_TIME_GREATER(time1, time2) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ((time1).tv_sec > (time2).tv_sec || \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ((time1).tv_sec == (time2).tv_sec && \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (time1).tv_usec > (time2).tv_usec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 #define EMACS_TIME_EQUAL_OR_GREATER(time1, time2) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ((time1).tv_sec > (time2).tv_sec || \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ((time1).tv_sec == (time2).tv_sec && \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (time1).tv_usec >= (time2).tv_usec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 #define EMACS_SET_SECS_USECS(time, secs, usecs) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (EMACS_SET_SECS (time, secs), EMACS_SET_USECS (time, usecs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
222 int set_file_times (char *filename, EMACS_TIME atime, EMACS_TIME mtime);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
224 void get_process_times (double *user_time, double *system_time,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 251
diff changeset
225 double *real_time);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 223
diff changeset
227 #if defined(WINDOWSNT) || defined(BROKEN_CYGWIN)
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 213
diff changeset
228
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 213
diff changeset
229 /* setitimer emulation for Win32 (see nt.c) */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 213
diff changeset
230
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 213
diff changeset
231 struct itimerval
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 213
diff changeset
232 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 213
diff changeset
233 struct timeval it_value;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 213
diff changeset
234 struct timeval it_interval;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 213
diff changeset
235 };
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 213
diff changeset
236
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 213
diff changeset
237 int setitimer (int kind, const struct itimerval* itnew,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 213
diff changeset
238 struct itimerval* itold);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 213
diff changeset
239
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 213
diff changeset
240 #define ITIMER_REAL 1
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 213
diff changeset
241 #define ITIMER_PROF 2
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 213
diff changeset
242
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 223
diff changeset
243 #endif /* WINDOWSNT */
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 213
diff changeset
244
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 #endif /* _XEMACS_SYSTIME_H_ */