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