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