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