annotate src/lisp.h @ 249:83b3d10dcba9 r20-5b23

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