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