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); \
|
251
|
198 int do_realloc_newsize = 0; \
|
185
|
199 while ((sizevar) < (do_realloc_needed_size)) { \
|
251
|
200 do_realloc_newsize = 2*(sizevar); \
|
|
201 if (do_realloc_newsize < 32) \
|
|
202 do_realloc_newsize = 32; \
|
|
203 (sizevar) = do_realloc_newsize; \
|
185
|
204 } \
|
251
|
205 if (do_realloc_newsize) \
|
|
206 XREALLOC_ARRAY (basevar, type, do_realloc_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
|
263
|
452 /* This is shared by process.h, events.h and others in future.
|
|
453 See events.h for description */
|
|
454 typedef unsigned int USID;
|
|
455
|
185
|
456 typedef struct
|
0
|
457 {
|
|
458 Dynarr_declare (struct glyph_cachel);
|
|
459 } glyph_cachel_dynarr;
|
|
460
|
|
461 struct buffer; /* "buffer.h" */
|
|
462 struct console; /* "console.h" */
|
|
463 struct device; /* "device.h" */
|
|
464 struct extent_fragment;
|
|
465 struct extent;
|
185
|
466 typedef struct extent *EXTENT;
|
0
|
467 struct frame; /* "frame.h" */
|
|
468 struct window; /* "window.h" */
|
|
469 struct Lisp_Event; /* "events.h" */
|
|
470 struct Lisp_Face;
|
|
471 struct Lisp_Process; /* "process.c" */
|
|
472 struct stat; /* <sys/stat.h> */
|
|
473 struct Lisp_Color_Instance;
|
|
474 struct Lisp_Font_Instance;
|
|
475 struct Lisp_Image_Instance;
|
|
476 struct display_line;
|
|
477 struct redisplay_info;
|
|
478 struct window_mirror;
|
|
479 struct scrollbar_instance;
|
|
480 struct font_metric_info;
|
|
481 struct face_cachel;
|
|
482 struct console_type_entry;
|
|
483
|
185
|
484 typedef struct
|
0
|
485 {
|
|
486 Dynarr_declare (Bufbyte);
|
185
|
487 } Bufbyte_dynarr;
|
0
|
488
|
185
|
489 typedef struct
|
0
|
490 {
|
|
491 Dynarr_declare (Extbyte);
|
185
|
492 } Extbyte_dynarr;
|
0
|
493
|
185
|
494 typedef struct
|
0
|
495 {
|
|
496 Dynarr_declare (Emchar);
|
185
|
497 } Emchar_dynarr;
|
0
|
498
|
185
|
499 typedef unsigned char unsigned_char;
|
|
500 typedef struct
|
0
|
501 {
|
|
502 Dynarr_declare (unsigned char);
|
|
503 } unsigned_char_dynarr;
|
|
504
|
185
|
505 typedef struct
|
0
|
506 {
|
|
507 Dynarr_declare (int);
|
|
508 } int_dynarr;
|
|
509
|
185
|
510 typedef struct
|
0
|
511 {
|
|
512 Dynarr_declare (Bufpos);
|
185
|
513 } Bufpos_dynarr;
|
0
|
514
|
185
|
515 typedef struct
|
0
|
516 {
|
|
517 Dynarr_declare (Bytind);
|
185
|
518 } Bytind_dynarr;
|
0
|
519
|
185
|
520 typedef struct
|
0
|
521 {
|
|
522 Dynarr_declare (Charcount);
|
185
|
523 } Charcount_dynarr;
|
0
|
524
|
185
|
525 typedef struct
|
0
|
526 {
|
|
527 Dynarr_declare (Bytecount);
|
185
|
528 } Bytecount_dynarr;
|
0
|
529
|
185
|
530 typedef struct
|
0
|
531 {
|
|
532 Dynarr_declare (struct console_type_entry);
|
|
533 } console_type_entry_dynarr;
|
|
534
|
|
535 /* Need to declare this here. */
|
|
536 enum external_data_format
|
|
537 {
|
|
538 /* Binary format. This is the simplest format and is what we
|
|
539 use in the absence of a more appropriate format. This converts
|
|
540 according to the `binary' coding system:
|
|
541
|
|
542 a) On input, bytes 0 - 255 are converted into characters 0 - 255.
|
|
543 b) On output, characters 0 - 255 are converted into bytes 0 - 255
|
|
544 and other characters are converted into `X'.
|
|
545 */
|
|
546 FORMAT_BINARY,
|
|
547
|
|
548 /* Format used for filenames. In the original Mule, this is
|
|
549 user-definable with the `pathname-coding-system' variable.
|
|
550 For the moment, we just use the `binary' coding system. */
|
|
551 FORMAT_FILENAME,
|
|
552
|
|
553 /* Format used for output to the terminal. This should be controlled
|
16
|
554 by the `terminal-coding-system' variable. Under kterm, this will
|
0
|
555 be some ISO2022 system. On some DOS machines, this is Shift-JIS. */
|
16
|
556 FORMAT_TERMINAL,
|
0
|
557
|
|
558 /* Format used for input from the terminal. This should be controlled
|
|
559 by the `keyboard-coding-system' variable. */
|
|
560 FORMAT_KEYBOARD,
|
173
|
561
|
0
|
562 /* Format used for the external Unix environment -- argv[], stuff
|
|
563 from getenv(), stuff from the /etc/passwd file, etc.
|
|
564
|
|
565 Perhaps should be the same as FORMAT_FILENAME. */
|
|
566 FORMAT_OS,
|
173
|
567
|
0
|
568 /* Compound-text format. This is the standard X format used for
|
|
569 data stored in properties, selections, and the like. This is
|
|
570 an 8-bit no-lock-shift ISO2022 coding system. */
|
|
571 FORMAT_CTEXT
|
|
572 };
|
|
573
|
149
|
574 #define FORMAT_NATIVE FORMAT_FILENAME
|
|
575
|
0
|
576 enum run_hooks_condition
|
|
577 {
|
|
578 RUN_HOOKS_TO_COMPLETION,
|
|
579 RUN_HOOKS_UNTIL_SUCCESS,
|
|
580 RUN_HOOKS_UNTIL_FAILURE
|
|
581 };
|
|
582
|
|
583 #ifdef HAVE_TOOLBARS
|
|
584 enum toolbar_pos
|
|
585 {
|
|
586 TOP_TOOLBAR,
|
|
587 BOTTOM_TOOLBAR,
|
|
588 LEFT_TOOLBAR,
|
|
589 RIGHT_TOOLBAR
|
|
590 };
|
|
591 #endif
|
|
592
|
|
593 #ifndef ERROR_CHECK_TYPECHECK
|
|
594
|
|
595 typedef enum error_behavior
|
|
596 {
|
|
597 ERROR_ME,
|
|
598 ERROR_ME_NOT,
|
|
599 ERROR_ME_WARN
|
|
600 } Error_behavior;
|
|
601
|
|
602 #define ERRB_EQ(a, b) ((a) == (b))
|
|
603
|
|
604 #else
|
|
605
|
|
606 /* By defining it like this, we provide strict type-checking
|
|
607 for code that lazily uses ints. */
|
|
608
|
|
609 typedef struct _error_behavior_struct_
|
|
610 {
|
|
611 int really_unlikely_name_to_have_accidentally_in_a_non_errb_structure;
|
|
612 } Error_behavior;
|
|
613
|
|
614 extern Error_behavior ERROR_ME;
|
|
615 extern Error_behavior ERROR_ME_NOT;
|
|
616 extern Error_behavior ERROR_ME_WARN;
|
|
617
|
|
618 #define ERRB_EQ(a, b) \
|
|
619 ((a).really_unlikely_name_to_have_accidentally_in_a_non_errb_structure == \
|
|
620 (b).really_unlikely_name_to_have_accidentally_in_a_non_errb_structure)
|
|
621
|
|
622 #endif
|
|
623
|
|
624 enum munge_me_out_the_door
|
|
625 {
|
|
626 MUNGE_ME_FUNCTION_KEY,
|
|
627 MUNGE_ME_KEY_TRANSLATION
|
|
628 };
|
|
629
|
|
630
|
|
631 /************************************************************************/
|
|
632 /* Definition of Lisp_Object data type */
|
|
633 /************************************************************************/
|
|
634
|
207
|
635 #ifdef USE_MINIMAL_TAGBITS
|
|
636 # define LRECORD_CONS
|
|
637 # define LRECORD_VECTOR
|
|
638 # define LRECORD_SYMBOL
|
|
639 # define LRECORD_STRING
|
|
640 #endif
|
0
|
641
|
|
642 /* Define the fundamental Lisp data structures */
|
|
643
|
|
644 /* This is the set of Lisp data types */
|
|
645
|
207
|
646 #ifndef USE_MINIMAL_TAGBITS
|
|
647
|
0
|
648 enum Lisp_Type
|
|
649 {
|
|
650 /* Integer. XINT(obj) is the integer value. */
|
207
|
651 Lisp_Type_Int,
|
173
|
652
|
0
|
653 /* XRECORD_LHEADER (object) points to a struct lrecord_header
|
|
654 lheader->implementation determines the type (and GC behaviour)
|
|
655 of the object. */
|
207
|
656 Lisp_Type_Record,
|
173
|
657
|
207
|
658 #ifndef LRECORD_CONS
|
0
|
659 /* Cons. XCONS (object) points to a struct Lisp_Cons. */
|
207
|
660 Lisp_Type_Cons,
|
|
661 #endif
|
173
|
662
|
207
|
663 #ifndef LRECORD_STRING
|
0
|
664 /* String. XSTRING (object) points to a struct Lisp_String.
|
|
665 The length of the string, and its contents, are stored therein. */
|
207
|
666 Lisp_Type_String,
|
|
667 #endif
|
173
|
668
|
0
|
669 #ifndef LRECORD_VECTOR
|
|
670 /* Vector of Lisp objects. XVECTOR(object) points to a struct Lisp_Vector.
|
|
671 The length of the vector, and its contents, are stored therein. */
|
207
|
672 Lisp_Type_Vector,
|
185
|
673 #endif /* !LRECORD_VECTOR */
|
173
|
674
|
0
|
675 #ifndef LRECORD_SYMBOL
|
|
676 /* Symbol. XSYMBOL (object) points to a struct Lisp_Symbol. */
|
185
|
677 Lisp_Type_Symbol,
|
0
|
678 #endif /* !LRECORD_SYMBOL */
|
173
|
679
|
207
|
680 Lisp_Type_Char
|
16
|
681 };
|
0
|
682
|
207
|
683 # define POINTER_TYPE_P(type) \
|
|
684 ((type) != Lisp_Type_Int && (type) != Lisp_Type_Char)
|
|
685
|
|
686 #else
|
|
687
|
|
688 enum Lisp_Type
|
|
689 {
|
|
690 Lisp_Type_Record,
|
|
691 Lisp_Type_Int_Even,
|
|
692 Lisp_Type_Char,
|
|
693 Lisp_Type_Int_Odd
|
|
694 };
|
|
695
|
|
696 #define POINTER_TYPE_P(type) ((type) == Lisp_Type_Record)
|
|
697
|
|
698 #endif
|
0
|
699
|
2
|
700 /* This should be the underlying type into which a Lisp_Object must fit.
|
0
|
701 In a strict ANSI world, this must be `int', since ANSI says you can't
|
|
702 use bitfields on any type other than `int'. However, on a machine
|
|
703 where `int' and `long' are not the same size, this should be the
|
|
704 longer of the two. (This also must be something into which a pointer
|
|
705 to an arbitrary object will fit, modulo any DATA_SEG_BITS cruft.)
|
|
706 */
|
|
707 #if (LONGBITS > INTBITS)
|
|
708 # define EMACS_INT long
|
|
709 # define EMACS_UINT unsigned long
|
|
710 #else
|
|
711 # define EMACS_INT int
|
|
712 # define EMACS_UINT unsigned int
|
|
713 #endif
|
|
714
|
|
715 /* Overridden by m/next.h */
|
|
716 #ifndef ASSERT_VALID_POINTER
|
|
717 # define ASSERT_VALID_POINTER(pnt) (assert ((((EMACS_UINT) pnt) & 3) == 0))
|
|
718 #endif
|
|
719
|
|
720 /* These values are overridden by the m- file on some machines. */
|
|
721 #ifndef GCTYPEBITS
|
207
|
722 # ifdef USE_MINIMAL_TAGBITS
|
|
723 # define GCTYPEBITS 2L
|
|
724 # else
|
|
725 # define GCTYPEBITS 3L
|
|
726 # endif
|
|
727 #endif
|
|
728
|
|
729 /* Valid values for GCMARKBITS are 0 and 1. */
|
|
730 #ifdef USE_MINIMAL_TAGBITS
|
|
731 # define GCMARKBITS 0L
|
|
732 #else
|
|
733 # define GCMARKBITS 1L
|
0
|
734 #endif
|
|
735
|
|
736 #ifndef VALBITS
|
207
|
737 # define VALBITS ((LONGBITS)-(GCTYPEBITS)-(GCMARKBITS))
|
0
|
738 #endif
|
|
739
|
|
740 #ifdef NO_UNION_TYPE
|
|
741 # include "lisp-disunion.h"
|
|
742 #else /* !NO_UNION_TYPE */
|
|
743 # include "lisp-union.h"
|
|
744 #endif /* !NO_UNION_TYPE */
|
|
745
|
|
746 /* WARNING WARNING WARNING. You must ensure on your own that proper
|
|
747 GC protection is provided for the elements in this array. */
|
185
|
748 typedef struct
|
0
|
749 {
|
|
750 Dynarr_declare (Lisp_Object);
|
185
|
751 } Lisp_Object_dynarr;
|
0
|
752
|
|
753 /* Close your eyes now lest you vomit or spontaneously combust ... */
|
|
754
|
|
755 #define HACKEQ_UNSAFE(obj1, obj2) \
|
|
756 (EQ (obj1, obj2) || (!POINTER_TYPE_P (XGCTYPE (obj1)) \
|
|
757 && !POINTER_TYPE_P (XGCTYPE (obj2)) \
|
207
|
758 && XCHAR_OR_INT (obj1) == XCHAR_OR_INT (obj2)))
|
0
|
759
|
70
|
760 #ifdef DEBUG_XEMACS
|
|
761 extern int debug_issue_ebola_notices;
|
|
762 int eq_with_ebola_notice (Lisp_Object, Lisp_Object);
|
|
763 #define EQ_WITH_EBOLA_NOTICE(obj1, obj2) \
|
|
764 (debug_issue_ebola_notices ? eq_with_ebola_notice (obj1, obj2) \
|
|
765 : EQ (obj1, obj2))
|
|
766 #else
|
|
767 #define EQ_WITH_EBOLA_NOTICE(obj1, obj2) EQ (obj1, obj2)
|
|
768 #endif
|
0
|
769
|
|
770 /* OK, you can open them again */
|
|
771
|
|
772 /************************************************************************/
|
|
773 /* Definitions of basic Lisp objects */
|
|
774 /************************************************************************/
|
|
775
|
|
776 #include "lrecord.h"
|
|
777
|
|
778 /********** unbound ***********/
|
|
779
|
|
780 /* Qunbound is a special Lisp_Object (actually of type
|
|
781 symbol-value-forward), that can never be visible to
|
|
782 the Lisp caller and thus can be used in the C code
|
|
783 to mean "no such value". */
|
|
784
|
|
785 #define UNBOUNDP(val) EQ (val, Qunbound)
|
|
786 #define GC_UNBOUNDP(val) GC_EQ (val, Qunbound)
|
173
|
787
|
0
|
788 /*********** cons ***********/
|
|
789
|
|
790 /* In a cons, the markbit of the car is the gc mark bit */
|
|
791
|
|
792 struct Lisp_Cons
|
|
793 {
|
207
|
794 #ifdef LRECORD_CONS
|
|
795 struct lrecord_header lheader;
|
|
796 #endif
|
0
|
797 Lisp_Object car, cdr;
|
|
798 };
|
|
799
|
|
800 #if 0 /* FSFmacs */
|
|
801 /* Like a cons, but records info on where the text lives that it was read from */
|
|
802 /* This is not really in use now */
|
|
803
|
|
804 struct Lisp_Buffer_Cons
|
|
805 {
|
|
806 Lisp_Object car, cdr;
|
|
807 struct buffer *buffer;
|
|
808 int bufpos;
|
|
809 };
|
|
810 #endif
|
|
811
|
207
|
812 #ifdef LRECORD_CONS
|
|
813
|
|
814 DECLARE_LRECORD (cons, struct Lisp_Cons);
|
|
815 #define XCONS(x) XRECORD (x, cons, struct Lisp_Cons)
|
|
816 #define XSETCONS(x, p) XSETRECORD (x, p, cons)
|
|
817 #define CONSP(x) RECORDP (x, cons)
|
|
818 #define GC_CONSP(x) GC_RECORDP (x, cons)
|
|
819 #define CHECK_CONS(x) CHECK_RECORD (x, cons)
|
|
820 #define CONCHECK_CONS(x) CONCHECK_RECORD (x, cons)
|
|
821
|
|
822 #define CONS_MARKED_P(c) MARKED_RECORD_HEADER_P(&((c)->lheader))
|
|
823 #define MARK_CONS(c) MARK_RECORD_HEADER (&((c)->lheader))
|
|
824
|
|
825 #else /* ! LRECORD_CONS */
|
|
826
|
185
|
827 DECLARE_NONRECORD (cons, Lisp_Type_Cons, struct Lisp_Cons);
|
|
828 #define XCONS(a) XNONRECORD (a, cons, Lisp_Type_Cons, struct Lisp_Cons)
|
|
829 #define XSETCONS(c, p) XSETOBJ (c, Lisp_Type_Cons, p)
|
|
830 #define CONSP(x) (XTYPE (x) == Lisp_Type_Cons)
|
|
831 #define GC_CONSP(x) (XGCTYPE (x) == Lisp_Type_Cons)
|
|
832 #define CHECK_CONS(x) CHECK_NONRECORD (x, Lisp_Type_Cons, Qconsp)
|
|
833 #define CONCHECK_CONS(x) CONCHECK_NONRECORD (x, Lisp_Type_Cons, Qconsp)
|
0
|
834
|
|
835 /* Define these because they're used in a few places, inside and
|
|
836 out of alloc.c */
|
|
837 #define CONS_MARKED_P(c) XMARKBIT (c->car)
|
|
838 #define MARK_CONS(c) XMARK (c->car)
|
|
839
|
207
|
840 #endif /* ! LRECORD_CONS */
|
|
841
|
0
|
842 #define NILP(x) EQ (x, Qnil)
|
|
843 #define GC_NILP(x) GC_EQ (x, Qnil)
|
|
844 #define CHECK_LIST(x) \
|
|
845 do { if ((!CONSP (x)) && !NILP (x)) dead_wrong_type_argument (Qlistp, x); } while (0)
|
|
846 #define CONCHECK_LIST(x) \
|
|
847 do { if ((!CONSP (x)) && !NILP (x)) x = wrong_type_argument (Qlistp, x); } while (0)
|
|
848 #define XCAR(a) (XCONS (a)->car)
|
|
849 #define XCDR(a) (XCONS (a)->cdr)
|
|
850
|
|
851 /* For a list that's known to be in valid list format --
|
|
852 will abort() if the list is not in valid format */
|
|
853 #define LIST_LOOP(consvar, list) \
|
|
854 for (consvar = list; !NILP (consvar); consvar = XCDR (consvar))
|
|
855
|
|
856 /* For a list that's known to be in valid list format, where we may
|
|
857 be deleting the current element out of the list --
|
|
858 will abort() if the list is not in valid format */
|
84
|
859 #define LIST_LOOP_DELETING(consvar, nextconsvar, list) \
|
|
860 for (consvar = list; \
|
|
861 !NILP (consvar) ? (nextconsvar = XCDR (consvar), 1) : 0; \
|
0
|
862 consvar = nextconsvar)
|
|
863
|
|
864 /* For a list that may not be in valid list format --
|
|
865 will signal an error if the list is not in valid format */
|
|
866 #define EXTERNAL_LIST_LOOP(consvar, listp) \
|
|
867 for (consvar = listp; !NILP (consvar); consvar = XCDR (consvar)) \
|
|
868 if (!CONSP (consvar)) \
|
|
869 signal_simple_error ("Invalid list format", listp); \
|
|
870 else
|
|
871
|
|
872 /* For a property list (alternating keywords/values) that may not be
|
|
873 in valid list format -- will signal an error if the list is not in
|
|
874 valid format. CONSVAR is used to keep track of the iterations
|
|
875 without modifying LISTP.
|
|
876
|
|
877 We have to be tricky to still keep the same C format.*/
|
|
878 #define EXTERNAL_PROPERTY_LIST_LOOP(consvar, keyword, value, listp) \
|
|
879 for (consvar = listp; \
|
|
880 (CONSP (consvar) && CONSP (XCDR (consvar)) ? \
|
|
881 (keyword = XCAR (consvar), value = XCAR (XCDR (consvar))) : \
|
|
882 (keyword = Qunbound, value = Qunbound)), \
|
|
883 !NILP (consvar); \
|
|
884 consvar = XCDR (XCDR (consvar))) \
|
|
885 if (UNBOUNDP (keyword)) \
|
|
886 signal_simple_error ("Invalid property list format", listp); \
|
|
887 else
|
|
888
|
|
889 /*********** string ***********/
|
|
890
|
|
891 /* In a string or vector, the sign bit of the `size' is the gc mark bit */
|
|
892
|
|
893 /* (The size and data fields have underscores prepended to catch old
|
|
894 code that attempts to reference the fields directly) */
|
|
895 struct Lisp_String
|
|
896 {
|
|
897 #ifdef LRECORD_STRING
|
|
898 struct lrecord_header lheader;
|
|
899 #endif
|
2
|
900 Bytecount _size;
|
0
|
901 Bufbyte *_data;
|
|
902 Lisp_Object plist;
|
|
903 };
|
|
904
|
|
905 #ifdef LRECORD_STRING
|
|
906
|
|
907 DECLARE_LRECORD (string, struct Lisp_String);
|
|
908 #define XSTRING(x) XRECORD (x, string, struct Lisp_String)
|
|
909 #define XSETSTRING(x, p) XSETRECORD (x, p, string)
|
|
910 #define STRINGP(x) RECORDP (x, string)
|
|
911 #define GC_STRINGP(x) GC_RECORDP (x, string)
|
|
912 #define CHECK_STRING(x) CHECK_RECORD (x, string)
|
|
913 #define CONCHECK_STRING(x) CONCHECK_RECORD (x, string)
|
|
914
|
185
|
915 #else /* ! LRECORD_STRING */
|
0
|
916
|
185
|
917 DECLARE_NONRECORD (string, Lisp_Type_String, struct Lisp_String);
|
|
918 #define XSTRING(x) XNONRECORD (x, string, Lisp_Type_String, struct Lisp_String)
|
|
919 #define XSETSTRING(x, p) XSETOBJ (x, Lisp_Type_String, p)
|
|
920 #define STRINGP(x) (XTYPE (x) == Lisp_Type_String)
|
|
921 #define GC_STRINGP(x) (XGCTYPE (x) == Lisp_Type_String)
|
|
922 #define CHECK_STRING(x) CHECK_NONRECORD (x, Lisp_Type_String, Qstringp)
|
|
923 #define CONCHECK_STRING(x) CONCHECK_NONRECORD (x, Lisp_Type_String, Qstringp)
|
0
|
924
|
185
|
925 #endif /* ! LRECORD_STRING */
|
0
|
926
|
70
|
927 #ifdef MULE
|
|
928
|
|
929 Charcount bytecount_to_charcount (CONST Bufbyte *ptr, Bytecount len);
|
|
930 Bytecount charcount_to_bytecount (CONST Bufbyte *ptr, Charcount len);
|
|
931
|
|
932 #else /* not MULE */
|
0
|
933
|
|
934 # define bytecount_to_charcount(ptr, len) (len)
|
|
935 # define charcount_to_bytecount(ptr, len) (len)
|
|
936
|
70
|
937 #endif /* not MULE */
|
|
938
|
0
|
939 #define string_length(s) ((s)->_size)
|
14
|
940 #define XSTRING_LENGTH(s) string_length (XSTRING (s))
|
0
|
941 #define string_data(s) ((s)->_data + 0)
|
14
|
942 #define XSTRING_DATA(s) string_data (XSTRING (s))
|
0
|
943 #define string_byte(s, i) ((s)->_data[i] + 0)
|
14
|
944 #define XSTRING_BYTE(s, i) string_byte (XSTRING (s), i)
|
0
|
945 #define string_byte_addr(s, i) (&((s)->_data[i]))
|
185
|
946 #define set_string_length(s, len) ((void) ((s)->_size = (len)))
|
|
947 #define set_string_data(s, ptr) ((void) ((s)->_data = (ptr)))
|
|
948 #define set_string_byte(s, i, c) ((void) ((s)->_data[i] = (c)))
|
0
|
949
|
|
950 void resize_string (struct Lisp_String *s, Bytecount pos, Bytecount delta);
|
|
951
|
70
|
952 #ifdef MULE
|
|
953
|
|
954 INLINE Charcount string_char_length (struct Lisp_String *s);
|
|
955 INLINE Charcount
|
|
956 string_char_length (struct Lisp_String *s)
|
|
957 {
|
|
958 return bytecount_to_charcount (string_data (s), string_length (s));
|
|
959 }
|
|
960
|
|
961 # define string_char(s, i) charptr_emchar_n (string_data (s), i)
|
|
962 # define string_char_addr(s, i) charptr_n_addr (string_data (s), i)
|
|
963 void set_string_char (struct Lisp_String *s, Charcount i, Emchar c);
|
|
964
|
|
965 #else /* not MULE */
|
|
966
|
0
|
967 # define string_char_length(s) string_length (s)
|
|
968 # define string_char(s, i) ((Emchar) string_byte (s, i))
|
|
969 # define string_char_addr(s, i) string_byte_addr (s, i)
|
|
970 # define set_string_char(s, i, c) set_string_byte (s, i, c)
|
|
971
|
70
|
972 #endif /* not MULE */
|
0
|
973
|
|
974 /*********** vector ***********/
|
|
975
|
|
976 struct Lisp_Vector
|
|
977 {
|
|
978 #ifdef LRECORD_VECTOR
|
207
|
979 struct lcrecord_header header;
|
0
|
980 #endif
|
|
981 long size;
|
|
982 /* next is now chained through v->contents[size], terminated by Qzero.
|
2
|
983 This means that pure vectors don't need a "next" */
|
0
|
984 /* struct Lisp_Vector *next; */
|
|
985 Lisp_Object contents[1];
|
|
986 };
|
|
987
|
|
988 #ifdef LRECORD_VECTOR
|
|
989
|
|
990 DECLARE_LRECORD (vector, struct Lisp_Vector);
|
|
991 #define XVECTOR(x) XRECORD (x, vector, struct Lisp_Vector)
|
|
992 #define XSETVECTOR(x, p) XSETRECORD (x, p, vector)
|
|
993 #define VECTORP(x) RECORDP (x, vector)
|
|
994 #define GC_VECTORP(x) GC_RECORDP (x, vector)
|
|
995 #define CHECK_VECTOR(x) CHECK_RECORD (x, vector)
|
|
996 #define CONCHECK_VECTOR(x) CONCHECK_RECORD (x, vector)
|
|
997
|
|
998 #else
|
|
999
|
185
|
1000 DECLARE_NONRECORD (vector, Lisp_Type_Vector, struct Lisp_Vector);
|
|
1001 #define XVECTOR(x) XNONRECORD (x, vector, Lisp_Type_Vector, struct Lisp_Vector)
|
|
1002 #define XSETVECTOR(x, p) XSETOBJ (x, Lisp_Type_Vector, p)
|
|
1003 #define VECTORP(x) (XTYPE (x) == Lisp_Type_Vector)
|
|
1004 #define GC_VECTORP(x) (XGCTYPE (x) == Lisp_Type_Vector)
|
|
1005 #define CHECK_VECTOR(x) CHECK_NONRECORD (x, Lisp_Type_Vector, Qvectorp)
|
|
1006 #define CONCHECK_VECTOR(x) CONCHECK_NONRECORD (x, Lisp_Type_Vector, Qvectorp)
|
0
|
1007
|
|
1008 #endif
|
|
1009
|
|
1010 #define vector_length(v) ((v)->size)
|
173
|
1011 #define XVECTOR_LENGTH(s) vector_length (XVECTOR (s))
|
0
|
1012 #define vector_data(v) ((v)->contents)
|
173
|
1013 #define XVECTOR_DATA(s) vector_data (XVECTOR (s))
|
207
|
1014 #ifndef LRECORD_VECTOR
|
|
1015 # define vector_next(v) ((v)->contents[(v)->size])
|
|
1016 #endif
|
173
|
1017
|
0
|
1018 /*********** bit vector ***********/
|
|
1019
|
|
1020 #if (LONGBITS < 16)
|
14
|
1021 #error What the hell?!
|
0
|
1022 #elif (LONGBITS < 32)
|
|
1023 # define LONGBITS_LOG2 4
|
|
1024 # define LONGBITS_POWER_OF_2 16
|
|
1025 #elif (LONGBITS < 64)
|
|
1026 # define LONGBITS_LOG2 5
|
|
1027 # define LONGBITS_POWER_OF_2 32
|
|
1028 #elif (LONGBITS < 128)
|
|
1029 # define LONGBITS_LOG2 6
|
|
1030 # define LONGBITS_POWER_OF_2 64
|
|
1031 #else
|
|
1032 #error You really have 128-bit integers?!
|
|
1033 #endif
|
|
1034
|
|
1035 struct Lisp_Bit_Vector
|
|
1036 {
|
|
1037 struct lrecord_header lheader;
|
|
1038 Lisp_Object next;
|
|
1039 long size;
|
|
1040 unsigned int bits[1];
|
|
1041 };
|
|
1042
|
|
1043 DECLARE_LRECORD (bit_vector, struct Lisp_Bit_Vector);
|
|
1044 #define XBIT_VECTOR(x) XRECORD (x, bit_vector, struct Lisp_Bit_Vector)
|
|
1045 #define XSETBIT_VECTOR(x, p) XSETRECORD (x, p, bit_vector)
|
|
1046 #define BIT_VECTORP(x) RECORDP (x, bit_vector)
|
|
1047 #define GC_BIT_VECTORP(x) GC_RECORDP (x, bit_vector)
|
|
1048 #define CHECK_BIT_VECTOR(x) CHECK_RECORD (x, bit_vector)
|
|
1049 #define CONCHECK_BIT_VECTOR(x) CONCHECK_RECORD (x, bit_vector)
|
|
1050
|
|
1051 #define BITP(x) (INTP (x) && (XINT (x) == 0 || XINT (x) == 1))
|
|
1052 #define GC_BITP(x) (GC_INTP (x) && (XINT (x) == 0 || XINT (x) == 1))
|
|
1053
|
|
1054 #define CHECK_BIT(x) \
|
|
1055 do { if (!BITP (x)) dead_wrong_type_argument (Qbitp, x); } while (0)
|
|
1056 #define CONCHECK_BIT(x) \
|
|
1057 do { if (!BITP (x)) x = wrong_type_argument (Qbitp, x); } while (0)
|
|
1058
|
|
1059 #define bit_vector_length(v) ((v)->size)
|
|
1060 #define bit_vector_next(v) ((v)->next)
|
|
1061
|
|
1062 INLINE int bit_vector_bit (struct Lisp_Bit_Vector *v, int i);
|
|
1063 INLINE int
|
|
1064 bit_vector_bit (struct Lisp_Bit_Vector *v, int i)
|
|
1065 {
|
|
1066 unsigned int ui = (unsigned int) i;
|
|
1067
|
|
1068 return (((v)->bits[ui >> LONGBITS_LOG2] >> (ui & (LONGBITS_POWER_OF_2 - 1)))
|
|
1069 & 1);
|
|
1070 }
|
|
1071
|
|
1072 INLINE void set_bit_vector_bit (struct Lisp_Bit_Vector *v, int i, int value);
|
|
1073 INLINE void
|
|
1074 set_bit_vector_bit (struct Lisp_Bit_Vector *v, int i, int value)
|
|
1075 {
|
|
1076 unsigned int ui = (unsigned int) i;
|
|
1077 if (value)
|
|
1078 (v)->bits[ui >> LONGBITS_LOG2] |= (1 << (ui & (LONGBITS_POWER_OF_2 - 1)));
|
|
1079 else
|
|
1080 (v)->bits[ui >> LONGBITS_LOG2] &= ~(1 << (ui & (LONGBITS_POWER_OF_2 - 1)));
|
|
1081 }
|
|
1082
|
|
1083 /* Number of longs required to hold LEN bits */
|
|
1084 #define BIT_VECTOR_LONG_STORAGE(len) \
|
|
1085 ((len + LONGBITS_POWER_OF_2 - 1) >> LONGBITS_LOG2)
|
|
1086
|
|
1087
|
|
1088 /*********** symbol ***********/
|
|
1089
|
|
1090 /* In a symbol, the markbit of the plist is used as the gc mark bit */
|
|
1091
|
|
1092 struct Lisp_Symbol
|
|
1093 {
|
|
1094 #ifdef LRECORD_SYMBOL
|
|
1095 struct lrecord_header lheader;
|
|
1096 #endif
|
|
1097 /* next symbol in this obarray bucket */
|
|
1098 struct Lisp_Symbol *next;
|
|
1099 struct Lisp_String *name;
|
|
1100 Lisp_Object value;
|
|
1101 Lisp_Object function;
|
245
|
1102 Lisp_Object obarray;
|
0
|
1103 Lisp_Object plist;
|
|
1104 };
|
|
1105
|
|
1106 #define SYMBOL_IS_KEYWORD(sym) (string_byte (XSYMBOL(sym)->name, 0) == ':')
|
|
1107 #define KEYWORDP(obj) (SYMBOLP (obj) && SYMBOL_IS_KEYWORD (obj))
|
|
1108
|
|
1109 #ifdef LRECORD_SYMBOL
|
|
1110
|
|
1111 DECLARE_LRECORD (symbol, struct Lisp_Symbol);
|
|
1112 #define XSYMBOL(x) XRECORD (x, symbol, struct Lisp_Symbol)
|
|
1113 #define XSETSYMBOL(x, p) XSETRECORD (x, p, symbol)
|
|
1114 #define SYMBOLP(x) RECORDP (x, symbol)
|
|
1115 #define GC_SYMBOLP(x) GC_RECORDP (x, symbol)
|
|
1116 #define CHECK_SYMBOL(x) CHECK_RECORD (x, symbol)
|
|
1117 #define CONCHECK_SYMBOL(x) CONCHECK_RECORD (x, symbol)
|
|
1118
|
|
1119 #else
|
|
1120
|
185
|
1121 DECLARE_NONRECORD (symbol, Lisp_Type_Symbol, struct Lisp_Symbol);
|
|
1122 #define XSYMBOL(x) XNONRECORD (x, symbol, Lisp_Type_Symbol, struct Lisp_Symbol)
|
|
1123 #define XSETSYMBOL(s, p) XSETOBJ ((s), Lisp_Type_Symbol, (p))
|
|
1124 #define SYMBOLP(x) (XTYPE (x) == Lisp_Type_Symbol)
|
|
1125 #define GC_SYMBOLP(x) (XGCTYPE (x) == Lisp_Type_Symbol)
|
|
1126 #define CHECK_SYMBOL(x) CHECK_NONRECORD (x, Lisp_Type_Symbol, Qsymbolp)
|
|
1127 #define CONCHECK_SYMBOL(x) CONCHECK_NONRECORD (x, Lisp_Type_Symbol, Qsymbolp)
|
0
|
1128
|
|
1129 #endif
|
|
1130
|
|
1131 #define symbol_next(s) ((s)->next)
|
|
1132 #define symbol_name(s) ((s)->name)
|
|
1133 #define symbol_value(s) ((s)->value)
|
|
1134 #define symbol_function(s) ((s)->function)
|
|
1135 #define symbol_plist(s) ((s)->plist)
|
|
1136
|
|
1137 /*********** subr ***********/
|
|
1138
|
195
|
1139 typedef Lisp_Object (*lisp_fn_t) ();
|
84
|
1140
|
0
|
1141 struct Lisp_Subr
|
|
1142 {
|
|
1143 struct lrecord_header lheader;
|
|
1144 short min_args, max_args;
|
|
1145 CONST char *prompt;
|
|
1146 CONST char *doc;
|
|
1147 CONST char *name;
|
74
|
1148 lisp_fn_t subr_fn;
|
0
|
1149 };
|
|
1150
|
|
1151 DECLARE_LRECORD (subr, struct Lisp_Subr);
|
|
1152 #define XSUBR(x) XRECORD (x, subr, struct Lisp_Subr)
|
|
1153 #define XSETSUBR(x, p) XSETRECORD (x, p, subr)
|
|
1154 #define SUBRP(x) RECORDP (x, subr)
|
|
1155 #define GC_SUBRP(x) GC_RECORDP (x, subr)
|
|
1156 #define CHECK_SUBR(x) CHECK_RECORD (x, subr)
|
|
1157 #define CONCHECK_SUBR(x) CONCHECK_RECORD (x, subr)
|
|
1158
|
|
1159 #define subr_function(subr) (subr)->subr_fn
|
|
1160 #define subr_name(subr) (subr)->name
|
|
1161
|
|
1162 /*********** marker ***********/
|
|
1163
|
|
1164 struct Lisp_Marker
|
|
1165 {
|
|
1166 struct lrecord_header lheader;
|
|
1167 struct Lisp_Marker *next, *prev;
|
|
1168 struct buffer *buffer;
|
|
1169 Memind memind;
|
|
1170 char insertion_type;
|
|
1171 };
|
|
1172
|
|
1173 DECLARE_LRECORD (marker, struct Lisp_Marker);
|
|
1174 #define XMARKER(x) XRECORD (x, marker, struct Lisp_Marker)
|
|
1175 #define XSETMARKER(x, p) XSETRECORD (x, p, marker)
|
|
1176 #define MARKERP(x) RECORDP (x, marker)
|
|
1177 #define GC_MARKERP(x) GC_RECORDP (x, marker)
|
|
1178 #define CHECK_MARKER(x) CHECK_RECORD (x, marker)
|
|
1179 #define CONCHECK_MARKER(x) CONCHECK_RECORD (x, marker)
|
|
1180
|
|
1181 /* The second check was looking for GCed markers still in use */
|
|
1182 /* if (INTP (XMARKER (x)->lheader.next.v)) abort (); */
|
|
1183
|
|
1184 #define marker_next(m) ((m)->next)
|
|
1185 #define marker_prev(m) ((m)->prev)
|
|
1186
|
|
1187 /*********** char ***********/
|
|
1188
|
185
|
1189 #define CHARP(x) (XTYPE (x) == Lisp_Type_Char)
|
|
1190 #define GC_CHARP(x) (XGCTYPE (x) == Lisp_Type_Char)
|
0
|
1191
|
|
1192 #ifdef ERROR_CHECK_TYPECHECK
|
|
1193
|
|
1194 INLINE Emchar XCHAR (Lisp_Object obj);
|
|
1195 INLINE Emchar
|
|
1196 XCHAR (Lisp_Object obj)
|
|
1197 {
|
70
|
1198 assert (CHARP (obj));
|
207
|
1199 return XCHARVAL (obj);
|
0
|
1200 }
|
|
1201
|
|
1202 #else
|
|
1203
|
207
|
1204 #define XCHAR(x) XCHARVAL (x)
|
0
|
1205
|
|
1206 #endif
|
|
1207
|
185
|
1208 #define CHECK_CHAR(x) CHECK_NONRECORD (x, Lisp_Type_Char, Qcharacterp)
|
|
1209 #define CONCHECK_CHAR(x) CONCHECK_NONRECORD (x, Lisp_Type_Char, Qcharacterp)
|
0
|
1210
|
|
1211
|
|
1212 /*********** float ***********/
|
|
1213
|
|
1214 #ifdef LISP_FLOAT_TYPE
|
|
1215
|
|
1216 struct Lisp_Float
|
|
1217 {
|
|
1218 struct lrecord_header lheader;
|
|
1219 union { double d; struct Lisp_Float *next; } data;
|
|
1220 };
|
|
1221
|
|
1222 DECLARE_LRECORD (float, struct Lisp_Float);
|
|
1223 #define XFLOAT(x) XRECORD (x, float, struct Lisp_Float)
|
|
1224 #define XSETFLOAT(x, p) XSETRECORD (x, p, float)
|
|
1225 #define FLOATP(x) RECORDP (x, float)
|
|
1226 #define GC_FLOATP(x) GC_RECORDP (x, float)
|
|
1227 #define CHECK_FLOAT(x) CHECK_RECORD (x, float)
|
|
1228 #define CONCHECK_FLOAT(x) CONCHECK_RECORD (x, float)
|
|
1229
|
|
1230 #define float_next(f) ((f)->data.next)
|
|
1231 #define float_data(f) ((f)->data.d)
|
|
1232
|
|
1233 #define XFLOATINT(n) extract_float (n)
|
|
1234
|
|
1235 #define CHECK_INT_OR_FLOAT(x) \
|
|
1236 do { if ( !INTP (x) && !FLOATP (x)) \
|
|
1237 dead_wrong_type_argument (Qnumberp, (x)); } while (0)
|
|
1238 #define CONCHECK_INT_OR_FLOAT(x) \
|
|
1239 do { if ( !INTP (x) && !FLOATP (x)) \
|
|
1240 x = wrong_type_argument (Qnumberp, (x)); } while (0)
|
|
1241
|
|
1242 /* These are always continuable because they change their arguments
|
|
1243 even when no error is signalled. */
|
|
1244
|
185
|
1245 #define CHECK_INT_OR_FLOAT_COERCE_MARKER(x) do \
|
|
1246 { if (INTP (x) || FLOATP (x)) \
|
|
1247 ; \
|
|
1248 else if (MARKERP (x)) \
|
|
1249 x = make_int (marker_position (x)); \
|
|
1250 else \
|
|
1251 x = wrong_type_argument (Qnumber_or_marker_p, x); \
|
16
|
1252 } while (0)
|
0
|
1253
|
185
|
1254 #define CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER(x) do \
|
|
1255 { if (INTP (x) || FLOATP (x)) \
|
|
1256 ; \
|
|
1257 else if (CHARP (x)) \
|
|
1258 x = make_int (XCHAR (x)); \
|
|
1259 else if (MARKERP (x)) \
|
|
1260 x = make_int (marker_position (x)); \
|
|
1261 else \
|
|
1262 x = wrong_type_argument (Qnumber_char_or_marker_p, x); \
|
16
|
1263 } while (0)
|
0
|
1264
|
|
1265 # define INT_OR_FLOATP(x) (INTP (x) || FLOATP (x))
|
|
1266 # define GC_INT_OR_FLOATP(x) (GC_INTP (x) || GC_FLOATP (x))
|
|
1267
|
|
1268 #else /* not LISP_FLOAT_TYPE */
|
|
1269
|
|
1270 #define XFLOAT(x) --- error! No float support. ---
|
|
1271 #define XSETFLOAT(x, p) --- error! No float support. ---
|
|
1272 #define FLOATP(x) 0
|
|
1273 #define GC_FLOATP(x) 0
|
|
1274 #define CHECK_FLOAT(x) --- error! No float support. ---
|
|
1275 #define CONCHECK_FLOAT(x) --- error! No float support. ---
|
|
1276
|
|
1277 #define XFLOATINT(n) XINT(n)
|
|
1278 #define CHECK_INT_OR_FLOAT CHECK_INT
|
|
1279 #define CONCHECK_INT_OR_FLOAT CONCHECK_INT
|
|
1280 #define CHECK_INT_OR_FLOAT_COERCE_MARKER CHECK_INT_COERCE_MARKER
|
|
1281 #define CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER \
|
|
1282 CHECK_INT_COERCE_CHAR_OR_MARKER
|
|
1283 #define INT_OR_FLOATP(x) (INTP (x))
|
|
1284 # define GC_INT_OR_FLOATP(x) (GC_INTP (x))
|
|
1285
|
|
1286 #endif /* not LISP_FLOAT_TYPE */
|
|
1287
|
207
|
1288 #ifdef USE_MINIMAL_TAGBITS
|
|
1289 # define INTP(x) \
|
|
1290 (XTYPE (x) == Lisp_Type_Int_Even || XTYPE(x) == Lisp_Type_Int_Odd)
|
|
1291 # define GC_INTP(x) \
|
|
1292 (XGCTYPE (x) == Lisp_Type_Int_Even || XGCTYPE(x) == Lisp_Type_Int_Odd)
|
|
1293 #else
|
|
1294 # define INTP(x) (XTYPE (x) == Lisp_Type_Int)
|
|
1295 # define GC_INTP(x) (XGCTYPE (x) == Lisp_Type_Int)
|
|
1296 #endif
|
0
|
1297
|
|
1298 #define ZEROP(x) EQ (x, Qzero)
|
|
1299 #define GC_ZEROP(x) GC_EQ (x, Qzero)
|
|
1300
|
|
1301 #ifdef ERROR_CHECK_TYPECHECK
|
|
1302
|
|
1303 INLINE EMACS_INT XINT (Lisp_Object obj);
|
|
1304 INLINE EMACS_INT
|
|
1305 XINT (Lisp_Object obj)
|
|
1306 {
|
|
1307 assert (INTP (obj));
|
|
1308 return XREALINT (obj);
|
|
1309 }
|
|
1310
|
|
1311 #else
|
|
1312
|
|
1313 #define XINT(obj) XREALINT (obj)
|
|
1314
|
|
1315 #endif
|
|
1316
|
207
|
1317 #ifdef ERROR_CHECK_TYPECHECK
|
|
1318
|
|
1319 INLINE EMACS_INT XCHAR_OR_INT (Lisp_Object obj);
|
|
1320 INLINE EMACS_INT
|
|
1321 XCHAR_OR_INT (Lisp_Object obj)
|
|
1322 {
|
|
1323 assert (INTP (obj) || CHARP (obj));
|
|
1324 return CHARP (obj) ? XCHAR (obj) : XINT (obj);
|
|
1325 }
|
|
1326
|
|
1327 #else
|
|
1328
|
|
1329 #define XCHAR_OR_INT(obj) (CHARP ((obj)) ? XCHAR ((obj)) : XINT ((obj)))
|
|
1330
|
|
1331 #endif
|
|
1332
|
|
1333 #ifdef USE_MINIMAL_TAGBITS
|
|
1334 /*
|
|
1335 * can't use CHECK_NONRECORD and CONCHECK_NONRECORD here because in
|
|
1336 * the USE_MINIMAL_TAGBITS implementation Lisp integers have two types.
|
|
1337 */
|
|
1338 # define CHECK_INT(x) do { \
|
|
1339 if (! INTP (x)) \
|
|
1340 dead_wrong_type_argument (Qintegerp, x); \
|
|
1341 } while (0)
|
|
1342 # define CONCHECK_INT(x) do { \
|
|
1343 if (! INTP (x)) \
|
|
1344 x = wrong_type_argument (Qintegerp, x); \
|
|
1345 } while (0)
|
|
1346 #else
|
|
1347 # define CHECK_INT(x) CHECK_NONRECORD (x, Lisp_Type_Int, Qintegerp)
|
|
1348 # define CONCHECK_INT(x) CONCHECK_NONRECORD (x, Lisp_Type_Int, Qintegerp)
|
|
1349 #endif
|
0
|
1350
|
|
1351 #define NATNUMP(x) (INTP (x) && XINT (x) >= 0)
|
|
1352 #define GC_NATNUMP(x) (GC_INTP (x) && XINT (x) >= 0)
|
|
1353
|
|
1354 #define CHECK_NATNUM(x) \
|
|
1355 do { if (!NATNUMP (x)) dead_wrong_type_argument (Qnatnump, x); } while (0)
|
|
1356 #define CONCHECK_NATNUM(x) \
|
|
1357 do { if (!NATNUMP (x)) x = wrong_type_argument (Qnatnump, x); } while (0)
|
|
1358
|
|
1359 /* next three always continuable because they coerce their arguments. */
|
185
|
1360 #define CHECK_INT_COERCE_CHAR(x) do \
|
|
1361 { if (INTP (x)) \
|
|
1362 ; \
|
|
1363 else if (CHARP (x)) \
|
|
1364 x = make_int (XCHAR (x)); \
|
|
1365 else \
|
|
1366 x = wrong_type_argument (Qinteger_or_char_p, x); \
|
16
|
1367 } while (0)
|
0
|
1368
|
185
|
1369 #define CHECK_INT_COERCE_MARKER(x) do \
|
|
1370 { if (INTP (x)) \
|
|
1371 ; \
|
|
1372 else if (MARKERP (x)) \
|
|
1373 x = make_int (marker_position (x)); \
|
|
1374 else \
|
|
1375 x = wrong_type_argument (Qinteger_or_marker_p, x); \
|
16
|
1376 } while (0)
|
0
|
1377
|
185
|
1378 #define CHECK_INT_COERCE_CHAR_OR_MARKER(x) do \
|
|
1379 { if (INTP (x)) \
|
|
1380 ; \
|
|
1381 else if (CHARP (x)) \
|
|
1382 x = make_int (XCHAR (x)); \
|
|
1383 else if (MARKERP (x)) \
|
|
1384 x = make_int (marker_position (x)); \
|
|
1385 else \
|
|
1386 x = wrong_type_argument (Qinteger_char_or_marker_p, x); \
|
16
|
1387 } while (0)
|
0
|
1388
|
|
1389 /*********** pure space ***********/
|
|
1390
|
|
1391 #define CHECK_IMPURE(obj) \
|
|
1392 do { if (purified (obj)) pure_write_error (); } while (0)
|
|
1393
|
|
1394 /*********** structures ***********/
|
|
1395
|
185
|
1396 typedef struct structure_keyword_entry structure_keyword_entry;
|
0
|
1397 struct structure_keyword_entry
|
|
1398 {
|
|
1399 Lisp_Object keyword;
|
|
1400 int (*validate) (Lisp_Object keyword, Lisp_Object value,
|
|
1401 Error_behavior errb);
|
|
1402 };
|
|
1403
|
185
|
1404 typedef struct
|
0
|
1405 {
|
185
|
1406 Dynarr_declare (structure_keyword_entry);
|
|
1407 } structure_keyword_entry_dynarr;
|
0
|
1408
|
185
|
1409 typedef struct structure_type structure_type;
|
0
|
1410 struct structure_type
|
|
1411 {
|
|
1412 Lisp_Object type;
|
185
|
1413 structure_keyword_entry_dynarr *keywords;
|
0
|
1414 int (*validate) (Lisp_Object data, Error_behavior errb);
|
|
1415 Lisp_Object (*instantiate) (Lisp_Object data);
|
|
1416 };
|
|
1417
|
185
|
1418 typedef struct
|
0
|
1419 {
|
185
|
1420 Dynarr_declare (structure_type);
|
|
1421 } structure_type_dynarr;
|
0
|
1422
|
|
1423 struct structure_type *define_structure_type (Lisp_Object type,
|
|
1424 int (*validate)
|
|
1425 (Lisp_Object data,
|
|
1426 Error_behavior errb),
|
|
1427 Lisp_Object (*instantiate)
|
|
1428 (Lisp_Object data));
|
|
1429 void define_structure_type_keyword (struct structure_type *st,
|
|
1430 Lisp_Object keyword,
|
|
1431 int (*validate) (Lisp_Object keyword,
|
|
1432 Lisp_Object value,
|
|
1433 Error_behavior errb));
|
|
1434
|
|
1435 /*********** weak lists ***********/
|
|
1436
|
|
1437 enum weak_list_type
|
|
1438 {
|
|
1439 /* element disappears if it's unmarked. */
|
|
1440 WEAK_LIST_SIMPLE,
|
|
1441 /* element disappears if it's a cons and either its car or
|
|
1442 cdr is unmarked. */
|
|
1443 WEAK_LIST_ASSOC,
|
|
1444 /* element disappears if it's a cons and its car is unmarked. */
|
|
1445 WEAK_LIST_KEY_ASSOC,
|
|
1446 /* element disappears if it's a cons and its cdr is unmarked. */
|
|
1447 WEAK_LIST_VALUE_ASSOC
|
|
1448 };
|
|
1449
|
|
1450 struct weak_list
|
|
1451 {
|
|
1452 struct lcrecord_header header;
|
|
1453 Lisp_Object list; /* don't mark through this! */
|
|
1454 enum weak_list_type type;
|
|
1455 Lisp_Object next_weak; /* don't mark through this! */
|
|
1456 };
|
|
1457
|
|
1458 DECLARE_LRECORD (weak_list, struct weak_list);
|
|
1459 #define XWEAK_LIST(x) XRECORD (x, weak_list, struct weak_list)
|
|
1460 #define XSETWEAK_LIST(x, p) XSETRECORD (x, p, weak_list)
|
|
1461 #define WEAK_LISTP(x) RECORDP (x, weak_list)
|
|
1462 #define GC_WEAK_LISTP(x) GC_RECORDP (x, weak_list)
|
|
1463 #define CHECK_WEAK_LIST(x) CHECK_RECORD (x, weak_list)
|
|
1464 #define CONCHECK_WEAK_LIST(x) CONCHECK_RECORD (x, weak_list)
|
|
1465
|
|
1466 #define weak_list_list(w) ((w)->list)
|
|
1467 #define XWEAK_LIST_LIST(w) (XWEAK_LIST (w)->list)
|
|
1468
|
|
1469 Lisp_Object make_weak_list (enum weak_list_type type);
|
|
1470 /* The following two are only called by the garbage collector */
|
|
1471 int finish_marking_weak_lists (int (*obj_marked_p) (Lisp_Object),
|
|
1472 void (*markobj) (Lisp_Object));
|
|
1473 void prune_weak_lists (int (*obj_marked_p) (Lisp_Object));
|
|
1474
|
|
1475 /*********** lcrecord lists ***********/
|
|
1476
|
|
1477 struct lcrecord_list
|
|
1478 {
|
|
1479 struct lcrecord_header header;
|
|
1480 Lisp_Object free;
|
|
1481 int size;
|
|
1482 CONST struct lrecord_implementation *implementation;
|
|
1483 };
|
|
1484
|
|
1485 DECLARE_LRECORD (lcrecord_list, struct lcrecord_list);
|
|
1486 #define XLCRECORD_LIST(x) XRECORD (x, lcrecord_list, struct lcrecord_list)
|
|
1487 #define XSETLCRECORD_LIST(x, p) XSETRECORD (x, p, lcrecord_list)
|
|
1488 #define LCRECORD_LISTP(x) RECORDP (x, lcrecord_list)
|
|
1489 #define GC_LCRECORD_LISTP(x) GC_RECORDP (x, lcrecord_list)
|
|
1490 /* #define CHECK_LCRECORD_LIST(x) CHECK_RECORD (x, lcrecord_list)
|
|
1491 Lcrecord lists should never escape to the Lisp level, so
|
|
1492 functions should not be doing this. */
|
|
1493
|
|
1494 Lisp_Object make_lcrecord_list (int size,
|
|
1495 CONST struct lrecord_implementation
|
|
1496 *implementation);
|
|
1497 Lisp_Object allocate_managed_lcrecord (Lisp_Object lcrecord_list);
|
|
1498 void free_managed_lcrecord (Lisp_Object lcrecord_list, Lisp_Object lcrecord);
|
|
1499
|
|
1500
|
|
1501 /************************************************************************/
|
|
1502 /* Definitions of primitive Lisp functions and variables */
|
|
1503 /************************************************************************/
|
|
1504
|
16
|
1505
|
|
1506 /* DEFUN - Define a built-in Lisp-visible C function or `subr'.
|
0
|
1507 `lname' should be the name to give the function in Lisp,
|
|
1508 as a null-terminated C string.
|
16
|
1509 `Fname' should be the C equivalent of `lname', using only characters
|
|
1510 valid in a C identifier, with an "F" prepended.
|
20
|
1511 The name of the C constant structure that records information
|
|
1512 on this function for internal use is "S" concatenated with Fname.
|
0
|
1513 `minargs' should be a number, the minimum number of arguments allowed.
|
|
1514 `maxargs' should be a number, the maximum number of arguments allowed,
|
|
1515 or else MANY or UNEVALLED.
|
|
1516 MANY means pass a vector of evaluated arguments,
|
|
1517 in the form of an integer number-of-arguments
|
|
1518 followed by the address of a vector of Lisp_Objects
|
|
1519 which contains the argument values.
|
16
|
1520 UNEVALLED means pass the list of unevaluated arguments.
|
0
|
1521 `prompt' says how to read arguments for an interactive call.
|
|
1522 See the doc string for `interactive'.
|
|
1523 A null string means call interactively with no arguments.
|
16
|
1524 `arglist' are the comma-separated arguments (always Lisp_Objects) for
|
|
1525 the function.
|
|
1526 The docstring for the function is placed as a "C" comment between
|
|
1527 the prompt and the `args' argument. make-docfile reads the
|
|
1528 comment and creates the DOC file form it.
|
0
|
1529 */
|
|
1530
|
207
|
1531 #define SUBR_MAX_ARGS 12
|
0
|
1532 #define MANY -2
|
|
1533 #define UNEVALLED -1
|
|
1534
|
|
1535 /* Can't be const, because then subr->doc is read-only and
|
16
|
1536 Snarf_documentation chokes */
|
20
|
1537
|
211
|
1538 #ifdef USE_INDEXED_LRECORD_IMPLEMENTATION
|
|
1539 # define subr_lheader_initializer { 0, 0, 0 }
|
|
1540 #else
|
|
1541 # define subr_lheader_initializer { lrecord_subr }
|
|
1542 #endif
|
|
1543
|
20
|
1544 #define DEFUN(lname, Fname, minargs, maxargs, prompt, arglist) \
|
100
|
1545 Lisp_Object Fname (DEFUN_##maxargs arglist) ; /* See below */ \
|
211
|
1546 static struct Lisp_Subr S##Fname = { subr_lheader_initializer, \
|
74
|
1547 minargs, maxargs, prompt, 0, lname, (lisp_fn_t) Fname }; \
|
20
|
1548 Lisp_Object Fname (DEFUN_##maxargs arglist)
|
|
1549
|
16
|
1550 /* Heavy ANSI C preprocessor hackery to get DEFUN to declare a
|
|
1551 prototype that matches maxargs, and add the obligatory
|
|
1552 `Lisp_Object' type declaration to the formal C arguments. */
|
0
|
1553
|
20
|
1554 #define DEFUN_MANY(named_int, named_Lisp_Object) named_int, named_Lisp_Object
|
16
|
1555 #define DEFUN_UNEVALLED(args) Lisp_Object args
|
|
1556 #define DEFUN_0() void
|
207
|
1557 #define DEFUN_1(a) Lisp_Object a
|
|
1558 #define DEFUN_2(a,b) DEFUN_1(a), Lisp_Object b
|
|
1559 #define DEFUN_3(a,b,c) DEFUN_2(a,b), Lisp_Object c
|
|
1560 #define DEFUN_4(a,b,c,d) DEFUN_3(a,b,c), Lisp_Object d
|
|
1561 #define DEFUN_5(a,b,c,d,e) DEFUN_4(a,b,c,d), Lisp_Object e
|
|
1562 #define DEFUN_6(a,b,c,d,e,f) DEFUN_5(a,b,c,d,e), Lisp_Object f
|
|
1563 #define DEFUN_7(a,b,c,d,e,f,g) DEFUN_6(a,b,c,d,e,f), Lisp_Object g
|
|
1564 #define DEFUN_8(a,b,c,d,e,f,g,h) DEFUN_7(a,b,c,d,e,f,g), Lisp_Object h
|
|
1565 #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
|
|
1566 #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
|
|
1567 #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
|
|
1568 #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
|
1569
|
16
|
1570 /* WARNING: If you add defines here for higher values of maxargs,
|
|
1571 make sure to also fix the clauses in primitive_funcall(),
|
|
1572 and change the define of SUBR_MAX_ARGS above. */
|
0
|
1573
|
|
1574 #include "symeval.h"
|
|
1575
|
16
|
1576 /* Depth of special binding/unwind-protect stack. Use as arg to `unbind_to' */
|
0
|
1577 int specpdl_depth (void);
|
|
1578
|
|
1579
|
|
1580 /************************************************************************/
|
|
1581 /* Checking for QUIT */
|
|
1582 /************************************************************************/
|
|
1583
|
|
1584 /* Asynchronous events set something_happened, and then are processed
|
|
1585 within the QUIT macro. At this point, we are guaranteed to not be in
|
|
1586 any sensitive code. */
|
|
1587
|
|
1588 extern volatile int something_happened;
|
|
1589 int check_what_happened (void);
|
|
1590
|
|
1591 extern volatile int quit_check_signal_happened;
|
|
1592 extern volatile int quit_check_signal_tick_count;
|
|
1593 int check_quit (void);
|
|
1594
|
|
1595 void signal_quit (void);
|
|
1596
|
|
1597 /* Nonzero if ought to quit now. */
|
84
|
1598 #define QUITP \
|
|
1599 ((quit_check_signal_happened ? check_quit () : 0), \
|
|
1600 (!NILP (Vquit_flag) && (NILP (Vinhibit_quit) \
|
|
1601 || EQ (Vquit_flag, Qcritical))))
|
0
|
1602
|
|
1603 /* QUIT used to call QUITP, but there are some places where QUITP
|
|
1604 is called directly, and check_what_happened() should only be called
|
|
1605 when Emacs is actually ready to quit because it could do things
|
|
1606 like switch threads. */
|
84
|
1607 #define INTERNAL_QUITP \
|
|
1608 ((something_happened ? check_what_happened () : 0), \
|
|
1609 (!NILP (Vquit_flag) && \
|
0
|
1610 (NILP (Vinhibit_quit) || EQ (Vquit_flag, Qcritical))))
|
|
1611
|
84
|
1612 #define INTERNAL_REALLY_QUITP \
|
|
1613 (check_what_happened (), \
|
|
1614 (!NILP (Vquit_flag) && \
|
0
|
1615 (NILP (Vinhibit_quit) || EQ (Vquit_flag, Qcritical))))
|
|
1616
|
|
1617 /* Check quit-flag and quit if it is non-nil. Also do any other things
|
|
1618 that might have gotten queued until it was safe. */
|
16
|
1619 #define QUIT do { if (INTERNAL_QUITP) signal_quit (); } while (0)
|
0
|
1620
|
16
|
1621 #define REALLY_QUIT do { if (INTERNAL_REALLY_QUITP) signal_quit (); } while (0)
|
0
|
1622
|
|
1623
|
|
1624 /************************************************************************/
|
|
1625 /* hashing */
|
|
1626 /************************************************************************/
|
|
1627
|
16
|
1628 /* #### for a 64-bit machine, we should substitute a prime just over 2^32 */
|
|
1629 #define GOOD_HASH 65599 /* prime number just over 2^16; Dragon book, p. 435 */
|
|
1630 #define HASH2(a,b) (GOOD_HASH * (a) + (b))
|
|
1631 #define HASH3(a,b,c) (GOOD_HASH * HASH2 (a,b) + (c))
|
|
1632 #define HASH4(a,b,c,d) (GOOD_HASH * HASH3 (a,b,c) + (d))
|
|
1633 #define HASH5(a,b,c,d,e) (GOOD_HASH * HASH4 (a,b,c,d) + (e))
|
|
1634 #define HASH6(a,b,c,d,e,f) (GOOD_HASH * HASH5 (a,b,c,d,e) + (f))
|
|
1635 #define HASH7(a,b,c,d,e,f,g) (GOOD_HASH * HASH6 (a,b,c,d,e,f) + (g))
|
|
1636 #define HASH8(a,b,c,d,e,f,g,h) (GOOD_HASH * HASH7 (a,b,c,d,e,f,g) + (h))
|
|
1637 #define HASH9(a,b,c,d,e,f,g,h,i) (GOOD_HASH * HASH8 (a,b,c,d,e,f,g,h) + (i))
|
0
|
1638
|
|
1639 /* Enough already! */
|
|
1640
|
|
1641 #define LISP_HASH(obj) ((unsigned long) LISP_TO_VOID (obj))
|
|
1642 unsigned long string_hash (CONST void *xv);
|
|
1643 unsigned long memory_hash (CONST void *xv, int size);
|
|
1644 unsigned long internal_hash (Lisp_Object obj, int depth);
|
|
1645 unsigned long internal_array_hash (Lisp_Object *arr, int size, int depth);
|
|
1646
|
|
1647
|
|
1648 /************************************************************************/
|
|
1649 /* String translation */
|
|
1650 /************************************************************************/
|
|
1651
|
|
1652 #ifdef I18N3
|
|
1653 #ifdef HAVE_LIBINTL_H
|
|
1654 #include <libintl.h>
|
|
1655 #else
|
|
1656 char *dgettext (CONST char *, CONST char *);
|
|
1657 char *gettext (CONST char *);
|
|
1658 char *textdomain (CONST char *);
|
|
1659 char *bindtextdomain (CONST char *, CONST char *);
|
|
1660 #endif /* HAVE_LIBINTL_H */
|
|
1661
|
|
1662 #define GETTEXT(x) gettext(x)
|
|
1663 #define LISP_GETTEXT(x) Fgettext (x)
|
|
1664 #else /* !I18N3 */
|
|
1665 #define GETTEXT(x) (x)
|
|
1666 #define LISP_GETTEXT(x) (x)
|
|
1667 #endif /* !I18N3 */
|
|
1668
|
|
1669 /* DEFER_GETTEXT is used to identify strings which are translated when
|
|
1670 they are referenced instead of when they are defined.
|
|
1671 These include Qerror_messages and initialized arrays of strings.
|
|
1672 */
|
|
1673 #define DEFER_GETTEXT(x) (x)
|
|
1674
|
|
1675
|
|
1676 /************************************************************************/
|
|
1677 /* Garbage collection / GC-protection */
|
|
1678 /************************************************************************/
|
|
1679
|
|
1680 /* number of bytes of structure consed since last GC */
|
|
1681
|
|
1682 extern EMACS_INT consing_since_gc;
|
|
1683
|
|
1684 /* threshold for doing another gc */
|
|
1685
|
|
1686 extern EMACS_INT gc_cons_threshold;
|
|
1687
|
|
1688 /* Structure for recording stack slots that need marking */
|
|
1689
|
|
1690 /* This is a chain of structures, each of which points at a Lisp_Object
|
|
1691 variable whose value should be marked in garbage collection.
|
|
1692 Normally every link of the chain is an automatic variable of a function,
|
|
1693 and its `val' points to some argument or local variable of the function.
|
|
1694 On exit to the function, the chain is set back to the value it had on
|
|
1695 entry. This way, no link remains in the chain when the stack frame
|
173
|
1696 containing the link disappears.
|
0
|
1697
|
|
1698 Every function that can call Feval must protect in this fashion all
|
|
1699 Lisp_Object variables whose contents will be used again. */
|
|
1700
|
|
1701 extern struct gcpro *gcprolist;
|
|
1702
|
|
1703 struct gcpro
|
|
1704 {
|
|
1705 struct gcpro *next;
|
|
1706 Lisp_Object *var; /* Address of first protected variable */
|
|
1707 int nvars; /* Number of consecutive protected variables */
|
|
1708 };
|
|
1709
|
|
1710 /* Normally, you declare variables gcpro1, gcpro2, ... and use the
|
|
1711 GCPROn() macros. However, if you need to have nested gcpro's,
|
|
1712 declare ngcpro1, ngcpro2, ... and use NGCPROn(). If you need
|
|
1713 to nest another level, use nngcpro1, nngcpro2, ... and use
|
|
1714 NNGCPROn(). If you need to nest yet another level, create
|
|
1715 the appropriate macros. */
|
|
1716
|
|
1717 #ifdef DEBUG_GCPRO
|
|
1718
|
16
|
1719 void debug_gcpro1 ();
|
84
|
1720 void debug_gcpro2 ();
|
16
|
1721 void debug_gcpro3 ();
|
|
1722 void debug_gcpro4 ();
|
|
1723 void debug_gcpro5 ();
|
|
1724 void debug_ungcpro();
|
0
|
1725
|
|
1726 #define GCPRO1(v) \
|
|
1727 debug_gcpro1 (__FILE__, __LINE__,&gcpro1,&v)
|
|
1728 #define GCPRO2(v1,v2) \
|
|
1729 debug_gcpro2 (__FILE__, __LINE__,&gcpro1,&gcpro2,&v1,&v2)
|
|
1730 #define GCPRO3(v1,v2,v3) \
|
|
1731 debug_gcpro3 (__FILE__, __LINE__,&gcpro1,&gcpro2,&gcpro3,&v1,&v2,&v3)
|
|
1732 #define GCPRO4(v1,v2,v3,v4) \
|
|
1733 debug_gcpro4 (__FILE__, __LINE__,&gcpro1,&gcpro2,&gcpro3,&gcpro4,\
|
|
1734 &v1,&v2,&v3,&v4)
|
|
1735 #define GCPRO5(v1,v2,v3,v4,v5) \
|
|
1736 debug_gcpro5 (__FILE__, __LINE__,&gcpro1,&gcpro2,&gcpro3,&gcpro4,&gcpro5,\
|
|
1737 &v1,&v2,&v3,&v4,&v5)
|
|
1738 #define UNGCPRO \
|
|
1739 debug_ungcpro(__FILE__, __LINE__,&gcpro1)
|
|
1740
|
|
1741 #define NGCPRO1(v) \
|
|
1742 debug_gcpro1 (__FILE__, __LINE__,&ngcpro1,&v)
|
|
1743 #define NGCPRO2(v1,v2) \
|
|
1744 debug_gcpro2 (__FILE__, __LINE__,&ngcpro1,&ngcpro2,&v1,&v2)
|
|
1745 #define NGCPRO3(v1,v2,v3) \
|
|
1746 debug_gcpro3 (__FILE__, __LINE__,&ngcpro1,&ngcpro2,&ngcpro3,&v1,&v2,&v3)
|
|
1747 #define NGCPRO4(v1,v2,v3,v4) \
|
|
1748 debug_gcpro4 (__FILE__, __LINE__,&ngcpro1,&ngcpro2,&ngcpro3,&ngcpro4,\
|
|
1749 &v1,&v2,&v3,&v4)
|
|
1750 #define NGCPRO5(v1,v2,v3,v4,v5) \
|
|
1751 debug_gcpro5 (__FILE__, __LINE__,&ngcpro1,&ngcpro2,&ngcpro3,&ngcpro4,\
|
|
1752 &ngcpro5,&v1,&v2,&v3,&v4,&v5)
|
|
1753 #define NUNGCPRO \
|
|
1754 debug_ungcpro(__FILE__, __LINE__,&ngcpro1)
|
|
1755
|
|
1756 #define NNGCPRO1(v) \
|
|
1757 debug_gcpro1 (__FILE__, __LINE__,&nngcpro1,&v)
|
|
1758 #define NNGCPRO2(v1,v2) \
|
|
1759 debug_gcpro2 (__FILE__, __LINE__,&nngcpro1,&nngcpro2,&v1,&v2)
|
|
1760 #define NNGCPRO3(v1,v2,v3) \
|
|
1761 debug_gcpro3 (__FILE__, __LINE__,&nngcpro1,&nngcpro2,&nngcpro3,&v1,&v2,&v3)
|
|
1762 #define NNGCPRO4(v1,v2,v3,v4) \
|
|
1763 debug_gcpro4 (__FILE__, __LINE__,&nngcpro1,&nngcpro2,&nngcpro3,&nngcpro4,\
|
|
1764 &v1,&v2,&v3,&v4)
|
|
1765 #define NNGCPRO5(v1,v2,v3,v4,v5) \
|
|
1766 debug_gcpro5 (__FILE__, __LINE__,&nngcpro1,&nngcpro2,&nngcpro3,&nngcpro4,\
|
|
1767 &nngcpro5,&v1,&v2,&v3,&v4,&v5)
|
|
1768 #define NUNNGCPRO \
|
|
1769 debug_ungcpro(__FILE__, __LINE__,&nngcpro1)
|
|
1770
|
|
1771 #else /* ! DEBUG_GCPRO */
|
|
1772
|
|
1773 #define GCPRO1(varname) \
|
|
1774 {gcpro1.next = gcprolist; gcpro1.var = &varname; gcpro1.nvars = 1; \
|
|
1775 gcprolist = &gcpro1; }
|
|
1776
|
|
1777 #define GCPRO2(varname1, varname2) \
|
|
1778 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
|
16
|
1779 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
|
0
|
1780 gcprolist = &gcpro2; }
|
|
1781
|
|
1782 #define GCPRO3(varname1, varname2, varname3) \
|
|
1783 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
|
14
|
1784 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
|
|
1785 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
|
0
|
1786 gcprolist = &gcpro3; }
|
|
1787
|
|
1788 #define GCPRO4(varname1, varname2, varname3, varname4) \
|
|
1789 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
|
14
|
1790 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
|
|
1791 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
|
|
1792 gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \
|
0
|
1793 gcprolist = &gcpro4; }
|
|
1794
|
|
1795 #define GCPRO5(varname1, varname2, varname3, varname4, varname5) \
|
|
1796 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
|
14
|
1797 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
|
|
1798 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
|
|
1799 gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \
|
|
1800 gcpro5.next = &gcpro4; gcpro5.var = &varname5; gcpro5.nvars = 1; \
|
0
|
1801 gcprolist = &gcpro5; }
|
|
1802
|
|
1803 #define UNGCPRO (gcprolist = gcpro1.next)
|
|
1804
|
|
1805 #define NGCPRO1(varname) \
|
|
1806 {ngcpro1.next = gcprolist; ngcpro1.var = &varname; ngcpro1.nvars = 1; \
|
|
1807 gcprolist = &ngcpro1; }
|
|
1808
|
|
1809 #define NGCPRO2(varname1, varname2) \
|
|
1810 {ngcpro1.next = gcprolist; ngcpro1.var = &varname1; ngcpro1.nvars = 1; \
|
14
|
1811 ngcpro2.next = &ngcpro1; ngcpro2.var = &varname2; ngcpro2.nvars = 1; \
|
0
|
1812 gcprolist = &ngcpro2; }
|
|
1813
|
|
1814 #define NGCPRO3(varname1, varname2, varname3) \
|
|
1815 {ngcpro1.next = gcprolist; ngcpro1.var = &varname1; ngcpro1.nvars = 1; \
|
14
|
1816 ngcpro2.next = &ngcpro1; ngcpro2.var = &varname2; ngcpro2.nvars = 1; \
|
|
1817 ngcpro3.next = &ngcpro2; ngcpro3.var = &varname3; ngcpro3.nvars = 1; \
|
0
|
1818 gcprolist = &ngcpro3; }
|
|
1819
|
|
1820 #define NGCPRO4(varname1, varname2, varname3, varname4) \
|
|
1821 {ngcpro1.next = gcprolist; ngcpro1.var = &varname1; ngcpro1.nvars = 1; \
|
14
|
1822 ngcpro2.next = &ngcpro1; ngcpro2.var = &varname2; ngcpro2.nvars = 1; \
|
|
1823 ngcpro3.next = &ngcpro2; ngcpro3.var = &varname3; ngcpro3.nvars = 1; \
|
|
1824 ngcpro4.next = &ngcpro3; ngcpro4.var = &varname4; ngcpro4.nvars = 1; \
|
0
|
1825 gcprolist = &ngcpro4; }
|
|
1826
|
|
1827 #define NGCPRO5(varname1, varname2, varname3, varname4, varname5) \
|
|
1828 {ngcpro1.next = gcprolist; ngcpro1.var = &varname1; ngcpro1.nvars = 1; \
|
14
|
1829 ngcpro2.next = &ngcpro1; ngcpro2.var = &varname2; ngcpro2.nvars = 1; \
|
|
1830 ngcpro3.next = &ngcpro2; ngcpro3.var = &varname3; ngcpro3.nvars = 1; \
|
|
1831 ngcpro4.next = &ngcpro3; ngcpro4.var = &varname4; ngcpro4.nvars = 1; \
|
|
1832 ngcpro5.next = &ngcpro4; ngcpro5.var = &varname5; ngcpro5.nvars = 1; \
|
0
|
1833 gcprolist = &ngcpro5; }
|
|
1834
|
|
1835 #define NUNGCPRO (gcprolist = ngcpro1.next)
|
|
1836
|
|
1837 #define NNGCPRO1(varname) \
|
|
1838 {nngcpro1.next = gcprolist; nngcpro1.var = &varname; nngcpro1.nvars = 1; \
|
|
1839 gcprolist = &nngcpro1; }
|
|
1840
|
|
1841 #define NNGCPRO2(varname1, varname2) \
|
|
1842 {nngcpro1.next = gcprolist; nngcpro1.var = &varname1; nngcpro1.nvars = 1; \
|
|
1843 nngcpro2.next = &nngcpro1; nngcpro2.var = &varname2; nngcpro2.nvars = 1; \
|
|
1844 gcprolist = &nngcpro2; }
|
|
1845
|
|
1846 #define NNGCPRO3(varname1, varname2, varname3) \
|
|
1847 {nngcpro1.next = gcprolist; nngcpro1.var = &varname1; nngcpro1.nvars = 1; \
|
|
1848 nngcpro2.next = &nngcpro1; nngcpro2.var = &varname2; nngcpro2.nvars = 1; \
|
|
1849 nngcpro3.next = &nngcpro2; nngcpro3.var = &varname3; nngcpro3.nvars = 1; \
|
|
1850 gcprolist = &nngcpro3; }
|
|
1851
|
|
1852 #define NNGCPRO4(varname1, varname2, varname3, varname4) \
|
|
1853 {nngcpro1.next = gcprolist; nngcpro1.var = &varname1; nngcpro1.nvars = 1; \
|
|
1854 nngcpro2.next = &nngcpro1; nngcpro2.var = &varname2; nngcpro2.nvars = 1; \
|
|
1855 nngcpro3.next = &nngcpro2; nngcpro3.var = &varname3; nngcpro3.nvars = 1; \
|
|
1856 nngcpro4.next = &nngcpro3; nngcpro4.var = &varname4; nngcpro4.nvars = 1; \
|
|
1857 gcprolist = &nngcpro4; }
|
|
1858
|
|
1859 #define NNGCPRO5(varname1, varname2, varname3, varname4, varname5) \
|
|
1860 {nngcpro1.next = gcprolist; nngcpro1.var = &varname1; nngcpro1.nvars = 1; \
|
|
1861 nngcpro2.next = &nngcpro1; nngcpro2.var = &varname2; nngcpro2.nvars = 1; \
|
|
1862 nngcpro3.next = &nngcpro2; nngcpro3.var = &varname3; nngcpro3.nvars = 1; \
|
|
1863 nngcpro4.next = &nngcpro3; nngcpro4.var = &varname4; nngcpro4.nvars = 1; \
|
|
1864 nngcpro5.next = &nngcpro4; nngcpro5.var = &varname5; nngcpro5.nvars = 1; \
|
|
1865 gcprolist = &nngcpro5; }
|
|
1866
|
|
1867 #define NNUNGCPRO (gcprolist = nngcpro1.next)
|
|
1868
|
|
1869 #endif /* ! DEBUG_GCPRO */
|
|
1870
|
|
1871 /* Another try to fix SunPro C compiler warnings */
|
|
1872 /* "end-of-loop code not reached" */
|
|
1873 /* "statement not reached */
|
|
1874 #ifdef __SUNPRO_C
|
|
1875 #define RETURN__ if (1) return
|
|
1876 #define RETURN_NOT_REACHED(value)
|
|
1877 #else
|
|
1878 #define RETURN__ return
|
|
1879 #define RETURN_NOT_REACHED(value) return value;
|
|
1880 #endif
|
|
1881
|
|
1882 /* Evaluate expr, UNGCPRO, and then return the value of expr. */
|
185
|
1883 #define RETURN_UNGCPRO(expr) do \
|
|
1884 { \
|
|
1885 Lisp_Object ret_ungc_val = (expr); \
|
|
1886 UNGCPRO; \
|
|
1887 RETURN__ ret_ungc_val; \
|
0
|
1888 } while (0)
|
|
1889
|
|
1890 /* Evaluate expr, NUNGCPRO, UNGCPRO, and then return the value of expr. */
|
185
|
1891 #define RETURN_NUNGCPRO(expr) do \
|
|
1892 { \
|
|
1893 Lisp_Object ret_ungc_val = (expr); \
|
|
1894 NUNGCPRO; \
|
|
1895 UNGCPRO; \
|
|
1896 RETURN__ ret_ungc_val; \
|
0
|
1897 } while (0)
|
|
1898
|
|
1899 /* Evaluate expr, NNUNGCPRO, NUNGCPRO, UNGCPRO, and then return the
|
|
1900 value of expr. */
|
185
|
1901 #define RETURN_NNUNGCPRO(expr) do \
|
|
1902 { \
|
|
1903 Lisp_Object ret_ungc_val = (expr); \
|
|
1904 NNUNGCPRO; \
|
|
1905 NUNGCPRO; \
|
|
1906 UNGCPRO; \
|
|
1907 RETURN__ ret_ungc_val; \
|
0
|
1908 } while (0)
|
|
1909
|
|
1910 /* Evaluate expr, return it if it's not Qunbound. */
|
185
|
1911 #define RETURN_IF_NOT_UNBOUND(expr) do \
|
|
1912 { \
|
|
1913 Lisp_Object ret_nunb_val = (expr); \
|
|
1914 if (!UNBOUNDP (ret_nunb_val)) \
|
|
1915 RETURN__ ret_nunb_val; \
|
0
|
1916 } while (0)
|
|
1917
|
|
1918 /* Call staticpro (&var) to protect static variable `var'. */
|
|
1919 void staticpro (Lisp_Object *);
|
|
1920
|
|
1921 /* Nonzero means Emacs has already been initialized.
|
|
1922 Used during startup to detect startup of dumped Emacs. */
|
|
1923 extern int initialized;
|
|
1924
|
|
1925 #ifdef MEMORY_USAGE_STATS
|
|
1926
|
|
1927 /* This structure is used to keep statistics on the amount of memory
|
|
1928 in use.
|
|
1929
|
|
1930 WAS_REQUESTED stores the actual amount of memory that was requested
|
|
1931 of the allocation function. The *_OVERHEAD fields store the
|
|
1932 additional amount of memory that was grabbed by the functions to
|
|
1933 facilitate allocation, reallocation, etc. MALLOC_OVERHEAD is for
|
|
1934 memory allocated with malloc(); DYNARR_OVERHEAD is for dynamic
|
|
1935 arrays; GAP_OVERHEAD is for gap arrays. Note that for (e.g.)
|
|
1936 dynamic arrays, there is both MALLOC_OVERHEAD and DYNARR_OVERHEAD
|
|
1937 memory: The dynamic array allocates memory above and beyond what
|
|
1938 was asked of it, and when it in turns allocates memory using
|
|
1939 malloc(), malloc() allocates memory beyond what it was asked
|
|
1940 to allocate.
|
|
1941
|
|
1942 Functions that accept a structure of this sort do not initialize
|
|
1943 the fields to 0, and add any existing values to whatever was there
|
|
1944 before; this way, you can get a cumulative effect. */
|
|
1945
|
|
1946 struct overhead_stats
|
|
1947 {
|
|
1948 int was_requested;
|
|
1949 int malloc_overhead;
|
|
1950 int dynarr_overhead;
|
|
1951 int gap_overhead;
|
|
1952 };
|
|
1953
|
|
1954 #endif /* MEMORY_USAGE_STATS */
|
|
1955
|
|
1956 /* Some systems (e.g., NT) use a different path separator than Unix,
|
|
1957 in addition to a device separator. Default the path separator
|
|
1958 to '/', and don't test for a device separator in IS_ANY_SEP. */
|
|
1959
|
209
|
1960 #ifdef WINDOWSNT
|
|
1961 extern Lisp_Object Vdirectory_sep_char;
|
|
1962 #endif
|
|
1963
|
0
|
1964 #ifndef DIRECTORY_SEP
|
|
1965 #define DIRECTORY_SEP '/'
|
|
1966 #endif
|
|
1967 #ifndef IS_DIRECTORY_SEP
|
|
1968 #define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
|
|
1969 #endif
|
|
1970 #ifndef IS_DEVICE_SEP
|
|
1971 #ifndef DEVICE_SEP
|
|
1972 #define IS_DEVICE_SEP(_c_) 0
|
|
1973 #else
|
|
1974 #define IS_DEVICE_SEP(_c_) ((_c_) == DEVICE_SEP)
|
|
1975 #endif
|
|
1976 #endif
|
|
1977 #ifndef IS_ANY_SEP
|
|
1978 #define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_))
|
|
1979 #endif
|
|
1980
|
165
|
1981 #ifdef HAVE_INTTYPES_H
|
|
1982 #include <inttypes.h>
|
|
1983 #elif SIZEOF_VOID_P == SIZEOF_INT
|
|
1984 typedef int intptr_t;
|
|
1985 typedef unsigned int uintptr_t;
|
|
1986 #elif SIZEOF_VOID_P == SIZEOF_LONG
|
|
1987 typedef long intptr_t;
|
|
1988 typedef unsigned long uintptr_t;
|
|
1989 #elif defined(SIZEOF_LONG_LONG) && SIZEOF_VOID_P == SIZEOF_LONG_LONG
|
|
1990 typedef long long intptr_t;
|
|
1991 typedef unsigned long long uintptr_t;
|
|
1992 #else
|
|
1993 /* Just pray. May break, may not. */
|
|
1994 typedef char *intptr_t;
|
|
1995 typedef char *uintptr_t;
|
|
1996 #endif
|
|
1997
|
0
|
1998 #include "emacsfns.h"
|
|
1999
|
|
2000 #endif /* _XEMACS_LISP_H_ */
|