Mercurial > hg > xemacs-beta
annotate src/systime.h @ 5652:cc6f0266bc36
Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
lisp/ChangeLog addition:
2012-05-01 Aidan Kehoe <kehoea@parhasard.net>
Avoid #'delq in core code, for the sake of style and a (very
slightly) smaller binary.
* behavior.el (disable-behavior):
* behavior.el (compute-behavior-group-children):
* buff-menu.el (buffers-tab-items):
* byte-optimize.el (byte-optimize-delay-constants-math):
* byte-optimize.el (byte-optimize-logmumble):
* byte-optimize.el (byte-decompile-bytecode-1):
* byte-optimize.el (byte-optimize-lapcode):
* bytecomp.el:
* bytecomp.el (byte-compile-arglist-warn):
* bytecomp.el (byte-compile-warn-about-unresolved-functions):
* bytecomp.el (byte-compile-lambda):
* bytecomp.el (byte-compile-out-toplevel):
* bytecomp.el (byte-compile-insert):
* bytecomp.el (byte-compile-defalias-warn):
* cl-macs.el (cl-upcase-arg):
* cl-macs.el (cl-transform-lambda):
* cl-macs.el (cl-do-proclaim):
* cl-macs.el (defstruct):
* cl-macs.el (cl-make-type-test):
* cl-macs.el (define-compiler-macro):
* cl-macs.el (delete-duplicates):
* cus-edit.el (widget-face-value-delete):
* cus-edit.el (face-history):
* easymenu.el (easy-menu-remove):
* files.el (files-fetch-hook-value):
* files.el (file-expand-wildcards):
* font-lock.el (font-lock-update-removed-keyword-alist):
* font-lock.el (font-lock-remove-keywords):
* frame.el (frame-initialize):
* frame.el (frame-notice-user-settings):
* frame.el (set-frame-font):
* frame.el (delete-other-frames):
* frame.el (get-frame-for-buffer-noselect):
* gnuserv.el (gnuserv-kill-buffer-function):
* gnuserv.el (gnuserv-check-device):
* gnuserv.el (gnuserv-kill-client):
* gnuserv.el (gnuserv-buffer-done-1):
* gtk-font-menu.el (gtk-reset-device-font-menus):
* gutter-items.el (buffers-tab-items):
* gutter.el (set-gutter-element-visible-p):
* info.el (Info-find-file-node):
* info.el (Info-history-add):
* info.el (Info-build-annotation-completions):
* info.el (Info-index):
* info.el (Info-reannotate-node):
* itimer.el (delete-itimer):
* itimer.el (start-itimer):
* lib-complete.el (lib-complete:cache-completions):
* loadhist.el (unload-feature):
* menubar-items.el (build-buffers-menu-internal):
* menubar.el (delete-menu-item):
* menubar.el (relabel-menu-item):
* msw-font-menu.el (mswindows-reset-device-font-menus):
* mule/make-coding-system.el (fixed-width-generate-helper):
* next-error.el (next-error-find-buffer):
* obsolete.el:
* obsolete.el (find-non-ascii-charset-string):
* obsolete.el (find-non-ascii-charset-region):
* occur.el (multi-occur-by-filename-regexp):
* occur.el (occur-1):
* packages.el (packages-package-hierarchy-directory-names):
* packages.el (package-get-key-1):
* process.el (setenv):
* simple.el (undo):
* simple.el (handle-pre-motion-command-current-command-is-motion):
* sound.el (load-sound-file):
* wid-edit.el (widget-field-value-delete):
* wid-edit.el (widget-checklist-match-inline):
* wid-edit.el (widget-checklist-match-find):
* wid-edit.el (widget-editable-list-delete-at):
* wid-edit.el (widget-editable-list-entry-create):
* window.el (quit-window):
* x-font-menu.el (x-reset-device-font-menus-core):
1. Replace (delq nil (mapcar ....)) with analogous (mapcan ...)
forms; this is in non-dumped files, it was done previously in
dumped files.
2. Replace (delq FOO (copy-sequence BAR)) with (remove* FOO BAR),
where #'eq and #'eql are equivalent
3. Replace (delq FOO BAR) with (delete* FOO BAR), where FOO is not
a non-fixnum number. Saves a little space in the dumped file
(since the compiler macro adds :test #'eq to the delete* call if
it's not clear that FOO is not a non-fixnum number).
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Tue, 01 May 2012 16:17:42 +0100 |
parents | 308d34e9f07d |
children | a0d9bfe304de |
rev | line source |
---|---|
428 | 1 /* systime.h - System-dependent definitions for time manipulations. |
2 Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. | |
777 | 3 Copyright (C) 2001, 2002 Ben Wing. |
428 | 4 |
5 This file is part of XEmacs. | |
6 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3025
diff
changeset
|
7 XEmacs is free software: you can redistribute it and/or modify it |
428 | 8 under the terms of the GNU General Public License as published by the |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3025
diff
changeset
|
9 Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3025
diff
changeset
|
10 option) any later version. |
428 | 11 |
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3025
diff
changeset
|
18 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
428 | 19 |
20 /* Synched up with: FSF 19.30. */ | |
21 | |
440 | 22 #ifndef INCLUDED_systime_h_ |
23 #define INCLUDED_systime_h_ | |
428 | 24 |
25 #ifdef TIME_WITH_SYS_TIME | |
442 | 26 # include <sys/time.h> |
27 # include <time.h> | |
428 | 28 #else |
442 | 29 # ifdef HAVE_SYS_TIME_H |
30 # include <sys/time.h> | |
31 # else | |
32 # include <time.h> | |
33 # endif | |
428 | 34 #endif |
35 | |
777 | 36 #ifdef HAVE_SYS_TIMES_H |
37 /* Need this for struct tms */ | |
771 | 38 # include <sys/times.h> |
39 #endif | |
40 | |
428 | 41 /* select() is supposed to be (Unix98) defined in sys/time.h, |
42 but FreeBSD and Irix 5 put it in unistd.h instead. | |
43 If we have it, including it can't hurt. */ | |
44 #ifdef HAVE_UNISTD_H | |
45 #include <unistd.h> | |
46 #endif | |
47 | |
442 | 48 #ifdef WIN32_NATIVE |
49 | |
50 /* This defines struct timeval */ | |
51 #include <winsock.h> | |
52 | |
53 struct timezone | |
54 { | |
55 int tz_minuteswest; /* minutes west of Greenwich */ | |
56 int tz_dsttime; /* type of dst correction */ | |
57 }; | |
58 | |
59 #ifdef HAVE_X_WINDOWS | |
428 | 60 /* Provides gettimeofday etc */ |
61 #include <X11/Xw32defs.h> | |
62 #include <X11/Xos.h> | |
442 | 63 #else |
64 /* X11R6 on NT provides the single parameter version of this command */ | |
65 void gettimeofday (struct timeval *, struct timezone *); | |
66 #endif /* HAVE_X_WINDOWS */ | |
67 | |
68 #endif /* WIN32_NATIVE */ | |
428 | 69 |
592 | 70 /* struct utimbuf */ |
71 | |
460 | 72 #ifdef HAVE_UTIME |
428 | 73 # include <utime.h> |
74 #endif | |
75 | |
592 | 76 #ifdef WIN32_NATIVE |
77 # include <sys/utime.h> | |
771 | 78 #ifdef emacs |
79 int mswindows_utime (Lisp_Object path, struct utimbuf *thymes); | |
80 #endif | |
592 | 81 #endif |
82 | |
442 | 83 #if defined(HAVE_TZNAME) && !defined(WIN32_NATIVE) && !defined(CYGWIN) |
428 | 84 #ifndef tzname /* For SGI. */ |
85 extern char *tzname[]; /* RS6000 and others want it this way. */ | |
86 #endif | |
87 #endif | |
88 | |
89 /* On some configurations (hpux8.0, X11R4), sys/time.h and X11/Xos.h | |
90 disagree about the name of the guard symbol. */ | |
91 #ifdef HPUX | |
92 #ifdef _STRUCT_TIMEVAL | |
93 #ifndef __TIMEVAL__ | |
94 #define __TIMEVAL__ | |
95 #endif | |
96 #endif | |
97 #endif | |
98 | |
99 /* EMACS_TIME is the type to use to represent temporal intervals. | |
3025 | 100 At one point this was `struct timeval' on some systems, int on others. |
428 | 101 But this is stupid. Other things than select() code like to |
102 manipulate time values, and so microsecond precision should be | |
103 maintained. Separate typedefs and conversion functions are provided | |
104 for select(). | |
105 | |
106 EMACS_SECS (TIME) is an rvalue for the seconds component of TIME. | |
107 EMACS_SET_SECS (TIME, SECONDS) sets that to SECONDS. | |
108 | |
109 EMACS_USECS (TIME) is an rvalue for the microseconds component of TIME. | |
110 EMACS_SET_USECS (TIME, MICROSECONDS) sets that to MICROSECONDS. | |
111 | |
112 Note that all times are returned in "normalized" format (i.e. the | |
113 usecs value is in the range 0 <= value < 1000000) and are assumed | |
114 to be passed in in this format. | |
115 | |
116 EMACS_SET_SECS_USECS (TIME, SECS, USECS) sets both components of TIME. | |
117 | |
118 EMACS_GET_TIME (TIME) stores the current system time in TIME, which | |
119 should be an lvalue. | |
120 | |
121 set_file_times (PATH, ATIME, MTIME) changes the last-access and | |
122 last-modification times of the file named PATH to ATIME and | |
123 MTIME, which are EMACS_TIMEs. | |
124 | |
125 EMACS_NORMALIZE_TIME (TIME) coerces TIME into normalized format. | |
126 | |
127 EMACS_ADD_TIME (DEST, SRC1, SRC2) adds SRC1 to SRC2 and stores the | |
128 result in DEST. Either or both may be negative. | |
129 | |
130 EMACS_SUB_TIME (DEST, SRC1, SRC2) subtracts SRC2 from SRC1 and | |
131 stores the result in DEST. Either or both may be negative. | |
132 | |
133 EMACS_TIME_NEG_P (TIME) is true iff TIME is negative. | |
134 | |
135 EMACS_TIME_EQUAL (TIME1, TIME2) is true iff TIME1 is the same as TIME2. | |
136 EMACS_TIME_GREATER (TIME1, TIME2) is true iff TIME1 is greater than | |
137 TIME2. | |
138 EMACS_TIME_EQUAL_OR_GREATER (TIME1, TIME2) is true iff TIME1 is | |
139 greater than or equal to TIME2. | |
140 | |
141 */ | |
142 | |
143 #ifdef HAVE_TIMEVAL | |
144 | |
145 #define EMACS_SELECT_TIME struct timeval | |
146 #define EMACS_TIME_TO_SELECT_TIME(time, select_time) ((select_time) = (time)) | |
147 | |
148 #else /* not HAVE_TIMEVAL */ | |
149 | |
150 struct timeval | |
151 { | |
152 long tv_sec; /* seconds */ | |
153 long tv_usec; /* microseconds */ | |
154 }; | |
155 | |
156 #define EMACS_SELECT_TIME int | |
157 #define EMACS_TIME_TO_SELECT_TIME(time, select_time) \ | |
158 EMACS_TIME_TO_INT (time, select_time) | |
159 | |
160 #endif /* not HAVE_TIMEVAL */ | |
161 | |
162 #define EMACS_TIME_TO_INT(time, intvar) \ | |
163 do { \ | |
164 EMACS_TIME tmptime = time; \ | |
165 \ | |
166 if (tmptime.tv_usec > 0) \ | |
167 (intvar) = tmptime.tv_sec + 1; \ | |
168 else \ | |
169 (intvar) = tmptime.tv_sec; \ | |
170 } while (0) | |
171 | |
172 #define EMACS_TIME struct timeval | |
173 #define EMACS_SECS(time) ((time).tv_sec + 0) | |
174 #define EMACS_USECS(time) ((time).tv_usec + 0) | |
175 #define EMACS_SET_SECS(time, seconds) ((time).tv_sec = (seconds)) | |
176 #define EMACS_SET_USECS(time, microseconds) ((time).tv_usec = (microseconds)) | |
177 | |
178 #if !defined (HAVE_GETTIMEOFDAY) | |
442 | 179 int gettimeofday (struct timeval *, void *); |
428 | 180 #endif |
181 | |
182 /* On SVR4, the compiler may complain if given this extra BSD arg. */ | |
183 #ifdef GETTIMEOFDAY_ONE_ARGUMENT | |
442 | 184 #define EMACS_GETTIMEOFDAY(time) gettimeofday(time) |
185 #else | |
186 #define EMACS_GETTIMEOFDAY(time) gettimeofday(time,0) | |
187 #endif | |
188 | |
428 | 189 /* According to the Xt sources, some NTP daemons on some systems may |
190 return non-normalized values. */ | |
191 #define EMACS_GET_TIME(time) \ | |
192 do { \ | |
442 | 193 EMACS_GETTIMEOFDAY (&(time)); \ |
428 | 194 EMACS_NORMALIZE_TIME (time); \ |
195 } while (0) | |
196 | |
197 #define EMACS_NORMALIZE_TIME(time) \ | |
198 do { \ | |
199 while ((time).tv_usec >= 1000000) \ | |
200 { \ | |
201 (time).tv_usec -= 1000000; \ | |
202 (time).tv_sec++; \ | |
203 } \ | |
204 while ((time).tv_usec < 0) \ | |
205 { \ | |
206 (time).tv_usec += 1000000; \ | |
207 (time).tv_sec--; \ | |
208 } \ | |
209 } while (0) | |
210 | |
211 #define EMACS_ADD_TIME(dest, src1, src2) \ | |
212 do { \ | |
213 (dest).tv_sec = (src1).tv_sec + (src2).tv_sec; \ | |
214 (dest).tv_usec = (src1).tv_usec + (src2).tv_usec; \ | |
215 EMACS_NORMALIZE_TIME (dest); \ | |
216 } while (0) | |
217 | |
218 #define EMACS_SUB_TIME(dest, src1, src2) \ | |
219 do { \ | |
220 (dest).tv_sec = (src1).tv_sec - (src2).tv_sec; \ | |
221 (dest).tv_usec = (src1).tv_usec - (src2).tv_usec; \ | |
222 EMACS_NORMALIZE_TIME (dest); \ | |
223 } while (0) | |
224 | |
225 #define EMACS_TIME_NEG_P(time) ((long)(time).tv_sec < 0) | |
226 | |
227 #define EMACS_TIME_EQUAL(time1, time2) \ | |
228 ((time1).tv_sec == (time2).tv_sec && \ | |
229 (time1).tv_usec == (time2).tv_usec) | |
230 | |
231 #define EMACS_TIME_GREATER(time1, time2) \ | |
232 ((time1).tv_sec > (time2).tv_sec || \ | |
233 ((time1).tv_sec == (time2).tv_sec && \ | |
234 (time1).tv_usec > (time2).tv_usec)) | |
235 | |
236 #define EMACS_TIME_EQUAL_OR_GREATER(time1, time2) \ | |
237 ((time1).tv_sec > (time2).tv_sec || \ | |
238 ((time1).tv_sec == (time2).tv_sec && \ | |
239 (time1).tv_usec >= (time2).tv_usec)) | |
240 | |
241 #define EMACS_SET_SECS_USECS(time, secs, usecs) \ | |
242 (EMACS_SET_SECS (time, secs), EMACS_SET_USECS (time, usecs)) | |
243 | |
592 | 244 #ifdef emacs |
245 int set_file_times (Lisp_Object path, EMACS_TIME atime, EMACS_TIME mtime); | |
428 | 246 void get_process_times (double *user_time, double *system_time, |
247 double *real_time); | |
867 | 248 Ibyte *qxe_ctime (const time_t *value); |
771 | 249 |
250 #endif | |
428 | 251 |
611 | 252 #ifdef WIN32_NATIVE |
428 | 253 |
611 | 254 /* setitimer emulation for Win32 (see win32.c) */ |
428 | 255 |
256 struct itimerval | |
257 { | |
258 struct timeval it_value; | |
259 struct timeval it_interval; | |
260 }; | |
261 | |
262 #define ITIMER_REAL 1 | |
263 #define ITIMER_PROF 2 | |
264 | |
442 | 265 #endif /* WIN32_NATIVE */ |
428 | 266 |
1315 | 267 #ifdef WIN32_ANY |
611 | 268 |
269 int mswindows_setitimer (int kind, const struct itimerval *itnew, | |
270 struct itimerval *itold); | |
271 | |
1315 | 272 #endif /* WIN32_ANY */ |
611 | 273 |
274 /* #### Move this comment elsewhere when we figure out the place. | |
275 | |
276 "qxe" is a unique prefix used to identify encapsulations of standard | |
277 library functions. We used to play pre-processing games but in | |
278 general this leads to nothing but trouble because someone first | |
279 encountering the code will have no idea that what appears to be a | |
280 call to a library function has actually been redefined to be a call | |
281 somewhere else. This is doubly true when the redefinition occurs | |
282 in out-of-the way s+m files and only on certainly systems. | |
283 | |
617 | 284 The name "qxe" was chosen because it is a unique string that is not |
285 going to be found anywhere else in the sources (unlike, for example, | |
286 the prefixes "xemacs" or "sys") and is easy to type. Alternative | |
287 names are certainly possible, and suggestions are welcome. | |
288 | |
611 | 289 By making the encapsulation explicit we might be making the code |
290 that uses is slightly less pretty, but this is more than compensated | |
291 for by the huge increase in clarity. | |
292 | |
293 "Standard library function" can refer to any function in any | |
294 standard library. If we are explicitly changing the semantics | |
295 (e.g. Mule-encapsulating), we should use an extended version of | |
296 the prefix, e.g. perhaps "qxe_xlat_" for functions that Mule- | |
297 encapsulate, or "qxe_retry_" for functions that automatically | |
298 retry a system call interrupted by EINTR. In general, if there | |
299 is no prefix extension, it means the function is trying to | |
300 provide (more or less) the same semantics as the standard library | |
301 function; but be aware that the reimplementation may be incomplete | |
302 or differ in important respects. This is especially the case | |
303 when attempts are made to implement Unix functions on MS Windows. | |
617 | 304 |
305 (The comment on the particular encapsulation should describe what | |
306 standard function is being emulated, if this is not obvious, and | |
307 what the differences, if any, from that standard function are.) | |
308 | |
309 An example of this is the qxe_setitimer() function. This attempts | |
310 to emulate the POSIX (Unix98?) standard setitimer(), as found on | |
311 all modern versions of Unix. Normally, we just call the system- | |
312 provided setitimer() function. When emulated on MS Windows and | |
313 Cygwin, however, the ITNEW and ITOLD values cannot be different | |
314 from each other if both are non-zero, due to limitations in the | |
315 underlying multimedia-timer API. By simply using setitimer() with | |
316 preprocessor tricks, a programmer would almost have to be a | |
317 mind-reader to figure this out. With the explicit encapsulation, a | |
318 programmer need only look at the definition of qxe_setitimer() to | |
319 see what its semantics are. | |
611 | 320 */ |
321 | |
322 int qxe_setitimer (int kind, const struct itimerval *itnew, | |
323 struct itimerval *itold); | |
324 | |
440 | 325 #endif /* INCLUDED_systime_h_ */ |