0
|
1 /* Fundamental definitions for XEmacs Lisp interpreter.
|
|
2 Copyright (C) 1985-1987, 1992-1995 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1993-1996 Richard Mlynarik.
|
|
4 Copyright (C) 1995, 1996 Ben Wing.
|
|
5
|
|
6 This file is part of XEmacs.
|
|
7
|
|
8 XEmacs is free software; you can redistribute it and/or modify it
|
|
9 under the terms of the GNU General Public License as published by the
|
|
10 Free Software Foundation; either version 2, or (at your option) any
|
|
11 later version.
|
|
12
|
|
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
16 for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with XEmacs; see the file COPYING. If not, write to
|
|
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 Boston, MA 02111-1307, USA. */
|
|
22
|
|
23 /* Synched up with: FSF 19.30. */
|
|
24
|
|
25 #ifndef _XEMACS_LISP_H_
|
|
26 #define _XEMACS_LISP_H_
|
|
27
|
|
28 /************************************************************************/
|
|
29 /* general definitions */
|
|
30 /************************************************************************/
|
|
31
|
|
32 /* We include the following generally useful header files so that you
|
|
33 don't have to worry about prototypes when using the standard C
|
|
34 library functions and macros. These files shouldn't be excessively
|
|
35 large so they shouldn't cause that much of a slowdown. */
|
|
36
|
|
37 #include <stdlib.h>
|
|
38 #include <string.h> /* primarily for memcpy, etc. */
|
|
39 #include <stdio.h> /* NULL, etc. */
|
|
40 #include <ctype.h>
|
|
41 #include <stdarg.h>
|
|
42 #ifdef HAVE_UNISTD_H
|
|
43 #include <unistd.h>
|
|
44 #endif
|
|
45 #ifndef INCLUDED_FCNTL
|
|
46 # define INCLUDED_FCNTL
|
|
47 # include <fcntl.h>
|
|
48 #endif /* INCLUDED_FCNTL */
|
|
49
|
|
50 #ifdef __lucid
|
|
51 # include <sysent.h>
|
|
52 #endif
|
|
53
|
|
54 #include "blocktype.h" /* A generally useful include */
|
|
55 #include "dynarr.h" /* A generally useful include */
|
|
56 #include "symsinit.h" /* compiler warning suppression */
|
|
57
|
|
58 /* Also define min() and max(). (Some compilers put them in strange
|
|
59 places that won't be referenced by the above include files, such
|
|
60 as 'macros.h' under Solaris.) */
|
|
61
|
|
62 #ifndef min
|
|
63 #define min(a,b) ((a) <= (b) ? (a) : (b))
|
|
64 #endif
|
|
65 #ifndef max
|
|
66 #define max(a,b) ((a) > (b) ? (a) : (b))
|
|
67 #endif
|
|
68
|
|
69 /* Emacs needs to use its own definitions of certain system calls on
|
|
70 some systems (like SunOS 4.1 and USG systems, where the read system
|
|
71 call is interruptible but Emacs expects it not to be; and under
|
|
72 MULE, where all filenames need to be converted to external format).
|
|
73 To do this, we #define read to be sys_read, which is defined in
|
|
74 sysdep.c. We first #undef read, in case some system file defines
|
|
75 read as a macro. sysdep.c doesn't encapsulate read, so the call to
|
|
76 read inside of sys_read will do the right thing.
|
|
77
|
|
78 DONT_ENCAPSULATE is used in files such as sysdep.c that want to
|
|
79 call the actual system calls rather than the encapsulated versions.
|
|
80 Those files can call sys_read to get the (possibly) encapsulated
|
|
81 versions.
|
|
82
|
|
83 IMPORTANT: the redefinition of the system call must occur *after* the
|
|
84 inclusion of any header files that declare or define the system call;
|
|
85 otherwise lots of unfriendly things can happen. This goes for all
|
|
86 encapsulated system calls.
|
|
87
|
|
88 We encapsulate the most common system calls here; we assume their
|
|
89 declarations are in one of the standard header files included above.
|
|
90 Other encapsulations are declared in the appropriate sys*.h file. */
|
|
91
|
|
92 #if defined (ENCAPSULATE_READ) && !defined (DONT_ENCAPSULATE)
|
|
93 # undef read
|
|
94 # define read sys_read
|
|
95 #endif
|
|
96 #if !defined (ENCAPSULATE_READ) && defined (DONT_ENCAPSULATE)
|
|
97 # define sys_read read
|
|
98 #endif
|
|
99
|
|
100 #if defined (ENCAPSULATE_WRITE) && !defined (DONT_ENCAPSULATE)
|
|
101 # undef write
|
|
102 # define write sys_write
|
|
103 #endif
|
|
104 #if !defined (ENCAPSULATE_WRITE) && defined (DONT_ENCAPSULATE)
|
|
105 # define sys_write write
|
|
106 #endif
|
|
107
|
|
108 #if defined (ENCAPSULATE_OPEN) && !defined (DONT_ENCAPSULATE)
|
|
109 # undef open
|
|
110 # define open sys_open
|
|
111 #endif
|
|
112 #if !defined (ENCAPSULATE_OPEN) && defined (DONT_ENCAPSULATE)
|
|
113 # define sys_open open
|
|
114 #endif
|
|
115
|
|
116 #if defined (ENCAPSULATE_CLOSE) && !defined (DONT_ENCAPSULATE)
|
|
117 # undef close
|
|
118 # define close sys_close
|
|
119 #endif
|
|
120 #if !defined (ENCAPSULATE_CLOSE) && defined (DONT_ENCAPSULATE)
|
|
121 # define sys_close close
|
|
122 #endif
|
|
123
|
|
124 /* Now the stdio versions ... */
|
|
125
|
|
126 #if defined (ENCAPSULATE_FREAD) && !defined (DONT_ENCAPSULATE)
|
|
127 # undef fread
|
|
128 # define fread sys_fread
|
|
129 #endif
|
|
130 #if !defined (ENCAPSULATE_FREAD) && defined (DONT_ENCAPSULATE)
|
|
131 # define sys_fread fread
|
|
132 #endif
|
|
133
|
|
134 #if defined (ENCAPSULATE_FWRITE) && !defined (DONT_ENCAPSULATE)
|
|
135 # undef fwrite
|
|
136 # define fwrite sys_fwrite
|
|
137 #endif
|
|
138 #if !defined (ENCAPSULATE_FWRITE) && defined (DONT_ENCAPSULATE)
|
|
139 # define sys_fwrite fwrite
|
|
140 #endif
|
|
141
|
|
142 #if defined (ENCAPSULATE_FOPEN) && !defined (DONT_ENCAPSULATE)
|
|
143 # undef fopen
|
|
144 # define fopen sys_fopen
|
|
145 #endif
|
|
146 #if !defined (ENCAPSULATE_FOPEN) && defined (DONT_ENCAPSULATE)
|
|
147 # define sys_fopen fopen
|
|
148 #endif
|
|
149
|
|
150 #if defined (ENCAPSULATE_FCLOSE) && !defined (DONT_ENCAPSULATE)
|
|
151 # undef fclose
|
|
152 # define fclose sys_fclose
|
|
153 #endif
|
|
154 #if !defined (ENCAPSULATE_FCLOSE) && defined (DONT_ENCAPSULATE)
|
|
155 # define sys_fclose fclose
|
|
156 #endif
|
|
157
|
|
158 /* generally useful */
|
|
159 #define countof(x) (sizeof(x)/sizeof(x[0]))
|
|
160 #define slot_offset(type, slot_name) \
|
|
161 ((unsigned) (((char *) (&(((type *)0)->slot_name))) - ((char *)0)))
|
|
162 #define malloc_type(type) ((type *) xmalloc (sizeof (type)))
|
|
163 #define malloc_type_and_zero(type) ((type *) xmalloc_and_zero (sizeof (type)))
|
|
164
|
|
165 /* also generally useful if you want to avoid arbitrary size limits
|
|
166 but don't need a full dynamic array. Assumes that BASEVAR points
|
|
167 to a malloced array of TYPE objects (or possibly a NULL pointer,
|
|
168 if SIZEVAR is 0), with the total size stored in SIZEVAR. This
|
|
169 macro will realloc BASEVAR as necessary so that it can hold at
|
|
170 least NEEDED_SIZE objects. The reallocing is done by doubling,
|
|
171 which ensures constant amortized time per element. */
|
80
|
172 #define DO_REALLOC(basevar, sizevar, needed_size, type) do \
|
|
173 { \
|
|
174 /* Avoid side-effectualness. */ \
|
|
175 /* Dammit! Macros suffer from dynamic scope! */ \
|
|
176 /* We demand inline functions! */ \
|
|
177 int do_realloc_needed_size = (needed_size); \
|
|
178 int newsize = 0; \
|
|
179 while ((sizevar) < (do_realloc_needed_size)) { \
|
|
180 newsize = 2*(sizevar); \
|
|
181 if (newsize < 32) \
|
|
182 newsize = 32; \
|
|
183 (sizevar) = newsize; \
|
|
184 } \
|
|
185 if (newsize) \
|
|
186 (basevar) = (type *) xrealloc (basevar, \
|
|
187 (newsize)*sizeof(type)); \
|
0
|
188 } while (0)
|
|
189
|
|
190 #ifdef ERROR_CHECK_MALLOC
|
80
|
191 #define xfree(lvalue) do \
|
|
192 { \
|
|
193 void **ptr = (void **) &(lvalue); \
|
|
194 xfree_1 (*ptr); \
|
|
195 *ptr = (void *) 0xDEADBEEF; \
|
0
|
196 } while (0)
|
|
197 #else
|
|
198 #define xfree_1 xfree
|
|
199 #endif
|
|
200
|
|
201 /* We assume an ANSI C compiler and libraries and memcpy, memset, memcmp */
|
|
202 /* (This definition is here because system header file macros may want
|
|
203 * to call bzero (eg FD_ZERO) */
|
|
204 #ifndef bzero
|
|
205 # define bzero(m, l) memset ((m), 0, (l))
|
|
206 #endif
|
|
207
|
|
208 #ifndef PRINTF_ARGS
|
|
209 # if defined (__GNUC__) && (__GNUC__ >= 2)
|
|
210 # define PRINTF_ARGS(string_index,first_to_check) \
|
|
211 __attribute__ ((format (printf, string_index, first_to_check)))
|
|
212 # else
|
|
213 # define PRINTF_ARGS(string_index,first_to_check)
|
|
214 # endif /* GNUC */
|
|
215 #endif
|
|
216
|
|
217 #ifndef DOESNT_RETURN
|
|
218 # if defined __GNUC__
|
|
219 # if ((__GNUC__ > 2) || (__GNUC__ == 2) && (__GNUC_MINOR__ >= 5))
|
|
220 # define DOESNT_RETURN void volatile
|
|
221 # define DECLARE_DOESNT_RETURN(decl) \
|
|
222 extern void volatile decl __attribute__ ((noreturn))
|
|
223 # define DECLARE_DOESNT_RETURN_GCC__ATTRIBUTE__SYNTAX_SUCKS(decl,str,idx) \
|
|
224 /* Should be able to state multiple independent __attribute__s, but \
|
|
225 the losing syntax doesn't work that way, and screws losing cpp */ \
|
|
226 extern void volatile decl \
|
|
227 __attribute__ ((noreturn, format (printf, str, idx)))
|
|
228 # else
|
|
229 # define DOESNT_RETURN void volatile
|
|
230 # define DECLARE_DOESNT_RETURN(decl) extern void volatile decl
|
|
231 # define DECLARE_DOESNT_RETURN_GCC__ATTRIBUTE__SYNTAX_SUCKS(decl,str,idx) \
|
|
232 extern void volatile decl PRINTF_ARGS(str,idx)
|
|
233 # endif /* GNUC 2.5 */
|
|
234 # else
|
|
235 # define DOESNT_RETURN void
|
|
236 # define DECLARE_DOESNT_RETURN(decl) extern void decl
|
|
237 # define DECLARE_DOESNT_RETURN_GCC__ATTRIBUTE__SYNTAX_SUCKS(decl,str,idx) \
|
|
238 extern void decl PRINTF_ARGS(str,idx)
|
|
239 # endif /* GNUC */
|
|
240 #endif
|
|
241
|
|
242 #ifndef ALIGNOF
|
|
243 # if defined (__GNUC__) && (__GNUC__ >= 2)
|
|
244 # define ALIGNOF(x) __alignof (x)
|
|
245 # else
|
|
246 # define ALIGNOF(x) sizeof (x)
|
|
247 # endif
|
|
248 #endif
|
|
249
|
|
250 #define ALIGN_SIZE(len, unit) \
|
|
251 ((((len) + (unit) - 1) / (unit)) * (unit))
|
|
252
|
|
253 /* #### Yuck, this is kind of evil */
|
80
|
254 #define ALIGN_PTR(ptr, unit) \
|
|
255 ((void *) ALIGN_SIZE ((long) (ptr), unit))
|
0
|
256
|
|
257 #ifdef QUANTIFY
|
|
258 #include "quantify.h"
|
80
|
259 #define QUANTIFY_START_RECORDING \
|
|
260 do { quantify_start_recording_data (); } while (0)
|
|
261 #define QUANTIFY_STOP_RECORDING \
|
|
262 do { quantify_stop_recording_data (); } while (0)
|
0
|
263 #else /* !QUANTIFY */
|
|
264 #define QUANTIFY_START_RECORDING
|
|
265 #define QUANTIFY_STOP_RECORDING
|
|
266 #endif /* !QUANTIFY */
|
|
267
|
|
268 #ifndef DO_NOTHING
|
|
269 #define DO_NOTHING do {} while (0)
|
|
270 #endif
|
|
271
|
|
272 /* We define assert iff USE_ASSERTIONS or DEBUG_XEMACS is defined.
|
|
273 Otherwise we it to NULL. Quantify has shown that the time the
|
|
274 assert checks take is measurable so let's not include them in
|
|
275 production binaries. */
|
|
276
|
|
277 #ifdef USE_ASSERTIONS
|
|
278 /* Highly dubious kludge */
|
|
279 /* (thanks, Jamie, I feel better now -- ben) */
|
|
280 DECLARE_DOESNT_RETURN (assert_failed (CONST char *, int, CONST char *));
|
70
|
281 # define abort() (assert_failed (__FILE__, __LINE__, "abort()"))
|
0
|
282 # define assert(x) ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, #x))
|
|
283 #else
|
|
284 # ifdef DEBUG_XEMACS
|
|
285 # define assert(x) ((x) ? (void) 0 : (void) abort ())
|
|
286 # else
|
|
287 # define assert(x)
|
|
288 # endif
|
|
289 #endif
|
|
290
|
|
291 #ifdef DEBUG_XEMACS
|
|
292 #define REGISTER
|
|
293 #else
|
|
294 #define REGISTER register
|
|
295 #endif
|
|
296
|
|
297 #ifndef INT_MAX
|
|
298 #define INT_MAX ((int) ((1U << (INTBITS - 1)) - 1))
|
|
299 #endif
|
|
300
|
|
301 #if defined (__GNUC__) && (__GNUC__ >= 2)
|
|
302 /* Entomological studies have revealed that the following junk is
|
|
303 necessary under GCC. GCC has a compiler bug where incorrect
|
|
304 code will be generated if you use a global temporary variable
|
|
305 in a macro and the macro occurs twice in the same expression.
|
|
306 As it happens, we can avoid this problem using a GCC language
|
|
307 extension. Thus we play weird games with syntax to avoid having
|
|
308 to provide two definitions for lots of macros.
|
|
309
|
|
310 The approximate way this works is as follows:
|
|
311
|
|
312 1. Use these macros whenever you want to avoid evaluating an
|
|
313 argument more than once in a macro. (It's almost always a
|
|
314 good idea to make your macros safe like this.)
|
|
315 2. Choose a name for the temporary variable you will store
|
|
316 the parameter in. It should begin with `MT' and
|
|
317 be distinguishing, since it will (or may) be a global
|
|
318 variable.
|
|
319 3. In the same header file as the macro, put in a
|
|
320 MAC_DECLARE_EXTERN for the temporary variable. This
|
|
321 resolves to an external variable declaration for some
|
|
322 compilers.
|
|
323 4. Put a MAC_DEFINE for the variable in a C file somewhere.
|
|
324 This resolves to a variable definition for some compilers.
|
|
325 5. Write your macro with no semicolons or commas in it.
|
|
326 Remember to use parentheses to surround macro arguments,
|
|
327 but you do not need to surround each separate statement
|
|
328 or the temporary variable with parentheses.
|
|
329 6. Write your macro like this:
|
|
330
|
|
331 #define foo(bar,baz) \
|
|
332 MAC_BEGIN \
|
|
333 MAC_DECLARE (struct frobozz *, MTfoobar, bar) \
|
|
334 SOME_EXPRESSION \
|
|
335 MAC_SEP \
|
|
336 SOME OTHER EXPRESSION \
|
|
337 MAC_END
|
|
338
|
|
339 7. You only need to use MAC_SEP if you have more than one
|
|
340 expression in the macro, not counting any MAC_DECLARE
|
|
341 statements.
|
|
342
|
|
343 DONT_DECLARE_MAC_VARS is used in signal.c, for asynchronous signals.
|
|
344 All functions that may be called from within an asynchronous signal
|
|
345 handler must declare local variables (with MAC_DECLARE_LOCAL) for
|
|
346 the (normally global) variables used in these sorts of macros.
|
|
347 Otherwise, a signal could occur in the middle of processing one
|
|
348 of these macros and the signal handler could use the same macro,
|
|
349 resulting in the global variable getting overwritten and yielding
|
|
350 nasty evil crashes that are very difficult to track down.
|
|
351 */
|
|
352 # define MAC_BEGIN ({
|
|
353 # define MAC_DECLARE(type, var, value) type var = (value);
|
|
354 # define MAC_SEP ;
|
|
355 # define MAC_END ; })
|
|
356 # define MAC_DECLARE_EXTERN(type, var)
|
|
357 # define MAC_DECLARE_LOCAL(type, var)
|
|
358 # define MAC_DEFINE(type, var)
|
|
359 #else
|
|
360 # define MAC_BEGIN (
|
|
361 # define MAC_DECLARE(type, var, value) var = (value),
|
|
362 # define MAC_SEP ,
|
|
363 # define MAC_END )
|
|
364 # ifdef DONT_DECLARE_MAC_VARS
|
|
365 # define MAC_DECLARE_EXTERN(type, var)
|
|
366 # else
|
|
367 # define MAC_DECLARE_EXTERN(type, var) extern type var;
|
|
368 # endif
|
|
369 # define MAC_DECLARE_LOCAL(type, var) type var;
|
|
370 # define MAC_DEFINE(type, var) type var;
|
|
371 #endif
|
|
372
|
|
373 /* For Lo, the Lord didst appear and look upon the face of the code,
|
|
374 and the Lord was unhappy with the strange syntax that had come
|
|
375 into vogue with the cryptic name of "C". And so the Lord didst
|
|
376 decree, that from now on all programmers shall use Pascal syntax,
|
|
377 a syntax truly and in sooth ordained in heaven. Amen. */
|
|
378
|
|
379
|
|
380 /************************************************************************/
|
|
381 /* typedefs */
|
|
382 /************************************************************************/
|
|
383
|
|
384 /* We put typedefs here so that prototype declarations don't choke.
|
|
385 Note that we don't actually declare the structures here (except
|
|
386 maybe for simple structures like Dynarrs); that keeps them private
|
|
387 to the routines that actually use them. */
|
|
388
|
|
389 /* The data representing the text in a buffer is logically a set
|
|
390 of Bufbytes, declared as follows. */
|
|
391
|
|
392 typedef unsigned char Bufbyte;
|
|
393
|
|
394 /* The data representing a string in "external" format (simple
|
|
395 binary format) is logically a set of Extbytes, declared as follows. */
|
|
396
|
|
397 typedef unsigned char Extbyte;
|
|
398
|
|
399 /* To the user, a buffer is made up of characters, declared as follows.
|
|
400 In the non-Mule world, characters and Bufbytes are equivalent.
|
14
|
401 In the Mule world, a character requires (typically) 1 to 4
|
0
|
402 Bufbytes for its representation in a buffer. */
|
|
403
|
|
404 typedef int Emchar;
|
|
405
|
|
406 /* Different ways of referring to a position in a buffer. We use
|
|
407 the typedefs in preference to 'int' to make it clearer what
|
|
408 sort of position is being used. See extents.c for a description
|
|
409 of the different positions. We put them here instead of in
|
|
410 buffer.h (where they rightfully belong) to avoid syntax errors
|
|
411 in function prototypes. */
|
|
412
|
|
413 typedef int Bufpos;
|
|
414 typedef int Bytind;
|
|
415 typedef int Memind;
|
|
416
|
|
417 /* Counts of bytes or chars */
|
|
418
|
|
419 typedef int Bytecount;
|
|
420 typedef int Charcount;
|
|
421
|
|
422 /* Length in bytes of a string in external format */
|
|
423 typedef int Extcount;
|
|
424
|
|
425 typedef struct lstream Lstream;
|
|
426
|
|
427 typedef unsigned int face_index;
|
|
428 typedef struct face_cachel_dynarr_type
|
|
429 {
|
|
430 Dynarr_declare (struct face_cachel);
|
|
431 } face_cachel_dynarr;
|
|
432
|
|
433 typedef unsigned int glyph_index;
|
|
434 typedef struct glyph_cachel_dynarr_type
|
|
435 {
|
|
436 Dynarr_declare (struct glyph_cachel);
|
|
437 } glyph_cachel_dynarr;
|
|
438
|
|
439 struct buffer; /* "buffer.h" */
|
|
440 struct console; /* "console.h" */
|
|
441 struct device; /* "device.h" */
|
|
442 struct extent_fragment;
|
|
443 struct extent;
|
|
444 struct frame; /* "frame.h" */
|
|
445 struct window; /* "window.h" */
|
|
446 struct Lisp_Event; /* "events.h" */
|
|
447 struct Lisp_Face;
|
|
448 struct Lisp_Process; /* "process.c" */
|
|
449 struct stat; /* <sys/stat.h> */
|
|
450 struct Lisp_Color_Instance;
|
|
451 struct Lisp_Font_Instance;
|
|
452 struct Lisp_Image_Instance;
|
|
453 struct display_line;
|
|
454 struct redisplay_info;
|
|
455 struct window_mirror;
|
|
456 struct scrollbar_instance;
|
|
457 struct font_metric_info;
|
|
458 struct face_cachel;
|
|
459 struct console_type_entry;
|
|
460
|
|
461 typedef struct bufbyte_dynarr_type
|
|
462 {
|
|
463 Dynarr_declare (Bufbyte);
|
|
464 } bufbyte_dynarr;
|
|
465
|
|
466 typedef struct extbyte_dynarr_type
|
|
467 {
|
|
468 Dynarr_declare (Extbyte);
|
|
469 } extbyte_dynarr;
|
|
470
|
|
471 typedef struct emchar_dynarr_type
|
|
472 {
|
|
473 Dynarr_declare (Emchar);
|
|
474 } emchar_dynarr;
|
|
475
|
|
476 typedef struct unsigned_char_dynarr_type
|
|
477 {
|
|
478 Dynarr_declare (unsigned char);
|
|
479 } unsigned_char_dynarr;
|
|
480
|
|
481 typedef struct int_dynarr_type
|
|
482 {
|
|
483 Dynarr_declare (int);
|
|
484 } int_dynarr;
|
|
485
|
|
486 typedef struct bufpos_dynarr_type
|
|
487 {
|
|
488 Dynarr_declare (Bufpos);
|
|
489 } bufpos_dynarr;
|
|
490
|
|
491 typedef struct bytind_dynarr_type
|
|
492 {
|
|
493 Dynarr_declare (Bytind);
|
|
494 } bytind_dynarr;
|
|
495
|
|
496 typedef struct charcount_dynarr_type
|
|
497 {
|
|
498 Dynarr_declare (Charcount);
|
|
499 } charcount_dynarr;
|
|
500
|
|
501 typedef struct bytecount_dynarr_type
|
|
502 {
|
|
503 Dynarr_declare (Bytecount);
|
|
504 } bytecount_dynarr;
|
|
505
|
|
506 typedef struct console_type_entry_dynarr_type
|
|
507 {
|
|
508 Dynarr_declare (struct console_type_entry);
|
|
509 } console_type_entry_dynarr;
|
|
510
|
|
511 /* Need to declare this here. */
|
|
512 enum external_data_format
|
|
513 {
|
|
514 /* Binary format. This is the simplest format and is what we
|
|
515 use in the absence of a more appropriate format. This converts
|
|
516 according to the `binary' coding system:
|
|
517
|
|
518 a) On input, bytes 0 - 255 are converted into characters 0 - 255.
|
|
519 b) On output, characters 0 - 255 are converted into bytes 0 - 255
|
|
520 and other characters are converted into `X'.
|
|
521 */
|
|
522 FORMAT_BINARY,
|
|
523
|
|
524 /* Format used for filenames. In the original Mule, this is
|
|
525 user-definable with the `pathname-coding-system' variable.
|
|
526 For the moment, we just use the `binary' coding system. */
|
|
527 FORMAT_FILENAME,
|
|
528
|
|
529 /* Format used for output to the terminal. This should be controlled
|
16
|
530 by the `terminal-coding-system' variable. Under kterm, this will
|
0
|
531 be some ISO2022 system. On some DOS machines, this is Shift-JIS. */
|
16
|
532 FORMAT_TERMINAL,
|
0
|
533
|
|
534 /* Format used for input from the terminal. This should be controlled
|
|
535 by the `keyboard-coding-system' variable. */
|
|
536 FORMAT_KEYBOARD,
|
|
537
|
|
538 /* Format used for the external Unix environment -- argv[], stuff
|
|
539 from getenv(), stuff from the /etc/passwd file, etc.
|
|
540
|
|
541 Perhaps should be the same as FORMAT_FILENAME. */
|
|
542 FORMAT_OS,
|
|
543
|
|
544 /* Compound-text format. This is the standard X format used for
|
|
545 data stored in properties, selections, and the like. This is
|
|
546 an 8-bit no-lock-shift ISO2022 coding system. */
|
|
547 FORMAT_CTEXT
|
|
548 };
|
|
549
|
|
550 enum run_hooks_condition
|
|
551 {
|
|
552 RUN_HOOKS_TO_COMPLETION,
|
|
553 RUN_HOOKS_UNTIL_SUCCESS,
|
|
554 RUN_HOOKS_UNTIL_FAILURE
|
|
555 };
|
|
556
|
|
557 #ifdef HAVE_TOOLBARS
|
|
558 enum toolbar_pos
|
|
559 {
|
|
560 TOP_TOOLBAR,
|
|
561 BOTTOM_TOOLBAR,
|
|
562 LEFT_TOOLBAR,
|
|
563 RIGHT_TOOLBAR
|
|
564 };
|
|
565 #endif
|
|
566
|
|
567 #ifndef ERROR_CHECK_TYPECHECK
|
|
568
|
|
569 typedef enum error_behavior
|
|
570 {
|
|
571 ERROR_ME,
|
|
572 ERROR_ME_NOT,
|
|
573 ERROR_ME_WARN
|
|
574 } Error_behavior;
|
|
575
|
|
576 #define ERRB_EQ(a, b) ((a) == (b))
|
|
577
|
|
578 #else
|
|
579
|
|
580 /* By defining it like this, we provide strict type-checking
|
|
581 for code that lazily uses ints. */
|
|
582
|
|
583 typedef struct _error_behavior_struct_
|
|
584 {
|
|
585 int really_unlikely_name_to_have_accidentally_in_a_non_errb_structure;
|
|
586 } Error_behavior;
|
|
587
|
|
588 extern Error_behavior ERROR_ME;
|
|
589 extern Error_behavior ERROR_ME_NOT;
|
|
590 extern Error_behavior ERROR_ME_WARN;
|
|
591
|
|
592 #define ERRB_EQ(a, b) \
|
|
593 ((a).really_unlikely_name_to_have_accidentally_in_a_non_errb_structure == \
|
|
594 (b).really_unlikely_name_to_have_accidentally_in_a_non_errb_structure)
|
|
595
|
|
596 #endif
|
|
597
|
|
598 enum munge_me_out_the_door
|
|
599 {
|
|
600 MUNGE_ME_FUNCTION_KEY,
|
|
601 MUNGE_ME_KEY_TRANSLATION
|
|
602 };
|
|
603
|
|
604
|
|
605 /************************************************************************/
|
|
606 /* Definition of Lisp_Object data type */
|
|
607 /************************************************************************/
|
|
608
|
|
609 /* There's not any particular reason not to use lrecords for these; some
|
|
610 objects get slightly larger, but we get 3 bit tags instead of 4.
|
|
611 */
|
70
|
612 #define LRECORD_SYMBOL
|
0
|
613
|
|
614
|
|
615 /* Define the fundamental Lisp data structures */
|
|
616
|
|
617 /* This is the set of Lisp data types */
|
|
618
|
|
619 enum Lisp_Type
|
|
620 {
|
|
621 /* Integer. XINT(obj) is the integer value. */
|
|
622 Lisp_Int /* 0 DTP-FIXNUM */
|
|
623
|
|
624 /* XRECORD_LHEADER (object) points to a struct lrecord_header
|
|
625 lheader->implementation determines the type (and GC behaviour)
|
|
626 of the object. */
|
|
627 ,Lisp_Record /* 1 DTP-OTHER-POINTER */
|
|
628
|
|
629 /* Cons. XCONS (object) points to a struct Lisp_Cons. */
|
|
630 ,Lisp_Cons /* 2 DTP-LIST */
|
|
631
|
|
632 /* LRECORD_STRING is NYI */
|
|
633 /* String. XSTRING (object) points to a struct Lisp_String.
|
|
634 The length of the string, and its contents, are stored therein. */
|
|
635 ,Lisp_String /* 3 DTP-STRING */
|
|
636
|
|
637 #ifndef LRECORD_VECTOR
|
|
638 /* Vector of Lisp objects. XVECTOR(object) points to a struct Lisp_Vector.
|
|
639 The length of the vector, and its contents, are stored therein. */
|
|
640 ,Lisp_Vector /* 4 DTP-SIMPLE-ARRAY */
|
|
641 #endif
|
|
642
|
|
643 #ifndef LRECORD_SYMBOL
|
|
644 /* Symbol. XSYMBOL (object) points to a struct Lisp_Symbol. */
|
|
645 ,Lisp_Symbol
|
|
646 #endif /* !LRECORD_SYMBOL */
|
70
|
647
|
|
648 ,Lisp_Char /* 5 DTP-CHAR */
|
16
|
649 };
|
0
|
650
|
|
651 /* unsafe! */
|
70
|
652 #define POINTER_TYPE_P(type) ((type) != Lisp_Int && (type) != Lisp_Char)
|
0
|
653
|
2
|
654 /* This should be the underlying type into which a Lisp_Object must fit.
|
0
|
655 In a strict ANSI world, this must be `int', since ANSI says you can't
|
|
656 use bitfields on any type other than `int'. However, on a machine
|
|
657 where `int' and `long' are not the same size, this should be the
|
|
658 longer of the two. (This also must be something into which a pointer
|
|
659 to an arbitrary object will fit, modulo any DATA_SEG_BITS cruft.)
|
|
660 */
|
|
661 #if (LONGBITS > INTBITS)
|
|
662 # define EMACS_INT long
|
|
663 # define EMACS_UINT unsigned long
|
|
664 #else
|
|
665 # define EMACS_INT int
|
|
666 # define EMACS_UINT unsigned int
|
|
667 #endif
|
|
668
|
|
669 /* Cast pointers to this type to compare them. Some machines want int. */
|
|
670 #ifndef PNTR_COMPARISON_TYPE
|
|
671 # define PNTR_COMPARISON_TYPE unsigned int
|
|
672 #endif
|
|
673
|
|
674 /* Overridden by m/next.h */
|
|
675 #ifndef ASSERT_VALID_POINTER
|
|
676 # define ASSERT_VALID_POINTER(pnt) (assert ((((EMACS_UINT) pnt) & 3) == 0))
|
|
677 #endif
|
|
678
|
|
679 /* These values are overridden by the m- file on some machines. */
|
|
680 #ifndef GCTYPEBITS
|
|
681 # define GCTYPEBITS 3L
|
|
682 #endif
|
|
683
|
|
684 #ifndef VALBITS
|
|
685 # define VALBITS ((LONGBITS)-((GCTYPEBITS)+1L))
|
|
686 #endif
|
|
687
|
|
688 #ifdef NO_UNION_TYPE
|
|
689 # include "lisp-disunion.h"
|
|
690 #else /* !NO_UNION_TYPE */
|
|
691 # include "lisp-union.h"
|
|
692 #endif /* !NO_UNION_TYPE */
|
|
693
|
|
694 /* WARNING WARNING WARNING. You must ensure on your own that proper
|
|
695 GC protection is provided for the elements in this array. */
|
|
696 typedef struct lisp_dynarr_type
|
|
697 {
|
|
698 Dynarr_declare (Lisp_Object);
|
|
699 } lisp_dynarr;
|
|
700
|
|
701 /* Close your eyes now lest you vomit or spontaneously combust ... */
|
|
702
|
|
703 #define HACKEQ_UNSAFE(obj1, obj2) \
|
|
704 (EQ (obj1, obj2) || (!POINTER_TYPE_P (XGCTYPE (obj1)) \
|
|
705 && !POINTER_TYPE_P (XGCTYPE (obj2)) \
|
|
706 && XREALINT (obj1) == XREALINT (obj2)))
|
|
707
|
70
|
708 #ifdef DEBUG_XEMACS
|
|
709 extern int debug_issue_ebola_notices;
|
|
710 int eq_with_ebola_notice (Lisp_Object, Lisp_Object);
|
|
711 #define EQ_WITH_EBOLA_NOTICE(obj1, obj2) \
|
|
712 (debug_issue_ebola_notices ? eq_with_ebola_notice (obj1, obj2) \
|
|
713 : EQ (obj1, obj2))
|
|
714 #else
|
|
715 #define EQ_WITH_EBOLA_NOTICE(obj1, obj2) EQ (obj1, obj2)
|
|
716 #endif
|
0
|
717
|
|
718 /* OK, you can open them again */
|
|
719
|
|
720 /************************************************************************/
|
|
721 /* Definitions of basic Lisp objects */
|
|
722 /************************************************************************/
|
|
723
|
|
724 #include "lrecord.h"
|
|
725
|
|
726 /********** unbound ***********/
|
|
727
|
|
728 /* Qunbound is a special Lisp_Object (actually of type
|
|
729 symbol-value-forward), that can never be visible to
|
|
730 the Lisp caller and thus can be used in the C code
|
|
731 to mean "no such value". */
|
|
732
|
|
733 #define UNBOUNDP(val) EQ (val, Qunbound)
|
|
734 #define GC_UNBOUNDP(val) GC_EQ (val, Qunbound)
|
|
735
|
|
736 /*********** cons ***********/
|
|
737
|
|
738 /* In a cons, the markbit of the car is the gc mark bit */
|
|
739
|
|
740 struct Lisp_Cons
|
|
741 {
|
|
742 Lisp_Object car, cdr;
|
|
743 };
|
|
744
|
|
745 #if 0 /* FSFmacs */
|
|
746 /* Like a cons, but records info on where the text lives that it was read from */
|
|
747 /* This is not really in use now */
|
|
748
|
|
749 struct Lisp_Buffer_Cons
|
|
750 {
|
|
751 Lisp_Object car, cdr;
|
|
752 struct buffer *buffer;
|
|
753 int bufpos;
|
|
754 };
|
|
755 #endif
|
|
756
|
|
757 DECLARE_NONRECORD (cons, Lisp_Cons, struct Lisp_Cons);
|
|
758 #define XCONS(a) XNONRECORD (a, cons, Lisp_Cons, struct Lisp_Cons)
|
|
759 #define XSETCONS(c, p) XSETOBJ (c, Lisp_Cons, p)
|
|
760 #define CONSP(x) (XTYPE (x) == Lisp_Cons)
|
|
761 #define GC_CONSP(x) (XGCTYPE (x) == Lisp_Cons)
|
|
762 #define CHECK_CONS(x) CHECK_NONRECORD (x, Lisp_Cons, Qconsp)
|
|
763 #define CONCHECK_CONS(x) CONCHECK_NONRECORD (x, Lisp_Cons, Qconsp)
|
|
764
|
|
765 /* Define these because they're used in a few places, inside and
|
|
766 out of alloc.c */
|
|
767 #define CONS_MARKED_P(c) XMARKBIT (c->car)
|
|
768 #define MARK_CONS(c) XMARK (c->car)
|
|
769
|
|
770 #define NILP(x) EQ (x, Qnil)
|
|
771 #define GC_NILP(x) GC_EQ (x, Qnil)
|
|
772 #define CHECK_LIST(x) \
|
|
773 do { if ((!CONSP (x)) && !NILP (x)) dead_wrong_type_argument (Qlistp, x); } while (0)
|
|
774 #define CONCHECK_LIST(x) \
|
|
775 do { if ((!CONSP (x)) && !NILP (x)) x = wrong_type_argument (Qlistp, x); } while (0)
|
|
776 #define XCAR(a) (XCONS (a)->car)
|
|
777 #define XCDR(a) (XCONS (a)->cdr)
|
|
778
|
|
779 /* For a list that's known to be in valid list format --
|
|
780 will abort() if the list is not in valid format */
|
|
781 #define LIST_LOOP(consvar, list) \
|
|
782 for (consvar = list; !NILP (consvar); consvar = XCDR (consvar))
|
|
783
|
|
784 /* For a list that's known to be in valid list format, where we may
|
|
785 be deleting the current element out of the list --
|
|
786 will abort() if the list is not in valid format */
|
84
|
787 #define LIST_LOOP_DELETING(consvar, nextconsvar, list) \
|
|
788 for (consvar = list; \
|
|
789 !NILP (consvar) ? (nextconsvar = XCDR (consvar), 1) : 0; \
|
0
|
790 consvar = nextconsvar)
|
|
791
|
|
792 /* For a list that may not be in valid list format --
|
|
793 will signal an error if the list is not in valid format */
|
|
794 #define EXTERNAL_LIST_LOOP(consvar, listp) \
|
|
795 for (consvar = listp; !NILP (consvar); consvar = XCDR (consvar)) \
|
|
796 if (!CONSP (consvar)) \
|
|
797 signal_simple_error ("Invalid list format", listp); \
|
|
798 else
|
|
799
|
|
800 /* For a property list (alternating keywords/values) that may not be
|
|
801 in valid list format -- will signal an error if the list is not in
|
|
802 valid format. CONSVAR is used to keep track of the iterations
|
|
803 without modifying LISTP.
|
|
804
|
|
805 We have to be tricky to still keep the same C format.*/
|
|
806 #define EXTERNAL_PROPERTY_LIST_LOOP(consvar, keyword, value, listp) \
|
|
807 for (consvar = listp; \
|
|
808 (CONSP (consvar) && CONSP (XCDR (consvar)) ? \
|
|
809 (keyword = XCAR (consvar), value = XCAR (XCDR (consvar))) : \
|
|
810 (keyword = Qunbound, value = Qunbound)), \
|
|
811 !NILP (consvar); \
|
|
812 consvar = XCDR (XCDR (consvar))) \
|
|
813 if (UNBOUNDP (keyword)) \
|
|
814 signal_simple_error ("Invalid property list format", listp); \
|
|
815 else
|
|
816
|
|
817 /*********** string ***********/
|
|
818
|
|
819 /* In a string or vector, the sign bit of the `size' is the gc mark bit */
|
|
820
|
|
821 /* (The size and data fields have underscores prepended to catch old
|
|
822 code that attempts to reference the fields directly) */
|
|
823 struct Lisp_String
|
|
824 {
|
|
825 #ifdef LRECORD_STRING
|
|
826 struct lrecord_header lheader;
|
|
827 #endif
|
2
|
828 Bytecount _size;
|
0
|
829 Bufbyte *_data;
|
|
830 Lisp_Object plist;
|
|
831 };
|
|
832
|
|
833 #ifdef LRECORD_STRING
|
|
834
|
|
835 DECLARE_LRECORD (string, struct Lisp_String);
|
|
836 #define XSTRING(x) XRECORD (x, string, struct Lisp_String)
|
|
837 #define XSETSTRING(x, p) XSETRECORD (x, p, string)
|
|
838 #define STRINGP(x) RECORDP (x, string)
|
|
839 #define GC_STRINGP(x) GC_RECORDP (x, string)
|
|
840 #define CHECK_STRING(x) CHECK_RECORD (x, string)
|
|
841 #define CONCHECK_STRING(x) CONCHECK_RECORD (x, string)
|
|
842
|
|
843 #else
|
|
844
|
|
845 DECLARE_NONRECORD (string, Lisp_String, struct Lisp_String);
|
|
846 #define XSTRING(x) XNONRECORD (x, string, Lisp_String, struct Lisp_String)
|
|
847 #define XSETSTRING(x, p) XSETOBJ (x, Lisp_String, p)
|
|
848 #define STRINGP(x) (XTYPE (x) == Lisp_String)
|
|
849 #define GC_STRINGP(x) (XGCTYPE (x) == Lisp_String)
|
|
850 #define CHECK_STRING(x) CHECK_NONRECORD (x, Lisp_String, Qstringp)
|
|
851 #define CONCHECK_STRING(x) CONCHECK_NONRECORD (x, Lisp_String, Qstringp)
|
|
852
|
|
853 #endif
|
|
854
|
70
|
855 #ifdef MULE
|
|
856
|
|
857 Charcount bytecount_to_charcount (CONST Bufbyte *ptr, Bytecount len);
|
|
858 Bytecount charcount_to_bytecount (CONST Bufbyte *ptr, Charcount len);
|
|
859
|
|
860 #else /* not MULE */
|
0
|
861
|
|
862 # define bytecount_to_charcount(ptr, len) (len)
|
|
863 # define charcount_to_bytecount(ptr, len) (len)
|
|
864
|
70
|
865 #endif /* not MULE */
|
|
866
|
0
|
867 #define string_length(s) ((s)->_size)
|
14
|
868 #define XSTRING_LENGTH(s) string_length (XSTRING (s))
|
0
|
869 #define string_data(s) ((s)->_data + 0)
|
14
|
870 #define XSTRING_DATA(s) string_data (XSTRING (s))
|
0
|
871 #define string_byte(s, i) ((s)->_data[i] + 0)
|
14
|
872 #define XSTRING_BYTE(s, i) string_byte (XSTRING (s), i)
|
0
|
873 #define string_byte_addr(s, i) (&((s)->_data[i]))
|
|
874 #define set_string_length(s, len) do { (s)->_size = (len); } while (0)
|
|
875 #define set_string_data(s, ptr) do { (s)->_data = (ptr); } while (0)
|
|
876 #define set_string_byte(s, i, c) do { (s)->_data[i] = (c); } while (0)
|
|
877
|
|
878 void resize_string (struct Lisp_String *s, Bytecount pos, Bytecount delta);
|
|
879
|
70
|
880 #ifdef MULE
|
|
881
|
|
882 INLINE Charcount string_char_length (struct Lisp_String *s);
|
|
883 INLINE Charcount
|
|
884 string_char_length (struct Lisp_String *s)
|
|
885 {
|
|
886 return bytecount_to_charcount (string_data (s), string_length (s));
|
|
887 }
|
|
888
|
|
889 # define string_char(s, i) charptr_emchar_n (string_data (s), i)
|
|
890 # define string_char_addr(s, i) charptr_n_addr (string_data (s), i)
|
|
891 void set_string_char (struct Lisp_String *s, Charcount i, Emchar c);
|
|
892
|
|
893 #else /* not MULE */
|
|
894
|
0
|
895 # define string_char_length(s) string_length (s)
|
|
896 # define string_char(s, i) ((Emchar) string_byte (s, i))
|
|
897 # define string_char_addr(s, i) string_byte_addr (s, i)
|
|
898 # define set_string_char(s, i, c) set_string_byte (s, i, c)
|
|
899
|
70
|
900 #endif /* not MULE */
|
0
|
901
|
|
902 /*********** vector ***********/
|
|
903
|
|
904 struct Lisp_Vector
|
|
905 {
|
|
906 #ifdef LRECORD_VECTOR
|
|
907 struct lrecord_header lheader;
|
|
908 #endif
|
|
909 long size;
|
|
910 /* next is now chained through v->contents[size], terminated by Qzero.
|
2
|
911 This means that pure vectors don't need a "next" */
|
0
|
912 /* struct Lisp_Vector *next; */
|
|
913 Lisp_Object contents[1];
|
|
914 };
|
|
915
|
|
916 #ifdef LRECORD_VECTOR
|
|
917
|
|
918 DECLARE_LRECORD (vector, struct Lisp_Vector);
|
|
919 #define XVECTOR(x) XRECORD (x, vector, struct Lisp_Vector)
|
|
920 #define XSETVECTOR(x, p) XSETRECORD (x, p, vector)
|
|
921 #define VECTORP(x) RECORDP (x, vector)
|
|
922 #define GC_VECTORP(x) GC_RECORDP (x, vector)
|
|
923 #define CHECK_VECTOR(x) CHECK_RECORD (x, vector)
|
|
924 #define CONCHECK_VECTOR(x) CONCHECK_RECORD (x, vector)
|
|
925
|
|
926 #else
|
|
927
|
|
928 DECLARE_NONRECORD (vector, Lisp_Vector, struct Lisp_Vector);
|
|
929 #define XVECTOR(x) XNONRECORD (x, vector, Lisp_Vector, struct Lisp_Vector)
|
|
930 #define XSETVECTOR(x, p) XSETOBJ (x, Lisp_Vector, p)
|
|
931 #define VECTORP(x) (XTYPE (x) == Lisp_Vector)
|
|
932 #define GC_VECTORP(x) (XGCTYPE (x) == Lisp_Vector)
|
|
933 #define CHECK_VECTOR(x) CHECK_NONRECORD (x, Lisp_Vector, Qvectorp)
|
|
934 #define CONCHECK_VECTOR(x) CONCHECK_NONRECORD (x, Lisp_Vector, Qvectorp)
|
|
935
|
|
936 #endif
|
|
937
|
|
938 #define vector_length(v) ((v)->size)
|
|
939 #define vector_data(v) ((v)->contents)
|
|
940 #define vector_next(v) ((v)->contents[(v)->size])
|
|
941
|
|
942 /*********** bit vector ***********/
|
|
943
|
|
944 #if (LONGBITS < 16)
|
14
|
945 #error What the hell?!
|
0
|
946 #elif (LONGBITS < 32)
|
|
947 # define LONGBITS_LOG2 4
|
|
948 # define LONGBITS_POWER_OF_2 16
|
|
949 #elif (LONGBITS < 64)
|
|
950 # define LONGBITS_LOG2 5
|
|
951 # define LONGBITS_POWER_OF_2 32
|
|
952 #elif (LONGBITS < 128)
|
|
953 # define LONGBITS_LOG2 6
|
|
954 # define LONGBITS_POWER_OF_2 64
|
|
955 #else
|
|
956 #error You really have 128-bit integers?!
|
|
957 #endif
|
|
958
|
|
959 struct Lisp_Bit_Vector
|
|
960 {
|
|
961 struct lrecord_header lheader;
|
|
962 Lisp_Object next;
|
|
963 long size;
|
|
964 unsigned int bits[1];
|
|
965 };
|
|
966
|
|
967 DECLARE_LRECORD (bit_vector, struct Lisp_Bit_Vector);
|
|
968 #define XBIT_VECTOR(x) XRECORD (x, bit_vector, struct Lisp_Bit_Vector)
|
|
969 #define XSETBIT_VECTOR(x, p) XSETRECORD (x, p, bit_vector)
|
|
970 #define BIT_VECTORP(x) RECORDP (x, bit_vector)
|
|
971 #define GC_BIT_VECTORP(x) GC_RECORDP (x, bit_vector)
|
|
972 #define CHECK_BIT_VECTOR(x) CHECK_RECORD (x, bit_vector)
|
|
973 #define CONCHECK_BIT_VECTOR(x) CONCHECK_RECORD (x, bit_vector)
|
|
974
|
|
975 #define BITP(x) (INTP (x) && (XINT (x) == 0 || XINT (x) == 1))
|
|
976 #define GC_BITP(x) (GC_INTP (x) && (XINT (x) == 0 || XINT (x) == 1))
|
|
977
|
|
978 #define CHECK_BIT(x) \
|
|
979 do { if (!BITP (x)) dead_wrong_type_argument (Qbitp, x); } while (0)
|
|
980 #define CONCHECK_BIT(x) \
|
|
981 do { if (!BITP (x)) x = wrong_type_argument (Qbitp, x); } while (0)
|
|
982
|
|
983 #define bit_vector_length(v) ((v)->size)
|
|
984 #define bit_vector_next(v) ((v)->next)
|
|
985
|
|
986 INLINE int bit_vector_bit (struct Lisp_Bit_Vector *v, int i);
|
|
987 INLINE int
|
|
988 bit_vector_bit (struct Lisp_Bit_Vector *v, int i)
|
|
989 {
|
|
990 unsigned int ui = (unsigned int) i;
|
|
991
|
|
992 return (((v)->bits[ui >> LONGBITS_LOG2] >> (ui & (LONGBITS_POWER_OF_2 - 1)))
|
|
993 & 1);
|
|
994 }
|
|
995
|
|
996 INLINE void set_bit_vector_bit (struct Lisp_Bit_Vector *v, int i, int value);
|
|
997 INLINE void
|
|
998 set_bit_vector_bit (struct Lisp_Bit_Vector *v, int i, int value)
|
|
999 {
|
|
1000 unsigned int ui = (unsigned int) i;
|
|
1001 if (value)
|
|
1002 (v)->bits[ui >> LONGBITS_LOG2] |= (1 << (ui & (LONGBITS_POWER_OF_2 - 1)));
|
|
1003 else
|
|
1004 (v)->bits[ui >> LONGBITS_LOG2] &= ~(1 << (ui & (LONGBITS_POWER_OF_2 - 1)));
|
|
1005 }
|
|
1006
|
|
1007 /* Number of longs required to hold LEN bits */
|
|
1008 #define BIT_VECTOR_LONG_STORAGE(len) \
|
|
1009 ((len + LONGBITS_POWER_OF_2 - 1) >> LONGBITS_LOG2)
|
|
1010
|
|
1011
|
|
1012 /*********** symbol ***********/
|
|
1013
|
|
1014 /* In a symbol, the markbit of the plist is used as the gc mark bit */
|
|
1015
|
|
1016 struct Lisp_Symbol
|
|
1017 {
|
|
1018 #ifdef LRECORD_SYMBOL
|
|
1019 struct lrecord_header lheader;
|
|
1020 #endif
|
|
1021 /* next symbol in this obarray bucket */
|
|
1022 struct Lisp_Symbol *next;
|
|
1023 struct Lisp_String *name;
|
|
1024 Lisp_Object value;
|
|
1025 Lisp_Object function;
|
|
1026 Lisp_Object plist;
|
|
1027 };
|
|
1028
|
|
1029 #define SYMBOL_IS_KEYWORD(sym) (string_byte (XSYMBOL(sym)->name, 0) == ':')
|
|
1030 #define KEYWORDP(obj) (SYMBOLP (obj) && SYMBOL_IS_KEYWORD (obj))
|
|
1031
|
|
1032 #ifdef LRECORD_SYMBOL
|
|
1033
|
|
1034 DECLARE_LRECORD (symbol, struct Lisp_Symbol);
|
|
1035 #define XSYMBOL(x) XRECORD (x, symbol, struct Lisp_Symbol)
|
|
1036 #define XSETSYMBOL(x, p) XSETRECORD (x, p, symbol)
|
|
1037 #define SYMBOLP(x) RECORDP (x, symbol)
|
|
1038 #define GC_SYMBOLP(x) GC_RECORDP (x, symbol)
|
|
1039 #define CHECK_SYMBOL(x) CHECK_RECORD (x, symbol)
|
|
1040 #define CONCHECK_SYMBOL(x) CONCHECK_RECORD (x, symbol)
|
|
1041
|
|
1042 #else
|
|
1043
|
|
1044 DECLARE_NONRECORD (symbol, Lisp_Symbol, struct Lisp_Symbol);
|
|
1045 #define XSYMBOL(x) XNONRECORD (x, symbol, Lisp_Symbol, struct Lisp_Symbol)
|
|
1046 #define XSETSYMBOL(s, p) XSETOBJ ((s), Lisp_Symbol, (p))
|
|
1047 #define SYMBOLP(x) (XTYPE (x) == Lisp_Symbol)
|
|
1048 #define GC_SYMBOLP(x) (XGCTYPE (x) == Lisp_Symbol)
|
|
1049 #define CHECK_SYMBOL(x) CHECK_NONRECORD (x, Lisp_Symbol, Qsymbolp)
|
|
1050 #define CONCHECK_SYMBOL(x) CONCHECK_NONRECORD (x, Lisp_Symbol, Qsymbolp)
|
|
1051
|
|
1052 #endif
|
|
1053
|
|
1054 #define symbol_next(s) ((s)->next)
|
|
1055 #define symbol_name(s) ((s)->name)
|
|
1056 #define symbol_value(s) ((s)->value)
|
|
1057 #define symbol_function(s) ((s)->function)
|
|
1058 #define symbol_plist(s) ((s)->plist)
|
|
1059
|
|
1060 /*********** subr ***********/
|
|
1061
|
74
|
1062 typedef Lisp_Object (*lisp_fn_t) (Lisp_Object, ...);
|
84
|
1063
|
0
|
1064 struct Lisp_Subr
|
|
1065 {
|
|
1066 struct lrecord_header lheader;
|
|
1067 short min_args, max_args;
|
|
1068 CONST char *prompt;
|
|
1069 CONST char *doc;
|
|
1070 CONST char *name;
|
74
|
1071 lisp_fn_t subr_fn;
|
0
|
1072 };
|
|
1073
|
|
1074 DECLARE_LRECORD (subr, struct Lisp_Subr);
|
|
1075 #define XSUBR(x) XRECORD (x, subr, struct Lisp_Subr)
|
|
1076 #define XSETSUBR(x, p) XSETRECORD (x, p, subr)
|
|
1077 #define SUBRP(x) RECORDP (x, subr)
|
|
1078 #define GC_SUBRP(x) GC_RECORDP (x, subr)
|
|
1079 #define CHECK_SUBR(x) CHECK_RECORD (x, subr)
|
|
1080 #define CONCHECK_SUBR(x) CONCHECK_RECORD (x, subr)
|
|
1081
|
|
1082 #define subr_function(subr) (subr)->subr_fn
|
|
1083 #define subr_name(subr) (subr)->name
|
|
1084
|
|
1085 /*********** marker ***********/
|
|
1086
|
|
1087 struct Lisp_Marker
|
|
1088 {
|
|
1089 struct lrecord_header lheader;
|
|
1090 struct Lisp_Marker *next, *prev;
|
|
1091 struct buffer *buffer;
|
|
1092 Memind memind;
|
|
1093 char insertion_type;
|
|
1094 };
|
|
1095
|
|
1096 DECLARE_LRECORD (marker, struct Lisp_Marker);
|
|
1097 #define XMARKER(x) XRECORD (x, marker, struct Lisp_Marker)
|
|
1098 #define XSETMARKER(x, p) XSETRECORD (x, p, marker)
|
|
1099 #define MARKERP(x) RECORDP (x, marker)
|
|
1100 #define GC_MARKERP(x) GC_RECORDP (x, marker)
|
|
1101 #define CHECK_MARKER(x) CHECK_RECORD (x, marker)
|
|
1102 #define CONCHECK_MARKER(x) CONCHECK_RECORD (x, marker)
|
|
1103
|
|
1104 /* The second check was looking for GCed markers still in use */
|
|
1105 /* if (INTP (XMARKER (x)->lheader.next.v)) abort (); */
|
|
1106
|
|
1107 #define marker_next(m) ((m)->next)
|
|
1108 #define marker_prev(m) ((m)->prev)
|
|
1109
|
|
1110 /*********** char ***********/
|
|
1111
|
70
|
1112 #define CHARP(x) (XTYPE (x) == Lisp_Char)
|
|
1113 #define GC_CHARP(x) (XGCTYPE (x) == Lisp_Char)
|
0
|
1114
|
|
1115 #ifdef ERROR_CHECK_TYPECHECK
|
|
1116
|
|
1117 INLINE Emchar XCHAR (Lisp_Object obj);
|
|
1118 INLINE Emchar
|
|
1119 XCHAR (Lisp_Object obj)
|
|
1120 {
|
70
|
1121 assert (CHARP (obj));
|
0
|
1122 return XREALINT (obj);
|
|
1123 }
|
|
1124
|
|
1125 #else
|
|
1126
|
70
|
1127 #define XCHAR(x) XREALINT (x)
|
0
|
1128
|
|
1129 #endif
|
|
1130
|
70
|
1131 #define CHECK_CHAR(x) CHECK_NONRECORD (x, Lisp_Char, Qcharacterp)
|
|
1132 #define CONCHECK_CHAR(x) CONCHECK_NONRECORD (x, Lisp_Char, Qcharacterp)
|
0
|
1133
|
|
1134
|
|
1135 /*********** float ***********/
|
|
1136
|
|
1137 #ifdef LISP_FLOAT_TYPE
|
|
1138
|
|
1139 struct Lisp_Float
|
|
1140 {
|
|
1141 struct lrecord_header lheader;
|
|
1142 union { double d; struct Lisp_Float *next; } data;
|
|
1143 };
|
|
1144
|
|
1145 DECLARE_LRECORD (float, struct Lisp_Float);
|
|
1146 #define XFLOAT(x) XRECORD (x, float, struct Lisp_Float)
|
|
1147 #define XSETFLOAT(x, p) XSETRECORD (x, p, float)
|
|
1148 #define FLOATP(x) RECORDP (x, float)
|
|
1149 #define GC_FLOATP(x) GC_RECORDP (x, float)
|
|
1150 #define CHECK_FLOAT(x) CHECK_RECORD (x, float)
|
|
1151 #define CONCHECK_FLOAT(x) CONCHECK_RECORD (x, float)
|
|
1152
|
|
1153 #define float_next(f) ((f)->data.next)
|
|
1154 #define float_data(f) ((f)->data.d)
|
|
1155
|
|
1156 #ifndef DBL_DIG
|
|
1157 # define DBL_DIG 16
|
|
1158 #endif
|
|
1159
|
|
1160 #define XFLOATINT(n) extract_float (n)
|
|
1161
|
|
1162 #define CHECK_INT_OR_FLOAT(x) \
|
|
1163 do { if ( !INTP (x) && !FLOATP (x)) \
|
|
1164 dead_wrong_type_argument (Qnumberp, (x)); } while (0)
|
|
1165 #define CONCHECK_INT_OR_FLOAT(x) \
|
|
1166 do { if ( !INTP (x) && !FLOATP (x)) \
|
|
1167 x = wrong_type_argument (Qnumberp, (x)); } while (0)
|
|
1168
|
|
1169 /* These are always continuable because they change their arguments
|
|
1170 even when no error is signalled. */
|
|
1171
|
84
|
1172 #define CHECK_INT_OR_FLOAT_COERCE_MARKER(x) do \
|
|
1173 { if (INTP (x) || FLOATP (x)) \
|
|
1174 ; \
|
|
1175 else if (MARKERP (x)) \
|
|
1176 x = make_int (marker_position (x)); \
|
|
1177 else \
|
|
1178 x = wrong_type_argument (Qnumber_or_marker_p, x); \
|
16
|
1179 } while (0)
|
0
|
1180
|
84
|
1181 #define CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER(x) do \
|
|
1182 { if (INTP (x) || FLOATP (x)) \
|
|
1183 ; \
|
|
1184 else if (CHARP (x)) \
|
|
1185 x = make_int (XCHAR (x)); \
|
|
1186 else if (MARKERP (x)) \
|
|
1187 x = make_int (marker_position (x)); \
|
|
1188 else \
|
|
1189 x = wrong_type_argument (Qnumber_char_or_marker_p, x); \
|
16
|
1190 } while (0)
|
0
|
1191
|
|
1192 # define INT_OR_FLOATP(x) (INTP (x) || FLOATP (x))
|
|
1193 # define GC_INT_OR_FLOATP(x) (GC_INTP (x) || GC_FLOATP (x))
|
|
1194
|
|
1195 #else /* not LISP_FLOAT_TYPE */
|
|
1196
|
|
1197 #define XFLOAT(x) --- error! No float support. ---
|
|
1198 #define XSETFLOAT(x, p) --- error! No float support. ---
|
|
1199 #define FLOATP(x) 0
|
|
1200 #define GC_FLOATP(x) 0
|
|
1201 #define CHECK_FLOAT(x) --- error! No float support. ---
|
|
1202 #define CONCHECK_FLOAT(x) --- error! No float support. ---
|
|
1203
|
|
1204 #define XFLOATINT(n) XINT(n)
|
|
1205 #define CHECK_INT_OR_FLOAT CHECK_INT
|
|
1206 #define CONCHECK_INT_OR_FLOAT CONCHECK_INT
|
|
1207 #define CHECK_INT_OR_FLOAT_COERCE_MARKER CHECK_INT_COERCE_MARKER
|
|
1208 #define CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER \
|
|
1209 CHECK_INT_COERCE_CHAR_OR_MARKER
|
|
1210 #define INT_OR_FLOATP(x) (INTP (x))
|
|
1211 # define GC_INT_OR_FLOATP(x) (GC_INTP (x))
|
|
1212
|
|
1213 #endif /* not LISP_FLOAT_TYPE */
|
|
1214
|
|
1215 #define INTP(x) (XTYPE (x) == Lisp_Int)
|
|
1216 #define GC_INTP(x) (XGCTYPE (x) == Lisp_Int)
|
|
1217
|
|
1218 #define ZEROP(x) EQ (x, Qzero)
|
|
1219 #define GC_ZEROP(x) GC_EQ (x, Qzero)
|
|
1220
|
|
1221 #ifdef ERROR_CHECK_TYPECHECK
|
|
1222
|
|
1223 INLINE EMACS_INT XINT (Lisp_Object obj);
|
|
1224 INLINE EMACS_INT
|
|
1225 XINT (Lisp_Object obj)
|
|
1226 {
|
|
1227 assert (INTP (obj));
|
|
1228 return XREALINT (obj);
|
|
1229 }
|
|
1230
|
|
1231 #else
|
|
1232
|
|
1233 #define XINT(obj) XREALINT (obj)
|
|
1234
|
|
1235 #endif
|
|
1236
|
|
1237 #define CHECK_INT(x) CHECK_NONRECORD (x, Lisp_Int, Qintegerp)
|
|
1238 #define CONCHECK_INT(x) CONCHECK_NONRECORD (x, Lisp_Int, Qintegerp)
|
|
1239
|
|
1240 #define NATNUMP(x) (INTP (x) && XINT (x) >= 0)
|
|
1241 #define GC_NATNUMP(x) (GC_INTP (x) && XINT (x) >= 0)
|
|
1242
|
|
1243 #define CHECK_NATNUM(x) \
|
|
1244 do { if (!NATNUMP (x)) dead_wrong_type_argument (Qnatnump, x); } while (0)
|
|
1245 #define CONCHECK_NATNUM(x) \
|
|
1246 do { if (!NATNUMP (x)) x = wrong_type_argument (Qnatnump, x); } while (0)
|
|
1247
|
|
1248 /* next three always continuable because they coerce their arguments. */
|
84
|
1249 #define CHECK_INT_COERCE_CHAR(x) do \
|
|
1250 { if (INTP (x)) \
|
|
1251 ; \
|
|
1252 else if (CHARP (x)) \
|
|
1253 x = make_int (XCHAR (x)); \
|
|
1254 else \
|
|
1255 x = wrong_type_argument (Qinteger_or_char_p, x); \
|
16
|
1256 } while (0)
|
0
|
1257
|
84
|
1258 #define CHECK_INT_COERCE_MARKER(x) do \
|
|
1259 { if (INTP (x)) \
|
|
1260 ; \
|
|
1261 else if (MARKERP (x)) \
|
|
1262 x = make_int (marker_position (x)); \
|
|
1263 else \
|
|
1264 x = wrong_type_argument (Qinteger_or_marker_p, x); \
|
16
|
1265 } while (0)
|
0
|
1266
|
84
|
1267 #define CHECK_INT_COERCE_CHAR_OR_MARKER(x) do \
|
|
1268 { if (INTP (x)) \
|
|
1269 ; \
|
|
1270 else if (CHARP (x)) \
|
|
1271 x = make_int (XCHAR (x)); \
|
|
1272 else if (MARKERP (x)) \
|
|
1273 x = make_int (marker_position (x)); \
|
|
1274 else \
|
|
1275 x = wrong_type_argument (Qinteger_char_or_marker_p, x); \
|
16
|
1276 } while (0)
|
0
|
1277
|
|
1278 /*********** pure space ***********/
|
|
1279
|
|
1280 #define CHECK_IMPURE(obj) \
|
|
1281 do { if (purified (obj)) pure_write_error (); } while (0)
|
|
1282
|
|
1283 /*********** structures ***********/
|
|
1284
|
|
1285 struct structure_keyword_entry
|
|
1286 {
|
|
1287 Lisp_Object keyword;
|
|
1288 int (*validate) (Lisp_Object keyword, Lisp_Object value,
|
|
1289 Error_behavior errb);
|
|
1290 };
|
|
1291
|
|
1292 typedef struct structure_keyword_entry_dynarr_type
|
|
1293 {
|
|
1294 Dynarr_declare (struct structure_keyword_entry);
|
|
1295 } Structure_keyword_entry_dynarr;
|
|
1296
|
|
1297 struct structure_type
|
|
1298 {
|
|
1299 Lisp_Object type;
|
|
1300 Structure_keyword_entry_dynarr *keywords;
|
|
1301 int (*validate) (Lisp_Object data, Error_behavior errb);
|
|
1302 Lisp_Object (*instantiate) (Lisp_Object data);
|
|
1303 };
|
|
1304
|
|
1305 typedef struct structure_type_dynarr_type
|
|
1306 {
|
|
1307 Dynarr_declare (struct structure_type);
|
|
1308 } Structure_type_dynarr;
|
|
1309
|
|
1310 struct structure_type *define_structure_type (Lisp_Object type,
|
|
1311 int (*validate)
|
|
1312 (Lisp_Object data,
|
|
1313 Error_behavior errb),
|
|
1314 Lisp_Object (*instantiate)
|
|
1315 (Lisp_Object data));
|
|
1316 void define_structure_type_keyword (struct structure_type *st,
|
|
1317 Lisp_Object keyword,
|
|
1318 int (*validate) (Lisp_Object keyword,
|
|
1319 Lisp_Object value,
|
|
1320 Error_behavior errb));
|
|
1321
|
|
1322 /*********** weak lists ***********/
|
|
1323
|
|
1324 enum weak_list_type
|
|
1325 {
|
|
1326 /* element disappears if it's unmarked. */
|
|
1327 WEAK_LIST_SIMPLE,
|
|
1328 /* element disappears if it's a cons and either its car or
|
|
1329 cdr is unmarked. */
|
|
1330 WEAK_LIST_ASSOC,
|
|
1331 /* element disappears if it's a cons and its car is unmarked. */
|
|
1332 WEAK_LIST_KEY_ASSOC,
|
|
1333 /* element disappears if it's a cons and its cdr is unmarked. */
|
|
1334 WEAK_LIST_VALUE_ASSOC
|
|
1335 };
|
|
1336
|
|
1337 struct weak_list
|
|
1338 {
|
|
1339 struct lcrecord_header header;
|
|
1340 Lisp_Object list; /* don't mark through this! */
|
|
1341 enum weak_list_type type;
|
|
1342 Lisp_Object next_weak; /* don't mark through this! */
|
|
1343 };
|
|
1344
|
|
1345 DECLARE_LRECORD (weak_list, struct weak_list);
|
|
1346 #define XWEAK_LIST(x) XRECORD (x, weak_list, struct weak_list)
|
|
1347 #define XSETWEAK_LIST(x, p) XSETRECORD (x, p, weak_list)
|
|
1348 #define WEAK_LISTP(x) RECORDP (x, weak_list)
|
|
1349 #define GC_WEAK_LISTP(x) GC_RECORDP (x, weak_list)
|
|
1350 #define CHECK_WEAK_LIST(x) CHECK_RECORD (x, weak_list)
|
|
1351 #define CONCHECK_WEAK_LIST(x) CONCHECK_RECORD (x, weak_list)
|
|
1352
|
|
1353 #define weak_list_list(w) ((w)->list)
|
|
1354 #define XWEAK_LIST_LIST(w) (XWEAK_LIST (w)->list)
|
|
1355
|
|
1356 Lisp_Object make_weak_list (enum weak_list_type type);
|
|
1357 /* The following two are only called by the garbage collector */
|
|
1358 int finish_marking_weak_lists (int (*obj_marked_p) (Lisp_Object),
|
|
1359 void (*markobj) (Lisp_Object));
|
|
1360 void prune_weak_lists (int (*obj_marked_p) (Lisp_Object));
|
|
1361
|
|
1362 /*********** lcrecord lists ***********/
|
|
1363
|
|
1364 struct lcrecord_list
|
|
1365 {
|
|
1366 struct lcrecord_header header;
|
|
1367 Lisp_Object free;
|
|
1368 int size;
|
|
1369 CONST struct lrecord_implementation *implementation;
|
|
1370 };
|
|
1371
|
|
1372 DECLARE_LRECORD (lcrecord_list, struct lcrecord_list);
|
|
1373 #define XLCRECORD_LIST(x) XRECORD (x, lcrecord_list, struct lcrecord_list)
|
|
1374 #define XSETLCRECORD_LIST(x, p) XSETRECORD (x, p, lcrecord_list)
|
|
1375 #define LCRECORD_LISTP(x) RECORDP (x, lcrecord_list)
|
|
1376 #define GC_LCRECORD_LISTP(x) GC_RECORDP (x, lcrecord_list)
|
|
1377 /* #define CHECK_LCRECORD_LIST(x) CHECK_RECORD (x, lcrecord_list)
|
|
1378 Lcrecord lists should never escape to the Lisp level, so
|
|
1379 functions should not be doing this. */
|
|
1380
|
|
1381 Lisp_Object make_lcrecord_list (int size,
|
|
1382 CONST struct lrecord_implementation
|
|
1383 *implementation);
|
|
1384 Lisp_Object allocate_managed_lcrecord (Lisp_Object lcrecord_list);
|
|
1385 void free_managed_lcrecord (Lisp_Object lcrecord_list, Lisp_Object lcrecord);
|
|
1386
|
|
1387
|
|
1388 /************************************************************************/
|
|
1389 /* Definitions of primitive Lisp functions and variables */
|
|
1390 /************************************************************************/
|
|
1391
|
16
|
1392
|
|
1393 /* DEFUN - Define a built-in Lisp-visible C function or `subr'.
|
0
|
1394 `lname' should be the name to give the function in Lisp,
|
|
1395 as a null-terminated C string.
|
16
|
1396 `Fname' should be the C equivalent of `lname', using only characters
|
|
1397 valid in a C identifier, with an "F" prepended.
|
20
|
1398 The name of the C constant structure that records information
|
|
1399 on this function for internal use is "S" concatenated with Fname.
|
0
|
1400 `minargs' should be a number, the minimum number of arguments allowed.
|
|
1401 `maxargs' should be a number, the maximum number of arguments allowed,
|
|
1402 or else MANY or UNEVALLED.
|
|
1403 MANY means pass a vector of evaluated arguments,
|
|
1404 in the form of an integer number-of-arguments
|
|
1405 followed by the address of a vector of Lisp_Objects
|
|
1406 which contains the argument values.
|
16
|
1407 UNEVALLED means pass the list of unevaluated arguments.
|
0
|
1408 `prompt' says how to read arguments for an interactive call.
|
|
1409 See the doc string for `interactive'.
|
|
1410 A null string means call interactively with no arguments.
|
16
|
1411 `arglist' are the comma-separated arguments (always Lisp_Objects) for
|
|
1412 the function.
|
|
1413 The docstring for the function is placed as a "C" comment between
|
|
1414 the prompt and the `args' argument. make-docfile reads the
|
|
1415 comment and creates the DOC file form it.
|
0
|
1416 */
|
|
1417
|
|
1418 #define SUBR_MAX_ARGS 8
|
|
1419 #define MANY -2
|
|
1420 #define UNEVALLED -1
|
|
1421
|
|
1422 /* Can't be const, because then subr->doc is read-only and
|
16
|
1423 Snarf_documentation chokes */
|
20
|
1424
|
|
1425 #define DEFUN(lname, Fname, minargs, maxargs, prompt, arglist) \
|
100
|
1426 Lisp_Object Fname (DEFUN_##maxargs arglist) ; /* See below */ \
|
74
|
1427 static struct Lisp_Subr S##Fname = { {lrecord_subr}, \
|
|
1428 minargs, maxargs, prompt, 0, lname, (lisp_fn_t) Fname }; \
|
20
|
1429 Lisp_Object Fname (DEFUN_##maxargs arglist)
|
|
1430
|
16
|
1431 /* Heavy ANSI C preprocessor hackery to get DEFUN to declare a
|
|
1432 prototype that matches maxargs, and add the obligatory
|
|
1433 `Lisp_Object' type declaration to the formal C arguments. */
|
0
|
1434
|
20
|
1435 #define DEFUN_MANY(named_int, named_Lisp_Object) named_int, named_Lisp_Object
|
16
|
1436 #define DEFUN_UNEVALLED(args) Lisp_Object args
|
|
1437 #define DEFUN_0() void
|
|
1438 #define DEFUN_1(a) Lisp_Object a
|
|
1439 #define DEFUN_2(a,b) DEFUN_1(a), Lisp_Object b
|
|
1440 #define DEFUN_3(a,b,c) DEFUN_2(a,b), Lisp_Object c
|
|
1441 #define DEFUN_4(a,b,c,d) DEFUN_3(a,b,c), Lisp_Object d
|
|
1442 #define DEFUN_5(a,b,c,d,e) DEFUN_4(a,b,c,d), Lisp_Object e
|
|
1443 #define DEFUN_6(a,b,c,d,e,f) DEFUN_5(a,b,c,d,e), Lisp_Object f
|
|
1444 #define DEFUN_7(a,b,c,d,e,f,g) DEFUN_6(a,b,c,d,e,f), Lisp_Object g
|
|
1445 #define DEFUN_8(a,b,c,d,e,f,g,h) DEFUN_7(a,b,c,d,e,f,g), Lisp_Object h
|
84
|
1446
|
16
|
1447 /* WARNING: If you add defines here for higher values of maxargs,
|
|
1448 make sure to also fix the clauses in primitive_funcall(),
|
|
1449 and change the define of SUBR_MAX_ARGS above. */
|
0
|
1450
|
|
1451 #include "symeval.h"
|
|
1452
|
16
|
1453 /* Depth of special binding/unwind-protect stack. Use as arg to `unbind_to' */
|
0
|
1454 int specpdl_depth (void);
|
|
1455
|
|
1456
|
|
1457 /************************************************************************/
|
|
1458 /* Checking for QUIT */
|
|
1459 /************************************************************************/
|
|
1460
|
|
1461 /* Asynchronous events set something_happened, and then are processed
|
|
1462 within the QUIT macro. At this point, we are guaranteed to not be in
|
|
1463 any sensitive code. */
|
|
1464
|
|
1465 extern volatile int something_happened;
|
|
1466 int check_what_happened (void);
|
|
1467
|
|
1468 extern volatile int quit_check_signal_happened;
|
|
1469 extern volatile int quit_check_signal_tick_count;
|
|
1470 int check_quit (void);
|
|
1471
|
|
1472 void signal_quit (void);
|
|
1473
|
|
1474 /* Nonzero if ought to quit now. */
|
84
|
1475 #define QUITP \
|
|
1476 ((quit_check_signal_happened ? check_quit () : 0), \
|
|
1477 (!NILP (Vquit_flag) && (NILP (Vinhibit_quit) \
|
|
1478 || EQ (Vquit_flag, Qcritical))))
|
0
|
1479
|
|
1480 /* QUIT used to call QUITP, but there are some places where QUITP
|
|
1481 is called directly, and check_what_happened() should only be called
|
|
1482 when Emacs is actually ready to quit because it could do things
|
|
1483 like switch threads. */
|
84
|
1484 #define INTERNAL_QUITP \
|
|
1485 ((something_happened ? check_what_happened () : 0), \
|
|
1486 (!NILP (Vquit_flag) && \
|
0
|
1487 (NILP (Vinhibit_quit) || EQ (Vquit_flag, Qcritical))))
|
|
1488
|
84
|
1489 #define INTERNAL_REALLY_QUITP \
|
|
1490 (check_what_happened (), \
|
|
1491 (!NILP (Vquit_flag) && \
|
0
|
1492 (NILP (Vinhibit_quit) || EQ (Vquit_flag, Qcritical))))
|
|
1493
|
|
1494 /* Check quit-flag and quit if it is non-nil. Also do any other things
|
|
1495 that might have gotten queued until it was safe. */
|
16
|
1496 #define QUIT do { if (INTERNAL_QUITP) signal_quit (); } while (0)
|
0
|
1497
|
16
|
1498 #define REALLY_QUIT do { if (INTERNAL_REALLY_QUITP) signal_quit (); } while (0)
|
0
|
1499
|
|
1500
|
|
1501 /************************************************************************/
|
|
1502 /* hashing */
|
|
1503 /************************************************************************/
|
|
1504
|
16
|
1505 /* #### for a 64-bit machine, we should substitute a prime just over 2^32 */
|
|
1506 #define GOOD_HASH 65599 /* prime number just over 2^16; Dragon book, p. 435 */
|
|
1507 #define HASH2(a,b) (GOOD_HASH * (a) + (b))
|
|
1508 #define HASH3(a,b,c) (GOOD_HASH * HASH2 (a,b) + (c))
|
|
1509 #define HASH4(a,b,c,d) (GOOD_HASH * HASH3 (a,b,c) + (d))
|
|
1510 #define HASH5(a,b,c,d,e) (GOOD_HASH * HASH4 (a,b,c,d) + (e))
|
|
1511 #define HASH6(a,b,c,d,e,f) (GOOD_HASH * HASH5 (a,b,c,d,e) + (f))
|
|
1512 #define HASH7(a,b,c,d,e,f,g) (GOOD_HASH * HASH6 (a,b,c,d,e,f) + (g))
|
|
1513 #define HASH8(a,b,c,d,e,f,g,h) (GOOD_HASH * HASH7 (a,b,c,d,e,f,g) + (h))
|
|
1514 #define HASH9(a,b,c,d,e,f,g,h,i) (GOOD_HASH * HASH8 (a,b,c,d,e,f,g,h) + (i))
|
0
|
1515
|
|
1516 /* Enough already! */
|
|
1517
|
|
1518 #define LISP_HASH(obj) ((unsigned long) LISP_TO_VOID (obj))
|
|
1519 unsigned long string_hash (CONST void *xv);
|
|
1520 unsigned long memory_hash (CONST void *xv, int size);
|
|
1521 unsigned long internal_hash (Lisp_Object obj, int depth);
|
|
1522 unsigned long internal_array_hash (Lisp_Object *arr, int size, int depth);
|
|
1523
|
|
1524
|
|
1525 /************************************************************************/
|
|
1526 /* String translation */
|
|
1527 /************************************************************************/
|
|
1528
|
|
1529 #ifdef I18N3
|
|
1530 #ifdef HAVE_LIBINTL_H
|
|
1531 #include <libintl.h>
|
|
1532 #else
|
|
1533 char *dgettext (CONST char *, CONST char *);
|
|
1534 char *gettext (CONST char *);
|
|
1535 char *textdomain (CONST char *);
|
|
1536 char *bindtextdomain (CONST char *, CONST char *);
|
|
1537 #endif /* HAVE_LIBINTL_H */
|
|
1538
|
|
1539 #define GETTEXT(x) gettext(x)
|
|
1540 #define LISP_GETTEXT(x) Fgettext (x)
|
|
1541 #else /* !I18N3 */
|
|
1542 #define GETTEXT(x) (x)
|
|
1543 #define LISP_GETTEXT(x) (x)
|
|
1544 #endif /* !I18N3 */
|
|
1545
|
|
1546 /* DEFER_GETTEXT is used to identify strings which are translated when
|
|
1547 they are referenced instead of when they are defined.
|
|
1548 These include Qerror_messages and initialized arrays of strings.
|
|
1549 */
|
|
1550 #define DEFER_GETTEXT(x) (x)
|
|
1551
|
|
1552
|
|
1553 /************************************************************************/
|
|
1554 /* Garbage collection / GC-protection */
|
|
1555 /************************************************************************/
|
|
1556
|
|
1557 /* number of bytes of structure consed since last GC */
|
|
1558
|
|
1559 extern EMACS_INT consing_since_gc;
|
|
1560
|
|
1561 /* threshold for doing another gc */
|
|
1562
|
|
1563 extern EMACS_INT gc_cons_threshold;
|
|
1564
|
|
1565 /* Structure for recording stack slots that need marking */
|
|
1566
|
|
1567 /* This is a chain of structures, each of which points at a Lisp_Object
|
|
1568 variable whose value should be marked in garbage collection.
|
|
1569 Normally every link of the chain is an automatic variable of a function,
|
|
1570 and its `val' points to some argument or local variable of the function.
|
|
1571 On exit to the function, the chain is set back to the value it had on
|
|
1572 entry. This way, no link remains in the chain when the stack frame
|
|
1573 containing the link disappears.
|
|
1574
|
|
1575 Every function that can call Feval must protect in this fashion all
|
|
1576 Lisp_Object variables whose contents will be used again. */
|
|
1577
|
|
1578 extern struct gcpro *gcprolist;
|
|
1579
|
|
1580 struct gcpro
|
|
1581 {
|
|
1582 struct gcpro *next;
|
|
1583 Lisp_Object *var; /* Address of first protected variable */
|
|
1584 int nvars; /* Number of consecutive protected variables */
|
|
1585 };
|
|
1586
|
|
1587 /* Normally, you declare variables gcpro1, gcpro2, ... and use the
|
|
1588 GCPROn() macros. However, if you need to have nested gcpro's,
|
|
1589 declare ngcpro1, ngcpro2, ... and use NGCPROn(). If you need
|
|
1590 to nest another level, use nngcpro1, nngcpro2, ... and use
|
|
1591 NNGCPROn(). If you need to nest yet another level, create
|
|
1592 the appropriate macros. */
|
|
1593
|
|
1594 #ifdef DEBUG_GCPRO
|
|
1595
|
16
|
1596 void debug_gcpro1 ();
|
84
|
1597 void debug_gcpro2 ();
|
16
|
1598 void debug_gcpro3 ();
|
|
1599 void debug_gcpro4 ();
|
|
1600 void debug_gcpro5 ();
|
|
1601 void debug_ungcpro();
|
0
|
1602
|
|
1603 #define GCPRO1(v) \
|
|
1604 debug_gcpro1 (__FILE__, __LINE__,&gcpro1,&v)
|
|
1605 #define GCPRO2(v1,v2) \
|
|
1606 debug_gcpro2 (__FILE__, __LINE__,&gcpro1,&gcpro2,&v1,&v2)
|
|
1607 #define GCPRO3(v1,v2,v3) \
|
|
1608 debug_gcpro3 (__FILE__, __LINE__,&gcpro1,&gcpro2,&gcpro3,&v1,&v2,&v3)
|
|
1609 #define GCPRO4(v1,v2,v3,v4) \
|
|
1610 debug_gcpro4 (__FILE__, __LINE__,&gcpro1,&gcpro2,&gcpro3,&gcpro4,\
|
|
1611 &v1,&v2,&v3,&v4)
|
|
1612 #define GCPRO5(v1,v2,v3,v4,v5) \
|
|
1613 debug_gcpro5 (__FILE__, __LINE__,&gcpro1,&gcpro2,&gcpro3,&gcpro4,&gcpro5,\
|
|
1614 &v1,&v2,&v3,&v4,&v5)
|
|
1615 #define UNGCPRO \
|
|
1616 debug_ungcpro(__FILE__, __LINE__,&gcpro1)
|
|
1617
|
|
1618 #define NGCPRO1(v) \
|
|
1619 debug_gcpro1 (__FILE__, __LINE__,&ngcpro1,&v)
|
|
1620 #define NGCPRO2(v1,v2) \
|
|
1621 debug_gcpro2 (__FILE__, __LINE__,&ngcpro1,&ngcpro2,&v1,&v2)
|
|
1622 #define NGCPRO3(v1,v2,v3) \
|
|
1623 debug_gcpro3 (__FILE__, __LINE__,&ngcpro1,&ngcpro2,&ngcpro3,&v1,&v2,&v3)
|
|
1624 #define NGCPRO4(v1,v2,v3,v4) \
|
|
1625 debug_gcpro4 (__FILE__, __LINE__,&ngcpro1,&ngcpro2,&ngcpro3,&ngcpro4,\
|
|
1626 &v1,&v2,&v3,&v4)
|
|
1627 #define NGCPRO5(v1,v2,v3,v4,v5) \
|
|
1628 debug_gcpro5 (__FILE__, __LINE__,&ngcpro1,&ngcpro2,&ngcpro3,&ngcpro4,\
|
|
1629 &ngcpro5,&v1,&v2,&v3,&v4,&v5)
|
|
1630 #define NUNGCPRO \
|
|
1631 debug_ungcpro(__FILE__, __LINE__,&ngcpro1)
|
|
1632
|
|
1633 #define NNGCPRO1(v) \
|
|
1634 debug_gcpro1 (__FILE__, __LINE__,&nngcpro1,&v)
|
|
1635 #define NNGCPRO2(v1,v2) \
|
|
1636 debug_gcpro2 (__FILE__, __LINE__,&nngcpro1,&nngcpro2,&v1,&v2)
|
|
1637 #define NNGCPRO3(v1,v2,v3) \
|
|
1638 debug_gcpro3 (__FILE__, __LINE__,&nngcpro1,&nngcpro2,&nngcpro3,&v1,&v2,&v3)
|
|
1639 #define NNGCPRO4(v1,v2,v3,v4) \
|
|
1640 debug_gcpro4 (__FILE__, __LINE__,&nngcpro1,&nngcpro2,&nngcpro3,&nngcpro4,\
|
|
1641 &v1,&v2,&v3,&v4)
|
|
1642 #define NNGCPRO5(v1,v2,v3,v4,v5) \
|
|
1643 debug_gcpro5 (__FILE__, __LINE__,&nngcpro1,&nngcpro2,&nngcpro3,&nngcpro4,\
|
|
1644 &nngcpro5,&v1,&v2,&v3,&v4,&v5)
|
|
1645 #define NUNNGCPRO \
|
|
1646 debug_ungcpro(__FILE__, __LINE__,&nngcpro1)
|
|
1647
|
|
1648 #else /* ! DEBUG_GCPRO */
|
|
1649
|
|
1650 #define GCPRO1(varname) \
|
|
1651 {gcpro1.next = gcprolist; gcpro1.var = &varname; gcpro1.nvars = 1; \
|
|
1652 gcprolist = &gcpro1; }
|
|
1653
|
|
1654 #define GCPRO2(varname1, varname2) \
|
|
1655 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
|
16
|
1656 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
|
0
|
1657 gcprolist = &gcpro2; }
|
|
1658
|
|
1659 #define GCPRO3(varname1, varname2, varname3) \
|
|
1660 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
|
14
|
1661 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
|
|
1662 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
|
0
|
1663 gcprolist = &gcpro3; }
|
|
1664
|
|
1665 #define GCPRO4(varname1, varname2, varname3, varname4) \
|
|
1666 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
|
14
|
1667 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
|
|
1668 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
|
|
1669 gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \
|
0
|
1670 gcprolist = &gcpro4; }
|
|
1671
|
|
1672 #define GCPRO5(varname1, varname2, varname3, varname4, varname5) \
|
|
1673 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
|
14
|
1674 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
|
|
1675 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
|
|
1676 gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \
|
|
1677 gcpro5.next = &gcpro4; gcpro5.var = &varname5; gcpro5.nvars = 1; \
|
0
|
1678 gcprolist = &gcpro5; }
|
|
1679
|
|
1680 #define UNGCPRO (gcprolist = gcpro1.next)
|
|
1681
|
|
1682 #define NGCPRO1(varname) \
|
|
1683 {ngcpro1.next = gcprolist; ngcpro1.var = &varname; ngcpro1.nvars = 1; \
|
|
1684 gcprolist = &ngcpro1; }
|
|
1685
|
|
1686 #define NGCPRO2(varname1, varname2) \
|
|
1687 {ngcpro1.next = gcprolist; ngcpro1.var = &varname1; ngcpro1.nvars = 1; \
|
14
|
1688 ngcpro2.next = &ngcpro1; ngcpro2.var = &varname2; ngcpro2.nvars = 1; \
|
0
|
1689 gcprolist = &ngcpro2; }
|
|
1690
|
|
1691 #define NGCPRO3(varname1, varname2, varname3) \
|
|
1692 {ngcpro1.next = gcprolist; ngcpro1.var = &varname1; ngcpro1.nvars = 1; \
|
14
|
1693 ngcpro2.next = &ngcpro1; ngcpro2.var = &varname2; ngcpro2.nvars = 1; \
|
|
1694 ngcpro3.next = &ngcpro2; ngcpro3.var = &varname3; ngcpro3.nvars = 1; \
|
0
|
1695 gcprolist = &ngcpro3; }
|
|
1696
|
|
1697 #define NGCPRO4(varname1, varname2, varname3, varname4) \
|
|
1698 {ngcpro1.next = gcprolist; ngcpro1.var = &varname1; ngcpro1.nvars = 1; \
|
14
|
1699 ngcpro2.next = &ngcpro1; ngcpro2.var = &varname2; ngcpro2.nvars = 1; \
|
|
1700 ngcpro3.next = &ngcpro2; ngcpro3.var = &varname3; ngcpro3.nvars = 1; \
|
|
1701 ngcpro4.next = &ngcpro3; ngcpro4.var = &varname4; ngcpro4.nvars = 1; \
|
0
|
1702 gcprolist = &ngcpro4; }
|
|
1703
|
|
1704 #define NGCPRO5(varname1, varname2, varname3, varname4, varname5) \
|
|
1705 {ngcpro1.next = gcprolist; ngcpro1.var = &varname1; ngcpro1.nvars = 1; \
|
14
|
1706 ngcpro2.next = &ngcpro1; ngcpro2.var = &varname2; ngcpro2.nvars = 1; \
|
|
1707 ngcpro3.next = &ngcpro2; ngcpro3.var = &varname3; ngcpro3.nvars = 1; \
|
|
1708 ngcpro4.next = &ngcpro3; ngcpro4.var = &varname4; ngcpro4.nvars = 1; \
|
|
1709 ngcpro5.next = &ngcpro4; ngcpro5.var = &varname5; ngcpro5.nvars = 1; \
|
0
|
1710 gcprolist = &ngcpro5; }
|
|
1711
|
|
1712 #define NUNGCPRO (gcprolist = ngcpro1.next)
|
|
1713
|
|
1714 #define NNGCPRO1(varname) \
|
|
1715 {nngcpro1.next = gcprolist; nngcpro1.var = &varname; nngcpro1.nvars = 1; \
|
|
1716 gcprolist = &nngcpro1; }
|
|
1717
|
|
1718 #define NNGCPRO2(varname1, varname2) \
|
|
1719 {nngcpro1.next = gcprolist; nngcpro1.var = &varname1; nngcpro1.nvars = 1; \
|
|
1720 nngcpro2.next = &nngcpro1; nngcpro2.var = &varname2; nngcpro2.nvars = 1; \
|
|
1721 gcprolist = &nngcpro2; }
|
|
1722
|
|
1723 #define NNGCPRO3(varname1, varname2, varname3) \
|
|
1724 {nngcpro1.next = gcprolist; nngcpro1.var = &varname1; nngcpro1.nvars = 1; \
|
|
1725 nngcpro2.next = &nngcpro1; nngcpro2.var = &varname2; nngcpro2.nvars = 1; \
|
|
1726 nngcpro3.next = &nngcpro2; nngcpro3.var = &varname3; nngcpro3.nvars = 1; \
|
|
1727 gcprolist = &nngcpro3; }
|
|
1728
|
|
1729 #define NNGCPRO4(varname1, varname2, varname3, varname4) \
|
|
1730 {nngcpro1.next = gcprolist; nngcpro1.var = &varname1; nngcpro1.nvars = 1; \
|
|
1731 nngcpro2.next = &nngcpro1; nngcpro2.var = &varname2; nngcpro2.nvars = 1; \
|
|
1732 nngcpro3.next = &nngcpro2; nngcpro3.var = &varname3; nngcpro3.nvars = 1; \
|
|
1733 nngcpro4.next = &nngcpro3; nngcpro4.var = &varname4; nngcpro4.nvars = 1; \
|
|
1734 gcprolist = &nngcpro4; }
|
|
1735
|
|
1736 #define NNGCPRO5(varname1, varname2, varname3, varname4, varname5) \
|
|
1737 {nngcpro1.next = gcprolist; nngcpro1.var = &varname1; nngcpro1.nvars = 1; \
|
|
1738 nngcpro2.next = &nngcpro1; nngcpro2.var = &varname2; nngcpro2.nvars = 1; \
|
|
1739 nngcpro3.next = &nngcpro2; nngcpro3.var = &varname3; nngcpro3.nvars = 1; \
|
|
1740 nngcpro4.next = &nngcpro3; nngcpro4.var = &varname4; nngcpro4.nvars = 1; \
|
|
1741 nngcpro5.next = &nngcpro4; nngcpro5.var = &varname5; nngcpro5.nvars = 1; \
|
|
1742 gcprolist = &nngcpro5; }
|
|
1743
|
|
1744 #define NNUNGCPRO (gcprolist = nngcpro1.next)
|
|
1745
|
|
1746 #endif /* ! DEBUG_GCPRO */
|
|
1747
|
|
1748 /* Another try to fix SunPro C compiler warnings */
|
|
1749 /* "end-of-loop code not reached" */
|
|
1750 /* "statement not reached */
|
|
1751 #ifdef __SUNPRO_C
|
|
1752 #define RETURN__ if (1) return
|
|
1753 #define RETURN_NOT_REACHED(value)
|
|
1754 #else
|
|
1755 #define RETURN__ return
|
|
1756 #define RETURN_NOT_REACHED(value) return value;
|
|
1757 #endif
|
|
1758
|
|
1759 /* Evaluate expr, UNGCPRO, and then return the value of expr. */
|
84
|
1760 #define RETURN_UNGCPRO(expr) do \
|
|
1761 { \
|
|
1762 Lisp_Object ret_ungc_val = (expr); \
|
|
1763 UNGCPRO; \
|
|
1764 RETURN__ ret_ungc_val; \
|
0
|
1765 } while (0)
|
|
1766
|
|
1767 /* Evaluate expr, NUNGCPRO, UNGCPRO, and then return the value of expr. */
|
84
|
1768 #define RETURN_NUNGCPRO(expr) do \
|
|
1769 { \
|
|
1770 Lisp_Object ret_ungc_val = (expr); \
|
|
1771 NUNGCPRO; \
|
|
1772 UNGCPRO; \
|
|
1773 RETURN__ ret_ungc_val; \
|
0
|
1774 } while (0)
|
|
1775
|
|
1776 /* Evaluate expr, NNUNGCPRO, NUNGCPRO, UNGCPRO, and then return the
|
|
1777 value of expr. */
|
84
|
1778 #define RETURN_NNUNGCPRO(expr) do \
|
|
1779 { \
|
|
1780 Lisp_Object ret_ungc_val = (expr); \
|
|
1781 NNUNGCPRO; \
|
|
1782 NUNGCPRO; \
|
|
1783 UNGCPRO; \
|
|
1784 RETURN__ ret_ungc_val; \
|
0
|
1785 } while (0)
|
|
1786
|
|
1787 /* Evaluate expr, return it if it's not Qunbound. */
|
84
|
1788 #define RETURN_IF_NOT_UNBOUND(expr) do \
|
|
1789 { \
|
|
1790 Lisp_Object ret_nunb_val = (expr); \
|
|
1791 if (!UNBOUNDP (ret_nunb_val)) \
|
|
1792 RETURN__ ret_nunb_val; \
|
0
|
1793 } while (0)
|
|
1794
|
|
1795 /* Call staticpro (&var) to protect static variable `var'. */
|
|
1796 void staticpro (Lisp_Object *);
|
|
1797
|
|
1798 /* Nonzero means Emacs has already been initialized.
|
|
1799 Used during startup to detect startup of dumped Emacs. */
|
|
1800 extern int initialized;
|
|
1801
|
|
1802 #ifdef MEMORY_USAGE_STATS
|
|
1803
|
|
1804 /* This structure is used to keep statistics on the amount of memory
|
|
1805 in use.
|
|
1806
|
|
1807 WAS_REQUESTED stores the actual amount of memory that was requested
|
|
1808 of the allocation function. The *_OVERHEAD fields store the
|
|
1809 additional amount of memory that was grabbed by the functions to
|
|
1810 facilitate allocation, reallocation, etc. MALLOC_OVERHEAD is for
|
|
1811 memory allocated with malloc(); DYNARR_OVERHEAD is for dynamic
|
|
1812 arrays; GAP_OVERHEAD is for gap arrays. Note that for (e.g.)
|
|
1813 dynamic arrays, there is both MALLOC_OVERHEAD and DYNARR_OVERHEAD
|
|
1814 memory: The dynamic array allocates memory above and beyond what
|
|
1815 was asked of it, and when it in turns allocates memory using
|
|
1816 malloc(), malloc() allocates memory beyond what it was asked
|
|
1817 to allocate.
|
|
1818
|
|
1819 Functions that accept a structure of this sort do not initialize
|
|
1820 the fields to 0, and add any existing values to whatever was there
|
|
1821 before; this way, you can get a cumulative effect. */
|
|
1822
|
|
1823 struct overhead_stats
|
|
1824 {
|
|
1825 int was_requested;
|
|
1826 int malloc_overhead;
|
|
1827 int dynarr_overhead;
|
|
1828 int gap_overhead;
|
|
1829 };
|
|
1830
|
|
1831 #endif /* MEMORY_USAGE_STATS */
|
|
1832
|
|
1833 /* Some systems (e.g., NT) use a different path separator than Unix,
|
|
1834 in addition to a device separator. Default the path separator
|
|
1835 to '/', and don't test for a device separator in IS_ANY_SEP. */
|
|
1836
|
|
1837 #ifndef DIRECTORY_SEP
|
|
1838 #define DIRECTORY_SEP '/'
|
|
1839 #endif
|
|
1840 #ifndef IS_DIRECTORY_SEP
|
|
1841 #define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
|
|
1842 #endif
|
|
1843 #ifndef IS_DEVICE_SEP
|
|
1844 #ifndef DEVICE_SEP
|
|
1845 #define IS_DEVICE_SEP(_c_) 0
|
|
1846 #else
|
|
1847 #define IS_DEVICE_SEP(_c_) ((_c_) == DEVICE_SEP)
|
|
1848 #endif
|
|
1849 #endif
|
|
1850 #ifndef IS_ANY_SEP
|
|
1851 #define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_))
|
|
1852 #endif
|
|
1853
|
|
1854 #include "emacsfns.h"
|
|
1855
|
|
1856 #endif /* _XEMACS_LISP_H_ */
|