Mercurial > hg > xemacs-beta
annotate src/lisp.h @ 5117:3742ea8250b5 ben-lisp-object ben-lisp-object-final-ws-year-2005
Checking in final CVS version of workspace 'ben-lisp-object'
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Sat, 26 Dec 2009 00:20:27 -0600 |
parents | d30cd499e445 |
children | e0db3c197671 |
rev | line source |
---|---|
428 | 1 /* Fundamental definitions for XEmacs Lisp interpreter. |
2 Copyright (C) 1985-1987, 1992-1995 Free Software Foundation, Inc. | |
3 Copyright (C) 1993-1996 Richard Mlynarik. | |
2535 | 4 Copyright (C) 1995, 1996, 2000, 2001, 2002, 2003, 2004, 2005 Ben Wing. |
428 | 5 |
6 This file is part of XEmacs. | |
7 | |
8 XEmacs is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
10 Free Software Foundation; either version 2, or (at your option) any | |
11 later version. | |
12 | |
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with XEmacs; see the file COPYING. If not, write to | |
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 Boston, MA 02111-1307, USA. */ | |
22 | |
23 /* Synched up with: FSF 19.30. */ | |
24 | |
853 | 25 /* Authorship: |
26 | |
27 Based on code from pre-release FSF 19, c. 1991. | |
28 Various changes by Jamie Zawinski 1991-1994: | |
29 converting to ANSI C, splitting out function prototypes to a separate | |
30 file (later moved back for unknown reasons by Steve Baur?), debug-gcpro | |
31 stuff (now moribund). | |
32 ANSI-fication of DEFUN macros by Felix Lee, c. 1992? | |
33 NOT_REACHED, DOESNT_RETURN, PRINTF_ARGS by Richard Mlynarik, c. 1994. | |
34 Many changes over the years corresponding to Lisp_Object definition | |
35 changes, esp. by Richard Mlynarik (c. 1993) and Kyle Jones (c. 1998). | |
36 See alloc.c for more details. | |
37 Overhauled and reordered by Ben Wing, 1995-1996, and many things added: | |
38 Dynarrs, REALLOC macros, asserts, typedefs, inline header code, | |
39 first LIST_LOOP macros, CONCHECK_*, all error-checking code | |
40 (e.g. error-checking versions of XFOO macros), structure read syntax, | |
41 weak lists, lcrecord lists, reworking of quit handling, object hashing, | |
42 nested GCPRO, character objects and Ebola checking, memory usage stats, | |
43 others. | |
44 LOADHIST changes from Steve Baur, c. 1997? | |
45 Various macro-related changes by Martin Buchholz, 1998-1999: | |
46 LIST_LOOP macros greatly expanded and tortoise-hared; | |
47 RETURN_SANS_WARNINGS; reworked DEFUN macros; EXFUN macros (???). | |
1743 | 48 Various macro-related changes by Jerry James, 2003: |
49 MODULE_API introduced; | |
50 Compiler-specific definitions modernized and moved to compiler.h. | |
853 | 51 */ |
52 | |
440 | 53 #ifndef INCLUDED_lisp_h_ |
54 #define INCLUDED_lisp_h_ | |
428 | 55 |
56 /************************************************************************/ | |
57 /* general definitions */ | |
58 /************************************************************************/ | |
59 | |
2367 | 60 /* Conventions in comments: |
61 | |
62 "Mule-izing" is the process of going through a file and eliminating | |
63 assumptions that the internal format (Ibyte * text) is the same as the | |
64 external format used by library routines. Mule-ization should also | |
65 include replacing *ALL* raw references to `char' or `unsigned char' with | |
66 one of the self-documenting types created below. How exactly to do the | |
67 conversion, and how to write correctly Mule-ized code, is described in | |
68 the internals manual. Files that say "This file is Mule-ized" have | |
69 been reviewed at some point; that's not to say that incorrect code hasn't | |
70 crept in, though. | |
71 | |
72 "Unicode-splitting" is the process of fixing a file so that it will | |
73 handle external text in Unicode under Microsoft Windows, as appropriate. | |
74 ("splitting" because it needs to handle either Unicode or variable-width | |
75 multibyte depending on the OS -- NT or 9x). See intl-win32.c. | |
76 | |
77 #### is a way of marking problems of any sort. | |
78 | |
79 !!#### marks places that are not properly Mule-ized. | |
80 | |
81 &&#### marks places that need to be fixed in order for the "8-bit mule" | |
82 conversion to work correctly, i.e. in order to support multiple different | |
83 buffer formats under Mule, including a fixed 8-bit format. | |
84 | |
85 ^^#### marks places that need to be fixed in order to eliminate the | |
86 assumption that Ibyte * text is composed of 1-byte units (e.g. UTF-16 | |
87 is composed of 2-byte units and might be a possible format to consider | |
88 for Ibyte * text). | |
89 | |
90 %%#### marks places that need work for KKCC (the new garbage collector). | |
91 | |
92 */ | |
93 | |
1318 | 94 /* -------------------------- include files --------------------- */ |
442 | 95 |
428 | 96 /* We include the following generally useful header files so that you |
97 don't have to worry about prototypes when using the standard C | |
98 library functions and macros. These files shouldn't be excessively | |
99 large so they shouldn't cause that much of a slowdown. */ | |
100 | |
101 #include <stdlib.h> | |
102 #include <string.h> /* primarily for memcpy, etc. */ | |
103 #include <stdio.h> /* NULL, etc. */ | |
104 #include <ctype.h> | |
105 #include <stdarg.h> | |
106 #include <stddef.h> /* offsetof */ | |
107 #include <sys/types.h> | |
442 | 108 #include <limits.h> |
109 | |
1318 | 110 /* -------------------------- error-checking ------------------------ */ |
853 | 111 |
112 /* The large categories established by configure can be subdivided into | |
113 smaller subcategories, for problems in specific modules. You can't | |
114 control this using configure, but you can manually stick in a define as | |
115 necessary. */ | |
116 | |
117 #ifdef ERROR_CHECK_STRUCTURES | |
118 /* Check for problems with the catch list and specbind stack */ | |
119 #define ERROR_CHECK_CATCH | |
120 /* Check for insufficient use of call_trapping_problems(), particularly | |
121 due to glyph-related changes causing eval or QUIT within redisplay */ | |
122 #define ERROR_CHECK_TRAPPING_PROBLEMS | |
123 #endif | |
124 | |
1318 | 125 #ifdef ERROR_CHECK_TYPES |
126 #define type_checking_assert(assertion) assert (assertion) | |
127 #define type_checking_assert_at_line(assertion, file, line) \ | |
128 assert_at_line (assertion, file, line) | |
129 #define type_checking_assert_with_message(assertion, msg) \ | |
130 assert_with_message (assertion, msg) | |
131 #else | |
132 #define type_checking_assert(assertion) | |
133 #define type_checking_assert_at_line(assertion, file, line) | |
134 #define type_checking_assert_with_message(assertion, msg) | |
135 #endif | |
136 #ifdef ERROR_CHECK_GC | |
137 #define gc_checking_assert(assertion) assert (assertion) | |
138 #define gc_checking_assert_at_line(assertion, file, line) \ | |
139 assert_at_line (assertion, file, line) | |
140 #define gc_checking_assert_with_message(assertion, msg) \ | |
141 assert_with_message (assertion, msg) | |
142 #else | |
143 #define gc_checking_assert(assertion) | |
144 #define gc_checking_assert_at_line(assertion, file, line) | |
145 #define gc_checking_assert_with_message(assertion, msg) | |
146 #endif | |
147 #ifdef ERROR_CHECK_TEXT | |
148 #define text_checking_assert(assertion) assert (assertion) | |
149 #define text_checking_assert_at_line(assertion, file, line) \ | |
150 assert_at_line (assertion, file, line) | |
151 #define text_checking_assert_with_message(assertion, msg) \ | |
152 assert_with_message (assertion, msg) | |
153 #else | |
154 #define text_checking_assert(assertion) | |
155 #define text_checking_assert_at_line(assertion, file, line) | |
156 #define text_checking_assert_with_message(assertion, msg) | |
157 #endif | |
158 #ifdef ERROR_CHECK_TRAPPING_PROBLEMS | |
159 #define trapping_problems_checking_assert(assertion) assert (assertion) | |
160 #define trapping_problems_checking_assert_at_line(assertion, file, line) \ | |
161 assert_at_line (assertion, file, line) | |
162 #define trapping_problems_checking_assert_with_message(assertion, msg) \ | |
163 assert_with_message (assertion, msg) | |
164 #else | |
165 #define trapping_problems_checking_assert(assertion) | |
166 #define trapping_problems_checking_assert_at_line(assertion, file, line) | |
167 #define trapping_problems_checking_assert_with_message(assertion, msg) | |
168 #endif | |
169 | |
2367 | 170 /************************************************************************/ |
171 /** Definitions of basic types **/ | |
172 /************************************************************************/ | |
173 | |
174 /* ------------- generic 8/16/32/64/128-bit integral types ------------ */ | |
647 | 175 |
826 | 176 #if SIZEOF_SHORT == 2 |
177 #define INT_16_BIT short | |
178 #define UINT_16_BIT unsigned short | |
179 #elif SIZEOF_INT == 2 | |
180 /* Bwa ha ha. As if XEmacs could actually support such systems. */ | |
181 #define INT_16_BIT int | |
182 #define UINT_16_BIT unsigned int | |
183 #else | |
184 #error Unable to find a 16-bit integral type | |
185 #endif | |
186 | |
187 #if SIZEOF_INT == 4 | |
188 #define INT_32_BIT int | |
189 #define UINT_32_BIT unsigned int | |
190 #define MAKE_32_BIT_UNSIGNED_CONSTANT(num) num##U | |
191 #elif SIZEOF_LONG == 4 | |
192 /* Bwa ha ha again. */ | |
193 #define INT_32_BIT long | |
194 #define UINT_32_BIT unsigned long | |
195 #define MAKE_32_BIT_UNSIGNED_CONSTANT(num) num##UL | |
196 #elif SIZEOF_SHORT == 4 | |
197 /* And again. */ | |
198 #define INT_32_BIT short | |
199 #define UINT_32_BIT unsigned short | |
200 #define MAKE_32_BIT_UNSIGNED_CONSTANT(num) num##U | |
1429 | 201 #elif 1 /* Unable to find a 32-bit integral type! */ |
826 | 202 #error What kind of strange-ass system are you running on? |
203 #endif | |
204 | |
205 #if SIZEOF_LONG == 8 | |
206 #define INT_64_BIT long | |
207 #define UINT_64_BIT unsigned long | |
208 #define MAKE_64_BIT_UNSIGNED_CONSTANT(num) num##UL | |
209 #elif SIZEOF_LONG_LONG == 8 | |
210 #define INT_64_BIT long long | |
211 #define UINT_64_BIT unsigned long long | |
212 #define MAKE_64_BIT_UNSIGNED_CONSTANT(num) num##ULL | |
213 /* No error otherwise; just leave undefined */ | |
214 #endif | |
215 | |
216 #if SIZEOF_LONG_LONG == 16 | |
217 #define INT_128_BIT long long | |
218 #define UINT_128_BIT unsigned long long | |
219 #define MAKE_128_BIT_UNSIGNED_CONSTANT(num) num##ULL | |
220 /* No error otherwise; just leave undefined */ | |
221 #endif | |
222 | |
223 /* #### Fill this in for other systems */ | |
224 #if defined (INT_64_BIT) && !(defined (i386) || defined (__i386__)) | |
225 #define EFFICIENT_INT_64_BIT INT_64_BIT | |
226 #define EFFICIENT_UINT_64_BIT UINT_64_BIT | |
227 #endif | |
228 | |
229 #if defined (INT_128_BIT) | |
230 #define EFFICIENT_INT_128_BIT INT_128_BIT | |
231 #define EFFICIENT_UINT_128_BIT UINT_128_BIT | |
232 #endif | |
233 | |
2367 | 234 #ifdef HAVE_INTTYPES_H |
235 #include <inttypes.h> | |
236 #elif defined (HAVE_INTPTR_T_IN_SYS_TYPES_H) | |
237 /* included elsewhere */ | |
238 #elif SIZEOF_VOID_P == SIZEOF_INT | |
239 typedef int intptr_t; | |
240 typedef unsigned int uintptr_t; | |
241 #elif SIZEOF_VOID_P == SIZEOF_LONG | |
242 typedef long intptr_t; | |
243 typedef unsigned long uintptr_t; | |
244 #elif defined (SIZEOF_LONG_LONG) && SIZEOF_VOID_P == SIZEOF_LONG_LONG | |
245 typedef long long intptr_t; | |
246 typedef unsigned long long uintptr_t; | |
247 #else | |
248 /* Just pray. May break, may not. */ | |
249 typedef long intptr_t; | |
250 typedef unsigned long uintptr_t; | |
251 #endif | |
252 | |
253 /* ---------------------- definition of EMACS_INT --------------------- */ | |
254 | |
255 /* EMACS_INT is the underlying integral type into which a Lisp_Object must fit. | |
256 In particular, it must be large enough to contain a pointer. | |
257 config.h can override this, e.g. to use `long long' for bigger lisp ints. | |
258 | |
259 #### In point of fact, it would NOT be a good idea for config.h to mess | |
260 with EMACS_INT. A lot of code makes the basic assumption that EMACS_INT | |
261 is the size of a pointer. */ | |
262 | |
263 #ifndef SIZEOF_EMACS_INT | |
264 # define SIZEOF_EMACS_INT SIZEOF_VOID_P | |
265 #endif | |
266 | |
267 #ifndef EMACS_INT | |
268 # if SIZEOF_EMACS_INT == SIZEOF_LONG | |
269 # define EMACS_INT long | |
270 # elif SIZEOF_EMACS_INT == SIZEOF_INT | |
271 # define EMACS_INT int | |
272 # elif SIZEOF_EMACS_INT == SIZEOF_LONG_LONG | |
273 # define EMACS_INT long long | |
274 # else | |
275 # error Unable to determine suitable type for EMACS_INT | |
276 # endif | |
277 #endif | |
278 | |
279 #ifndef EMACS_UINT | |
280 # define EMACS_UINT unsigned EMACS_INT | |
281 #endif | |
282 | |
283 #define BITS_PER_EMACS_INT (SIZEOF_EMACS_INT * BITS_PER_CHAR) | |
284 | |
285 /* -------------------------- basic byte typedefs --------------------- */ | |
286 | |
287 /* The definitions we put here and in the next section use typedefs to | |
288 attribute specific meaning to types that by themselves are pretty | |
289 general. | |
290 | |
291 REMEMBER! These typedefs are purely for documentation purposes; from | |
647 | 292 the C code's perspective, they are exactly equivalent to `char *', |
293 `unsigned char *', etc., so you can freely use them with library | |
2367 | 294 functions declared as such. |
295 | |
296 (See also "Byte/Character Types" in text.c) | |
297 | |
298 The basic semantics for `char': | |
299 | |
300 a) [Ibyte] pointer to internally-formatted text | |
301 b) [Extbyte] pointer to text in some external format, which can be | |
302 defined as all formats other than the internal one | |
303 c) [Ascbyte] pure ASCII text | |
304 d) [Binbyte] binary data that is not meant to be interpreted as text | |
305 e) [Rawbyte] general data in memory, where we don't care about whether | |
306 it's text or binary | |
307 f) [Boolbyte] a zero or a one | |
308 g) [Bitbyte] a byte used for bit fields | |
309 h) [Chbyte] null-semantics `char *'; used when casting an argument to | |
310 an external API where the the other types may not be | |
311 appropriate | |
312 | |
313 | |
314 Prefixing codes: | |
315 | |
316 C = plain char, when the base type is unsigned | |
317 U = unsigned | |
318 S = signed | |
319 | |
320 Ideally, XEmacs code should NEVER directly use `char' or any type | |
321 derived from it. This is for Mule-cleanliness. If you find yourself | |
322 wanting or needing to use `char' and one of the above six semantics does | |
323 not apply, add a new type of semantics; don't use `char' directly. | |
324 | |
325 See text.c under "Byte Types", and following sections. | |
326 */ | |
647 | 327 |
328 /* The data representing the text in a buffer is logically a set | |
867 | 329 of Ibytes, declared as follows. */ |
330 | |
331 typedef unsigned char Ibyte; | |
647 | 332 |
333 /* The following should be used when you are working with internal data | |
334 but for whatever reason need to have it declared a "char *". Examples | |
335 are function arguments whose values are most commonly literal strings, | |
336 or where you have to apply a stdlib string function to internal data. | |
337 | |
2367 | 338 In general, you should avoid this where possible and use Ascbyte if the |
339 text is just ASCII (e.g. string literals) or otherwise Ibyte, for | |
340 consistency. For example, the new Mule workspace contains Ibyte | |
341 versions of the stdlib string functions. */ | |
867 | 342 |
343 typedef char CIbyte; | |
647 | 344 |
345 /* The data representing a string in "external" format (binary or any | |
346 external encoding) is logically a set of Extbytes, declared as | |
347 follows. Extbyte is guaranteed to be just a char, so for example | |
348 strlen (Extbyte *) is OK. Extbyte is only a documentation device | |
349 for referring to external text. */ | |
350 | |
351 typedef char Extbyte; | |
771 | 352 typedef unsigned char UExtbyte; |
647 | 353 |
2367 | 354 #define EXTTEXT_ZTERM_SIZE (sizeof (Extbyte)) |
647 | 355 |
356 /* A byte in a string in entirely US-ASCII format: (Nothing outside | |
357 the range 00 - 7F) */ | |
358 | |
2367 | 359 typedef char Ascbyte; |
360 typedef unsigned char UAscbyte; | |
361 | |
362 /* A generic memory pointer, no text or binary semantics assumed. | |
363 In general, there should be no manipulation of the memory pointed to | |
364 by these pointers other than just copying it around. */ | |
365 | |
366 typedef unsigned char Rawbyte; | |
367 typedef char CRawbyte; | |
368 | |
369 /* A byte in a string in binary (not meant as text) format: */ | |
370 | |
371 typedef unsigned char Binbyte; | |
372 typedef char CBinbyte; | |
373 typedef signed char SBinbyte; | |
374 | |
375 /* A byte used to represent a boolean value: 0 or 1. | |
376 Normally use plain Boolint, and only use Boolbyte to save space. */ | |
377 | |
378 typedef char Boolbyte; | |
379 | |
380 /* A byte composed of bitfields. Hardly ever used. */ | |
381 | |
382 typedef unsigned char Bitbyte; | |
383 | |
384 /* A no-semantics `char'. Used (pretty-much) ONLY for casting arguments to | |
385 functions accepting a `char *', `unsigned char *', etc. where the other | |
386 types don't exactly apply and what you are logically concerned with is | |
387 the type of the function's argument and not its semantics. | |
388 | |
389 DO NOT DO NOT DO NOT DO NOT use this as a sloppy replacement for one of | |
390 the other types. If you're not using this as part of casting an | |
391 argument to a function call, and you're not Ben Wing, you're using it | |
392 wrong. Go find another one of the types. */ | |
393 | |
394 typedef char Chbyte; | |
395 typedef unsigned char UChbyte; | |
396 typedef signed char SChbyte; | |
397 | |
398 /* ------------------------ other text-related typedefs ------------------- */ | |
647 | 399 |
826 | 400 /* To the user, a buffer is made up of characters. In the non-Mule world, |
867 | 401 characters and Ibytes are equivalent, restricted to the range 0 - 255. |
826 | 402 In the Mule world, many more characters are possible (19 bits worth, |
867 | 403 more or less), and a character requires (typically) 1 to 4 Ibytes for |
826 | 404 its representation in a buffer or string. Note that the representation |
405 of a character by itself, in a variable, is very different from its | |
406 representation in a string of text (in a buffer or Lisp string). | |
407 | |
408 Under Mule, text can be represented in more than one way. The "default" | |
409 format is variable-width (1 to 4 bytes) and compatible with ASCII -- | |
410 ASCII chars are stored in one byte, as themselves, and all other chars | |
411 use only high bytes. The default format is currently the only format | |
412 used for text stored anywhere but in a buffer. In a buffer, other | |
413 formats -- fixed-width formats (1, 2, or 4 bytes) -- are possible, for | |
414 speed. | |
415 | |
416 See text.c/text.h for a detailed discussion of all of this. */ | |
417 | |
418 /* A character, as represented on its own. */ | |
647 | 419 |
867 | 420 typedef int Ichar; |
647 | 421 |
826 | 422 /* The "raw value" of a character as stored in the buffer. In the default |
423 format, this is just the same as the character. In fixed-width formats, | |
424 this is the actual value in the buffer, which will be limited to the | |
425 range as established by the format. This is used when searching for a | |
426 character in a buffer -- it's faster to convert the character to the raw | |
427 value and look for that, than repeatedly convert each raw value in the | |
428 buffer into a character. */ | |
429 | |
867 | 430 typedef int Raw_Ichar; |
826 | 431 |
2367 | 432 /* Internal text as a series of textual units (8-bit bytes in the old |
433 "Mule" encoding -- still the standard internal encoding -- and in UTF-8, | |
434 but 16-bit bytes in UTF-16 and 32-bit bytes in UTF-32). See text.c. */ | |
435 | |
436 #ifdef UTF16_IBYTE_FORMAT | |
437 #define NON_ASCII_INTERNAL_FORMAT | |
438 typedef unsigned short Itext; | |
439 #else | |
440 typedef Ibyte Itext; | |
441 #endif | |
442 typedef EMACS_INT Textcount; | |
443 | |
444 #define ITEXT_SIZE (sizeof (Itext)) | |
445 /* Use this to emphasize that we are adding space for the zero-terminator */ | |
446 #define ITEXT_ZTERM_SIZE ITEXT_SIZE | |
447 | |
448 /* Wexttext is wchar_t on WIN32_NATIVE (and perhaps other systems that | |
449 support wchar_t's in library functions), and Extbyte otherwise. This is | |
450 used whenever we have to do any sort of manipulation of | |
451 externally-encoded strings -- generally a very bad idea, and unsafe, but | |
452 in some cases we have no choice (especially at startup, and esp. prior | |
453 to pdump, where we haven't loaded the Unicode tables necessary for | |
454 conversion under Windows). On platforms where the external encoding may | |
455 be Unicode (i.e. Windows), we always do our manipulations in Unicode, | |
456 converting to and from multibyte if necessary -- otherwise we'd have to | |
457 conditionalize on Unicode vs. multibyte all over the place, which is | |
458 just a nightmare. */ | |
459 #ifdef WIN32_NATIVE | |
460 #define WEXTTEXT_IS_WIDE | |
461 typedef wchar_t Wexttext; | |
462 #else | |
463 typedef Extbyte Wexttext; | |
464 #endif | |
826 | 465 |
466 #if !defined (__cplusplus) || !defined (CPLUSPLUS_INTEGRAL_CLASSES_NOT_YET) | |
467 | |
468 /* Counts of bytes or chars */ | |
469 | |
470 typedef EMACS_INT Bytecount; | |
471 typedef EMACS_INT Charcount; | |
472 | |
647 | 473 /* Different ways of referring to a position in a buffer. We use |
474 the typedefs in preference to 'EMACS_INT' to make it clearer what | |
826 | 475 sort of position is being used. See text.c for a description |
476 of the different positions. | |
477 | |
478 Note that buffer positions are 1-based, and there's a gap in the middle | |
479 of a buffer; that's why we have separate typedefs. For Lisp strings and | |
480 other strings of text, we just use Bytecount and Charcount. */ | |
800 | 481 |
665 | 482 typedef EMACS_INT Charbpos; |
483 typedef EMACS_INT Bytebpos; | |
484 typedef EMACS_INT Membpos; | |
647 | 485 |
826 | 486 /* Different ways of referring to a position that can be either in a buffer |
487 or string; used when passing around an object that can be either a | |
488 buffer or string, and an associated position. Conceptually, they | |
489 resolve as follows: | |
490 | |
491 Typedef Buffer String | |
492 ------------------------------------------------------ | |
493 Charxpos Charbpos Charcount | |
494 Bytexpos Bytebpos Bytecount | |
495 Memxpos Membpos Bytecount | |
496 | |
497 */ | |
498 | |
814 | 499 typedef EMACS_INT Charxpos; |
500 typedef EMACS_INT Bytexpos; | |
501 typedef EMACS_INT Memxpos; | |
502 | |
503 #else /* __cplusplus */ | |
504 | |
505 /* Implement strong type-checking of the above integral types by declaring | |
506 them to be classes and using operator overloading. Unfortunately this | |
507 is a huge pain in the ass because C++ doesn't strongly distinguish | |
508 "bool" and "size_t" from int. The problem is especially bad with "bool" | |
2956 | 509 -- if you want to be able to say `if (len--)' where len is e.g. a |
814 | 510 Bytecount, you need to declare a conversion operator to bool(); and |
511 since bool is just an alias for int, you suddenly get tons and tons of | |
512 ambiguities, which need to be resolved by lots of laborious declarations | |
513 for every single possible type combination. Hence the multitude of | |
514 declarations in DECLARE_INTCLASS_ARITH_COMPARE(). The bool/int | |
515 equivalence also means that we have to forcibly block the combinations | |
516 we don't want by creating overloaded versions of them and declaring them | |
517 private. */ | |
518 | |
519 class Bytecount; | |
520 class Bytebpos; | |
521 class Bytexpos; | |
522 class Charcount; | |
523 class Charbpos; | |
524 class Charxpos; | |
525 class Membpos; | |
526 class Memxpos; | |
527 | |
528 /* Declare the arithmetic and comparison operations for an integral class, | |
529 i.e. one of the above classes. If this is a "position" class, where the | |
530 difference between two positions is a different class (a "count" class), | |
531 then use POSCL for the position class and COUNTCL for the count class. | |
532 If this is a simple class, where all operations yield the same class, | |
533 substitute the same class for POSCL and COUNTCL. */ | |
534 | |
535 #define DECLARE_INTCLASS_ARITH_COMPARE(poscl, countcl) \ | |
536 poscl operator += (const countcl& l) { data += l.data; return *this; } \ | |
537 poscl operator -= (const countcl& l) { data -= l.data; return *this; } \ | |
538 poscl operator + (const countcl& l) const { return poscl (data + l.data); } \ | |
539 poscl operator - (const countcl& l) const { return poscl (data - l.data); } \ | |
540 poscl operator += (const int& l) { data += l; return *this; } \ | |
541 poscl operator -= (const int& l) { data -= l; return *this; } \ | |
542 poscl operator + (const int& l) const { return poscl (data + l); } \ | |
543 poscl operator - (const int& l) const { return poscl (data - l); } \ | |
544 poscl operator += (const unsigned int& l) { data += l; return *this; } \ | |
545 poscl operator -= (const unsigned int& l) { data -= l; return *this; } \ | |
546 poscl operator + (const unsigned int& l) const \ | |
547 { return poscl (data + l); } \ | |
548 poscl operator - (const unsigned int& l) const \ | |
549 { return poscl (data - l); } \ | |
550 poscl operator += (const long& l) { data += l; return *this; } \ | |
551 poscl operator -= (const long& l) { data -= l; return *this; } \ | |
552 poscl operator + (const long& l) const { return poscl (data + l); } \ | |
553 poscl operator - (const long& l) const { return poscl (data - l); } \ | |
554 poscl operator += (const unsigned long& l) { data += l; return *this; } \ | |
555 poscl operator -= (const unsigned long& l) { data -= l; return *this; } \ | |
556 poscl operator + (const unsigned long& l) const \ | |
557 { return poscl (data + l); } \ | |
558 poscl operator - (const unsigned long& l) const \ | |
559 { return poscl (data - l); } \ | |
560 poscl operator += (const short& l) { data += l; return *this; } \ | |
561 poscl operator -= (const short& l) { data -= l; return *this; } \ | |
562 poscl operator + (const short& l) const { return poscl (data + l); } \ | |
563 poscl operator - (const short& l) const { return poscl (data - l); } \ | |
564 poscl operator += (const unsigned short& l) { data += l; return *this; } \ | |
565 poscl operator -= (const unsigned short& l) { data -= l; return *this; } \ | |
566 poscl operator + (const unsigned short& l) const \ | |
567 { return poscl (data + l); } \ | |
568 poscl operator - (const unsigned short& l) const \ | |
569 { return poscl (data - l); } \ | |
570 \ | |
571 poscl operator *= (const countcl& l) { data *= l.data; return *this; } \ | |
572 poscl operator /= (const countcl& l) { data /= l.data; return *this; } \ | |
573 poscl operator * (const countcl& l) const { return poscl (data * l.data); } \ | |
574 poscl operator / (const countcl& l) const { return poscl (data / l.data); } \ | |
575 poscl operator *= (const int& l) { data *= l; return *this; } \ | |
576 poscl operator /= (const int& l) { data /= l; return *this; } \ | |
577 poscl operator * (const int& l) const { return poscl (data * l); } \ | |
578 poscl operator / (const int& l) const { return poscl (data / l); } \ | |
579 poscl operator *= (const unsigned int& l) { data *= l; return *this; } \ | |
580 poscl operator /= (const unsigned int& l) { data /= l; return *this; } \ | |
581 poscl operator * (const unsigned int& l) const { return poscl (data * l); } \ | |
582 poscl operator / (const unsigned int& l) const { return poscl (data / l); } \ | |
583 poscl operator *= (const long& l) { data *= l; return *this; } \ | |
584 poscl operator /= (const long& l) { data /= l; return *this; } \ | |
585 poscl operator * (const long& l) const { return poscl (data * l); } \ | |
586 poscl operator / (const long& l) const { return poscl (data / l); } \ | |
587 poscl operator *= (const unsigned long& l) { data *= l; return *this; } \ | |
588 poscl operator /= (const unsigned long& l) { data /= l; return *this; } \ | |
589 poscl operator * (const unsigned long& l) const \ | |
590 { return poscl (data * l); } \ | |
591 poscl operator / (const unsigned long& l) const \ | |
592 { return poscl (data / l); } \ | |
593 poscl operator *= (const short& l) { data *= l; return *this; } \ | |
594 poscl operator /= (const short& l) { data /= l; return *this; } \ | |
595 poscl operator * (const short& l) const { return poscl (data * l); } \ | |
596 poscl operator / (const short& l) const { return poscl (data / l); } \ | |
597 poscl operator *= (const unsigned short& l) { data *= l; return *this; } \ | |
598 poscl operator /= (const unsigned short& l) { data /= l; return *this; } \ | |
599 poscl operator * (const unsigned short& l) const \ | |
600 { return poscl (data * l); } \ | |
601 poscl operator / (const unsigned short& l) const \ | |
602 { return poscl (data / l); } \ | |
603 \ | |
604 poscl operator &= (const countcl& l) { data &= l.data; return *this; } \ | |
605 poscl operator |= (const countcl& l) { data |= l.data; return *this; } \ | |
606 poscl operator & (const countcl& l) const { return poscl (data & l.data); } \ | |
607 poscl operator | (const countcl& l) const { return poscl (data | l.data); } \ | |
608 poscl operator &= (const int& l) { data &= l; return *this; } \ | |
609 poscl operator |= (const int& l) { data |= l; return *this; } \ | |
610 poscl operator & (const int& l) const { return poscl (data & l); } \ | |
611 poscl operator | (const int& l) const { return poscl (data | l); } \ | |
612 poscl operator &= (const unsigned int& l) { data &= l; return *this; } \ | |
613 poscl operator |= (const unsigned int& l) { data |= l; return *this; } \ | |
614 poscl operator & (const unsigned int& l) const { return poscl (data & l); } \ | |
615 poscl operator | (const unsigned int& l) const { return poscl (data | l); } \ | |
616 poscl operator &= (const long& l) { data &= l; return *this; } \ | |
617 poscl operator |= (const long& l) { data |= l; return *this; } \ | |
618 poscl operator & (const long& l) const { return poscl (data & l); } \ | |
619 poscl operator | (const long& l) const { return poscl (data | l); } \ | |
620 poscl operator &= (const unsigned long& l) { data &= l; return *this; } \ | |
621 poscl operator |= (const unsigned long& l) { data |= l; return *this; } \ | |
622 poscl operator & (const unsigned long& l) const \ | |
623 { return poscl (data & l); } \ | |
624 poscl operator | (const unsigned long& l) const \ | |
625 { return poscl (data | l); } \ | |
626 poscl operator &= (const short& l) { data &= l; return *this; } \ | |
627 poscl operator |= (const short& l) { data |= l; return *this; } \ | |
628 poscl operator & (const short& l) const { return poscl (data & l); } \ | |
629 poscl operator | (const short& l) const { return poscl (data | l); } \ | |
630 poscl operator &= (const unsigned short& l) { data &= l; return *this; } \ | |
631 poscl operator |= (const unsigned short& l) { data |= l; return *this; } \ | |
632 poscl operator & (const unsigned short& l) const \ | |
633 { return poscl (data & l); } \ | |
634 poscl operator | (const unsigned short& l) const \ | |
635 { return poscl (data | l); } \ | |
636 \ | |
637 poscl operator - () { return poscl (-data); } \ | |
638 poscl operator-- () { data--; return *this; } \ | |
639 poscl operator-- (int) { data--; return poscl (data + 1); } \ | |
640 poscl operator++ () { data++; return *this; } \ | |
641 poscl operator++ (int) { data++; return poscl (data - 1); } \ | |
642 \ | |
643 bool operator < (const poscl& l) const { return data < l.data; } \ | |
644 bool operator <= (const poscl& l) const { return data <= l.data; } \ | |
645 bool operator > (const poscl& l) const { return data > l.data; } \ | |
646 bool operator >= (const poscl& l) const { return data >= l.data; } \ | |
647 bool operator == (const poscl& l) const { return data == l.data; } \ | |
648 bool operator != (const poscl& l) const { return data != l.data; } \ | |
649 bool operator < (const int& l) const { return data < (EMACS_INT) l; } \ | |
650 bool operator <= (const int& l) const { return data <= (EMACS_INT) l; } \ | |
651 bool operator > (const int& l) const { return data > (EMACS_INT) l; } \ | |
652 bool operator >= (const int& l) const { return data >= (EMACS_INT) l; } \ | |
653 bool operator == (const int& l) const { return data == (EMACS_INT) l; } \ | |
654 bool operator != (const int& l) const { return data != (EMACS_INT) l; } \ | |
655 bool operator < (const unsigned int& l) const \ | |
656 { return data < (EMACS_INT) l; } \ | |
657 bool operator <= (const unsigned int& l) const \ | |
658 { return data <= (EMACS_INT) l; } \ | |
659 bool operator > (const unsigned int& l) const \ | |
660 { return data > (EMACS_INT) l; } \ | |
661 bool operator >= (const unsigned int& l) const \ | |
662 { return data >= (EMACS_INT) l; } \ | |
663 bool operator == (const unsigned int& l) const \ | |
664 { return data == (EMACS_INT) l; } \ | |
665 bool operator != (const unsigned int& l) const \ | |
666 { return data != (EMACS_INT) l; } \ | |
667 bool operator < (const long& l) const { return data < (EMACS_INT) l; } \ | |
668 bool operator <= (const long& l) const { return data <= (EMACS_INT) l; } \ | |
669 bool operator > (const long& l) const { return data > (EMACS_INT) l; } \ | |
670 bool operator >= (const long& l) const { return data >= (EMACS_INT) l; } \ | |
671 bool operator == (const long& l) const { return data == (EMACS_INT) l; } \ | |
672 bool operator != (const long& l) const { return data != (EMACS_INT) l; } \ | |
673 bool operator < (const unsigned long& l) const \ | |
674 { return data < (EMACS_INT) l; } \ | |
675 bool operator <= (const unsigned long& l) const \ | |
676 { return data <= (EMACS_INT) l; } \ | |
677 bool operator > (const unsigned long& l) const \ | |
678 { return data > (EMACS_INT) l; } \ | |
679 bool operator >= (const unsigned long& l) const \ | |
680 { return data >= (EMACS_INT) l; } \ | |
681 bool operator == (const unsigned long& l) const \ | |
682 { return data == (EMACS_INT) l; } \ | |
683 bool operator != (const unsigned long& l) const \ | |
684 { return data != (EMACS_INT) l; } \ | |
685 bool operator < (const short& l) const { return data < (EMACS_INT) l; } \ | |
686 bool operator <= (const short& l) const { return data <= (EMACS_INT) l; } \ | |
687 bool operator > (const short& l) const { return data > (EMACS_INT) l; } \ | |
688 bool operator >= (const short& l) const { return data >= (EMACS_INT) l; } \ | |
689 bool operator == (const short& l) const { return data == (EMACS_INT) l; } \ | |
690 bool operator != (const short& l) const { return data != (EMACS_INT) l; } \ | |
691 bool operator < (const unsigned short& l) const \ | |
692 { return data < (EMACS_INT) l; } \ | |
693 bool operator <= (const unsigned short& l) const \ | |
694 { return data <= (EMACS_INT) l; } \ | |
695 bool operator > (const unsigned short& l) const \ | |
696 { return data > (EMACS_INT) l; } \ | |
697 bool operator >= (const unsigned short& l) const \ | |
698 { return data >= (EMACS_INT) l; } \ | |
699 bool operator == (const unsigned short& l) const \ | |
700 { return data == (EMACS_INT) l; } \ | |
701 bool operator != (const unsigned short& l) const \ | |
702 { return data != (EMACS_INT) l; } \ | |
703 bool operator ! () const { return !data; } | |
704 | |
705 /* Declare the "bad" or disallowed arithmetic and comparion operations | |
706 between class GOOD and class BAD. Meant to go inside the private | |
707 section of class GOOD. */ | |
708 | |
709 #define DECLARE_BAD_INTCLASS_ARITH_COMPARE(good, bad) \ | |
710 good operator += (const bad& l) { return badret; } \ | |
711 good operator -= (const bad& l) { return badret; } \ | |
712 good operator *= (const bad& l) { return badret; } \ | |
713 good operator /= (const bad& l) { return badret; } \ | |
714 good operator + (const bad& l) { return badret; } \ | |
715 good operator - (const bad& l) { return badret; } \ | |
716 good operator * (const bad& l) { return badret; } \ | |
717 good operator / (const bad& l) { return badret; } \ | |
718 \ | |
719 bool operator < (const bad& l) { return 0; } \ | |
720 bool operator <= (const bad& l) { return 0; } \ | |
721 bool operator > (const bad& l) { return 0; } \ | |
722 bool operator >= (const bad& l) { return 0; } \ | |
723 bool operator == (const bad& l) { return 0; } \ | |
724 bool operator != (const bad& l) { return 0; } | |
725 | |
726 /* Declare the "bad" or disallowed arithmetic operations between class GOOD | |
727 and another of the same class, for a position class. Meant to go inside | |
728 the private section of class GOOD. */ | |
729 | |
730 #define DECLARE_BAD_POS_CLASS_ARITH(good) \ | |
731 good operator += (const good& l) { return badret; } \ | |
732 good operator -= (const good& l) { return badret; } \ | |
733 good operator *= (const good& l) { return badret; } \ | |
734 good operator /= (const good& l) { return badret; } \ | |
735 good operator + (const good& l) { return badret; } \ | |
736 good operator * (const good& l) { return badret; } \ | |
737 good operator / (const good& l) { return badret; } | |
738 | |
739 /* Basic declaration at the top of all integral classes. Don't call | |
740 directly, use one of the more specific versions below. */ | |
741 | |
742 #define DECLARE_INTCLASS(cl) \ | |
743 public: \ | |
744 EMACS_INT data; \ | |
745 cl () { data = 0xCDCDCDCD; } \ | |
746 cl (int i) { data = i; } \ | |
747 cl (unsigned int i) { data = i; } \ | |
748 cl (long i) { data = i; } \ | |
749 cl (unsigned long i) { data = i; } \ | |
750 cl (short i) { data = i; } \ | |
751 cl (unsigned short i) { data = i; } \ | |
752 operator EMACS_INT () const { return data; } | |
753 | |
754 /* Basic declaration at the top of all count classes. */ | |
755 | |
756 #define DECLARE_COUNT_CLASS(cl) \ | |
757 DECLARE_INTCLASS (cl) \ | |
758 DECLARE_INTCLASS_ARITH_COMPARE (cl, cl) \ | |
759 private: \ | |
760 static cl badret; | |
761 | |
762 /* Basic declaration at the bottom of the prelude of all position classes. | |
763 Don't call directly. */ | |
764 | |
765 #define DECLARE_POS_CLASS_SECOND_HALF(cl, countcl) \ | |
766 DECLARE_INTCLASS_ARITH_COMPARE (cl, countcl) \ | |
767 countcl operator - (const cl& l) const { return countcl (data - l.data); } \ | |
768 private: \ | |
769 static cl badret; \ | |
770 DECLARE_BAD_POS_INTCLASS_ARITH (cl) | |
771 | |
772 /* Basic declaration at the top of all buffer position classes. */ | |
773 | |
774 #define DECLARE_BPOS_CLASS(cl, countcl) \ | |
775 DECLARE_INTCLASS (cl) \ | |
776 DECLARE_POS_CLASS_SECOND_HALF (cl, countcl) | |
777 | |
778 /* Basic declaration at the top of all X-position classes (that can refer | |
779 to buffers or strings). CL1 and CL2 are the equivalent more specific | |
1318 | 780 classes referring only to buffers or strings, respectively. */ |
814 | 781 |
782 #define DECLARE_XPOS_CLASS(cl, countcl, cl1, cl2) \ | |
783 DECLARE_INTCLASS (cl) \ | |
784 cl (const cl1& x) { data = x.data; } \ | |
785 cl (const cl2& x) { data = x.data; } \ | |
786 operator cl1 () const { return cl1 (data); } \ | |
787 operator cl2 () const { return cl2 (data); } \ | |
788 DECLARE_POS_CLASS_SECOND_HALF (cl, countcl) | |
789 | |
790 /* Declare the "bad" or disallowed arithmetic and comparion operations | |
791 between class CHARCL (a character class) and various non-character | |
792 classes. Meant to go inside the private section of class GOOD. */ | |
793 | |
794 #define DECLARE_BAD_CHAR_INTCLASS_ARITH_COMPARE(charcl) \ | |
795 DECLARE_BAD_INTCLASS_ARITH_COMPARE (charcl, Bytecount) \ | |
796 DECLARE_BAD_INTCLASS_ARITH_COMPARE (charcl, Bytebpos) \ | |
797 DECLARE_BAD_INTCLASS_ARITH_COMPARE (charcl, Bytexpos) \ | |
798 DECLARE_BAD_INTCLASS_ARITH_COMPARE (charcl, Membpos) \ | |
799 DECLARE_BAD_INTCLASS_ARITH_COMPARE (charcl, Memxpos) | |
800 | |
801 /* Declare the "bad" or disallowed arithmetic and comparion operations | |
802 between class BYTECL (a byte class) and various non-byte classes. | |
803 Meant to go inside the private section of class GOOD. */ | |
804 | |
805 #define DECLARE_BAD_BYTE_INTCLASS_ARITH_COMPARE(bytecl) \ | |
806 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charcount) \ | |
807 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charbpos) \ | |
808 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charxpos) \ | |
809 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Membpos) \ | |
810 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Memxpos) | |
811 | |
812 /* Declare the "bad" or disallowed arithmetic and comparion operations | |
813 between class BYTECL (a mem class) and various non-mem classes. | |
814 Meant to go inside the private section of class GOOD. */ | |
815 | |
816 #define DECLARE_BAD_MEM_INTCLASS_ARITH_COMPARE(bytecl) \ | |
817 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charcount) \ | |
818 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charbpos) \ | |
819 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charxpos) \ | |
820 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Bytebpos) \ | |
821 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Bytexpos) | |
822 | |
823 class Charcount | |
824 { | |
825 DECLARE_COUNT_CLASS (Charcount) | |
826 DECLARE_BAD_CHAR_INTCLASS_ARITH_COMPARE (Charcount) | |
827 }; | |
828 | |
829 class Charbpos | |
830 { | |
831 DECLARE_BPOS_CLASS (Charbpos, Charcount) | |
832 DECLARE_BAD_CHAR_INTCLASS_ARITH_COMPARE (Charbpos) | |
833 }; | |
834 | |
835 class Charxpos | |
836 { | |
837 DECLARE_XPOS_CLASS (Charxpos, Charcount, Charbpos, Charcount) | |
838 DECLARE_BAD_CHAR_INTCLASS_ARITH_COMPARE (Charxpos) | |
839 }; | |
840 | |
841 class Bytecount | |
842 { | |
843 DECLARE_COUNT_CLASS (Bytecount) | |
844 DECLARE_BAD_BYTE_INTCLASS_ARITH_COMPARE (Bytecount) | |
845 }; | |
846 | |
847 class Bytebpos | |
848 { | |
849 DECLARE_BPOS_CLASS (Bytebpos, Bytecount) | |
850 DECLARE_BAD_BYTE_INTCLASS_ARITH_COMPARE (Bytebpos) | |
851 }; | |
852 | |
853 class Bytexpos | |
854 { | |
855 DECLARE_XPOS_CLASS (Bytexpos, Bytecount, Bytebpos, Bytecount) | |
856 DECLARE_BAD_BYTE_INTCLASS_ARITH_COMPARE (Bytexpos) | |
857 }; | |
858 | |
859 class Membpos | |
860 { | |
861 DECLARE_BPOS_CLASS (Membpos, Bytecount) | |
862 DECLARE_BAD_MEM_INTCLASS_ARITH_COMPARE (Membpos) | |
863 }; | |
864 | |
865 class Memxpos | |
866 { | |
867 DECLARE_XPOS_CLASS (Memxpos, Bytecount, Membpos, Bytecount) | |
868 DECLARE_BAD_MEM_INTCLASS_ARITH_COMPARE (Memxpos) | |
869 }; | |
870 | |
826 | 871 #define DECLARE_POINTER_TYPE_ARITH_COUNT(pointer, countcl) \ |
872 inline pointer operator += (const pointer & x, const countcl& y) \ | |
873 { x += y.data; return x; } \ | |
874 inline pointer operator -= (const pointer & x, const countcl& y) \ | |
875 { x -= y.data; return x; } \ | |
876 inline pointer operator + (const pointer x, const countcl& y) \ | |
877 { return x + y.data; } \ | |
878 inline pointer operator - (const pointer x, const countcl& y) \ | |
814 | 879 { return x - y.data; } |
880 | |
881 #define DECLARE_INTEGRAL_TYPE_ARITH_COUNT(integral, countcl) \ | |
882 inline integral operator += (integral & x, const countcl& y) \ | |
883 { x += y.data; return x; } \ | |
884 inline integral operator -= (integral & x, const countcl& y) \ | |
885 { x -= y.data; return x; } \ | |
886 inline countcl operator + (integral x, const countcl& y) \ | |
887 { return countcl (x + y.data); } \ | |
888 inline countcl operator - (integral x, const countcl& y) \ | |
889 { return countcl (x - y.data); } | |
890 | |
891 #define DECLARE_INTEGRAL_TYPE_COMPARE(integral, cl) \ | |
892 inline bool operator < (integral x, const cl& y) \ | |
893 { return (EMACS_INT) x < y.data; } \ | |
894 inline bool operator <= (integral x, const cl& y) \ | |
895 { return (EMACS_INT) x <= y.data; } \ | |
896 inline bool operator > (integral x, const cl& y) \ | |
897 { return (EMACS_INT) x > y.data; } \ | |
898 inline bool operator >= (integral x, const cl& y) \ | |
899 { return (EMACS_INT) x >= y.data; } \ | |
900 inline bool operator == (integral x, const cl& y) \ | |
901 { return (EMACS_INT) x == y.data; } \ | |
902 inline bool operator != (integral x, const cl& y) \ | |
903 { return (EMACS_INT) x != y.data; } | |
904 | |
905 #if 0 | |
906 /* Unfortunately C++ doesn't let you overload the ?: operator, so we have | |
907 to manually deal with ambiguities using casting */ | |
908 #define DECLARE_INTEGRAL_TYPE_TRISTATE(integral, cl) \ | |
909 inline cl operator ?: (bool b, integral x, const cl& y) \ | |
910 { return b ? cl (x) : y; } \ | |
911 inline cl operator ?: (bool b, const cl& x, integral y) \ | |
912 { return b ? x : cl (y); } | |
913 #endif /* 0 */ | |
914 | |
867 | 915 /* DECLARE_POINTER_TYPE_ARITH_COUNT (const Ibyte *, Bytecount); |
826 | 916 DECLARE_POINTER_TYPE_ARITH_COUNT (const Extbyte *, Bytecount); */ |
867 | 917 DECLARE_POINTER_TYPE_ARITH_COUNT (Ibyte *, Bytecount); |
814 | 918 DECLARE_POINTER_TYPE_ARITH_COUNT (Extbyte *, Bytecount); |
919 | |
920 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (int, Bytecount); | |
921 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (int, Charcount); | |
922 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (unsigned int, Bytecount); | |
923 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (unsigned int, Charcount); | |
924 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (long, Bytecount); | |
925 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (long, Charcount); | |
926 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (unsigned long, Bytecount); | |
927 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (unsigned long, Charcount); | |
928 | |
929 DECLARE_INTEGRAL_TYPE_COMPARE (int, Bytecount); | |
930 DECLARE_INTEGRAL_TYPE_COMPARE (int, Charcount); | |
931 DECLARE_INTEGRAL_TYPE_COMPARE (unsigned int, Bytecount); | |
932 DECLARE_INTEGRAL_TYPE_COMPARE (unsigned int, Charcount); | |
933 DECLARE_INTEGRAL_TYPE_COMPARE (long, Bytecount); | |
934 DECLARE_INTEGRAL_TYPE_COMPARE (long, Charcount); | |
935 DECLARE_INTEGRAL_TYPE_COMPARE (unsigned long, Bytecount); | |
936 DECLARE_INTEGRAL_TYPE_COMPARE (unsigned long, Charcount); | |
937 | |
938 #if 0 /* doesn't work */ | |
867 | 939 inline Bytecount operator - (const Ibyte *x, const Ibyte *y) \ |
814 | 940 { return Bytecount (x - y); } |
941 #endif | |
942 | |
943 #endif /* __cplusplus */ | |
944 | |
665 | 945 /* Counts of elements */ |
946 typedef EMACS_INT Elemcount; | |
947 /* Hash codes */ | |
948 typedef unsigned long Hashcode; | |
2367 | 949 /* Booleans */ |
950 typedef int Boolint; | |
771 | 951 |
793 | 952 /* ------------------------ basic compiler defines ------------------- */ |
428 | 953 |
1743 | 954 #include "compiler.h" |
1632 | 955 |
793 | 956 /* ------------------------ alignment definitions ------------------- */ |
957 | |
454 | 958 /* No type has a greater alignment requirement than max_align_t. |
959 (except perhaps for types we don't use, like long double) */ | |
960 typedef union | |
961 { | |
962 struct { long l; } l; | |
963 struct { void *p; } p; | |
964 struct { void (*f)(void); } f; | |
965 struct { double d; } d; | |
966 } max_align_t; | |
967 | |
771 | 968 /* ALIGNOF returns the required alignment of a type -- i.e. a value such |
969 that data of this type must begin at a memory address which is a | |
970 multiple of that value. For simple types, this is often the same size | |
971 as the type itself. */ | |
972 | |
428 | 973 #ifndef ALIGNOF |
974 # if defined (__GNUC__) && (__GNUC__ >= 2) | |
454 | 975 /* gcc has an extension that gives us exactly what we want. */ |
976 # define ALIGNOF(type) __alignof__ (type) | |
977 # elif ! defined (__cplusplus) | |
978 /* The following is mostly portable, except that: | |
979 - it doesn't work for inside out declarations like void (*) (void). | |
980 (so just call ALIGNOF with a typedef'ed name) | |
981 - it doesn't work with C++. The C++ committee has decided, | |
982 in its infinite wisdom, that: | |
983 "Types must be declared in declarations, not in expressions." */ | |
984 # define ALIGNOF(type) offsetof (struct { char c; type member; }, member) | |
428 | 985 # else |
456 | 986 /* C++ is annoying, but it has a big bag of tricks. |
987 The following doesn't have the "inside out" declaration bug C does. */ | |
458 | 988 template<typename T> struct alignment_trick { char c; T member; }; |
456 | 989 # define ALIGNOF(type) offsetof (alignment_trick<type>, member) |
428 | 990 # endif |
454 | 991 #endif /* ALIGNOF */ |
428 | 992 |
771 | 993 /* ALIGN_SIZE returns the smallest size greater than or equal to LEN which |
994 is a multiple of UNIT. This can be used to assure that data that | |
995 follows a block of the returned size is of correct alignment for a type | |
996 whose alignment (as returned by ALIGNOF) is UNIT (provided that the | |
997 block itself is correctly aligned for this type; memory returned by | |
998 malloc() is guaranteed to be correctly aligned for all types). */ | |
999 | |
428 | 1000 #define ALIGN_SIZE(len, unit) \ |
1001 ((((len) + (unit) - 1) / (unit)) * (unit)) | |
1002 | |
826 | 1003 /* ALIGN_FOR_TYPE returns the smallest size greater than or equal to LEN |
1004 which is aligned for the given type. This can be used to assure that | |
1005 data that follows a block of the returned size is of correct alignment | |
1006 for the type (provided that the block itself is correctly aligned for | |
1007 this type; memory returned by malloc() is guaranteed to be correctly | |
1008 aligned for all types). */ | |
1009 | |
1010 #define ALIGN_FOR_TYPE(len, type) ALIGN_SIZE (len, ALIGNOF (type)) | |
1011 | |
771 | 1012 /* MAX_ALIGN_SIZE returns the smallest size greater than or equal to LEN |
1013 which guarantees that data following a block of such size is correctly | |
1014 aligned for all types (provided that the block itself is so aligned, | |
1015 which is the case for memory returned by malloc()). */ | |
1016 | |
826 | 1017 #define MAX_ALIGN_SIZE(len) ALIGN_FOR_TYPE (len, max_align_t) |
1018 | |
1019 /* ALIGN_PTR returns the smallest pointer >= PTR which is aligned for | |
1020 data of TYPE. */ | |
1021 #define ALIGN_PTR(ptr, type) ((void *) ALIGN_FOR_TYPE ((size_t) (ptr), type)) | |
428 | 1022 |
1743 | 1023 BEGIN_C_DECLS |
1650 | 1024 |
793 | 1025 /* ------------------------ assertions ------------------- */ |
428 | 1026 |
1027 /* We define assert iff USE_ASSERTIONS or DEBUG_XEMACS is defined. | |
1028 Otherwise we define it to be empty. Quantify has shown that the | |
1029 time the assert checks take is measurable so let's not include them | |
771 | 1030 in production binaries. |
1031 | |
788 | 1032 If ASSERTIONS_DONT_ABORT defined, we will continue after assertion |
1033 failures. | |
1034 | |
1035 assert_at_line() is used for asserts inside of inline functions called | |
1036 from error-checking macros. If we're not tricky, we just get the file | |
1037 and line of the inline function, which is not very useful. */ | |
428 | 1038 |
1039 /* Highly dubious kludge */ | |
1040 /* (thanks, Jamie, I feel better now -- ben) */ | |
2367 | 1041 MODULE_API void assert_failed (const Ascbyte *, int, const Ascbyte *); |
2535 | 1042 #define ABORT() (assert_failed (__FILE__, __LINE__, "ABORT()")) |
1043 | |
1044 #ifdef USE_ASSERTIONS | |
428 | 1045 # define assert(x) ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, #x)) |
853 | 1046 # define assert_with_message(x, msg) \ |
1047 ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, msg)) | |
788 | 1048 # define assert_at_line(x, file, line) \ |
1049 ((x) ? (void) 0 : assert_failed (file, line, #x)) | |
2535 | 1050 #elif defined (DEBUG_XEMACS) |
1051 # define assert(x) ((x) ? (void) 0 : (void) ABORT ()) | |
2956 | 1052 # define assert_with_message(x, msg) assert (x) |
2535 | 1053 # define assert_at_line(x, file, line) assert (x) |
428 | 1054 #else |
2956 | 1055 /* This used to be ((void) (0)) but that triggers lots of unused variable |
1056 warnings. It's pointless to force all that code to be rewritten, with | |
1057 added ifdefs. Any reasonable compiler will eliminate an expression with | |
1058 no effects. */ | |
1059 # define assert(x) ((void) (x)) | |
1060 # define assert_with_message(x, msg) assert (x) | |
2535 | 1061 # define assert_at_line(x, file, line) assert (x) |
428 | 1062 #endif |
1063 | |
2367 | 1064 /************************************************************************/ |
1065 /** Memory allocation **/ | |
1066 /************************************************************************/ | |
853 | 1067 |
793 | 1068 /* ------------------------ simple memory allocation ------------------- */ |
1069 | |
2367 | 1070 /* Basic memory allocation and freeing functions */ |
1071 void malloc_warning (const Ascbyte *); | |
1743 | 1072 MODULE_API void *xmalloc (Bytecount size) ATTRIBUTE_MALLOC; |
1073 MODULE_API void *xmalloc_and_zero (Bytecount size) ATTRIBUTE_MALLOC; | |
1074 MODULE_API void *xrealloc (void *, Bytecount size) ATTRIBUTE_MALLOC; | |
2367 | 1075 MODULE_API Chbyte *xstrdup (const Chbyte *) ATTRIBUTE_MALLOC; |
1076 | |
1077 /* Basic free function */ | |
1078 | |
1079 MODULE_API void xfree_1 (void *); | |
1080 #ifdef ERROR_CHECK_MALLOC | |
1081 /* This used to use a temporary variable, which both avoided the multiple | |
1082 evaluation and obviated the need for the TYPE argument. But that triggered | |
1083 complaints under strict aliasing. #### There should be a better way. */ | |
1084 #define xfree(lvalue, type) do \ | |
1085 { \ | |
1086 xfree_1 (lvalue); \ | |
1087 VOIDP_CAST (lvalue) = (void *) 0xDEADBEEF; \ | |
1088 } while (0) | |
1089 #else | |
1090 #define xfree(lvalue,type) xfree_1 (lvalue) | |
1091 #endif /* ERROR_CHECK_MALLOC */ | |
1092 | |
1093 /* ------------------------ stack allocation -------------------------- */ | |
1094 | |
1095 /* Allocating excessively large blocks on the stack can cause crashes. | |
851 | 1096 We provide MALLOC_OR_ALLOCA() below for places where it's likely that |
1097 large amounts will be allocated; it mallocs the block if it's too big. | |
1098 Unfortunately, that requires a call to unbind_to() at the end of the | |
1099 function, and it's not feasible to rewrite all calls to alloca() this | |
1100 way. | |
1101 | |
1102 Instead, we use the portable C alloca() substitute in alloca.c above a | |
1103 certain size. This actually uses malloc(), but checks the current stack | |
1104 pointer to see if data from previous alloca() calls needs to be freed. | |
1105 However, this can lead to large heap sizes -- especially since cleanup | |
1106 can only happen in a parent function, and will never happen if (as will | |
1107 often be the case) it's the same function in the same place in the code | |
1108 that keeps tripping the alloca() limit. | |
1109 | |
1110 So we set up a system to periodically force cleanup. Currently we | |
1111 do cleanup: | |
1112 | |
1113 -- Only when there's C alloca() data, and then | |
1114 -- Every stack alloca() or allocation of Lisp data, every call to | |
1115 next_event_internal() [typically near the top of the stack], | |
1116 or every 10th funcall | |
1117 | |
1118 This should not be a big penalty because | |
1119 | |
1120 (a) If there are few C alloca() chunks, checking them will be fast | |
1121 (b) If not, we've allocated a huge amount of heap space (remember, each | |
1122 chunk represents > 256K of heap), and we really want them gone | |
1123 */ | |
1124 | |
1125 /* We use a larger maximum when the choice is alloca() vs. the C alloca() | |
1126 substitute than when the choice is vs. malloc(), because in the former | |
1127 case, our alternative choice is less palatable because the memory may | |
1128 not be freed for awhile. */ | |
1129 | |
1130 #define MAX_ALLOCA_VS_C_ALLOCA 262144 | |
1131 #define MAX_ALLOCA_VS_MALLOC 65536 | |
1132 | |
1133 #define MAX_FUNCALLS_BETWEEN_ALLOCA_CLEANUP 10 | |
1134 | |
1632 | 1135 extern MODULE_API Bytecount __temp_alloca_size__; |
851 | 1136 extern Bytecount funcall_alloca_count; |
1137 | |
1333 | 1138 #ifdef ERROR_CHECK_MALLOC |
1632 | 1139 extern MODULE_API int regex_malloc_disallowed; |
1333 | 1140 #define REGEX_MALLOC_CHECK() assert (!regex_malloc_disallowed) |
1141 #else | |
1142 #define REGEX_MALLOC_CHECK() ((void) 0) | |
1143 #endif | |
1144 | |
851 | 1145 /* Do stack or heap alloca() depending on size. |
1146 | |
1147 NOTE: The use of a global temporary like this is unsafe if ALLOCA() occurs | |
1148 twice anywhere in the same expression; but that seems highly unlikely. The | |
1149 alternative is to force all callers to declare a local temporary if the | |
1150 expression has side effects -- something easy to forget. */ | |
1151 | |
1152 #define ALLOCA(size) \ | |
1333 | 1153 (REGEX_MALLOC_CHECK (), \ |
1154 __temp_alloca_size__ = (size), \ | |
851 | 1155 __temp_alloca_size__ > MAX_ALLOCA_VS_C_ALLOCA ? \ |
1156 xemacs_c_alloca (__temp_alloca_size__) : \ | |
1157 (need_to_check_c_alloca ? xemacs_c_alloca (0) : 0, \ | |
1158 alloca (__temp_alloca_size__))) | |
1159 | |
1318 | 1160 /* Version of ALLOCA() that is guaranteed to work inside of function calls |
1161 (i.e., we call the C alloca if regular alloca() is broken inside of | |
1162 function calls). */ | |
1163 #ifdef BROKEN_ALLOCA_IN_FUNCTION_CALLS | |
1164 #define ALLOCA_FUNCALL_OK(size) xemacs_c_alloca (size) | |
1165 #else | |
1166 #define ALLOCA_FUNCALL_OK(size) ALLOCA (size) | |
1167 #endif | |
1168 | |
2367 | 1169 MODULE_API void *xemacs_c_alloca (unsigned int size) ATTRIBUTE_MALLOC; |
1170 | |
1171 MODULE_API int record_unwind_protect_freeing (void *ptr); | |
1172 | |
1173 DECLARE_INLINE_HEADER ( | |
1174 void * | |
1175 xmalloc_and_record_unwind (Bytecount size) | |
1176 ) | |
1177 { | |
1178 void *ptr = xmalloc (size); | |
1179 record_unwind_protect_freeing (ptr); | |
1180 return ptr; | |
1181 } | |
1182 | |
851 | 1183 /* WARNING: If you use this, you must unbind_to() at the end of your |
1184 function! */ | |
1185 | |
1186 #define MALLOC_OR_ALLOCA(size) \ | |
1333 | 1187 (REGEX_MALLOC_CHECK (), \ |
1188 __temp_alloca_size__ = (size), \ | |
851 | 1189 __temp_alloca_size__ > MAX_ALLOCA_VS_MALLOC ? \ |
1190 xmalloc_and_record_unwind (__temp_alloca_size__) : \ | |
1191 (need_to_check_c_alloca ? xemacs_c_alloca (0) : 0, \ | |
1192 alloca (__temp_alloca_size__))) | |
793 | 1193 |
2367 | 1194 /* -------------- convenience functions for memory allocation ------------- */ |
1195 | |
1196 #define countof(x) ((int) (sizeof(x)/sizeof((x)[0]))) | |
1197 #define xnew(type) ((type *) xmalloc (sizeof (type))) | |
1198 #define xnew_array(type, len) ((type *) xmalloc ((len) * sizeof (type))) | |
1199 #define xnew_and_zero(type) ((type *) xmalloc_and_zero (sizeof (type))) | |
1200 #define xzero(lvalue) ((void) memset (&(lvalue), '\0', sizeof (lvalue))) | |
1201 #define xnew_array_and_zero(type, len) ((type *) xmalloc_and_zero ((len) * sizeof (type))) | |
1202 | |
1203 #define alloca_new(type) ((type *) ALLOCA (sizeof (type))) | |
1204 #define alloca_array(type, len) ((type *) ALLOCA ((len) * sizeof (type))) | |
1205 | |
1206 #define alloca_itexts(num) alloca_array (Itext, num) | |
1207 #define alloca_ibytes(num) alloca_array (Ibyte, num) | |
1208 #define alloca_extbytes(num) alloca_array (Extbyte, num) | |
1209 #define alloca_rawbytes(num) alloca_array (Rawbyte, num) | |
1210 #define alloca_binbytes(num) alloca_array (Binbyte, num) | |
1211 #define alloca_ascbytes(num) alloca_array (Ascbyte, num) | |
1212 #define xmalloc_itexts(num) xnew_array (Itext, num) | |
1213 #define xnew_ibytes(num) xnew_array (Ibyte, num) | |
1214 #define xnew_extbytes(num) xnew_array (Extbyte, num) | |
1215 #define xnew_rawbytes(num) xnew_array (Rawbyte, num) | |
1216 #define xnew_binbytes(num) xnew_array (Binbyte, num) | |
1217 #define xnew_ascbytes(num) xnew_array (Ascbyte, num) | |
1218 | |
1219 /* Make an alloca'd copy of a Ibyte * */ | |
1220 #define IBYTE_STRING_TO_ALLOCA(p, lval) \ | |
1221 do { \ | |
1222 Ibyte **_bsta_ = (Ibyte **) &(lval); \ | |
1223 const Ibyte *_bsta_2 = (p); \ | |
1224 Bytecount _bsta_3 = qxestrlen (_bsta_2); \ | |
1225 *_bsta_ = alloca_ibytes (1 + _bsta_3); \ | |
1226 memcpy (*_bsta_, _bsta_2, 1 + _bsta_3); \ | |
1227 } while (0) | |
1228 | |
1229 /* ----------------- convenience functions for reallocation --------------- */ | |
1230 | |
1231 #define XREALLOC_ARRAY(ptr, type, len) \ | |
1232 ((void) (ptr = (type *) xrealloc (ptr, (len) * sizeof (type)))) | |
1233 | |
793 | 1234 /* also generally useful if you want to avoid arbitrary size limits |
1235 but don't need a full dynamic array. Assumes that BASEVAR points | |
1236 to a malloced array of TYPE objects (or possibly a NULL pointer, | |
1237 if SIZEVAR is 0), with the total size stored in SIZEVAR. This | |
1238 macro will realloc BASEVAR as necessary so that it can hold at | |
1239 least NEEDED_SIZE objects. The reallocing is done by doubling, | |
1240 which ensures constant amortized time per element. */ | |
1241 #define DO_REALLOC(basevar, sizevar, needed_size, type) do { \ | |
1242 Bytecount do_realloc_needed_size = (needed_size); \ | |
1333 | 1243 REGEX_MALLOC_CHECK (); \ |
793 | 1244 if ((sizevar) < do_realloc_needed_size) \ |
1245 { \ | |
1246 if ((sizevar) < 32) \ | |
1247 (sizevar) = 32; \ | |
1248 while ((sizevar) < do_realloc_needed_size) \ | |
1249 (sizevar) *= 2; \ | |
1250 XREALLOC_ARRAY (basevar, type, (sizevar)); \ | |
1251 } \ | |
1252 } while (0) | |
1253 | |
1254 /* ------------------------ dynamic arrays ------------------- */ | |
1255 | |
1318 | 1256 #ifdef ERROR_CHECK_STRUCTURES |
1257 #define Dynarr_declare(type) \ | |
1258 type *base; \ | |
1259 int locked; \ | |
1260 int elsize; \ | |
1261 int cur; \ | |
1262 int largest; \ | |
1263 int max | |
1264 #else | |
793 | 1265 #define Dynarr_declare(type) \ |
1266 type *base; \ | |
1267 int elsize; \ | |
1268 int cur; \ | |
1269 int largest; \ | |
1270 int max | |
1318 | 1271 #endif /* ERROR_CHECK_STRUCTURES */ |
793 | 1272 |
1273 typedef struct dynarr | |
1274 { | |
1275 Dynarr_declare (void); | |
1276 } Dynarr; | |
1277 | |
1632 | 1278 MODULE_API void *Dynarr_newf (int elsize); |
2367 | 1279 MODULE_API void Dynarr_resize (void *dy, Elemcount size); |
1632 | 1280 MODULE_API void Dynarr_insert_many (void *d, const void *el, int len, int start); |
1281 MODULE_API void Dynarr_delete_many (void *d, int start, int len); | |
1282 MODULE_API void Dynarr_free (void *d); | |
793 | 1283 |
1284 #define Dynarr_new(type) ((type##_dynarr *) Dynarr_newf (sizeof (type))) | |
1285 #define Dynarr_new2(dynarr_type, type) \ | |
1286 ((dynarr_type *) Dynarr_newf (sizeof (type))) | |
1287 #define Dynarr_at(d, pos) ((d)->base[pos]) | |
1288 #define Dynarr_atp(d, pos) (&Dynarr_at (d, pos)) | |
1289 #define Dynarr_begin(d) Dynarr_atp (d, 0) | |
819 | 1290 #define Dynarr_end(d) Dynarr_atp (d, Dynarr_length (d) - 1) |
793 | 1291 #define Dynarr_sizeof(d) ((d)->cur * (d)->elsize) |
1292 | |
800 | 1293 #ifdef ERROR_CHECK_STRUCTURES |
793 | 1294 DECLARE_INLINE_HEADER ( |
1295 Dynarr * | |
2367 | 1296 Dynarr_verify_1 (void *d, const Ascbyte *file, int line) |
793 | 1297 ) |
1298 { | |
1299 Dynarr *dy = (Dynarr *) d; | |
1300 assert_at_line (dy->cur >= 0 && dy->cur <= dy->largest && | |
1301 dy->largest <= dy->max, file, line); | |
1302 return dy; | |
1303 } | |
1304 | |
1318 | 1305 DECLARE_INLINE_HEADER ( |
1306 Dynarr * | |
2367 | 1307 Dynarr_verify_mod_1 (void *d, const Ascbyte *file, int line) |
1318 | 1308 ) |
1309 { | |
1310 Dynarr *dy = (Dynarr *) d; | |
1311 assert_at_line (!dy->locked, file, line); | |
1312 assert_at_line (dy->cur >= 0 && dy->cur <= dy->largest && | |
1313 dy->largest <= dy->max, file, line); | |
1314 return dy; | |
1315 } | |
1316 | |
793 | 1317 #define Dynarr_verify(d) Dynarr_verify_1 (d, __FILE__, __LINE__) |
1318 | 1318 #define Dynarr_verify_mod(d) Dynarr_verify_mod_1 (d, __FILE__, __LINE__) |
1319 #define Dynarr_lock(d) (Dynarr_verify_mod (d)->locked = 1) | |
1320 #define Dynarr_unlock(d) ((d)->locked = 0) | |
793 | 1321 #else |
1322 #define Dynarr_verify(d) (d) | |
1318 | 1323 #define Dynarr_verify_mod(d) (d) |
1324 #define Dynarr_lock(d) | |
1325 #define Dynarr_unlock(d) | |
800 | 1326 #endif /* ERROR_CHECK_STRUCTURES */ |
793 | 1327 |
1328 #define Dynarr_length(d) (Dynarr_verify (d)->cur) | |
1329 #define Dynarr_largest(d) (Dynarr_verify (d)->largest) | |
1318 | 1330 #define Dynarr_reset(d) (Dynarr_verify_mod (d)->cur = 0) |
793 | 1331 #define Dynarr_add_many(d, el, len) Dynarr_insert_many (d, el, len, (d)->cur) |
1332 #define Dynarr_insert_many_at_start(d, el, len) \ | |
1333 Dynarr_insert_many (d, el, len, 0) | |
1334 #define Dynarr_add_literal_string(d, s) Dynarr_add_many (d, s, sizeof (s) - 1) | |
1318 | 1335 #define Dynarr_add_lisp_string(d, s, codesys) \ |
1336 do { \ | |
1337 Lisp_Object dyna_ls_s = (s); \ | |
1338 Lisp_Object dyna_ls_cs = (codesys); \ | |
1339 Extbyte *dyna_ls_eb; \ | |
1340 Bytecount dyna_ls_bc; \ | |
1341 \ | |
1342 LISP_STRING_TO_SIZED_EXTERNAL (dyna_ls_s, dyna_ls_eb, \ | |
1343 dyna_ls_bc, dyna_ls_cs); \ | |
1344 Dynarr_add_many (d, dyna_ls_eb, dyna_ls_bc); \ | |
793 | 1345 } while (0) |
1346 | |
1318 | 1347 #define Dynarr_add(d, el) ( \ |
1348 Dynarr_verify_mod (d)->cur >= (d)->max ? Dynarr_resize ((d), (d)->cur+1) : \ | |
1349 (void) 0, \ | |
1350 ((d)->base)[(d)->cur++] = (el), \ | |
793 | 1351 (d)->cur > (d)->largest ? (d)->largest = (d)->cur : (int) 0) |
1352 | |
1353 /* The following defines will get you into real trouble if you aren't | |
1354 careful. But they can save a lot of execution time when used wisely. */ | |
1318 | 1355 #define Dynarr_increment(d) (Dynarr_verify_mod (d)->cur++) |
1356 #define Dynarr_set_size(d, n) (Dynarr_verify_mod (d)->cur = n) | |
1357 | |
1358 #define Dynarr_pop(d) \ | |
1359 (assert ((d)->cur > 0), Dynarr_verify_mod (d)->cur--, \ | |
1360 Dynarr_at (d, (d)->cur)) | |
1361 #define Dynarr_delete(d, i) Dynarr_delete_many (d, i, 1) | |
793 | 1362 #define Dynarr_delete_by_pointer(d, p) \ |
1363 Dynarr_delete_many (d, (p) - ((d)->base), 1) | |
1364 | |
1318 | 1365 #define Dynarr_delete_object(d, el) \ |
1366 do \ | |
1367 { \ | |
1368 REGISTER int i; \ | |
1369 for (i = Dynarr_length (d) - 1; i >= 0; i--) \ | |
1370 { \ | |
1371 if (el == Dynarr_at (d, i)) \ | |
1372 Dynarr_delete_many (d, i, 1); \ | |
1373 } \ | |
996 | 1374 } while (0) |
1375 | |
793 | 1376 #ifdef MEMORY_USAGE_STATS |
1377 struct overhead_stats; | |
1378 Bytecount Dynarr_memory_usage (void *d, struct overhead_stats *stats); | |
1379 #endif | |
428 | 1380 |
2367 | 1381 void *stack_like_malloc (Bytecount size); |
1382 void stack_like_free (void *val); | |
1383 | |
1384 /************************************************************************/ | |
1385 /** Definitions of more complex types **/ | |
1386 /************************************************************************/ | |
428 | 1387 |
647 | 1388 /* Note that the simplest typedefs are near the top of this file. */ |
1389 | |
428 | 1390 /* We put typedefs here so that prototype declarations don't choke. |
1391 Note that we don't actually declare the structures here (except | |
1392 maybe for simple structures like Dynarrs); that keeps them private | |
1393 to the routines that actually use them. */ | |
1394 | |
771 | 1395 /* ------------------------------- */ |
1396 /* Error_Behavior typedefs */ | |
1397 /* ------------------------------- */ | |
1398 | |
800 | 1399 #ifndef ERROR_CHECK_TYPES |
771 | 1400 |
1401 typedef enum error_behavior | |
428 | 1402 { |
771 | 1403 ERROR_ME, |
1404 ERROR_ME_NOT, | |
793 | 1405 ERROR_ME_WARN, |
1406 ERROR_ME_DEBUG_WARN | |
771 | 1407 } Error_Behavior; |
1408 | |
1409 #define ERRB_EQ(a, b) ((a) == (b)) | |
1410 | |
1411 #else | |
1412 | |
1413 /* By defining it like this, we provide strict type-checking | |
1414 for code that lazily uses ints. */ | |
1415 | |
1416 typedef struct _error_behavior_struct_ | |
428 | 1417 { |
771 | 1418 int really_unlikely_name_to_have_accidentally_in_a_non_errb_structure; |
1419 } Error_Behavior; | |
1420 | |
1421 extern Error_Behavior ERROR_ME; | |
1422 extern Error_Behavior ERROR_ME_NOT; | |
1423 extern Error_Behavior ERROR_ME_WARN; | |
793 | 1424 extern Error_Behavior ERROR_ME_DEBUG_WARN; |
771 | 1425 |
1426 #define ERRB_EQ(a, b) \ | |
1427 ((a).really_unlikely_name_to_have_accidentally_in_a_non_errb_structure == \ | |
1428 (b).really_unlikely_name_to_have_accidentally_in_a_non_errb_structure) | |
1429 | |
1430 #endif | |
1431 | |
1432 /* ------------------------------- */ | |
1433 /* Empty structures and typedefs */ | |
1434 /* ------------------------------- */ | |
428 | 1435 |
1436 struct buffer; /* "buffer.h" */ | |
1437 struct console; /* "console.h" */ | |
1438 struct device; /* "device.h" */ | |
1439 struct extent_fragment; | |
1440 struct extent; | |
1441 struct frame; /* "frame.h" */ | |
1442 struct window; /* "window.h" */ | |
771 | 1443 struct utimbuf; /* "systime.h" or <utime.h> */ |
428 | 1444 struct display_line; |
1445 struct display_glyph_area; | |
1446 struct display_box; | |
1447 struct redisplay_info; | |
1448 struct window_mirror; | |
1449 struct scrollbar_instance; | |
1450 struct font_metric_info; | |
1451 struct face_cachel; | |
1452 struct console_type_entry; | |
1453 | |
771 | 1454 /* This is shared by process.h, events.h and others in future. |
1455 See events.h for description */ | |
1456 typedef unsigned int USID; | |
1457 typedef int face_index; | |
1458 typedef int glyph_index; | |
1726 | 1459 typedef struct lstream Lstream; /* lstream.h */ |
872 | 1460 typedef struct extent *EXTENT; /* extents-impl.h */ |
771 | 1461 typedef struct Lisp_Event Lisp_Event; /* "events.h" */ |
872 | 1462 typedef struct Lisp_Face Lisp_Face; /* "faces-impl.h" */ |
771 | 1463 typedef struct Lisp_Process Lisp_Process; /* "procimpl.h" */ |
872 | 1464 typedef struct Lisp_Color_Instance Lisp_Color_Instance; /* objects-impl.h */ |
1465 typedef struct Lisp_Font_Instance Lisp_Font_Instance; /* objects-impl.h */ | |
1726 | 1466 typedef struct Lisp_Image_Instance Lisp_Image_Instance; /* glyphs.h */ |
771 | 1467 typedef struct Lisp_Gui_Item Lisp_Gui_Item; |
1468 | |
1469 /* ------------------------------- */ | |
1470 /* Dynarr typedefs */ | |
1471 /* ------------------------------- */ | |
1472 | |
1473 /* Dynarr typedefs -- basic types first */ | |
1474 | |
428 | 1475 typedef struct |
1476 { | |
867 | 1477 Dynarr_declare (Ibyte); |
1478 } Ibyte_dynarr; | |
428 | 1479 |
1480 typedef struct | |
1481 { | |
1482 Dynarr_declare (Extbyte); | |
1483 } Extbyte_dynarr; | |
1484 | |
1485 typedef struct | |
1486 { | |
867 | 1487 Dynarr_declare (Ichar); |
1488 } Ichar_dynarr; | |
428 | 1489 |
1490 typedef struct | |
1491 { | |
1492 Dynarr_declare (char); | |
1493 } char_dynarr; | |
1494 | |
771 | 1495 typedef struct |
1496 { | |
1497 Dynarr_declare (char *); | |
1498 } char_ptr_dynarr; | |
1499 | |
428 | 1500 typedef unsigned char unsigned_char; |
1501 typedef struct | |
1502 { | |
1503 Dynarr_declare (unsigned char); | |
1504 } unsigned_char_dynarr; | |
1505 | |
1506 typedef unsigned long unsigned_long; | |
1507 typedef struct | |
1508 { | |
1509 Dynarr_declare (unsigned long); | |
1510 } unsigned_long_dynarr; | |
1511 | |
1512 typedef struct | |
1513 { | |
1514 Dynarr_declare (int); | |
1515 } int_dynarr; | |
1516 | |
1517 typedef struct | |
1518 { | |
665 | 1519 Dynarr_declare (Charbpos); |
1520 } Charbpos_dynarr; | |
428 | 1521 |
1522 typedef struct | |
1523 { | |
665 | 1524 Dynarr_declare (Bytebpos); |
1525 } Bytebpos_dynarr; | |
428 | 1526 |
1527 typedef struct | |
1528 { | |
1529 Dynarr_declare (Charcount); | |
1530 } Charcount_dynarr; | |
1531 | |
1532 typedef struct | |
1533 { | |
1534 Dynarr_declare (Bytecount); | |
1535 } Bytecount_dynarr; | |
1536 | |
771 | 1537 /* Dynarr typedefs -- more complex types */ |
1538 | |
1539 typedef struct | |
1540 { | |
1541 Dynarr_declare (struct face_cachel); | |
1542 } face_cachel_dynarr; | |
1543 | |
1544 typedef struct | |
1545 { | |
1546 Dynarr_declare (struct glyph_cachel); | |
1547 } glyph_cachel_dynarr; | |
1548 | |
428 | 1549 typedef struct |
1550 { | |
1551 Dynarr_declare (struct console_type_entry); | |
1552 } console_type_entry_dynarr; | |
1553 | |
771 | 1554 /* ------------------------------- */ |
1555 /* enum typedefs */ | |
1556 /* ------------------------------- */ | |
1557 | |
428 | 1558 enum run_hooks_condition |
1559 { | |
1560 RUN_HOOKS_TO_COMPLETION, | |
1561 RUN_HOOKS_UNTIL_SUCCESS, | |
1562 RUN_HOOKS_UNTIL_FAILURE | |
1563 }; | |
1564 | |
1565 #ifdef HAVE_TOOLBARS | |
1566 enum toolbar_pos | |
1567 { | |
1568 TOP_TOOLBAR, | |
1569 BOTTOM_TOOLBAR, | |
1570 LEFT_TOOLBAR, | |
1571 RIGHT_TOOLBAR | |
1572 }; | |
1573 #endif | |
1574 | |
1575 enum edge_style | |
1576 { | |
1577 EDGE_ETCHED_IN, | |
1578 EDGE_ETCHED_OUT, | |
1579 EDGE_BEVEL_IN, | |
1580 EDGE_BEVEL_OUT | |
1581 }; | |
1582 | |
1583 enum munge_me_out_the_door | |
1584 { | |
1585 MUNGE_ME_FUNCTION_KEY, | |
1586 MUNGE_ME_KEY_TRANSLATION | |
1587 }; | |
1588 | |
771 | 1589 /* ------------------------------- */ |
1590 /* misc */ | |
1591 /* ------------------------------- */ | |
1592 | |
1593 #ifdef MEMORY_USAGE_STATS | |
1594 | |
1595 /* This structure is used to keep statistics on the amount of memory | |
1596 in use. | |
1597 | |
1598 WAS_REQUESTED stores the actual amount of memory that was requested | |
1599 of the allocation function. The *_OVERHEAD fields store the | |
1600 additional amount of memory that was grabbed by the functions to | |
1601 facilitate allocation, reallocation, etc. MALLOC_OVERHEAD is for | |
1602 memory allocated with malloc(); DYNARR_OVERHEAD is for dynamic | |
1603 arrays; GAP_OVERHEAD is for gap arrays. Note that for (e.g.) | |
1604 dynamic arrays, there is both MALLOC_OVERHEAD and DYNARR_OVERHEAD | |
1605 memory: The dynamic array allocates memory above and beyond what | |
1606 was asked of it, and when it in turns allocates memory using | |
1607 malloc(), malloc() allocates memory beyond what it was asked | |
1608 to allocate. | |
1609 | |
1610 Functions that accept a structure of this sort do not initialize | |
1611 the fields to 0, and add any existing values to whatever was there | |
1612 before; this way, you can get a cumulative effect. */ | |
1613 | |
1614 struct overhead_stats | |
1615 { | |
1616 int was_requested; | |
1617 int malloc_overhead; | |
1618 int dynarr_overhead; | |
1619 int gap_overhead; | |
1620 }; | |
1621 | |
1622 #endif /* MEMORY_USAGE_STATS */ | |
1623 | |
428 | 1624 |
1625 /************************************************************************/ | |
1626 /* Definition of Lisp_Object data type */ | |
1627 /************************************************************************/ | |
1628 | |
1629 /* Define the fundamental Lisp data structures */ | |
1630 | |
1631 /* This is the set of Lisp data types */ | |
1632 | |
1633 enum Lisp_Type | |
1634 { | |
1635 Lisp_Type_Record, | |
1636 Lisp_Type_Int_Even, | |
1637 Lisp_Type_Char, | |
1638 Lisp_Type_Int_Odd | |
1639 }; | |
1640 | |
1641 #define POINTER_TYPE_P(type) ((type) == Lisp_Type_Record) | |
1642 | |
1643 /* Overridden by m/next.h */ | |
1644 #ifndef ASSERT_VALID_POINTER | |
1645 # define ASSERT_VALID_POINTER(pnt) (assert ((((EMACS_UINT) pnt) & 3) == 0)) | |
1646 #endif | |
1647 | |
1648 #define GCMARKBITS 0 | |
1649 #define GCTYPEBITS 2 | |
1650 #define GCBITS 2 | |
1651 #define INT_GCBITS 1 | |
1652 | |
1653 #define INT_VALBITS (BITS_PER_EMACS_INT - INT_GCBITS) | |
1654 #define VALBITS (BITS_PER_EMACS_INT - GCBITS) | |
542 | 1655 #define EMACS_INT_MAX ((EMACS_INT) ((1UL << (INT_VALBITS - 1)) -1UL)) |
442 | 1656 #define EMACS_INT_MIN (-(EMACS_INT_MAX) - 1) |
802 | 1657 /* WARNING: evaluates its arg twice. */ |
1658 #define NUMBER_FITS_IN_AN_EMACS_INT(num) \ | |
1659 ((num) <= EMACS_INT_MAX && (num) >= EMACS_INT_MIN) | |
428 | 1660 |
1661 #ifdef USE_UNION_TYPE | |
1662 # include "lisp-union.h" | |
1663 #else /* !USE_UNION_TYPE */ | |
1664 # include "lisp-disunion.h" | |
1665 #endif /* !USE_UNION_TYPE */ | |
1666 | |
1667 #define XPNTR(x) ((void *) XPNTRVAL(x)) | |
1668 | |
1669 /* WARNING WARNING WARNING. You must ensure on your own that proper | |
1670 GC protection is provided for the elements in this array. */ | |
1671 typedef struct | |
1672 { | |
1673 Dynarr_declare (Lisp_Object); | |
1674 } Lisp_Object_dynarr; | |
1675 | |
452 | 1676 typedef struct |
1677 { | |
1678 Dynarr_declare (Lisp_Object *); | |
1679 } Lisp_Object_ptr_dynarr; | |
1680 | |
428 | 1681 /* Close your eyes now lest you vomit or spontaneously combust ... */ |
1682 | |
1683 #define HACKEQ_UNSAFE(obj1, obj2) \ | |
1684 (EQ (obj1, obj2) || (!POINTER_TYPE_P (XTYPE (obj1)) \ | |
1685 && !POINTER_TYPE_P (XTYPE (obj2)) \ | |
1686 && XCHAR_OR_INT (obj1) == XCHAR_OR_INT (obj2))) | |
1687 | |
1688 #ifdef DEBUG_XEMACS | |
1632 | 1689 extern MODULE_API int debug_issue_ebola_notices; |
1690 MODULE_API int eq_with_ebola_notice (Lisp_Object, Lisp_Object); | |
428 | 1691 #define EQ_WITH_EBOLA_NOTICE(obj1, obj2) \ |
1692 (debug_issue_ebola_notices ? eq_with_ebola_notice (obj1, obj2) \ | |
1693 : EQ (obj1, obj2)) | |
1694 #else | |
1695 #define EQ_WITH_EBOLA_NOTICE(obj1, obj2) EQ (obj1, obj2) | |
1696 #endif | |
1697 | |
1698 /* OK, you can open them again */ | |
1699 | |
1743 | 1700 END_C_DECLS |
1650 | 1701 |
428 | 1702 /************************************************************************/ |
442 | 1703 /** Definitions of basic Lisp objects **/ |
428 | 1704 /************************************************************************/ |
1705 | |
1706 #include "lrecord.h" | |
1707 | |
1743 | 1708 BEGIN_C_DECLS |
1650 | 1709 |
442 | 1710 /*------------------------------ unbound -------------------------------*/ |
428 | 1711 |
1712 /* Qunbound is a special Lisp_Object (actually of type | |
1713 symbol-value-forward), that can never be visible to | |
1714 the Lisp caller and thus can be used in the C code | |
1715 to mean "no such value". */ | |
1716 | |
1717 #define UNBOUNDP(val) EQ (val, Qunbound) | |
1718 | |
771 | 1719 /* Evaluate expr, return it if it's not Qunbound. */ |
1720 #define RETURN_IF_NOT_UNBOUND(expr) do \ | |
1721 { \ | |
1722 Lisp_Object ret_nunb_val = (expr); \ | |
1723 if (!UNBOUNDP (ret_nunb_val)) \ | |
1724 RETURN_SANS_WARNINGS ret_nunb_val; \ | |
1725 } while (0) | |
1726 | |
442 | 1727 /*------------------------------- cons ---------------------------------*/ |
428 | 1728 |
1729 /* In a cons, the markbit of the car is the gc mark bit */ | |
1730 | |
1731 struct Lisp_Cons | |
1732 { | |
1733 struct lrecord_header lheader; | |
853 | 1734 Lisp_Object car_, cdr_; |
428 | 1735 }; |
1736 typedef struct Lisp_Cons Lisp_Cons; | |
1737 | |
1738 #if 0 /* FSFmacs */ | |
1739 /* Like a cons, but records info on where the text lives that it was read from */ | |
1740 /* This is not really in use now */ | |
1741 | |
1742 struct Lisp_Buffer_Cons | |
1743 { | |
1744 Lisp_Object car, cdr; | |
1745 struct buffer *buffer; | |
665 | 1746 int charbpos; |
428 | 1747 }; |
1748 #endif | |
1749 | |
1632 | 1750 DECLARE_MODULE_API_LRECORD (cons, Lisp_Cons); |
428 | 1751 #define XCONS(x) XRECORD (x, cons, Lisp_Cons) |
617 | 1752 #define wrap_cons(p) wrap_record (p, cons) |
428 | 1753 #define CONSP(x) RECORDP (x, cons) |
1754 #define CHECK_CONS(x) CHECK_RECORD (x, cons) | |
1755 #define CONCHECK_CONS(x) CONCHECK_RECORD (x, cons) | |
1756 | |
2720 | 1757 #ifdef MC_ALLOC |
1758 #define CONS_MARKED_P(c) MARKED_P (&((c)->lheader)) | |
1759 #define MARK_CONS(c) MARK (&((c)->lheader)) | |
1760 #else /* not MC_ALLOC */ | |
428 | 1761 #define CONS_MARKED_P(c) MARKED_RECORD_HEADER_P(&((c)->lheader)) |
1762 #define MARK_CONS(c) MARK_RECORD_HEADER (&((c)->lheader)) | |
2720 | 1763 #endif /* not MC_ALLOC */ |
428 | 1764 |
1632 | 1765 extern MODULE_API Lisp_Object Qnil; |
428 | 1766 |
1767 #define NILP(x) EQ (x, Qnil) | |
853 | 1768 #define cons_car(a) ((a)->car_) |
1769 #define cons_cdr(a) ((a)->cdr_) | |
1770 #define XCAR(a) (XCONS (a)->car_) | |
1771 #define XCDR(a) (XCONS (a)->cdr_) | |
1318 | 1772 #define XCADR(a) (XCAR (XCDR (a))) |
1773 #define XCDDR(a) (XCDR (XCDR (a))) | |
1774 #define XCADDR(a) (XCAR (XCDDR (a))) | |
1775 #define XCDDDR(a) (XCDR (XCDDR (a))) | |
1776 #define XCADDDR(a) (XCAR (XCDDDR (a))) | |
1777 #define XCDDDDR(a) (XCDR (XCDDDR (a))) | |
1778 #define XCADDDDR(a) (XCAR (XCDDDDR (a))) | |
1779 #define XCDDDDDR(a) (XCDR (XCDDDDR (a))) | |
1780 #define XCADDDDDR(a) (XCAR (XCDDDDDR (a))) | |
1781 #define XCDDDDDDR(a) (XCDR (XCDDDDDR (a))) | |
1782 #define X1ST(a) XCAR (a) | |
1783 #define X2ND(a) XCADR (a) | |
1784 #define X3RD(a) XCADDR (a) | |
1785 #define X4TH(a) XCADDDR (a) | |
1786 #define X5TH(a) XCADDDDR (a) | |
1787 #define X6TH(a) XCADDDDDR (a) | |
1788 | |
853 | 1789 #define XSETCAR(a, b) (XCONS (a)->car_ = (b)) |
1790 #define XSETCDR(a, b) (XCONS (a)->cdr_ = (b)) | |
428 | 1791 #define LISTP(x) (CONSP(x) || NILP(x)) |
1792 | |
1793 #define CHECK_LIST(x) do { \ | |
1794 if (!LISTP (x)) \ | |
1795 dead_wrong_type_argument (Qlistp, x); \ | |
1796 } while (0) | |
1797 | |
1798 #define CONCHECK_LIST(x) do { \ | |
1799 if (!LISTP (x)) \ | |
1800 x = wrong_type_argument (Qlistp, x); \ | |
1801 } while (0) | |
1802 | |
442 | 1803 /*---------------------- list traversal macros -------------------------*/ |
1804 | |
1805 /* Note: These macros are for traversing through a list in some format, | |
1806 and executing code that you specify on each member of the list. | |
1807 | |
1808 There are two kinds of macros, those requiring surrounding braces, and | |
1809 those not requiring this. Which type of macro will be indicated. | |
1810 The general format for using a brace-requiring macro is | |
1811 | |
1812 { | |
1813 LIST_LOOP_3 (elt, list, tail) | |
1814 execute_code_here; | |
1815 } | |
1816 | |
1817 or | |
1818 | |
1819 { | |
1820 LIST_LOOP_3 (elt, list, tail) | |
1821 { | |
1822 execute_code_here; | |
1823 } | |
1824 } | |
1825 | |
1826 You can put variable declarations between the brace and beginning of | |
1827 macro, but NOTHING ELSE. | |
1828 | |
1829 The brace-requiring macros typically declare themselves any arguments | |
1830 that are initialized and iterated by the macros. If for some reason | |
1831 you need to declare these arguments yourself (e.g. to do something on | |
1832 them before the iteration starts, use the _NO_DECLARE versions of the | |
1833 macros.) | |
1834 */ | |
1835 | |
1836 /* There are two basic kinds of macros: those that handle "internal" lists | |
1837 that are known to be correctly structured (i.e. first element is a cons | |
1838 or nil, and the car of each cons is also a cons or nil, and there are | |
1839 no circularities), and those that handle "external" lists, where the | |
1840 list may have any sort of invalid formation. This is reflected in | |
1841 the names: those with "EXTERNAL_" work with external lists, and those | |
1842 without this prefix work with internal lists. The internal-list | |
1843 macros will hit an assertion failure if the structure is ill-formed; | |
1844 the external-list macros will signal an error in this case, either a | |
1845 malformed-list error or a circular-list error. | |
1846 */ | |
1847 | |
2367 | 1848 /* LIST_LOOP is a simple, old-fashioned macro. It doesn't require brace |
1849 surrounding, and iterates through a list, which may or may not known to | |
1850 be syntactically correct. It accepts two args, TAIL (set progressively | |
1851 to each cons starting with the first), and LIST, the list to iterate | |
1852 over. TAIL needs to be defined by the caller. | |
442 | 1853 |
1854 In each iteration, you can retrieve the current list item using XCAR | |
1855 (tail), or destructively modify the list using XSETCAR (tail, | |
1856 ...). */ | |
1857 | |
428 | 1858 #define LIST_LOOP(tail, list) \ |
1859 for (tail = list; \ | |
1860 !NILP (tail); \ | |
1861 tail = XCDR (tail)) | |
1862 | |
442 | 1863 /* The following macros are the "core" macros for list traversal. |
1864 | |
1865 *** ALL OF THESE MACROS MUST BE DECLARED INSIDE BRACES -- SEE ABOVE. *** | |
1866 | |
1867 LIST_LOOP_2 and EXTERNAL_LIST_LOOP_2 are the standard, most-often used | |
1868 macros. They take two arguments, an element variable ELT and the list | |
1869 LIST. ELT is automatically declared, and set to each element in turn | |
1870 from LIST. | |
1871 | |
1872 LIST_LOOP_3 and EXTERNAL_LIST_LOOP_3 are the same, but they have a third | |
1873 argument TAIL, another automatically-declared variable. At each iteration, | |
1874 this one points to the cons cell for which ELT is the car. | |
1875 | |
1876 EXTERNAL_LIST_LOOP_4 is like EXTERNAL_LIST_LOOP_3 but takes an additional | |
1877 LEN argument, again automatically declared, which counts the number of | |
1878 iterations gone by. It is 0 during the first iteration. | |
1879 | |
1880 EXTERNAL_LIST_LOOP_4_NO_DECLARE is like EXTERNAL_LIST_LOOP_4 but none | |
1881 of the variables are automatically declared, and so you need to declare | |
1882 them yourself. (ELT and TAIL are Lisp_Objects, and LEN is an EMACS_INT.) | |
1883 */ | |
1884 | |
1885 #define LIST_LOOP_2(elt, list) \ | |
1886 LIST_LOOP_3(elt, list, unused_tail_##elt) | |
1887 | |
1888 #define LIST_LOOP_3(elt, list, tail) \ | |
1889 Lisp_Object elt, tail; \ | |
1890 for (tail = list; \ | |
1891 NILP (tail) ? \ | |
1892 0 : (elt = XCAR (tail), 1); \ | |
1893 tail = XCDR (tail)) | |
428 | 1894 |
1895 /* The following macros are for traversing lisp lists. | |
1896 Signal an error if LIST is not properly acyclic and nil-terminated. | |
1897 | |
1898 Use tortoise/hare algorithm to check for cycles, but only if it | |
1899 looks like the list is getting too long. Not only is the hare | |
1900 faster than the tortoise; it even gets a head start! */ | |
1901 | |
1902 /* Optimized and safe macros for looping over external lists. */ | |
1903 #define CIRCULAR_LIST_SUSPICION_LENGTH 1024 | |
1904 | |
1905 #define EXTERNAL_LIST_LOOP_1(list) \ | |
1906 Lisp_Object ELL1_elt, ELL1_hare, ELL1_tortoise; \ | |
442 | 1907 EMACS_INT ELL1_len; \ |
1908 PRIVATE_EXTERNAL_LIST_LOOP_6 (ELL1_elt, list, ELL1_len, ELL1_hare, \ | |
428 | 1909 ELL1_tortoise, CIRCULAR_LIST_SUSPICION_LENGTH) |
1910 | |
1911 #define EXTERNAL_LIST_LOOP_2(elt, list) \ | |
442 | 1912 Lisp_Object elt, hare_##elt, tortoise_##elt; \ |
1913 EMACS_INT len_##elt; \ | |
1914 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len_##elt, hare_##elt, \ | |
428 | 1915 tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH) |
1916 | |
2367 | 1917 |
1918 #define GC_EXTERNAL_LIST_LOOP_2(elt, list) \ | |
1919 do { \ | |
1920 XGCDECL3 (elt); \ | |
1921 Lisp_Object elt, hare_##elt, tortoise_##elt; \ | |
1922 EMACS_INT len_##elt; \ | |
1923 XGCPRO3 (elt, elt, hare_##elt, tortoise_##elt); \ | |
1924 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len_##elt, hare_##elt, \ | |
1925 tortoise_##elt, \ | |
1926 CIRCULAR_LIST_SUSPICION_LENGTH) | |
1927 | |
1928 #define END_GC_EXTERNAL_LIST_LOOP(elt) \ | |
1929 XUNGCPRO (elt); \ | |
1930 } \ | |
1931 while (0) | |
1932 | |
428 | 1933 #define EXTERNAL_LIST_LOOP_3(elt, list, tail) \ |
442 | 1934 Lisp_Object elt, tail, tortoise_##elt; \ |
1935 EMACS_INT len_##elt; \ | |
1936 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len_##elt, tail, \ | |
1937 tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH) | |
1938 | |
1939 #define EXTERNAL_LIST_LOOP_4_NO_DECLARE(elt, list, tail, len) \ | |
428 | 1940 Lisp_Object tortoise_##elt; \ |
442 | 1941 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len, tail, \ |
428 | 1942 tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH) |
1943 | |
1944 #define EXTERNAL_LIST_LOOP_4(elt, list, tail, len) \ | |
442 | 1945 Lisp_Object elt, tail, tortoise_##elt; \ |
1946 EMACS_INT len; \ | |
1947 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len, tail, \ | |
428 | 1948 tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH) |
1949 | |
1950 | |
444 | 1951 #define PRIVATE_EXTERNAL_LIST_LOOP_6(elt, list, len, hare, \ |
1952 tortoise, suspicion_length) \ | |
1953 for (tortoise = hare = list, len = 0; \ | |
1954 \ | |
1955 (CONSP (hare) ? ((elt = XCAR (hare)), 1) : \ | |
1956 (NILP (hare) ? 0 : \ | |
1957 (signal_malformed_list_error (list), 0))); \ | |
1958 \ | |
1959 hare = XCDR (hare), \ | |
1960 (void) \ | |
1961 ((++len > suspicion_length) \ | |
1962 && \ | |
1963 ((((len & 1) != 0) && (tortoise = XCDR (tortoise), 0)), \ | |
1964 (EQ (hare, tortoise) && (signal_circular_list_error (list), 0))))) | |
428 | 1965 |
442 | 1966 /* GET_LIST_LENGTH and GET_EXTERNAL_LIST_LENGTH: |
1967 | |
1968 These two macros return the length of LIST (either an internal or external | |
1969 list, according to which macro is used), stored into LEN (which must | |
1970 be declared by the caller). Circularities are trapped in external lists | |
1971 (and cause errors). Neither macro need be declared inside brackets. */ | |
1972 | |
1973 #define GET_LIST_LENGTH(list, len) do { \ | |
1974 Lisp_Object GLL_tail; \ | |
1975 for (GLL_tail = list, len = 0; \ | |
1976 !NILP (GLL_tail); \ | |
1977 GLL_tail = XCDR (GLL_tail), ++len) \ | |
1978 DO_NOTHING; \ | |
1979 } while (0) | |
1980 | |
1981 #define GET_EXTERNAL_LIST_LENGTH(list, len) \ | |
1982 do { \ | |
1983 Lisp_Object GELL_elt, GELL_tail; \ | |
1984 EXTERNAL_LIST_LOOP_4_NO_DECLARE (GELL_elt, list, GELL_tail, len) \ | |
1985 ; \ | |
1986 } while (0) | |
1987 | |
1988 /* For a list that's known to be in valid list format, where we may | |
1989 be deleting the current element out of the list -- | |
2500 | 1990 will ABORT() if the list is not in valid format */ |
442 | 1991 #define LIST_LOOP_DELETING(consvar, nextconsvar, list) \ |
1992 for (consvar = list; \ | |
1993 !NILP (consvar) ? (nextconsvar = XCDR (consvar), 1) :0; \ | |
1994 consvar = nextconsvar) | |
1995 | |
1996 /* LIST_LOOP_DELETE_IF and EXTERNAL_LIST_LOOP_DELETE_IF: | |
1997 | |
1998 These two macros delete all elements of LIST (either an internal or | |
1999 external list, according to which macro is used) satisfying | |
2000 CONDITION, a C expression referring to variable ELT. ELT is | |
2001 automatically declared. Circularities are trapped in external | |
2002 lists (and cause errors). Neither macro need be declared inside | |
2003 brackets. */ | |
2004 | |
2005 #define LIST_LOOP_DELETE_IF(elt, list, condition) do { \ | |
2006 /* Do not use ##list when creating new variables because \ | |
2007 that may not be just a variable name. */ \ | |
2008 Lisp_Object prev_tail_##elt = Qnil; \ | |
2009 LIST_LOOP_3 (elt, list, tail_##elt) \ | |
2010 { \ | |
2011 if (condition) \ | |
2012 { \ | |
2013 if (NILP (prev_tail_##elt)) \ | |
2014 list = XCDR (tail_##elt); \ | |
2015 else \ | |
2016 XCDR (prev_tail_##elt) = XCDR (tail_##elt); \ | |
2017 } \ | |
2018 else \ | |
2019 prev_tail_##elt = tail_##elt; \ | |
2020 } \ | |
2021 } while (0) | |
2022 | |
2023 #define EXTERNAL_LIST_LOOP_DELETE_IF(elt, list, condition) do { \ | |
2024 Lisp_Object prev_tail_##elt = Qnil; \ | |
2025 EXTERNAL_LIST_LOOP_4 (elt, list, tail_##elt, len_##elt) \ | |
2026 { \ | |
2027 if (condition) \ | |
2028 { \ | |
2029 if (NILP (prev_tail_##elt)) \ | |
2030 list = XCDR (tail_##elt); \ | |
2031 else \ | |
2032 XCDR (prev_tail_##elt) = XCDR (tail_##elt); \ | |
2033 /* Keep tortoise from ever passing hare. */ \ | |
2034 len_##elt = 0; \ | |
2035 } \ | |
2036 else \ | |
2037 prev_tail_##elt = tail_##elt; \ | |
2038 } \ | |
2039 } while (0) | |
2040 | |
2041 | |
1204 | 2042 /* Macros for looping over internal alists. |
2043 | |
2044 *** ALL OF THESE MACROS MUST BE DECLARED INSIDE BRACES -- SEE ABOVE. *** | |
2045 | |
2046 ALIST_LOOP_3 loops over an alist, at each iteration setting CAR and CDR | |
2047 to the car and cdr of the acons. CAR and CDR are automatically | |
2048 declared. | |
2049 | |
2050 ALIST_LOOP_4 is similar to ALIST_LOOP_3 but contains an additional | |
2051 variable ACONS at the beginning for access to the acons itself.All of | |
2052 the variables ACONS, CAR and CDR are automatically declared. | |
2053 */ | |
2054 | |
2055 #define ALIST_LOOP_3(car, cdr, alist) \ | |
2056 Lisp_Object _al3_acons_##car, car, cdr, _al3_tail_##car; \ | |
2057 for (_al3_tail_##car = alist; \ | |
2058 NILP (_al3_tail_##car) ? \ | |
2059 0 : (_al3_acons_##car = XCAR (_al3_tail_##car), \ | |
2060 car = XCAR (_al3_acons_##car), \ | |
2061 cdr = XCDR (_al3_acons_##car), 1); \ | |
2062 _al3_tail_##car = XCDR (_al3_tail_##car)) | |
2063 | |
2064 #define ALIST_LOOP_4(acons, car, cdr, list) \ | |
2065 Lisp_Object acons, car, cdr, _al4_tail_##car; \ | |
2066 for (_al4_tail_##car = list; \ | |
2067 NILP (_al4_tail_##car) ? \ | |
2068 0 : (elt = XCAR (_al4_tail_##car), car = XCAR (elt), \ | |
2069 cdr = XCDR (elt), 1); \ | |
2070 _al4_tail_##car = XCDR (tail)) | |
2071 | |
442 | 2072 /* Macros for looping over external alists. |
2073 | |
2074 *** ALL OF THESE MACROS MUST BE DECLARED INSIDE BRACES -- SEE ABOVE. *** | |
2075 | |
2076 EXTERNAL_ALIST_LOOP_4 is similar to EXTERNAL_LIST_LOOP_2, but it | |
2077 assumes the elements are aconses (the elements in an alist) and | |
2078 sets two additional argument variables ELT_CAR and ELT_CDR to the | |
2079 car and cdr of the acons. All of the variables ELT, ELT_CAR and | |
2080 ELT_CDR are automatically declared. | |
2081 | |
2082 EXTERNAL_ALIST_LOOP_5 adds a TAIL argument to EXTERNAL_ALIST_LOOP_4, | |
2083 just like EXTERNAL_LIST_LOOP_3 does, and again TAIL is automatically | |
2084 declared. | |
2085 | |
2086 EXTERNAL_ALIST_LOOP_6 adds a LEN argument to EXTERNAL_ALIST_LOOP_5, | |
2087 just like EXTERNAL_LIST_LOOP_4 does, and again LEN is automatically | |
2088 declared. | |
2089 | |
2090 EXTERNAL_ALIST_LOOP_6_NO_DECLARE does not declare any of its arguments, | |
2091 just like EXTERNAL_LIST_LOOP_4_NO_DECLARE, and so these must be declared | |
2092 manually. | |
2093 */ | |
428 | 2094 |
2095 /* Optimized and safe macros for looping over external alists. */ | |
2096 #define EXTERNAL_ALIST_LOOP_4(elt, elt_car, elt_cdr, list) \ | |
442 | 2097 Lisp_Object elt, elt_car, elt_cdr; \ |
428 | 2098 Lisp_Object hare_##elt, tortoise_##elt; \ |
2099 EMACS_INT len_##elt; \ | |
442 | 2100 PRIVATE_EXTERNAL_ALIST_LOOP_8 (elt, elt_car, elt_cdr, list, \ |
428 | 2101 len_##elt, hare_##elt, tortoise_##elt, \ |
2102 CIRCULAR_LIST_SUSPICION_LENGTH) | |
2103 | |
2104 #define EXTERNAL_ALIST_LOOP_5(elt, elt_car, elt_cdr, list, tail) \ | |
442 | 2105 Lisp_Object elt, elt_car, elt_cdr, tail; \ |
428 | 2106 Lisp_Object tortoise_##elt; \ |
2107 EMACS_INT len_##elt; \ | |
442 | 2108 PRIVATE_EXTERNAL_ALIST_LOOP_8 (elt, elt_car, elt_cdr, list, \ |
428 | 2109 len_##elt, tail, tortoise_##elt, \ |
2110 CIRCULAR_LIST_SUSPICION_LENGTH) \ | |
2111 | |
2112 #define EXTERNAL_ALIST_LOOP_6(elt, elt_car, elt_cdr, list, tail, len) \ | |
442 | 2113 Lisp_Object elt, elt_car, elt_cdr, tail; \ |
2114 EMACS_INT len; \ | |
428 | 2115 Lisp_Object tortoise_##elt; \ |
442 | 2116 PRIVATE_EXTERNAL_ALIST_LOOP_8 (elt, elt_car, elt_cdr, list, \ |
428 | 2117 len, tail, tortoise_##elt, \ |
2118 CIRCULAR_LIST_SUSPICION_LENGTH) | |
2119 | |
442 | 2120 #define EXTERNAL_ALIST_LOOP_6_NO_DECLARE(elt, elt_car, elt_cdr, list, \ |
2121 tail, len) \ | |
2122 Lisp_Object tortoise_##elt; \ | |
2123 PRIVATE_EXTERNAL_ALIST_LOOP_8 (elt, elt_car, elt_cdr, list, \ | |
2124 len, tail, tortoise_##elt, \ | |
2125 CIRCULAR_LIST_SUSPICION_LENGTH) | |
2126 | |
2127 | |
2128 #define PRIVATE_EXTERNAL_ALIST_LOOP_8(elt, elt_car, elt_cdr, list, len, \ | |
2129 hare, tortoise, suspicion_length) \ | |
2130 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len, hare, tortoise, \ | |
2131 suspicion_length) \ | |
428 | 2132 if (CONSP (elt) ? (elt_car = XCAR (elt), elt_cdr = XCDR (elt), 0) :1) \ |
2133 continue; \ | |
2134 else | |
2135 | |
442 | 2136 /* Macros for looping over external property lists. |
2137 | |
2138 *** ALL OF THESE MACROS MUST BE DECLARED INSIDE BRACES -- SEE ABOVE. *** | |
2139 | |
2140 EXTERNAL_PROPERTY_LIST_LOOP_3 maps over an external list assumed to | |
2141 be a property list, consisting of alternating pairs of keys | |
2142 (typically symbols or keywords) and values. Each iteration | |
2143 processes one such pair out of LIST, assigning the two elements to | |
2144 KEY and VALUE respectively. Malformed lists and circularities are | |
2145 trapped as usual, and in addition, property lists with an odd number | |
2146 of elements also signal an error. | |
2147 | |
2148 EXTERNAL_PROPERTY_LIST_LOOP_4 adds a TAIL argument to | |
2149 EXTERNAL_PROPERTY_LIST_LOOP_3, just like EXTERNAL_LIST_LOOP_3 does, | |
2150 and again TAIL is automatically declared. | |
2151 | |
2152 EXTERNAL_PROPERTY_LIST_LOOP_5 adds a LEN argument to | |
2153 EXTERNAL_PROPERTY_LIST_LOOP_4, just like EXTERNAL_LIST_LOOP_4 does, | |
2154 and again LEN is automatically declared. Note that in this case, | |
2155 LEN counts the iterations, NOT the total number of list elements | |
2156 processed, which is 2 * LEN. | |
2157 | |
2158 EXTERNAL_PROPERTY_LIST_LOOP_5_NO_DECLARE does not declare any of its | |
2159 arguments, just like EXTERNAL_LIST_LOOP_4_NO_DECLARE, and so these | |
2160 must be declared manually. */ | |
428 | 2161 |
2162 /* Optimized and safe macros for looping over external property lists. */ | |
2163 #define EXTERNAL_PROPERTY_LIST_LOOP_3(key, value, list) \ | |
2164 Lisp_Object key, value, hare_##key, tortoise_##key; \ | |
442 | 2165 EMACS_INT len_##key; \ |
428 | 2166 EXTERNAL_PROPERTY_LIST_LOOP_7 (key, value, list, len_##key, hare_##key, \ |
2167 tortoise_##key, CIRCULAR_LIST_SUSPICION_LENGTH) | |
2168 | |
2169 #define EXTERNAL_PROPERTY_LIST_LOOP_4(key, value, list, tail) \ | |
2170 Lisp_Object key, value, tail, tortoise_##key; \ | |
442 | 2171 EMACS_INT len_##key; \ |
428 | 2172 EXTERNAL_PROPERTY_LIST_LOOP_7 (key, value, list, len_##key, tail, \ |
2173 tortoise_##key, CIRCULAR_LIST_SUSPICION_LENGTH) | |
2174 | |
2175 #define EXTERNAL_PROPERTY_LIST_LOOP_5(key, value, list, tail, len) \ | |
2176 Lisp_Object key, value, tail, tortoise_##key; \ | |
2177 EMACS_INT len; \ | |
2178 EXTERNAL_PROPERTY_LIST_LOOP_7 (key, value, list, len, tail, \ | |
2179 tortoise_##key, CIRCULAR_LIST_SUSPICION_LENGTH) | |
2180 | |
442 | 2181 #define EXTERNAL_PROPERTY_LIST_LOOP_5_NO_DECLARE(key, value, list, \ |
2182 tail, len) \ | |
2183 Lisp_Object tortoise_##key; \ | |
2184 EXTERNAL_PROPERTY_LIST_LOOP_7 (key, value, list, len, tail, \ | |
2185 tortoise_##key, CIRCULAR_LIST_SUSPICION_LENGTH) | |
2186 | |
428 | 2187 |
2188 #define EXTERNAL_PROPERTY_LIST_LOOP_7(key, value, list, len, hare, \ | |
2189 tortoise, suspicion_length) \ | |
2190 for (tortoise = hare = list, len = 0; \ | |
2191 \ | |
2192 ((CONSP (hare) && \ | |
2193 (key = XCAR (hare), \ | |
2194 hare = XCDR (hare), \ | |
442 | 2195 (CONSP (hare) ? 1 : \ |
2196 (signal_malformed_property_list_error (list), 0)))) ? \ | |
428 | 2197 (value = XCAR (hare), 1) : \ |
2198 (NILP (hare) ? 0 : \ | |
2199 (signal_malformed_property_list_error (list), 0))); \ | |
2200 \ | |
2201 hare = XCDR (hare), \ | |
2202 ((++len < suspicion_length) ? \ | |
2203 ((void) 0) : \ | |
2204 (((len & 1) ? \ | |
2205 ((void) (tortoise = XCDR (XCDR (tortoise)))) : \ | |
2206 ((void) 0)) \ | |
2207 , \ | |
2208 (EQ (hare, tortoise) ? \ | |
2209 ((void) signal_circular_property_list_error (list)) : \ | |
2210 ((void) 0))))) | |
2211 | |
2421 | 2212 #define PRIVATE_PROPERTY_LIST_LOOP_4(tail, key, value, plist) \ |
2213 for (tail = plist; \ | |
2214 NILP (tail) ? 0 : \ | |
2215 (key = XCAR (tail), tail = XCDR (tail), \ | |
2216 value = XCAR (tail), tail = XCDR (tail), 1); \ | |
428 | 2217 ) |
2218 | |
2421 | 2219 #define PROPERTY_LIST_LOOP_3(key, value, plist) \ |
2220 Lisp_Object key, value, tail_##key; \ | |
2221 PRIVATE_PROPERTY_LIST_LOOP_4 (tail_##key, key, value, plist) | |
2222 | |
2223 #define GC_PROPERTY_LIST_LOOP_3(key, value, plist) \ | |
2224 do { \ | |
2225 XGCDECL3 (key); \ | |
2226 Lisp_Object key, value, tail_##key; \ | |
2227 XGCPRO3 (key, key, value, tail_##key); \ | |
2228 PRIVATE_PROPERTY_LIST_LOOP_4 (tail_##key, key, value, plist) | |
2229 | |
2230 #define END_GC_PROPERTY_LIST_LOOP(key) \ | |
2231 XUNGCPRO (key); \ | |
2232 } \ | |
2233 while (0) | |
2234 | |
428 | 2235 /* Return 1 if LIST is properly acyclic and nil-terminated, else 0. */ |
826 | 2236 DECLARE_INLINE_HEADER ( |
2237 int | |
428 | 2238 TRUE_LIST_P (Lisp_Object object) |
826 | 2239 ) |
428 | 2240 { |
2241 Lisp_Object hare, tortoise; | |
2242 EMACS_INT len; | |
2243 | |
2244 for (hare = tortoise = object, len = 0; | |
2245 CONSP (hare); | |
2246 hare = XCDR (hare), len++) | |
2247 { | |
2248 if (len < CIRCULAR_LIST_SUSPICION_LENGTH) | |
2249 continue; | |
2250 | |
2251 if (len & 1) | |
2252 tortoise = XCDR (tortoise); | |
2253 else if (EQ (hare, tortoise)) | |
2254 return 0; | |
2255 } | |
2256 | |
2257 return NILP (hare); | |
2258 } | |
2259 | |
2260 /* Signal an error if LIST is not properly acyclic and nil-terminated. */ | |
2261 #define CHECK_TRUE_LIST(list) do { \ | |
2262 Lisp_Object CTL_list = (list); \ | |
2263 Lisp_Object CTL_hare, CTL_tortoise; \ | |
436 | 2264 EMACS_INT CTL_len; \ |
428 | 2265 \ |
2266 for (CTL_hare = CTL_tortoise = CTL_list, CTL_len = 0; \ | |
2267 CONSP (CTL_hare); \ | |
2268 CTL_hare = XCDR (CTL_hare), CTL_len++) \ | |
2269 { \ | |
2270 if (CTL_len < CIRCULAR_LIST_SUSPICION_LENGTH) \ | |
2271 continue; \ | |
2272 \ | |
2273 if (CTL_len & 1) \ | |
2274 CTL_tortoise = XCDR (CTL_tortoise); \ | |
2275 else if (EQ (CTL_hare, CTL_tortoise)) \ | |
2276 Fsignal (Qcircular_list, list1 (CTL_list)); \ | |
2277 } \ | |
2278 \ | |
2279 if (! NILP (CTL_hare)) \ | |
2280 signal_malformed_list_error (CTL_list); \ | |
2281 } while (0) | |
2282 | |
442 | 2283 /*------------------------------ string --------------------------------*/ |
428 | 2284 |
2285 struct Lisp_String | |
2286 { | |
771 | 2287 union |
2288 { | |
2289 struct lrecord_header lheader; | |
2290 struct | |
2291 { | |
2292 /* WARNING: Everything before ascii_begin must agree exactly with | |
2293 struct lrecord_header */ | |
2294 unsigned int type :8; | |
2720 | 2295 #ifdef MC_ALLOC |
2296 unsigned int lisp_readonly :1; | |
2297 unsigned int free :1; | |
2298 /* Number of chars at beginning of string that are one byte in length | |
2299 (byte_ascii_p) */ | |
2300 unsigned int ascii_begin :22; | |
2301 #else /* not MC_ALLOC */ | |
771 | 2302 unsigned int mark :1; |
2303 unsigned int c_readonly :1; | |
2304 unsigned int lisp_readonly :1; | |
2305 /* Number of chars at beginning of string that are one byte in length | |
826 | 2306 (byte_ascii_p) */ |
771 | 2307 unsigned int ascii_begin :21; |
2720 | 2308 #endif /* not MC_ALLOC */ |
771 | 2309 } v; |
2310 } u; | |
793 | 2311 Bytecount size_; |
867 | 2312 Ibyte *data_; |
428 | 2313 Lisp_Object plist; |
2314 }; | |
2315 typedef struct Lisp_String Lisp_String; | |
2316 | |
3063 | 2317 #ifdef MC_ALLOC |
2318 #define MAX_STRING_ASCII_BEGIN ((1 << 22) - 1) | |
2319 #else | |
851 | 2320 #define MAX_STRING_ASCII_BEGIN ((1 << 21) - 1) |
3063 | 2321 #endif |
771 | 2322 |
1632 | 2323 DECLARE_MODULE_API_LRECORD (string, Lisp_String); |
428 | 2324 #define XSTRING(x) XRECORD (x, string, Lisp_String) |
617 | 2325 #define wrap_string(p) wrap_record (p, string) |
428 | 2326 #define STRINGP(x) RECORDP (x, string) |
2327 #define CHECK_STRING(x) CHECK_RECORD (x, string) | |
2328 #define CONCHECK_STRING(x) CONCHECK_RECORD (x, string) | |
2329 | |
826 | 2330 /* Most basic macros for strings -- basically just accessing or setting |
2331 fields -- are here. Everything else is in text.h, since they depend on | |
2332 stuff there. */ | |
428 | 2333 |
793 | 2334 /* Operations on Lisp_String *'s; only ones left */ |
826 | 2335 #define set_lispstringp_length(s, len) ((void) ((s)->size_ = (len))) |
2336 #define set_lispstringp_data(s, ptr) ((void) ((s)->data_ = (ptr))) | |
2337 | |
2338 /* Operations on strings as Lisp_Objects. Don't manipulate Lisp_String *'s | |
2339 in any new code. */ | |
793 | 2340 #define XSTRING_LENGTH(s) (XSTRING (s)->size_) |
2341 #define XSTRING_PLIST(s) (XSTRING (s)->plist) | |
2342 #define XSTRING_DATA(s) (XSTRING (s)->data_ + 0) | |
2343 #define XSTRING_ASCII_BEGIN(s) (XSTRING (s)->u.v.ascii_begin + 0) | |
826 | 2344 #define XSET_STRING_LENGTH(s, ptr) set_lispstringp_length (XSTRING (s), ptr) |
2345 #define XSET_STRING_DATA(s, ptr) set_lispstringp_data (XSTRING (s), ptr) | |
771 | 2346 /* WARNING: If you modify an existing string, you must call |
2347 bump_string_modiff() afterwards. */ | |
793 | 2348 #define XSET_STRING_ASCII_BEGIN(s, val) \ |
2349 ((void) (XSTRING (s)->u.v.ascii_begin = (val))) | |
826 | 2350 #define XSTRING_FORMAT(s) FORMAT_DEFAULT |
428 | 2351 |
456 | 2352 /* Return the true aligned size of a struct whose last member is a |
2353 variable-length array field. (this is known as the "struct hack") */ | |
2354 /* Implementation: in practice, structtype and fieldtype usually have | |
2355 the same alignment, but we can't be sure. We need to use | |
2356 ALIGN_SIZE to be absolutely sure of getting the correct alignment. | |
2357 To help the compiler's optimizer, we use a ternary expression that | |
2358 only a very stupid compiler would fail to correctly simplify. */ | |
2359 #define FLEXIBLE_ARRAY_STRUCT_SIZEOF(structtype, \ | |
2360 fieldtype, \ | |
2361 fieldname, \ | |
2362 array_length) \ | |
2363 (ALIGNOF (structtype) == ALIGNOF (fieldtype) \ | |
2364 ? (offsetof (structtype, fieldname) + \ | |
2365 (offsetof (structtype, fieldname[1]) - \ | |
2366 offsetof (structtype, fieldname[0])) * \ | |
2367 (array_length)) \ | |
826 | 2368 : (ALIGN_FOR_TYPE \ |
456 | 2369 ((offsetof (structtype, fieldname) + \ |
2370 (offsetof (structtype, fieldname[1]) - \ | |
2371 offsetof (structtype, fieldname[0])) * \ | |
2372 (array_length)), \ | |
826 | 2373 structtype))) |
442 | 2374 |
2375 /*------------------------------ vector --------------------------------*/ | |
428 | 2376 |
2377 struct Lisp_Vector | |
2378 { | |
3017 | 2379 struct LCRECORD_HEADER header; |
428 | 2380 long size; |
2381 Lisp_Object contents[1]; | |
2382 }; | |
2383 typedef struct Lisp_Vector Lisp_Vector; | |
2384 | |
2385 DECLARE_LRECORD (vector, Lisp_Vector); | |
2386 #define XVECTOR(x) XRECORD (x, vector, Lisp_Vector) | |
617 | 2387 #define wrap_vector(p) wrap_record (p, vector) |
428 | 2388 #define VECTORP(x) RECORDP (x, vector) |
2389 #define CHECK_VECTOR(x) CHECK_RECORD (x, vector) | |
2390 #define CONCHECK_VECTOR(x) CONCHECK_RECORD (x, vector) | |
2391 | |
2392 #define vector_length(v) ((v)->size) | |
2393 #define XVECTOR_LENGTH(s) vector_length (XVECTOR (s)) | |
2394 #define vector_data(v) ((v)->contents) | |
2395 #define XVECTOR_DATA(s) vector_data (XVECTOR (s)) | |
2396 | |
442 | 2397 /*---------------------------- bit vectors -----------------------------*/ |
428 | 2398 |
2399 #if (LONGBITS < 16) | |
2400 #error What the hell?! | |
2401 #elif (LONGBITS < 32) | |
2402 # define LONGBITS_LOG2 4 | |
2403 # define LONGBITS_POWER_OF_2 16 | |
2404 #elif (LONGBITS < 64) | |
2405 # define LONGBITS_LOG2 5 | |
2406 # define LONGBITS_POWER_OF_2 32 | |
2407 #elif (LONGBITS < 128) | |
2408 # define LONGBITS_LOG2 6 | |
2409 # define LONGBITS_POWER_OF_2 64 | |
2410 #else | |
2411 #error You really have 128-bit integers?! | |
2412 #endif | |
2413 | |
2414 struct Lisp_Bit_Vector | |
2415 { | |
3017 | 2416 struct LCRECORD_HEADER lheader; |
665 | 2417 Elemcount size; |
428 | 2418 unsigned long bits[1]; |
2419 }; | |
2420 typedef struct Lisp_Bit_Vector Lisp_Bit_Vector; | |
2421 | |
2422 DECLARE_LRECORD (bit_vector, Lisp_Bit_Vector); | |
2423 #define XBIT_VECTOR(x) XRECORD (x, bit_vector, Lisp_Bit_Vector) | |
617 | 2424 #define wrap_bit_vector(p) wrap_record (p, bit_vector) |
428 | 2425 #define BIT_VECTORP(x) RECORDP (x, bit_vector) |
2426 #define CHECK_BIT_VECTOR(x) CHECK_RECORD (x, bit_vector) | |
2427 #define CONCHECK_BIT_VECTOR(x) CONCHECK_RECORD (x, bit_vector) | |
2428 | |
2429 #define BITP(x) (INTP (x) && (XINT (x) == 0 || XINT (x) == 1)) | |
2430 | |
2431 #define CHECK_BIT(x) do { \ | |
2432 if (!BITP (x)) \ | |
2433 dead_wrong_type_argument (Qbitp, x);\ | |
2434 } while (0) | |
2435 | |
2436 #define CONCHECK_BIT(x) do { \ | |
2437 if (!BITP (x)) \ | |
2438 x = wrong_type_argument (Qbitp, x); \ | |
2439 } while (0) | |
2440 | |
2441 #define bit_vector_length(v) ((v)->size) | |
2442 | |
826 | 2443 DECLARE_INLINE_HEADER ( |
2444 int | |
665 | 2445 bit_vector_bit (Lisp_Bit_Vector *v, Elemcount n) |
826 | 2446 ) |
428 | 2447 { |
2448 return ((v->bits[n >> LONGBITS_LOG2] >> (n & (LONGBITS_POWER_OF_2 - 1))) | |
2449 & 1); | |
2450 } | |
2451 | |
826 | 2452 DECLARE_INLINE_HEADER ( |
2453 void | |
665 | 2454 set_bit_vector_bit (Lisp_Bit_Vector *v, Elemcount n, int value) |
826 | 2455 ) |
428 | 2456 { |
2457 if (value) | |
2458 v->bits[n >> LONGBITS_LOG2] |= (1UL << (n & (LONGBITS_POWER_OF_2 - 1))); | |
2459 else | |
2460 v->bits[n >> LONGBITS_LOG2] &= ~(1UL << (n & (LONGBITS_POWER_OF_2 - 1))); | |
2461 } | |
2462 | |
2463 /* Number of longs required to hold LEN bits */ | |
2464 #define BIT_VECTOR_LONG_STORAGE(len) \ | |
2465 (((len) + LONGBITS_POWER_OF_2 - 1) >> LONGBITS_LOG2) | |
2466 | |
853 | 2467 |
442 | 2468 /*------------------------------ symbol --------------------------------*/ |
428 | 2469 |
440 | 2470 typedef struct Lisp_Symbol Lisp_Symbol; |
428 | 2471 struct Lisp_Symbol |
2472 { | |
2473 struct lrecord_header lheader; | |
2474 /* next symbol in this obarray bucket */ | |
440 | 2475 Lisp_Symbol *next; |
793 | 2476 Lisp_Object name; |
428 | 2477 Lisp_Object value; |
2478 Lisp_Object function; | |
2479 Lisp_Object plist; | |
2480 }; | |
2481 | |
2482 #define SYMBOL_IS_KEYWORD(sym) \ | |
826 | 2483 ((string_byte (symbol_name (XSYMBOL (sym)), 0) == ':') \ |
428 | 2484 && EQ (sym, oblookup (Vobarray, \ |
793 | 2485 XSTRING_DATA (symbol_name (XSYMBOL (sym))), \ |
2486 XSTRING_LENGTH (symbol_name (XSYMBOL (sym)))))) | |
428 | 2487 #define KEYWORDP(obj) (SYMBOLP (obj) && SYMBOL_IS_KEYWORD (obj)) |
2488 | |
1632 | 2489 DECLARE_MODULE_API_LRECORD (symbol, Lisp_Symbol); |
428 | 2490 #define XSYMBOL(x) XRECORD (x, symbol, Lisp_Symbol) |
617 | 2491 #define wrap_symbol(p) wrap_record (p, symbol) |
428 | 2492 #define SYMBOLP(x) RECORDP (x, symbol) |
2493 #define CHECK_SYMBOL(x) CHECK_RECORD (x, symbol) | |
2494 #define CONCHECK_SYMBOL(x) CONCHECK_RECORD (x, symbol) | |
2495 | |
2496 #define symbol_next(s) ((s)->next) | |
2497 #define symbol_name(s) ((s)->name) | |
2498 #define symbol_value(s) ((s)->value) | |
2499 #define symbol_function(s) ((s)->function) | |
2500 #define symbol_plist(s) ((s)->plist) | |
2501 | |
793 | 2502 #define XSYMBOL_NEXT(s) (XSYMBOL (s)->next) |
2503 #define XSYMBOL_NAME(s) (XSYMBOL (s)->name) | |
2504 #define XSYMBOL_VALUE(s) (XSYMBOL (s)->value) | |
2505 #define XSYMBOL_FUNCTION(s) (XSYMBOL (s)->function) | |
2506 #define XSYMBOL_PLIST(s) (XSYMBOL (s)->plist) | |
2507 | |
2508 | |
442 | 2509 /*------------------------------- subr ---------------------------------*/ |
428 | 2510 |
853 | 2511 /* A function that takes no arguments and returns a Lisp_Object. |
2512 We could define such types for n arguments, if needed. */ | |
428 | 2513 typedef Lisp_Object (*lisp_fn_t) (void); |
2514 | |
2515 struct Lisp_Subr | |
2516 { | |
2517 struct lrecord_header lheader; | |
442 | 2518 short min_args; |
2519 short max_args; | |
2520 const char *prompt; | |
2521 const char *doc; | |
2522 const char *name; | |
428 | 2523 lisp_fn_t subr_fn; |
2524 }; | |
2525 typedef struct Lisp_Subr Lisp_Subr; | |
2526 | |
2527 DECLARE_LRECORD (subr, Lisp_Subr); | |
2528 #define XSUBR(x) XRECORD (x, subr, Lisp_Subr) | |
617 | 2529 #define wrap_subr(p) wrap_record (p, subr) |
428 | 2530 #define SUBRP(x) RECORDP (x, subr) |
2531 #define CHECK_SUBR(x) CHECK_RECORD (x, subr) | |
2532 #define CONCHECK_SUBR(x) CONCHECK_RECORD (x, subr) | |
2533 | |
436 | 2534 #define subr_function(subr) ((subr)->subr_fn) |
2535 #define SUBR_FUNCTION(subr,max_args) \ | |
2536 ((Lisp_Object (*) (EXFUN_##max_args)) (subr)->subr_fn) | |
2537 #define subr_name(subr) ((subr)->name) | |
428 | 2538 |
442 | 2539 /*------------------------------ marker --------------------------------*/ |
2540 | |
428 | 2541 |
440 | 2542 typedef struct Lisp_Marker Lisp_Marker; |
428 | 2543 struct Lisp_Marker |
2544 { | |
2545 struct lrecord_header lheader; | |
440 | 2546 Lisp_Marker *next; |
2547 Lisp_Marker *prev; | |
428 | 2548 struct buffer *buffer; |
665 | 2549 Membpos membpos; |
428 | 2550 char insertion_type; |
2551 }; | |
2552 | |
1632 | 2553 DECLARE_MODULE_API_LRECORD (marker, Lisp_Marker); |
428 | 2554 #define XMARKER(x) XRECORD (x, marker, Lisp_Marker) |
617 | 2555 #define wrap_marker(p) wrap_record (p, marker) |
428 | 2556 #define MARKERP(x) RECORDP (x, marker) |
2557 #define CHECK_MARKER(x) CHECK_RECORD (x, marker) | |
2558 #define CONCHECK_MARKER(x) CONCHECK_RECORD (x, marker) | |
2559 | |
2560 /* The second check was looking for GCed markers still in use */ | |
2500 | 2561 /* if (INTP (XMARKER (x)->lheader.next.v)) ABORT (); */ |
428 | 2562 |
2563 #define marker_next(m) ((m)->next) | |
2564 #define marker_prev(m) ((m)->prev) | |
2565 | |
3063 | 2566 /*-------------------basic int (no connection to char)------------------*/ |
2567 | |
2568 #define ZEROP(x) EQ (x, Qzero) | |
428 | 2569 |
800 | 2570 #ifdef ERROR_CHECK_TYPES |
428 | 2571 |
3063 | 2572 #define XINT(x) XINT_1 (x, __FILE__, __LINE__) |
2573 | |
2574 DECLARE_INLINE_HEADER ( | |
2575 EMACS_INT | |
2576 XINT_1 (Lisp_Object obj, const Ascbyte *file, int line) | |
2577 ) | |
2578 { | |
2579 assert_at_line (INTP (obj), file, line); | |
2580 return XREALINT (obj); | |
2581 } | |
2582 | |
2583 #else /* no error checking */ | |
2584 | |
2585 #define XINT(obj) XREALINT (obj) | |
2586 | |
2587 #endif /* no error checking */ | |
2588 | |
2589 #define CHECK_INT(x) do { \ | |
2590 if (!INTP (x)) \ | |
2591 dead_wrong_type_argument (Qintegerp, x); \ | |
2592 } while (0) | |
2593 | |
2594 #define CONCHECK_INT(x) do { \ | |
2595 if (!INTP (x)) \ | |
2596 x = wrong_type_argument (Qintegerp, x); \ | |
2597 } while (0) | |
2598 | |
2599 #define NATNUMP(x) (INTP (x) && XINT (x) >= 0) | |
2600 | |
2601 #define CHECK_NATNUM(x) do { \ | |
2602 if (!NATNUMP (x)) \ | |
2603 dead_wrong_type_argument (Qnatnump, x); \ | |
2604 } while (0) | |
2605 | |
2606 #define CONCHECK_NATNUM(x) do { \ | |
2607 if (!NATNUMP (x)) \ | |
2608 x = wrong_type_argument (Qnatnump, x); \ | |
2609 } while (0) | |
2610 | |
2611 /*------------------------------- char ---------------------------------*/ | |
2612 | |
2613 /* NOTE: There are basic functions for converting between a character and | |
2614 the string representation of a character in text.h, as well as lots of | |
2615 other character-related stuff. There are other functions/macros for | |
2616 working with Ichars in charset.h, for retrieving the charset of an | |
2617 Ichar, the length of an Ichar when converted to text, etc. | |
2618 */ | |
2619 | |
2620 #ifdef MULE | |
2621 | |
2622 MODULE_API int non_ascii_valid_ichar_p (Ichar ch); | |
2623 | |
2624 /* Return whether the given Ichar is valid. | |
2625 */ | |
2626 | |
2627 DECLARE_INLINE_HEADER ( | |
2628 int | |
2629 valid_ichar_p (Ichar ch) | |
2630 ) | |
2631 { | |
2632 return (! (ch & ~0xFF)) || non_ascii_valid_ichar_p (ch); | |
2633 } | |
2634 | |
2635 #else /* not MULE */ | |
2636 | |
2637 /* This works when CH is negative, and correctly returns non-zero only when CH | |
2638 is in the range [0, 255], inclusive. */ | |
2639 #define valid_ichar_p(ch) (! (ch & ~0xFF)) | |
2640 | |
2641 #endif /* not MULE */ | |
2642 | |
2643 #ifdef ERROR_CHECK_TYPES | |
2644 | |
2645 DECLARE_INLINE_HEADER ( | |
2646 int | |
2647 CHARP_1 (Lisp_Object obj, const Ascbyte *file, int line) | |
2648 ) | |
2649 { | |
2650 if (XTYPE (obj) != Lisp_Type_Char) | |
2651 return 0; | |
2652 assert_at_line (valid_ichar_p (XCHARVAL (obj)), file, line); | |
2653 return 1; | |
2654 } | |
2655 | |
2656 #define CHARP(x) CHARP_1 (x, __FILE__, __LINE__) | |
2657 | |
826 | 2658 DECLARE_INLINE_HEADER ( |
867 | 2659 Ichar |
2367 | 2660 XCHAR_1 (Lisp_Object obj, const Ascbyte *file, int line) |
826 | 2661 ) |
428 | 2662 { |
3063 | 2663 Ichar ch; |
788 | 2664 assert_at_line (CHARP (obj), file, line); |
3063 | 2665 ch = XCHARVAL (obj); |
2666 assert_at_line (valid_ichar_p (ch), file, line); | |
2667 return ch; | |
428 | 2668 } |
2669 | |
788 | 2670 #define XCHAR(x) XCHAR_1 (x, __FILE__, __LINE__) |
2671 | |
3063 | 2672 #else /* not ERROR_CHECK_TYPES */ |
2673 | |
2674 #define CHARP(x) (XTYPE (x) == Lisp_Type_Char) | |
2675 #define XCHAR(x) ((Ichar) XCHARVAL (x)) | |
2676 | |
2677 #endif /* (else) not ERROR_CHECK_TYPES */ | |
2678 | |
2679 #define CONCHECK_CHAR(x) do { \ | |
2680 if (!CHARP (x)) \ | |
2681 x = wrong_type_argument (Qcharacterp, x); \ | |
2682 } while (0) | |
2683 | |
2684 #define CHECK_CHAR(x) do { \ | |
2685 if (!CHARP (x)) \ | |
2686 dead_wrong_type_argument (Qcharacterp, x); \ | |
2687 } while (0) | |
2688 | |
2689 | |
2690 DECLARE_INLINE_HEADER ( | |
2691 Lisp_Object | |
2692 make_char (Ichar val) | |
2693 ) | |
2694 { | |
2695 type_checking_assert (valid_ichar_p (val)); | |
2696 /* This is defined in lisp-union.h or lisp-disunion.h */ | |
2697 return make_char_1 (val); | |
2698 } | |
2699 | |
2700 /*------------------------- int-char connection ------------------------*/ | |
2701 | |
2702 #ifdef ERROR_CHECK_TYPES | |
2703 | |
2704 #define XCHAR_OR_INT(x) XCHAR_OR_INT_1 (x, __FILE__, __LINE__) | |
2705 | |
2706 DECLARE_INLINE_HEADER ( | |
2707 EMACS_INT | |
2708 XCHAR_OR_INT_1 (Lisp_Object obj, const Ascbyte *file, int line) | |
2709 ) | |
2710 { | |
2711 assert_at_line (INTP (obj) || CHARP (obj), file, line); | |
2712 return CHARP (obj) ? XCHAR (obj) : XINT (obj); | |
2713 } | |
2714 | |
788 | 2715 #else /* no error checking */ |
2716 | |
3063 | 2717 #define XCHAR_OR_INT(obj) (CHARP (obj) ? XCHAR (obj) : XINT (obj)) |
788 | 2718 |
2719 #endif /* no error checking */ | |
428 | 2720 |
3063 | 2721 /* True of X is an integer whose value is the valid integral equivalent of a |
2722 character. */ | |
2723 | |
2724 #define CHAR_INTP(x) (INTP (x) && valid_ichar_p (XINT (x))) | |
2725 | |
2726 /* True of X is a character or an integral value that can be converted into a | |
2727 character. */ | |
2728 #define CHAR_OR_CHAR_INTP(x) (CHARP (x) || CHAR_INTP (x)) | |
2729 | |
2730 DECLARE_INLINE_HEADER ( | |
2731 Ichar | |
2732 XCHAR_OR_CHAR_INT (Lisp_Object obj) | |
2733 ) | |
2734 { | |
2735 return CHARP (obj) ? XCHAR (obj) : XINT (obj); | |
2736 } | |
2737 | |
2738 /* Signal an error if CH is not a valid character or integer Lisp_Object. | |
2739 If CH is an integer Lisp_Object, convert it to a character Lisp_Object, | |
2740 but merely by repackaging, without performing tests for char validity. | |
2741 */ | |
2742 | |
2743 #define CHECK_CHAR_COERCE_INT(x) do { \ | |
2744 if (CHARP (x)) \ | |
2745 ; \ | |
2746 else if (CHAR_INTP (x)) \ | |
2747 x = make_char (XINT (x)); \ | |
2748 else \ | |
2749 x = wrong_type_argument (Qcharacterp, x); \ | |
2750 } while (0) | |
2751 | |
2752 /* next three always continuable because they coerce their arguments. */ | |
2753 #define CHECK_INT_COERCE_CHAR(x) do { \ | |
2754 if (INTP (x)) \ | |
2755 ; \ | |
2756 else if (CHARP (x)) \ | |
2757 x = make_int (XCHAR (x)); \ | |
2758 else \ | |
2759 x = wrong_type_argument (Qinteger_or_char_p, x); \ | |
2760 } while (0) | |
2761 | |
2762 #define CHECK_INT_COERCE_MARKER(x) do { \ | |
2763 if (INTP (x)) \ | |
2764 ; \ | |
2765 else if (MARKERP (x)) \ | |
2766 x = make_int (marker_position (x)); \ | |
2767 else \ | |
2768 x = wrong_type_argument (Qinteger_or_marker_p, x); \ | |
2769 } while (0) | |
2770 | |
2771 #define CHECK_INT_COERCE_CHAR_OR_MARKER(x) do { \ | |
2772 if (INTP (x)) \ | |
2773 ; \ | |
2774 else if (CHARP (x)) \ | |
2775 x = make_int (XCHAR (x)); \ | |
2776 else if (MARKERP (x)) \ | |
2777 x = make_int (marker_position (x)); \ | |
2778 else \ | |
2779 x = wrong_type_argument (Qinteger_char_or_marker_p, x); \ | |
2780 } while (0) | |
428 | 2781 |
442 | 2782 /*------------------------------ float ---------------------------------*/ |
428 | 2783 |
2784 /* Note: the 'unused_next_' field exists only to ensure that the | |
2785 `next' pointer fits within the structure, for the purposes of the | |
2786 free list. This makes a difference in the unlikely case of | |
2787 sizeof(double) being smaller than sizeof(void *). */ | |
2788 | |
2789 struct Lisp_Float | |
2790 { | |
2791 struct lrecord_header lheader; | |
2792 union { double d; struct Lisp_Float *unused_next_; } data; | |
2793 }; | |
2794 typedef struct Lisp_Float Lisp_Float; | |
2795 | |
2796 DECLARE_LRECORD (float, Lisp_Float); | |
2797 #define XFLOAT(x) XRECORD (x, float, Lisp_Float) | |
617 | 2798 #define wrap_float(p) wrap_record (p, float) |
428 | 2799 #define FLOATP(x) RECORDP (x, float) |
2800 #define CHECK_FLOAT(x) CHECK_RECORD (x, float) | |
2801 #define CONCHECK_FLOAT(x) CONCHECK_RECORD (x, float) | |
2802 | |
2803 #define float_data(f) ((f)->data.d) | |
2804 #define XFLOAT_DATA(x) float_data (XFLOAT (x)) | |
2805 | |
2806 #define XFLOATINT(n) extract_float (n) | |
2807 | |
2808 #define CHECK_INT_OR_FLOAT(x) do { \ | |
2809 if (!INT_OR_FLOATP (x)) \ | |
2810 dead_wrong_type_argument (Qnumberp, x); \ | |
2811 } while (0) | |
2812 | |
2813 #define CONCHECK_INT_OR_FLOAT(x) do { \ | |
2814 if (!INT_OR_FLOATP (x)) \ | |
2815 x = wrong_type_argument (Qnumberp, x); \ | |
2816 } while (0) | |
2817 | |
2818 # define INT_OR_FLOATP(x) (INTP (x) || FLOATP (x)) | |
2819 | |
442 | 2820 /*--------------------------- readonly objects -------------------------*/ |
440 | 2821 |
2720 | 2822 #ifndef MC_ALLOC |
428 | 2823 #define CHECK_C_WRITEABLE(obj) \ |
2824 do { if (c_readonly (obj)) c_write_error (obj); } while (0) | |
2825 | |
2720 | 2826 #define C_READONLY(obj) (C_READONLY_RECORD_HEADER_P(XRECORD_LHEADER (obj))) |
2827 #endif /* not MC_ALLOC */ | |
2828 | |
428 | 2829 #define CHECK_LISP_WRITEABLE(obj) \ |
2830 do { if (lisp_readonly (obj)) lisp_write_error (obj); } while (0) | |
2831 | |
2832 #define LISP_READONLY(obj) (LISP_READONLY_RECORD_HEADER_P(XRECORD_LHEADER (obj))) | |
2833 | |
980 | 2834 /*----------------------------- structures ----------------------------*/ |
428 | 2835 |
2836 typedef struct structure_keyword_entry structure_keyword_entry; | |
2837 struct structure_keyword_entry | |
2838 { | |
2839 Lisp_Object keyword; | |
2840 int (*validate) (Lisp_Object keyword, Lisp_Object value, | |
578 | 2841 Error_Behavior errb); |
428 | 2842 }; |
2843 | |
2844 typedef struct | |
2845 { | |
2846 Dynarr_declare (structure_keyword_entry); | |
2847 } structure_keyword_entry_dynarr; | |
2848 | |
2849 typedef struct structure_type structure_type; | |
2850 struct structure_type | |
2851 { | |
2852 Lisp_Object type; | |
2853 structure_keyword_entry_dynarr *keywords; | |
578 | 2854 int (*validate) (Lisp_Object data, Error_Behavior errb); |
428 | 2855 Lisp_Object (*instantiate) (Lisp_Object data); |
2856 }; | |
2857 | |
2858 typedef struct | |
2859 { | |
2860 Dynarr_declare (structure_type); | |
2861 } structure_type_dynarr; | |
2862 | |
2863 struct structure_type *define_structure_type (Lisp_Object type, | |
2864 int (*validate) | |
2865 (Lisp_Object data, | |
578 | 2866 Error_Behavior errb), |
428 | 2867 Lisp_Object (*instantiate) |
2868 (Lisp_Object data)); | |
2869 void define_structure_type_keyword (struct structure_type *st, | |
2870 Lisp_Object keyword, | |
2871 int (*validate) (Lisp_Object keyword, | |
2872 Lisp_Object value, | |
578 | 2873 Error_Behavior errb)); |
428 | 2874 |
858 | 2875 /*---------------------------- weak boxes ------------------------------*/ |
2876 | |
2877 struct weak_box | |
2878 { | |
3017 | 2879 struct LCRECORD_HEADER header; |
858 | 2880 Lisp_Object value; |
2881 | |
2882 Lisp_Object next_weak_box; /* don't mark through this! */ | |
2883 }; | |
2884 | |
2885 void prune_weak_boxes (void); | |
2886 Lisp_Object make_weak_box (Lisp_Object value); | |
2887 Lisp_Object weak_box_ref (Lisp_Object value); | |
2888 | |
2889 DECLARE_LRECORD (weak_box, struct weak_box); | |
2890 #define XWEAK_BOX(x) XRECORD (x, weak_box, struct weak_box) | |
2891 #define XSET_WEAK_BOX(x, v) (XWEAK_BOX (x)->value = (v)) | |
2892 #define wrap_weak_box(p) wrap_record (p, weak_box) | |
2893 #define WEAK_BOXP(x) RECORDP (x, weak_box) | |
2894 #define CHECK_WEAK_BOX(x) CHECK_RECORD (x, weak_box) | |
2895 #define CONCHECK_WEAK_BOX(x) CONCHECK_RECORD (x, weak_box) | |
2896 | |
888 | 2897 /*--------------------------- ephemerons ----------------------------*/ |
2898 | |
2899 struct ephemeron | |
2900 { | |
3017 | 2901 struct LCRECORD_HEADER header; |
888 | 2902 |
2903 Lisp_Object key; | |
2904 | |
2905 /* This field holds a pair. The cdr of this cons points to the next | |
2906 ephemeron in Vall_ephemerons. The car points to another pair | |
2907 whose car is the value and whose cdr is the finalizer. | |
2908 | |
2909 This representation makes it very easy to unlink an ephemeron | |
2910 from Vall_ephemerons and chain it into | |
2911 Vall_ephemerons_to_finalize. */ | |
2912 | |
2913 Lisp_Object cons_chain; | |
2914 | |
2915 Lisp_Object value; | |
2916 }; | |
2917 | |
2918 void prune_ephemerons (void); | |
2919 Lisp_Object ephemeron_value(Lisp_Object ephi); | |
1590 | 2920 void init_marking_ephemerons(void); |
2921 int continue_marking_ephemerons(void); | |
888 | 2922 int finish_marking_ephemerons(void); |
2923 Lisp_Object zap_finalize_list(void); | |
2924 Lisp_Object make_ephemeron(Lisp_Object key, Lisp_Object value, Lisp_Object finalizer); | |
2925 | |
2926 DECLARE_LRECORD(ephemeron, struct ephemeron); | |
2927 #define XEPHEMERON(x) XRECORD (x, ephemeron, struct ephemeron) | |
2928 #define XEPHEMERON_REF(x) (XEPHEMERON (x)->value) | |
2929 #define XEPHEMERON_NEXT(x) (XCDR (XEPHEMERON(x)->cons_chain)) | |
2930 #define XEPHEMERON_FINALIZER(x) (XCDR (XCAR (XEPHEMERON (x)->cons_chain))) | |
2931 #define XSET_EPHEMERON_NEXT(x, n) (XSETCDR (XEPHEMERON(x)->cons_chain, n)) | |
2932 #define XSET_EPHEMERON_VALUE(x, v) (XEPHEMERON(x)->value = (v)) | |
2933 #define XSET_EPHEMERON_KEY(x, k) (XEPHEMERON(x)->key = (k)) | |
2934 #define wrap_ephemeron(p) wrap_record (p, ephemeron) | |
2935 #define EPHEMERONP(x) RECORDP (x, ephemeron) | |
2936 #define CHECK_EPHEMERON(x) CHECK_RECORD (x, ephemeron) | |
2937 #define CONCHECK_EPHEMERON(x) CONCHECK_RECORD (x, ephemeron) | |
2938 | |
858 | 2939 |
442 | 2940 /*---------------------------- weak lists ------------------------------*/ |
428 | 2941 |
2942 enum weak_list_type | |
2943 { | |
2944 /* element disappears if it's unmarked. */ | |
2945 WEAK_LIST_SIMPLE, | |
2946 /* element disappears if it's a cons and either its car or | |
2947 cdr is unmarked. */ | |
2948 WEAK_LIST_ASSOC, | |
2949 /* element disappears if it's a cons and its car is unmarked. */ | |
2950 WEAK_LIST_KEY_ASSOC, | |
2951 /* element disappears if it's a cons and its cdr is unmarked. */ | |
442 | 2952 WEAK_LIST_VALUE_ASSOC, |
2953 /* element disappears if it's a cons and neither its car nor | |
2954 its cdr is marked. */ | |
2955 WEAK_LIST_FULL_ASSOC | |
428 | 2956 }; |
2957 | |
2958 struct weak_list | |
2959 { | |
3017 | 2960 struct LCRECORD_HEADER header; |
428 | 2961 Lisp_Object list; /* don't mark through this! */ |
2962 enum weak_list_type type; | |
2963 Lisp_Object next_weak; /* don't mark through this! */ | |
2964 }; | |
2965 | |
2966 DECLARE_LRECORD (weak_list, struct weak_list); | |
2967 #define XWEAK_LIST(x) XRECORD (x, weak_list, struct weak_list) | |
617 | 2968 #define wrap_weak_list(p) wrap_record (p, weak_list) |
428 | 2969 #define WEAK_LISTP(x) RECORDP (x, weak_list) |
2970 #define CHECK_WEAK_LIST(x) CHECK_RECORD (x, weak_list) | |
2971 #define CONCHECK_WEAK_LIST(x) CONCHECK_RECORD (x, weak_list) | |
2972 | |
2973 #define weak_list_list(w) ((w)->list) | |
2974 #define XWEAK_LIST_LIST(w) (XWEAK_LIST (w)->list) | |
2975 | |
2976 Lisp_Object make_weak_list (enum weak_list_type type); | |
2977 /* The following two are only called by the garbage collector */ | |
2978 int finish_marking_weak_lists (void); | |
2979 void prune_weak_lists (void); | |
2980 | |
1743 | 2981 END_C_DECLS |
428 | 2982 |
2983 /************************************************************************/ | |
771 | 2984 /* Definitions related to the format of text and of characters */ |
2985 /************************************************************************/ | |
2986 | |
2987 /* Note: | |
2988 | |
2989 "internally formatted text" and the term "internal format" in | |
2990 general are likely to refer to the format of text in buffers and | |
2991 strings; "externally formatted text" and the term "external format" | |
2992 refer to any text format used in the O.S. or elsewhere outside of | |
2993 XEmacs. The format of text and of a character are related and | |
2994 there must be a one-to-one relationship (hopefully through a | |
2995 relatively simple algorithmic means of conversion) between a string | |
2996 of text and an equivalent array of characters, but the conversion | |
2997 between the two is NOT necessarily trivial. | |
2998 | |
2999 In a non-Mule XEmacs, allowed characters are numbered 0 through | |
3000 255, where no fixed meaning is assigned to them, but (when | |
3001 representing text, rather than bytes in a binary file) in practice | |
3002 the lower half represents ASCII and the upper half some other 8-bit | |
3003 character set (chosen by setting the font, case tables, syntax | |
3004 tables, etc. appropriately for the character set through ad-hoc | |
3005 means such as the `iso-8859-1' file and the | |
3006 `standard-display-european' function). | |
3007 | |
3008 #### Finish this. | |
3009 | |
3010 */ | |
3011 #include "text.h" | |
3012 | |
3013 | |
3014 /************************************************************************/ | |
428 | 3015 /* Definitions of primitive Lisp functions and variables */ |
3016 /************************************************************************/ | |
3017 | |
3018 | |
3019 /* DEFUN - Define a built-in Lisp-visible C function or `subr'. | |
3020 `lname' should be the name to give the function in Lisp, | |
3021 as a null-terminated C string. | |
3022 `Fname' should be the C equivalent of `lname', using only characters | |
3023 valid in a C identifier, with an "F" prepended. | |
3024 The name of the C constant structure that records information | |
3025 on this function for internal use is "S" concatenated with Fname. | |
3026 `min_args' should be a number, the minimum number of arguments allowed. | |
3027 `max_args' should be a number, the maximum number of arguments allowed, | |
3028 or else MANY or UNEVALLED. | |
3029 MANY means pass a vector of evaluated arguments, | |
3030 in the form of an integer number-of-arguments | |
3031 followed by the address of a vector of Lisp_Objects | |
3032 which contains the argument values. | |
3033 UNEVALLED means pass the list of unevaluated arguments. | |
3034 `prompt' says how to read arguments for an interactive call. | |
3035 See the doc string for `interactive'. | |
3036 A null string means call interactively with no arguments. | |
3037 `arglist' are the comma-separated arguments (always Lisp_Objects) for | |
3038 the function. | |
3039 The docstring for the function is placed as a "C" comment between | |
3040 the prompt and the `args' argument. make-docfile reads the | |
3041 comment and creates the DOC file from it. | |
3042 */ | |
3043 | |
3044 #define EXFUN_0 void | |
3045 #define EXFUN_1 Lisp_Object | |
3046 #define EXFUN_2 Lisp_Object,Lisp_Object | |
3047 #define EXFUN_3 Lisp_Object,Lisp_Object,Lisp_Object | |
3048 #define EXFUN_4 Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object | |
3049 #define EXFUN_5 Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object | |
3050 #define EXFUN_6 Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object, \ | |
3051 Lisp_Object | |
3052 #define EXFUN_7 Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object, \ | |
3053 Lisp_Object,Lisp_Object | |
3054 #define EXFUN_8 Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object, \ | |
3055 Lisp_Object,Lisp_Object,Lisp_Object | |
3056 #define EXFUN_MANY int, Lisp_Object* | |
3057 #define EXFUN_UNEVALLED Lisp_Object | |
3058 #define EXFUN(sym, max_args) Lisp_Object sym (EXFUN_##max_args) | |
2268 | 3059 #define EXFUN_NORETURN(sym, max_args) \ |
3060 DECLARE_DOESNT_RETURN_TYPE (Lisp_Object, sym (EXFUN_##max_args)) | |
428 | 3061 |
3062 #define SUBR_MAX_ARGS 8 | |
3063 #define MANY -2 | |
3064 #define UNEVALLED -1 | |
3065 | |
3066 /* Can't be const, because then subr->doc is read-only and | |
3067 Snarf_documentation chokes */ | |
3068 | |
2720 | 3069 #ifdef MC_ALLOC |
3070 #define DEFUN(lname, Fname, min_args, max_args, prompt, arglist) \ | |
3071 Lisp_Object Fname (EXFUN_##max_args); \ | |
3072 static struct Lisp_Subr MC_ALLOC_S##Fname = \ | |
3073 { \ | |
3074 { /* struct lrecord_header */ \ | |
3075 lrecord_type_subr, /* lrecord_type_index */ \ | |
3076 1, /* lisp_readonly bit */ \ | |
3077 0, /* free */ \ | |
3078 0 /* uid */ \ | |
3079 }, \ | |
3080 min_args, \ | |
3081 max_args, \ | |
3082 prompt, \ | |
3083 0, /* doc string */ \ | |
3084 lname, \ | |
3085 (lisp_fn_t) Fname \ | |
3086 }; \ | |
2814 | 3087 static struct Lisp_Subr *S##Fname; \ |
2720 | 3088 Lisp_Object Fname (DEFUN_##max_args arglist) |
3089 | |
3090 #define DEFUN_NORETURN(lname, Fname, min_args, max_args, prompt, arglist) \ | |
3091 DECLARE_DOESNT_RETURN_TYPE (Lisp_Object, Fname (EXFUN_##max_args)); \ | |
3092 static struct Lisp_Subr MC_ALLOC_S##Fname = \ | |
3093 { \ | |
3094 { /* struct lrecord_header */ \ | |
3095 lrecord_type_subr, /* lrecord_type_index */ \ | |
3096 1, /* lisp_readonly bit */ \ | |
3097 0, /* free */ \ | |
3098 0 /* uid */ \ | |
3099 }, \ | |
3100 min_args, \ | |
3101 max_args, \ | |
3102 prompt, \ | |
3103 0, /* doc string */ \ | |
3104 lname, \ | |
3105 (lisp_fn_t) Fname \ | |
3106 }; \ | |
2814 | 3107 static struct Lisp_Subr *S##Fname; \ |
2720 | 3108 DOESNT_RETURN_TYPE (Lisp_Object) Fname (DEFUN_##max_args arglist) |
2834 | 3109 #define GET_DEFUN_LISP_OBJECT(Fname) \ |
3110 wrap_subr (S##Fname); | |
2720 | 3111 #else /* not MC_ALLOC */ |
428 | 3112 #define DEFUN(lname, Fname, min_args, max_args, prompt, arglist) \ |
3113 Lisp_Object Fname (EXFUN_##max_args); \ | |
442 | 3114 static struct Lisp_Subr S##Fname = \ |
3115 { \ | |
3116 { /* struct lrecord_header */ \ | |
3117 lrecord_type_subr, /* lrecord_type_index */ \ | |
3118 1, /* mark bit */ \ | |
3119 1, /* c_readonly bit */ \ | |
1111 | 3120 1, /* lisp_readonly bit */ \ |
3121 0 /* unused */ \ | |
442 | 3122 }, \ |
3123 min_args, \ | |
3124 max_args, \ | |
3125 prompt, \ | |
3126 0, /* doc string */ \ | |
3127 lname, \ | |
3128 (lisp_fn_t) Fname \ | |
3129 }; \ | |
428 | 3130 Lisp_Object Fname (DEFUN_##max_args arglist) |
3131 | |
2268 | 3132 #define DEFUN_NORETURN(lname, Fname, min_args, max_args, prompt, arglist) \ |
3133 DECLARE_DOESNT_RETURN_TYPE (Lisp_Object, Fname (EXFUN_##max_args)); \ | |
3134 static struct Lisp_Subr S##Fname = \ | |
3135 { \ | |
3136 { /* struct lrecord_header */ \ | |
3137 lrecord_type_subr, /* lrecord_type_index */ \ | |
3138 1, /* mark bit */ \ | |
3139 1, /* c_readonly bit */ \ | |
3140 1, /* lisp_readonly bit */ \ | |
3141 0 /* unused */ \ | |
3142 }, \ | |
3143 min_args, \ | |
3144 max_args, \ | |
3145 prompt, \ | |
3146 0, /* doc string */ \ | |
3147 lname, \ | |
3148 (lisp_fn_t) Fname \ | |
3149 }; \ | |
3150 DOESNT_RETURN_TYPE (Lisp_Object) Fname (DEFUN_##max_args arglist) | |
2834 | 3151 #define GET_DEFUN_LISP_OBJECT(Fname) \ |
3152 wrap_subr (&S##Fname); | |
2720 | 3153 #endif /* not MC_ALLOC */ |
2268 | 3154 |
428 | 3155 /* Heavy ANSI C preprocessor hackery to get DEFUN to declare a |
3156 prototype that matches max_args, and add the obligatory | |
3157 `Lisp_Object' type declaration to the formal C arguments. */ | |
3158 | |
3159 #define DEFUN_MANY(named_int, named_Lisp_Object) named_int, named_Lisp_Object | |
3160 #define DEFUN_UNEVALLED(args) Lisp_Object args | |
3161 #define DEFUN_0() void | |
3162 #define DEFUN_1(a) Lisp_Object a | |
3163 #define DEFUN_2(a,b) DEFUN_1(a), Lisp_Object b | |
3164 #define DEFUN_3(a,b,c) DEFUN_2(a,b), Lisp_Object c | |
3165 #define DEFUN_4(a,b,c,d) DEFUN_3(a,b,c), Lisp_Object d | |
3166 #define DEFUN_5(a,b,c,d,e) DEFUN_4(a,b,c,d), Lisp_Object e | |
3167 #define DEFUN_6(a,b,c,d,e,f) DEFUN_5(a,b,c,d,e), Lisp_Object f | |
3168 #define DEFUN_7(a,b,c,d,e,f,g) DEFUN_6(a,b,c,d,e,f), Lisp_Object g | |
3169 #define DEFUN_8(a,b,c,d,e,f,g,h) DEFUN_7(a,b,c,d,e,f,g),Lisp_Object h | |
3170 | |
3171 /* WARNING: If you add defines here for higher values of max_args, | |
3172 make sure to also fix the clauses in PRIMITIVE_FUNCALL(), | |
3173 and change the define of SUBR_MAX_ARGS above. */ | |
3174 | |
3175 #include "symeval.h" | |
3176 | |
1743 | 3177 BEGIN_C_DECLS |
1650 | 3178 |
428 | 3179 /* `specpdl' is the special binding/unwind-protect stack. |
3180 | |
3181 Knuth says (see the Jargon File): | |
3182 At MIT, `pdl' [abbreviation for `Push Down List'] used to | |
3183 be a more common synonym for `stack'. | |
3184 Everywhere else `stack' seems to be the preferred term. | |
3185 | |
3186 specpdl_depth is the current depth of `specpdl'. | |
771 | 3187 Save this for use later as arg to `unbind_to_1'. */ |
1632 | 3188 extern MODULE_API int specpdl_depth_counter; |
428 | 3189 #define specpdl_depth() specpdl_depth_counter |
3190 | |
442 | 3191 |
3192 #define CHECK_FUNCTION(fun) do { \ | |
3193 while (NILP (Ffunctionp (fun))) \ | |
3194 signal_invalid_function_error (fun); \ | |
3195 } while (0) | |
3196 | |
428 | 3197 |
3198 /************************************************************************/ | |
3199 /* Checking for QUIT */ | |
3200 /************************************************************************/ | |
3201 | |
1123 | 3202 /* NOTE NOTE NOTE: Invoking QUIT can cause random Lisp code to be executed! |
3203 This can happen in numerous ways. For example, on many platforms, QUIT | |
3204 needs to drain the event queue to see whether there's a C-g in the works. | |
3205 A side effect of this is that, if there's a menu-press event, menu filters | |
3206 (i.e. Lisp code) will be invoked. Lisp code could also happen if there's | |
3207 an asynchronous timeout, or if the debugger is invoked as a result of | |
3208 debug-on-quit and the user returns by hitting `r', etc. etc. | |
3209 | |
3210 However, GC CANNOT HAPPEN. It is forbidden everywhere within the QUIT- | |
3211 processing code, because most callers cannot tolerate GC during QUIT | |
3212 since it's just too prevalent. */ | |
3213 | |
853 | 3214 /* The exact workings of this mechanism are described in detail in signal.c. */ |
3215 | |
428 | 3216 /* Asynchronous events set something_happened, and then are processed |
3217 within the QUIT macro. At this point, we are guaranteed to not be in | |
3218 any sensitive code. */ | |
3219 | |
1632 | 3220 extern MODULE_API volatile int something_happened; |
3221 extern MODULE_API int dont_check_for_quit; | |
3222 MODULE_API void check_what_happened (void); | |
3223 | |
3224 extern MODULE_API volatile int quit_check_signal_happened; | |
428 | 3225 extern volatile int quit_check_signal_tick_count; |
1632 | 3226 MODULE_API void check_quit (void); |
3227 | |
3228 MODULE_API void signal_quit (void); | |
428 | 3229 |
853 | 3230 int begin_dont_check_for_quit (void); |
3231 int begin_do_check_for_quit (void); | |
3232 | |
3233 /* Nonzero if the values of `quit-flag' and `inhibit-quit' indicate | |
3234 that a quit should be signalled. */ | |
771 | 3235 #define QUIT_FLAG_SAYS_SHOULD_QUIT \ |
3236 (!NILP (Vquit_flag) && \ | |
3237 (NILP (Vinhibit_quit) \ | |
3238 || (EQ (Vquit_flag, Qcritical) && !dont_check_for_quit))) | |
3239 | |
853 | 3240 /* Nonzero if ought to quit now. This is the "efficient" version, which |
3241 respects the flags set to indicate whether the full quit check should | |
3242 be done. Therefore it may be inaccurate (i.e. lagging reality), esp. | |
3243 when poll for quit is used. | |
3244 | |
3245 This is defined for code that wants to allow quitting, but needs to | |
3246 do some cleanup if that happens. (You could always register the cleanup | |
3247 code using record_unwind_protect(), but sometimes it makes more sense | |
3248 to do it using QUITP.) To use this macro, just call it at the | |
3249 appropriate time, and if its value is non-zero, do your cleanup code | |
3250 and then call QUIT. | |
3251 | |
3252 A different version (below) is used for the actual QUIT macro. */ | |
428 | 3253 #define QUITP \ |
853 | 3254 ((quit_check_signal_happened ? check_quit () : (void) 0), \ |
771 | 3255 QUIT_FLAG_SAYS_SHOULD_QUIT) |
428 | 3256 |
853 | 3257 /* This is the version actually called by QUIT. The difference |
3258 between it and QUITP is that it also has side effects in that it | |
3259 will handle anything else that has recently signalled itself | |
3260 asynchronously and wants to be handled now. Currently this | |
3261 includes executing asynchronous timeouts that may have been set | |
3262 from Lisp or from the poll-for-quit or poll-for-sigchld | |
3263 timers. (#### It seems that, to be slightly more accurate, we | |
3264 should also process poll-for-quit timers in the above version. | |
3265 However, this mechanism is inherently approximate, so it really | |
3266 doesn't matter much.) In the future, it might also include doing a | |
3267 thread context switch. Callers of QUITP generally don't except | |
1123 | 3268 random side effects to happen (#### unfortunately, random side effects |
3269 can happen anyway, e.g. through menu filters -- see comment above), | |
3270 so we have this different version. */ | |
428 | 3271 #define INTERNAL_QUITP \ |
853 | 3272 ((something_happened ? check_what_happened () : (void) 0), \ |
771 | 3273 QUIT_FLAG_SAYS_SHOULD_QUIT) |
428 | 3274 |
3275 /* Check quit-flag and quit if it is non-nil. Also do any other things | |
853 | 3276 that are triggered by asynchronous events and might want to be |
3277 handled. */ | |
428 | 3278 #define QUIT do { if (INTERNAL_QUITP) signal_quit (); } while (0) |
3279 | |
3280 | |
3281 /************************************************************************/ | |
3282 /* hashing */ | |
3283 /************************************************************************/ | |
3284 | |
3285 /* #### for a 64-bit machine, we should substitute a prime just over 2^32 */ | |
3286 #define GOOD_HASH 65599 /* prime number just over 2^16; Dragon book, p. 435 */ | |
3287 #define HASH2(a,b) (GOOD_HASH * (a) + (b)) | |
3288 #define HASH3(a,b,c) (GOOD_HASH * HASH2 (a,b) + (c)) | |
3289 #define HASH4(a,b,c,d) (GOOD_HASH * HASH3 (a,b,c) + (d)) | |
3290 #define HASH5(a,b,c,d,e) (GOOD_HASH * HASH4 (a,b,c,d) + (e)) | |
3291 #define HASH6(a,b,c,d,e,f) (GOOD_HASH * HASH5 (a,b,c,d,e) + (f)) | |
3292 #define HASH7(a,b,c,d,e,f,g) (GOOD_HASH * HASH6 (a,b,c,d,e,f) + (g)) | |
3293 #define HASH8(a,b,c,d,e,f,g,h) (GOOD_HASH * HASH7 (a,b,c,d,e,f,g) + (h)) | |
3294 #define HASH9(a,b,c,d,e,f,g,h,i) (GOOD_HASH * HASH8 (a,b,c,d,e,f,g,h) + (i)) | |
3295 | |
3296 #define LISP_HASH(obj) ((unsigned long) LISP_TO_VOID (obj)) | |
2516 | 3297 Hashcode memory_hash (const void *xv, Bytecount size); |
3298 Hashcode internal_hash (Lisp_Object obj, int depth); | |
3299 Hashcode internal_array_hash (Lisp_Object *arr, int size, int depth); | |
428 | 3300 |
3301 | |
3302 /************************************************************************/ | |
3303 /* String translation */ | |
3304 /************************************************************************/ | |
3305 | |
771 | 3306 /* When support for message translation exists, GETTEXT() translates a |
3307 string from English into the language defined by | |
3308 `current-language-environment'. This is done by looking the string | |
3309 up in a large predefined table; if no translation is found, the | |
3310 original string is returned, and the failure is possibly logged so | |
3311 that the translation can later be entered into the table. | |
3312 | |
3313 In addition to this, there is a mechanism to snarf message strings | |
3314 out of the source code so that they can be entered into the tables. | |
3315 This is what make-msgfile.lex does. | |
3316 | |
3317 Handling `format' strings is more difficult: The format string | |
3318 should get translated, but not under all circumstances. When the | |
3319 format string is a Lisp string, what should happen is that | |
3320 Fformat() should format the untranslated args[0] and return that, | |
3321 and also call Fgettext() on args[0] and, if that is different, | |
3322 format it and store it in the `string-translatable' property of the | |
3323 returned string. See Fgettext(). | |
3324 | |
3325 CGETTEXT() is the same as GETTEXT() but works with char * strings | |
867 | 3326 instead of Ibyte * strings. |
771 | 3327 |
3328 build_msg_string() is a shorthand for build_string (GETTEXT (x)). | |
3329 build_msg_intstring() is a shorthand for build_intstring (GETTEXT (x)). | |
3330 */ | |
3331 | |
3332 #define GETTEXT(x) (x) | |
3333 #define CGETTEXT(x) (x) | |
3334 #define LISP_GETTEXT(x) (x) | |
428 | 3335 |
3336 /* DEFER_GETTEXT is used to identify strings which are translated when | |
3337 they are referenced instead of when they are defined. | |
3338 These include Qerror_messages and initialized arrays of strings. | |
3339 */ | |
3340 #define DEFER_GETTEXT(x) (x) | |
3341 | |
3342 | |
3343 /************************************************************************/ | |
3344 /* Garbage collection / GC-protection */ | |
3345 /************************************************************************/ | |
3346 | |
3347 /* Structure for recording stack slots that need marking */ | |
3348 | |
3349 /* This is a chain of structures, each of which points at a Lisp_Object | |
3350 variable whose value should be marked in garbage collection. | |
3351 Normally every link of the chain is an automatic variable of a function, | |
3352 and its `val' points to some argument or local variable of the function. | |
3353 On exit to the function, the chain is set back to the value it had on | |
3354 entry. This way, no link remains in the chain when the stack frame | |
3355 containing the link disappears. | |
3356 | |
3357 Every function that can call Feval must protect in this fashion all | |
3358 Lisp_Object variables whose contents will be used again. */ | |
3359 | |
1632 | 3360 extern MODULE_API struct gcpro *gcprolist; |
428 | 3361 |
1743 | 3362 END_C_DECLS |
1650 | 3363 |
1204 | 3364 /* #### Catching insufficient gcpro: |
3365 | |
3366 The C++ code below catches GCPRO without UNGCPRO or vice-versa. | |
3367 Catching cases where there's no GCPRO or UNGCPRO but should be, however, | |
3368 is much harder, but could be done: | |
3369 | |
3370 1. Lisp_Object becomes a real object. Its creator and destructor need to | |
3371 figure out whether the object is on the stack (by looking at the range | |
3372 that `this' is within), and if so, add the pointer to a list of all | |
3373 stack-based Lisp_Objects. | |
3374 | |
3375 2. The assignment method needs to do reference-counting on actual Lisp | |
3376 objects -- in particular, we need to know if there are any references | |
3377 to a Lisp object that are *NOT* from stack-based Lisp_Objects. | |
3378 | |
3379 3. When we get to a point in the code where we might garbage collect -- | |
3380 i.e. Ffuncall(), Feval(), or Fgarbage_collect() is called -- we look | |
3381 at our list of stack-based Lisp_Objects, and if there are any that | |
3382 point to Lisp objects with no non-stack references, see if there are | |
3383 any gcpros pointing to the object, and if not, set a flag indicating | |
3384 that the object is "destroyed". (Don't abort yet because the function | |
3385 might not use the object any more.) | |
3386 | |
3387 4. When we detag a pointer using XFOO(), abort if its "destroyed" flag | |
3388 is set. | |
3389 | |
3390 --ben | |
3391 */ | |
3392 | |
428 | 3393 struct gcpro |
3394 { | |
3395 struct gcpro *next; | |
771 | 3396 const Lisp_Object *var; /* Address of first protected variable */ |
428 | 3397 int nvars; /* Number of consecutive protected variables */ |
1204 | 3398 #if defined (__cplusplus) && defined (ERROR_CHECK_GC) |
3399 /* Try to catch GCPRO without UNGCPRO, or vice-versa. G++ complains (at | |
3400 least with sufficient numbers of warnings enabled, i.e. -Weffc++) if a | |
3401 copy constructor or assignment operator is not defined. */ | |
3402 gcpro () : next (0), var (0), nvars (0) { } | |
3403 gcpro (const gcpro& g) : next (g.next), var (g.var), nvars (g.nvars) { } | |
3404 gcpro& operator= (const gcpro& g) { next = g.next; var = g.var; | |
3405 nvars = g.nvars; | |
3406 return *this;} | |
3407 ~gcpro () { assert (!next); } | |
3408 #endif /* defined (__cplusplus) && defined (ERROR_CHECK_GC) */ | |
428 | 3409 }; |
3410 | |
3411 /* Normally, you declare variables gcpro1, gcpro2, ... and use the | |
3412 GCPROn() macros. However, if you need to have nested gcpro's, | |
3413 declare ngcpro1, ngcpro2, ... and use NGCPROn(). If you need | |
3414 to nest another level, use nngcpro1, nngcpro2, ... and use | |
3415 NNGCPROn(). If you need to nest yet another level, create | |
3416 the appropriate macros. */ | |
3417 | |
1123 | 3418 /* NOTE: About comments like "This function does not GC": These are there to |
3419 try to track whether GCPROing is necessary. Strictly speaking, some | |
3420 functions that say this might actually GC, but only when it is never | |
3421 possible to return (more specifically, in the process of signalling an | |
3422 error, the debugger may be invoked, and could GC). For GCPRO purposes, | |
3423 you only have to worry about functions that can GC and then return. | |
3424 The QUIT macro cannot GC any more, although this wasn't true at some point, | |
3425 and so some "This function can GC" comments may be inaccurate. | |
3426 */ | |
3427 | |
1743 | 3428 BEGIN_C_DECLS |
1650 | 3429 |
2367 | 3430 #define XGCDECL1(x) struct gcpro x##cpro1 |
3431 #define XGCDECL2(x) struct gcpro x##cpro1, x##cpro2 | |
3432 #define XGCDECL3(x) struct gcpro x##cpro1, x##cpro2, x##cpro3 | |
3433 #define XGCDECL4(x) struct gcpro x##cpro1, x##cpro2, x##cpro3, x##cpro4 | |
3434 #define XGCDECL5(x) struct gcpro x##cpro1, x##cpro2, x##cpro3, x##cpro4, x##cpro5 | |
3435 | |
428 | 3436 #ifdef DEBUG_GCPRO |
3437 | |
2367 | 3438 MODULE_API void debug_gcpro1 (Ascbyte *, int, struct gcpro *, Lisp_Object *); |
3439 MODULE_API void debug_gcpro2 (Ascbyte *, int, struct gcpro *, struct gcpro *, | |
1632 | 3440 Lisp_Object *, Lisp_Object *); |
2367 | 3441 MODULE_API void debug_gcpro3 (Ascbyte *, int, struct gcpro *, struct gcpro *, |
1632 | 3442 struct gcpro *, Lisp_Object *, Lisp_Object *, |
3443 Lisp_Object *); | |
2367 | 3444 MODULE_API void debug_gcpro4 (Ascbyte *, int, struct gcpro *, struct gcpro *, |
1632 | 3445 struct gcpro *, struct gcpro *, Lisp_Object *, |
3446 Lisp_Object *, Lisp_Object *, Lisp_Object *); | |
2367 | 3447 MODULE_API void debug_gcpro5 (Ascbyte *, int, struct gcpro *, struct gcpro *, |
1632 | 3448 struct gcpro *, struct gcpro *, struct gcpro *, |
3449 Lisp_Object *, Lisp_Object *, Lisp_Object *, | |
3450 Lisp_Object *, Lisp_Object *); | |
2367 | 3451 MODULE_API void debug_ungcpro(Ascbyte *, int, struct gcpro *); |
3452 | |
3453 #define XGCPRO1(x,v) \ | |
3454 debug_gcpro1 (__FILE__, __LINE__,&x##cpro1,&v) | |
3455 #define XGCPRO2(x,v1,v2) \ | |
3456 debug_gcpro2 (__FILE__, __LINE__,&x##cpro1,&x##cpro2,&v1,&v2) | |
3457 #define XGCPRO3(x,v1,v2,v3) \ | |
3458 debug_gcpro3 (__FILE__, __LINE__,&x##cpro1,&x##cpro2,&x##cpro3, \ | |
3459 &v1,&v2,&v3) | |
3460 #define XGCPRO4(x,v1,v2,v3,v4) \ | |
3461 debug_gcpro4 (__FILE__, __LINE__,&x##cpro1,&x##cpro2,&x##cpro3, \ | |
3462 &x##cpro4, \ | |
428 | 3463 &v1,&v2,&v3,&v4) |
2367 | 3464 #define XGCPRO5(x,v1,v2,v3,v4,v5) \ |
3465 debug_gcpro5 (__FILE__, __LINE__,&x##cpro1,&x##cpro2,&x##cpro3, \ | |
3466 &x##cpro4,&x##cpro5, \ | |
428 | 3467 &v1,&v2,&v3,&v4,&v5) |
2367 | 3468 #define XUNGCPRO(x) \ |
3469 debug_ungcpro(__FILE__, __LINE__,&x##cpro1) | |
428 | 3470 |
3471 #else /* ! DEBUG_GCPRO */ | |
3472 | |
2367 | 3473 #define XGCPRO1(x, var1) ((void) ( \ |
3474 x##cpro1.next = gcprolist, x##cpro1.var = &var1, x##cpro1.nvars = 1, \ | |
3475 gcprolist = &x##cpro1 )) | |
3476 | |
3477 #define XGCPRO2(x, var1, var2) ((void) ( \ | |
3478 x##cpro1.next = gcprolist, x##cpro1.var = &var1, x##cpro1.nvars = 1, \ | |
3479 x##cpro2.next = &x##cpro1, x##cpro2.var = &var2, x##cpro2.nvars = 1, \ | |
3480 gcprolist = &x##cpro2 )) | |
3481 | |
3482 #define XGCPRO3(x, var1, var2, var3) ((void) ( \ | |
3483 x##cpro1.next = gcprolist, x##cpro1.var = &var1, x##cpro1.nvars = 1, \ | |
3484 x##cpro2.next = &x##cpro1, x##cpro2.var = &var2, x##cpro2.nvars = 1, \ | |
3485 x##cpro3.next = &x##cpro2, x##cpro3.var = &var3, x##cpro3.nvars = 1, \ | |
3486 gcprolist = &x##cpro3 )) | |
3487 | |
3488 #define XGCPRO4(x, var1, var2, var3, var4) ((void) ( \ | |
3489 x##cpro1.next = gcprolist, x##cpro1.var = &var1, x##cpro1.nvars = 1, \ | |
3490 x##cpro2.next = &x##cpro1, x##cpro2.var = &var2, x##cpro2.nvars = 1, \ | |
3491 x##cpro3.next = &x##cpro2, x##cpro3.var = &var3, x##cpro3.nvars = 1, \ | |
3492 x##cpro4.next = &x##cpro3, x##cpro4.var = &var4, x##cpro4.nvars = 1, \ | |
3493 gcprolist = &x##cpro4 )) | |
3494 | |
3495 #define XGCPRO5(x, var1, var2, var3, var4, var5) ((void) ( \ | |
3496 x##cpro1.next = gcprolist, x##cpro1.var = &var1, x##cpro1.nvars = 1, \ | |
3497 x##cpro2.next = &x##cpro1, x##cpro2.var = &var2, x##cpro2.nvars = 1, \ | |
3498 x##cpro3.next = &x##cpro2, x##cpro3.var = &var3, x##cpro3.nvars = 1, \ | |
3499 x##cpro4.next = &x##cpro3, x##cpro4.var = &var4, x##cpro4.nvars = 1, \ | |
3500 x##cpro5.next = &x##cpro4, x##cpro5.var = &var5, x##cpro5.nvars = 1, \ | |
3501 gcprolist = &x##cpro5 )) | |
3502 | |
3503 #define XGCPRO1_ARRAY(x, array, n) ((void) ( \ | |
3504 x##cpro1.next = gcprolist, x##cpro1.var = array, x##cpro1.nvars = n, \ | |
3505 gcprolist = &x##cpro1 )) | |
3506 | |
3507 #define XGCPRO2_ARRAY(x, array1, n1, array2, n2) ((void) ( \ | |
3508 x##cpro1.next = gcprolist, x##cpro1.var = array1, x##cpro1.nvars = n1, \ | |
3509 x##cpro2.next = &x##cpro1, x##cpro2.var = array2, x##cpro2.nvars = n2, \ | |
3510 gcprolist = &x##cpro2 )) | |
3511 | |
3512 #define XGCPRO3_ARRAY(x, array1, n1, array2, n2, array3, n3) ((void) ( \ | |
3513 x##cpro1.next = gcprolist, x##cpro1.var = array1, x##cpro1.nvars = n1, \ | |
3514 x##cpro2.next = &x##cpro1, x##cpro2.var = array2, x##cpro2.nvars = n2, \ | |
3515 x##cpro3.next = &x##cpro2, x##cpro3.var = array3, x##cpro3.nvars = n3, \ | |
3516 gcprolist = &x##cpro3 )) | |
853 | 3517 |
1204 | 3518 #if defined (__cplusplus) && defined (ERROR_CHECK_GC) |
3519 /* We need to reset each gcpro to avoid triggering the assert() in | |
3520 ~gcpro(). This happens in UNGCPRO and longjmp(). */ | |
3521 #define UNWIND_GCPRO_TO(val) \ | |
3522 do \ | |
3523 { \ | |
3524 struct gcpro *__gcpro_stop = (val); \ | |
3525 /* Try to catch UNGCPRO without GCPRO. We arrange for there to be a \ | |
3526 sentinel at the end of the gcprolist, so it should never be NULL. */ \ | |
3527 assert (__gcpro_stop); \ | |
3528 while (gcprolist != __gcpro_stop) \ | |
3529 { \ | |
3530 struct gcpro *__gcpro_next = gcprolist->next; \ | |
3531 gcprolist->next = 0; \ | |
3532 gcprolist = __gcpro_next; \ | |
3533 assert (gcprolist); \ | |
3534 } \ | |
3535 } while (0) | |
3536 #else | |
3537 #define UNWIND_GCPRO_TO(val) (gcprolist = (val)) | |
3538 #endif /* defined (__cplusplus) && defined (ERROR_CHECK_GC) */ | |
3539 | |
2367 | 3540 #define XUNGCPRO(x) UNWIND_GCPRO_TO (x##cpro1.next) |
428 | 3541 |
3542 #endif /* ! DEBUG_GCPRO */ | |
3543 | |
2367 | 3544 #define GCDECL1 XGCDECL1 (g) |
3545 #define GCDECL2 XGCDECL2 (g) | |
3546 #define GCDECL3 XGCDECL3 (g) | |
3547 #define GCDECL4 XGCDECL4 (g) | |
3548 #define GCDECL5 XGCDECL5 (g) | |
3549 | |
3550 #define GCPRO1(a) XGCPRO1 (g,a) | |
3551 #define GCPRO2(a,b) XGCPRO2 (g,a,b) | |
3552 #define GCPRO3(a,b,c) XGCPRO3 (g,a,b,c) | |
3553 #define GCPRO4(a,b,c,d) XGCPRO4 (g,a,b,c,d) | |
3554 #define GCPRO5(a,b,c,d,e) XGCPRO5 (g,a,b,c,d,e) | |
3555 | |
3556 #define GCPRO1_ARRAY(a1,n1) XGCPRO1_ARRAY(g,a1,n1) | |
3557 #define GCPRO2_ARRAY(a1,n1,a2,n2) XGCPRO2_ARRAY (g,a1,n1,a2,n2) | |
3558 #define GCPRO3_ARRAY(a1,n1,a2,n2,a3,n3) XGCPRO3_ARRAY (g,a1,n1,a2,n2,a3,n3) | |
3559 | |
3560 #define UNGCPRO XUNGCPRO (g) | |
3561 | |
3562 #define NGCDECL1 XGCDECL1 (ng) | |
3563 #define NGCDECL2 XGCDECL2 (ng) | |
3564 #define NGCDECL3 XGCDECL3 (ng) | |
3565 #define NGCDECL4 XGCDECL4 (ng) | |
3566 #define NGCDECL5 XGCDECL5 (ng) | |
3567 | |
3568 #define NGCPRO1(a) XGCPRO1 (ng,a) | |
3569 #define NGCPRO2(a,b) XGCPRO2 (ng,a,b) | |
3570 #define NGCPRO3(a,b,c) XGCPRO3 (ng,a,b,c) | |
3571 #define NGCPRO4(a,b,c,d) XGCPRO4 (ng,a,b,c,d) | |
3572 #define NGCPRO5(a,b,c,d,e) XGCPRO5 (ng,a,b,c,d,e) | |
3573 | |
3574 #define NGCPRO1_ARRAY(a1,n1) XGCPRO1_ARRAY(ng,a1,n1) | |
3575 #define NGCPRO2_ARRAY(a1,n1,a2,n2) XGCPRO2_ARRAY (ng,a1,n1,a2,n2) | |
3576 #define NGCPRO3_ARRAY(a1,n1,a2,n2,a3,n3) XGCPRO3_ARRAY (ng,a1,n1,a2,n2,a3,n3) | |
3577 | |
3578 #define NUNGCPRO XUNGCPRO (ng) | |
3579 | |
3580 #define NNGCDECL1 XGCDECL1 (nng) | |
3581 #define NNGCDECL2 XGCDECL2 (nng) | |
3582 #define NNGCDECL3 XGCDECL3 (nng) | |
3583 #define NNGCDECL4 XGCDECL4 (nng) | |
3584 #define NNGCDECL5 XGCDECL5 (nng) | |
3585 | |
3586 #define NNGCPRO1(a) XGCPRO1 (nng,a) | |
3587 #define NNGCPRO2(a,b) XGCPRO2 (nng,a,b) | |
3588 #define NNGCPRO3(a,b,c) XGCPRO3 (nng,a,b,c) | |
3589 #define NNGCPRO4(a,b,c,d) XGCPRO4 (nng,a,b,c,d) | |
3590 #define NNGCPRO5(a,b,c,d,e) XGCPRO5 (nng,a,b,c,d,e) | |
3591 | |
3592 #define NNGCPRO1_ARRAY(a1,n1) XGCPRO1_ARRAY(nng,a1,n1) | |
3593 #define NNGCPRO2_ARRAY(a1,n1,a2,n2) XGCPRO2_ARRAY (nng,a1,n1,a2,n2) | |
3594 #define NNGCPRO3_ARRAY(a1,n1,a2,n2,a3,n3) XGCPRO3_ARRAY (nng,a1,n1,a2,n2,a3,n3) | |
3595 | |
3596 #define NNUNGCPRO XUNGCPRO (nng) | |
3597 | |
428 | 3598 /* Evaluate expr, UNGCPRO, and then return the value of expr. */ |
3599 #define RETURN_UNGCPRO(expr) do \ | |
3600 { \ | |
3601 Lisp_Object ret_ungc_val = (expr); \ | |
3602 UNGCPRO; \ | |
3603 RETURN_SANS_WARNINGS ret_ungc_val; \ | |
3604 } while (0) | |
3605 | |
3606 /* Evaluate expr, NUNGCPRO, UNGCPRO, and then return the value of expr. */ | |
3607 #define RETURN_NUNGCPRO(expr) do \ | |
3608 { \ | |
3609 Lisp_Object ret_ungc_val = (expr); \ | |
3610 NUNGCPRO; \ | |
3611 UNGCPRO; \ | |
3612 RETURN_SANS_WARNINGS ret_ungc_val; \ | |
3613 } while (0) | |
3614 | |
3615 /* Evaluate expr, NNUNGCPRO, NUNGCPRO, UNGCPRO, and then return the | |
3616 value of expr. */ | |
3617 #define RETURN_NNUNGCPRO(expr) do \ | |
3618 { \ | |
3619 Lisp_Object ret_ungc_val = (expr); \ | |
3620 NNUNGCPRO; \ | |
3621 NUNGCPRO; \ | |
3622 UNGCPRO; \ | |
3623 RETURN_SANS_WARNINGS ret_ungc_val; \ | |
3624 } while (0) | |
3625 | |
452 | 3626 extern Lisp_Object_ptr_dynarr *staticpros; |
3627 | |
771 | 3628 #ifdef DEBUG_XEMACS |
3629 | |
3630 /* Help debug crashes gc-marking a staticpro'ed object. */ | |
3631 | |
2367 | 3632 MODULE_API void staticpro_1 (Lisp_Object *, Ascbyte *); |
3633 MODULE_API void staticpro_nodump_1 (Lisp_Object *, Ascbyte *); | |
771 | 3634 #define staticpro(ptr) staticpro_1 (ptr, #ptr) |
3635 #define staticpro_nodump(ptr) staticpro_nodump_1 (ptr, #ptr) | |
3636 | |
996 | 3637 #ifdef HAVE_SHLIB |
2367 | 3638 MODULE_API void unstaticpro_nodump_1 (Lisp_Object *, Ascbyte *); |
996 | 3639 #define unstaticpro_nodump(ptr) unstaticpro_nodump_1 (ptr, #ptr) |
3640 #endif | |
3641 | |
771 | 3642 #else |
611 | 3643 |
428 | 3644 /* Call staticpro (&var) to protect static variable `var'. */ |
1632 | 3645 MODULE_API void staticpro (Lisp_Object *); |
428 | 3646 |
3647 /* Call staticpro_nodump (&var) to protect static variable `var'. */ | |
3648 /* var will not be saved at dump time */ | |
1632 | 3649 MODULE_API void staticpro_nodump (Lisp_Object *); |
428 | 3650 |
996 | 3651 #ifdef HAVE_SHLIB |
3652 /* Call unstaticpro_nodump (&var) to stop protecting static variable `var'. */ | |
1632 | 3653 MODULE_API void unstaticpro_nodump (Lisp_Object *); |
996 | 3654 #endif |
3655 | |
771 | 3656 #endif |
3657 | |
2720 | 3658 #ifdef MC_ALLOC |
3659 extern Lisp_Object_dynarr *mcpros; | |
3660 #ifdef DEBUG_XEMACS | |
3661 /* Help debug crashes gc-marking a mcpro'ed object. */ | |
3662 MODULE_API void mcpro_1 (Lisp_Object, char *); | |
3663 #define mcpro(ptr) mcpro_1 (ptr, #ptr) | |
3664 #else /* not DEBUG_XEMACS */ | |
3665 /* Call mcpro (&var) to protect mc variable `var'. */ | |
3666 MODULE_API void mcpro (Lisp_Object); | |
3667 #endif /* not DEBUG_XEMACS */ | |
3668 #endif /* MC_ALLOC */ | |
3669 | |
771 | 3670 void register_post_gc_action (void (*fun) (void *), void *arg); |
3671 int begin_gc_forbidden (void); | |
3672 void end_gc_forbidden (int count); | |
1957 | 3673 extern int gc_currently_forbidden; |
771 | 3674 |
1743 | 3675 END_C_DECLS |
1650 | 3676 |
771 | 3677 |
3678 /************************************************************************/ | |
3679 /* Misc definitions */ | |
3680 /************************************************************************/ | |
442 | 3681 |
3682 /************************************************************************/ | |
1983 | 3683 /* Other numeric types */ |
3684 /************************************************************************/ | |
3685 #ifdef WITH_NUMBER_TYPES | |
3686 #include "number.h" | |
1986 | 3687 #else |
3688 #define make_integer(x) make_int(x) | |
1983 | 3689 #endif |
3690 | |
3691 | |
3692 /************************************************************************/ | |
442 | 3693 /* prototypes */ |
3694 /************************************************************************/ | |
3695 | |
3696 /* NOTE: Prototypes should go HERE, not in various header files, unless | |
3697 they specifically reference a type that's not defined in lisp.h. | |
3698 (And even then, you might consider adding the type to lisp.h.) | |
3699 | |
3700 The idea is that header files typically contain the innards of objects, | |
3701 and we want to minimize the number of "dependencies" of one file on | |
3702 the specifics of such objects. Putting prototypes here minimizes the | |
3703 number of header files that need to be included -- good for a number | |
3704 of reasons. --ben */ | |
3705 | |
3706 /*--------------- prototypes for various public c functions ------------*/ | |
3707 | |
3708 /* Prototypes for all init/syms_of/vars_of initialization functions. */ | |
3709 #include "symsinit.h" | |
3710 | |
1743 | 3711 BEGIN_C_DECLS |
1650 | 3712 |
826 | 3713 /* Defined in abbrev.c */ |
1632 | 3714 MODULE_API EXFUN (Fexpand_abbrev, 0); |
826 | 3715 |
428 | 3716 /* Defined in alloc.c */ |
1632 | 3717 MODULE_API EXFUN (Fcons, 2); |
3718 MODULE_API EXFUN (Flist, MANY); | |
826 | 3719 EXFUN (Fmake_byte_code, MANY); |
1632 | 3720 MODULE_API EXFUN (Fmake_list, 2); |
3721 MODULE_API EXFUN (Fmake_string, 2); | |
3722 MODULE_API EXFUN (Fmake_symbol, 1); | |
3723 MODULE_API EXFUN (Fmake_vector, 2); | |
3724 MODULE_API EXFUN (Fvector, MANY); | |
826 | 3725 |
2720 | 3726 #ifndef MC_ALLOC |
428 | 3727 void release_breathing_space (void); |
2720 | 3728 #endif /* not MC_ALLOC */ |
428 | 3729 Lisp_Object noseeum_cons (Lisp_Object, Lisp_Object); |
1632 | 3730 MODULE_API Lisp_Object make_vector (Elemcount, Lisp_Object); |
3731 MODULE_API Lisp_Object vector1 (Lisp_Object); | |
3732 MODULE_API Lisp_Object vector2 (Lisp_Object, Lisp_Object); | |
3733 MODULE_API Lisp_Object vector3 (Lisp_Object, Lisp_Object, Lisp_Object); | |
665 | 3734 Lisp_Object make_bit_vector (Elemcount, Lisp_Object); |
3735 Lisp_Object make_bit_vector_from_byte_vector (unsigned char *, Elemcount); | |
428 | 3736 Lisp_Object noseeum_make_marker (void); |
3737 void garbage_collect_1 (void); | |
1632 | 3738 MODULE_API Lisp_Object acons (Lisp_Object, Lisp_Object, Lisp_Object); |
3739 MODULE_API Lisp_Object cons3 (Lisp_Object, Lisp_Object, Lisp_Object); | |
3740 MODULE_API Lisp_Object list1 (Lisp_Object); | |
3741 MODULE_API Lisp_Object list2 (Lisp_Object, Lisp_Object); | |
3742 MODULE_API Lisp_Object list3 (Lisp_Object, Lisp_Object, Lisp_Object); | |
3743 MODULE_API Lisp_Object list4 (Lisp_Object, Lisp_Object, Lisp_Object, | |
3744 Lisp_Object); | |
3745 MODULE_API Lisp_Object list5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, | |
3746 Lisp_Object); | |
3747 MODULE_API Lisp_Object list6 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, | |
3748 Lisp_Object, Lisp_Object); | |
428 | 3749 DECLARE_DOESNT_RETURN (memory_full (void)); |
3750 void disksave_object_finalization (void); | |
3751 extern int purify_flag; | |
3752 extern EMACS_INT gc_generation_number[1]; | |
3753 int c_readonly (Lisp_Object); | |
3754 int lisp_readonly (Lisp_Object); | |
1632 | 3755 MODULE_API void copy_lisp_object (Lisp_Object dst, Lisp_Object src); |
3756 MODULE_API Lisp_Object build_intstring (const Ibyte *); | |
3757 MODULE_API Lisp_Object build_string (const CIbyte *); | |
3758 MODULE_API Lisp_Object build_ext_string (const Extbyte *, Lisp_Object); | |
3759 MODULE_API Lisp_Object build_msg_intstring (const Ibyte *); | |
3760 MODULE_API Lisp_Object build_msg_string (const CIbyte *); | |
3761 MODULE_API Lisp_Object make_string (const Ibyte *, Bytecount); | |
3762 MODULE_API Lisp_Object make_ext_string (const Extbyte *, EMACS_INT, Lisp_Object); | |
771 | 3763 void init_string_ascii_begin (Lisp_Object string); |
428 | 3764 Lisp_Object make_uninit_string (Bytecount); |
1632 | 3765 MODULE_API Lisp_Object make_float (double); |
867 | 3766 Lisp_Object make_string_nocopy (const Ibyte *, Bytecount); |
853 | 3767 void free_cons (Lisp_Object); |
428 | 3768 void free_list (Lisp_Object); |
3769 void free_alist (Lisp_Object); | |
1204 | 3770 void free_marker (Lisp_Object); |
428 | 3771 int object_dead_p (Lisp_Object); |
3772 void mark_object (Lisp_Object obj); | |
1598 | 3773 #ifdef USE_KKCC |
2645 | 3774 #ifdef DEBUG_XEMACS |
3775 void kkcc_gc_stack_push_lisp_object_1 (Lisp_Object obj, int level, int pos); | |
3776 #define kkcc_gc_stack_push_lisp_object(obj, level, pos) \ | |
3777 kkcc_gc_stack_push_lisp_object_1 (obj, level, pos) | |
3778 void kkcc_backtrace (void); | |
3779 #else | |
3780 void kkcc_gc_stack_push_lisp_object_1 (Lisp_Object obj); | |
3781 #define kkcc_gc_stack_push_lisp_object(obj, level, pos) \ | |
3782 kkcc_gc_stack_push_lisp_object_1 (obj) | |
3783 #define kkcc_backtrace() | |
3784 #endif | |
1598 | 3785 #endif /* USE_KKCC */ |
428 | 3786 int marked_p (Lisp_Object obj); |
851 | 3787 extern int funcall_allocation_flag; |
814 | 3788 extern int need_to_garbage_collect; |
1632 | 3789 extern MODULE_API int need_to_check_c_alloca; |
888 | 3790 extern int need_to_signal_post_gc; |
1333 | 3791 extern Lisp_Object Qpost_gc_hook, Qgarbage_collecting; |
851 | 3792 void recompute_funcall_allocation_flag (void); |
428 | 3793 |
3794 #ifdef MEMORY_USAGE_STATS | |
665 | 3795 Bytecount malloced_storage_size (void *, Bytecount, struct overhead_stats *); |
3796 Bytecount fixed_type_block_overhead (Bytecount); | |
428 | 3797 #endif |
1204 | 3798 |
3799 #ifdef EVENT_DATA_AS_OBJECTS | |
3800 Lisp_Object make_key_data (void); | |
3801 Lisp_Object make_button_data (void); | |
3802 Lisp_Object make_motion_data (void); | |
3803 Lisp_Object make_process_data (void); | |
3804 Lisp_Object make_timeout_data (void); | |
3805 Lisp_Object make_magic_data (void); | |
3806 Lisp_Object make_magic_eval_data (void); | |
3807 Lisp_Object make_eval_data (void); | |
3808 Lisp_Object make_misc_user_data (void); | |
3809 void free_key_data (Lisp_Object); | |
3810 void free_button_data (Lisp_Object); | |
3811 void free_motion_data (Lisp_Object); | |
3812 void free_process_data (Lisp_Object); | |
3813 void free_timeout_data (Lisp_Object); | |
3814 void free_magic_data (Lisp_Object); | |
3815 void free_magic_eval_data (Lisp_Object); | |
3816 void free_eval_data (Lisp_Object); | |
3817 void free_misc_user_data (Lisp_Object); | |
3818 #endif /* EVENT_DATA_AS_OBJECTS */ | |
934 | 3819 |
428 | 3820 /* Defined in buffer.c */ |
3821 Lisp_Object get_truename_buffer (Lisp_Object); | |
3822 void switch_to_buffer (Lisp_Object, Lisp_Object); | |
3823 extern int find_file_compare_truenames; | |
3824 extern int find_file_use_truenames; | |
867 | 3825 Ibyte *get_initial_directory (Ibyte *pathname, Bytecount size); |
771 | 3826 void set_buffer_internal (struct buffer *b); |
3827 struct buffer *decode_buffer (Lisp_Object buffer, int allow_string); | |
3828 | |
3829 void record_buffer (Lisp_Object buf); | |
3830 Lisp_Object get_buffer (Lisp_Object name, | |
3831 int error_if_deleted_or_does_not_exist); | |
3832 int map_over_sharing_buffers (struct buffer *buf, | |
3833 int (*mapfun) (struct buffer *buf, | |
3834 void *closure), | |
3835 void *closure); | |
1204 | 3836 void cleanup_buffer_undo_lists (void); |
771 | 3837 |
3838 extern struct buffer *current_buffer; | |
3839 | |
3840 extern void init_initial_directory (void); /* initialize initial_directory */ | |
3841 | |
3842 EXFUN (Fbuffer_disable_undo, 1); | |
1632 | 3843 MODULE_API EXFUN (Fbuffer_modified_p, 1); |
3844 MODULE_API EXFUN (Fbuffer_name, 1); | |
3845 MODULE_API EXFUN (Fcurrent_buffer, 0); | |
771 | 3846 EXFUN (Ferase_buffer, 1); |
3847 EXFUN (Fget_buffer, 1); | |
3848 EXFUN (Fget_buffer_create, 1); | |
3849 EXFUN (Fget_file_buffer, 1); | |
1632 | 3850 MODULE_API EXFUN (Fkill_buffer, 1); |
771 | 3851 EXFUN (Fother_buffer, 3); |
3852 EXFUN (Frecord_buffer, 1); | |
1632 | 3853 MODULE_API EXFUN (Fset_buffer, 1); |
771 | 3854 EXFUN (Fset_buffer_modified_p, 2); |
3855 | |
3856 extern Lisp_Object QSscratch, Qafter_change_function, Qafter_change_functions; | |
3857 extern Lisp_Object Qbefore_change_function, Qbefore_change_functions; | |
3858 extern Lisp_Object Qbuffer_or_string_p, Qdefault_directory, Qfirst_change_hook; | |
3859 extern Lisp_Object Qpermanent_local, Vafter_change_function; | |
3860 extern Lisp_Object Vafter_change_functions, Vbefore_change_function; | |
3861 extern Lisp_Object Vbefore_change_functions, Vbuffer_alist, Vbuffer_defaults; | |
3862 extern Lisp_Object Vinhibit_read_only, Vtransient_mark_mode; | |
428 | 3863 |
563 | 3864 /* Defined in bytecode.c */ |
826 | 3865 EXFUN (Fbyte_code, 3); |
3866 | |
593 | 3867 DECLARE_DOESNT_RETURN (invalid_byte_code |
867 | 3868 (const CIbyte *reason, Lisp_Object frob)); |
563 | 3869 |
826 | 3870 /* Defined in callint.c */ |
3871 EXFUN (Fcall_interactively, 3); | |
3872 EXFUN (Fprefix_numeric_value, 1); | |
3873 | |
3874 /* Defined in casefiddle.c */ | |
3875 EXFUN (Fdowncase, 2); | |
3876 EXFUN (Fupcase, 2); | |
3877 EXFUN (Fupcase_initials, 2); | |
3878 EXFUN (Fupcase_initials_region, 3); | |
3879 EXFUN (Fupcase_region, 3); | |
3880 | |
3881 /* Defined in casetab.c */ | |
3882 EXFUN (Fset_standard_case_table, 1); | |
3883 | |
3884 /* Defined in chartab.c */ | |
3885 EXFUN (Freset_char_table, 1); | |
3886 | |
3887 /* Defined in cmds.c */ | |
3888 EXFUN (Fbeginning_of_line, 2); | |
3889 EXFUN (Fend_of_line, 2); | |
3890 EXFUN (Fforward_char, 2); | |
3891 EXFUN (Fforward_line, 2); | |
3892 | |
428 | 3893 /* Defined in data.c */ |
826 | 3894 EXFUN (Fadd1, 1); |
3895 EXFUN (Faref, 2); | |
3896 EXFUN (Faset, 3); | |
3897 EXFUN (Fcar, 1); | |
3898 EXFUN (Fcar_safe, 1); | |
3899 EXFUN (Fcdr, 1); | |
919 | 3900 EXFUN (Fcdr_safe, 1); |
826 | 3901 EXFUN (Fgeq, MANY); |
3902 EXFUN (Fgtr, MANY); | |
3903 EXFUN (Findirect_function, 1); | |
3904 EXFUN (Fleq, MANY); | |
3905 EXFUN (Flistp, 1); | |
3906 EXFUN (Flss, MANY); | |
3907 EXFUN (Fmax, MANY); | |
3908 EXFUN (Fmin, MANY); | |
3909 EXFUN (Fminus, MANY); | |
3910 EXFUN (Fnumber_to_string, 1); | |
3911 EXFUN (Fplus, MANY); | |
3912 EXFUN (Fquo, MANY); | |
3913 EXFUN (Frem, 2); | |
3914 EXFUN (Fsetcar, 2); | |
3915 EXFUN (Fsetcdr, 2); | |
3916 EXFUN (Fsub1, 1); | |
3917 EXFUN (Fsubr_max_args, 1); | |
3918 EXFUN (Fsubr_min_args, 1); | |
3919 EXFUN (Ftimes, MANY); | |
3920 | |
428 | 3921 DECLARE_DOESNT_RETURN (c_write_error (Lisp_Object)); |
3922 DECLARE_DOESNT_RETURN (lisp_write_error (Lisp_Object)); | |
3923 DECLARE_DOESNT_RETURN (args_out_of_range (Lisp_Object, Lisp_Object)); | |
3924 DECLARE_DOESNT_RETURN (args_out_of_range_3 (Lisp_Object, Lisp_Object, | |
3925 Lisp_Object)); | |
1632 | 3926 MODULE_API Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object); |
3927 MODULE_API | |
428 | 3928 DECLARE_DOESNT_RETURN (dead_wrong_type_argument (Lisp_Object, Lisp_Object)); |
3929 void check_int_range (EMACS_INT, EMACS_INT, EMACS_INT); | |
3930 | |
771 | 3931 EXFUN (Fint_to_char, 1); |
3932 EXFUN (Fchar_to_int, 1); | |
3933 | |
428 | 3934 enum arith_comparison { |
3935 arith_equal, | |
3936 arith_notequal, | |
3937 arith_less, | |
3938 arith_grtr, | |
3939 arith_less_or_equal, | |
3940 arith_grtr_or_equal }; | |
3941 Lisp_Object arithcompare (Lisp_Object, Lisp_Object, enum arith_comparison); | |
3942 | |
707 | 3943 /* Do NOT use word_to_lisp or wasteful_word_to_lisp to decode time_t's |
3944 unless you KNOW arg is non-negative. They cannot return negative | |
3945 values! Use make_time. */ | |
428 | 3946 Lisp_Object word_to_lisp (unsigned int); |
3947 unsigned int lisp_to_word (Lisp_Object); | |
3948 | |
3949 /* Defined in dired.c */ | |
867 | 3950 Lisp_Object make_directory_hash_table (const Ibyte *); |
428 | 3951 Lisp_Object wasteful_word_to_lisp (unsigned int); |
3952 | |
3953 /* Defined in doc.c */ | |
826 | 3954 EXFUN (Fsubstitute_command_keys, 1); |
3955 | |
814 | 3956 Lisp_Object unparesseuxify_doc_string (int fd, EMACS_INT position, |
867 | 3957 Ibyte *name_nonreloc, |
814 | 3958 Lisp_Object name_reloc, |
3959 int standard_doc_file); | |
428 | 3960 Lisp_Object read_doc_string (Lisp_Object); |
3961 | |
3962 /* Defined in doprnt.c */ | |
867 | 3963 Bytecount emacs_doprnt_va (Lisp_Object stream, const Ibyte *format_nonreloc, |
771 | 3964 Bytecount format_length, Lisp_Object format_reloc, |
3965 va_list vargs); | |
867 | 3966 Bytecount emacs_doprnt (Lisp_Object stream, const Ibyte *format_nonreloc, |
771 | 3967 Bytecount format_length, Lisp_Object format_reloc, |
3968 int nargs, const Lisp_Object *largs, ...); | |
867 | 3969 Lisp_Object emacs_vsprintf_string_lisp (const CIbyte *format_nonreloc, |
771 | 3970 Lisp_Object format_reloc, int nargs, |
3971 const Lisp_Object *largs); | |
867 | 3972 Lisp_Object emacs_sprintf_string_lisp (const CIbyte *format_nonreloc, |
771 | 3973 Lisp_Object format_reloc, int nargs, ...); |
867 | 3974 Ibyte *emacs_vsprintf_malloc_lisp (const CIbyte *format_nonreloc, |
771 | 3975 Lisp_Object format_reloc, int nargs, |
3976 const Lisp_Object *largs, | |
3977 Bytecount *len_out); | |
867 | 3978 Ibyte *emacs_sprintf_malloc_lisp (Bytecount *len_out, |
3979 const CIbyte *format_nonreloc, | |
771 | 3980 Lisp_Object format_reloc, int nargs, ...); |
867 | 3981 Lisp_Object emacs_vsprintf_string (const CIbyte *format, va_list vargs); |
3982 Lisp_Object emacs_sprintf_string (const CIbyte *format, ...) | |
771 | 3983 PRINTF_ARGS (1, 2); |
867 | 3984 Ibyte *emacs_vsprintf_malloc (const CIbyte *format, va_list vargs, |
771 | 3985 Bytecount *len_out); |
867 | 3986 Ibyte *emacs_sprintf_malloc (Bytecount *len_out, const CIbyte *format, ...) |
771 | 3987 PRINTF_ARGS (2, 3); |
867 | 3988 Bytecount emacs_vsprintf (Ibyte *output, const CIbyte *format, |
771 | 3989 va_list vargs); |
867 | 3990 Bytecount emacs_sprintf (Ibyte *output, const CIbyte *format, ...) |
771 | 3991 PRINTF_ARGS (2, 3); |
3992 | |
428 | 3993 |
3994 /* Defined in editfns.c */ | |
826 | 3995 EXFUN (Fbobp, 1); |
3996 EXFUN (Fbolp, 1); | |
3997 EXFUN (Fbuffer_substring, 3); | |
3998 EXFUN (Fchar_after, 2); | |
3999 EXFUN (Fchar_to_string, 1); | |
4000 EXFUN (Fdelete_region, 3); | |
4001 EXFUN (Feobp, 1); | |
4002 EXFUN (Feolp, 1); | |
4003 EXFUN (Ffollowing_char, 1); | |
4004 EXFUN (Fformat, MANY); | |
4005 EXFUN (Fgoto_char, 2); | |
4006 EXFUN (Finsert, MANY); | |
4007 EXFUN (Finsert_buffer_substring, 3); | |
4008 EXFUN (Finsert_char, 4); | |
4009 EXFUN (Fnarrow_to_region, 3); | |
4010 EXFUN (Fpoint, 1); | |
4011 EXFUN (Fpoint_marker, 2); | |
4012 EXFUN (Fpoint_max, 1); | |
4013 EXFUN (Fpoint_min, 1); | |
4014 EXFUN (Fpreceding_char, 1); | |
4015 EXFUN (Fsystem_name, 0); | |
4016 EXFUN (Fuser_home_directory, 0); | |
4017 EXFUN (Fuser_login_name, 1); | |
4018 EXFUN (Fwiden, 1); | |
4019 | |
428 | 4020 void uncache_home_directory (void); |
867 | 4021 Ibyte *get_home_directory (void); |
4022 Ibyte *user_login_name (uid_t *); | |
428 | 4023 void buffer_insert1 (struct buffer *, Lisp_Object); |
665 | 4024 Lisp_Object make_string_from_buffer (struct buffer *, Charbpos, Charcount); |
4025 Lisp_Object make_string_from_buffer_no_extents (struct buffer *, Charbpos, Charcount); | |
707 | 4026 Lisp_Object make_time (time_t); |
428 | 4027 Lisp_Object save_excursion_save (void); |
844 | 4028 Lisp_Object save_restriction_save (struct buffer *buf); |
428 | 4029 Lisp_Object save_excursion_restore (Lisp_Object); |
4030 Lisp_Object save_restriction_restore (Lisp_Object); | |
771 | 4031 void widen_buffer (struct buffer *b, int no_clip); |
4032 int beginning_of_line_p (struct buffer *b, Charbpos pt); | |
428 | 4033 |
4034 /* Defined in emacsfns.c */ | |
4035 Lisp_Object save_current_buffer_restore (Lisp_Object); | |
4036 | |
4037 /* Defined in emacs.c */ | |
2268 | 4038 EXFUN_NORETURN (Fkill_emacs, 1); |
826 | 4039 EXFUN (Frunning_temacs_p, 0); |
1123 | 4040 EXFUN (Fforce_debugging_signal, 1); |
826 | 4041 |
428 | 4042 SIGTYPE fatal_error_signal (int); |
2367 | 4043 Lisp_Object make_arg_list (int, Wexttext **); |
4044 void make_argc_argv (Lisp_Object, int *, Wexttext ***); | |
4045 void free_argc_argv (Wexttext **); | |
771 | 4046 Lisp_Object split_external_path (const Extbyte *path); |
867 | 4047 Lisp_Object split_env_path (const CIbyte *evarname, const Ibyte *default_); |
771 | 4048 |
428 | 4049 /* Nonzero means don't do interactive redisplay and don't change tty modes */ |
442 | 4050 extern int noninteractive, noninteractive1; |
2367 | 4051 extern int inhibit_non_essential_conversion_operations; |
428 | 4052 extern int preparing_for_armageddon; |
458 | 4053 extern Fixnum emacs_priority; |
428 | 4054 extern int suppress_early_error_handler_backtrace; |
771 | 4055 void debug_break (void); |
4056 int debug_can_access_memory (void *ptr, Bytecount len); | |
2210 | 4057 DECLARE_DOESNT_RETURN (really_abort (void)); |
776 | 4058 void zero_out_command_line_status_vars (void); |
428 | 4059 |
826 | 4060 /* Defined in emodules.c */ |
996 | 4061 #ifdef HAVE_SHLIB |
826 | 4062 EXFUN (Flist_modules, 0); |
4063 EXFUN (Fload_module, 3); | |
996 | 4064 extern int unloading_module; |
4065 #endif | |
826 | 4066 |
428 | 4067 /* Defined in eval.c */ |
1706 | 4068 MODULE_API EXFUN (Fapply, MANY); |
826 | 4069 EXFUN (Fbacktrace, 2); |
4070 EXFUN (Fcommand_execute, 3); | |
4071 EXFUN (Fcommandp, 1); | |
1706 | 4072 MODULE_API EXFUN (Feval, 1); |
4073 MODULE_API EXFUN (Ffuncall, MANY); | |
826 | 4074 EXFUN (Ffunctionp, 1); |
4075 EXFUN (Finteractive_p, 0); | |
4076 EXFUN (Fprogn, UNEVALLED); | |
1706 | 4077 MODULE_API EXFUN (Fsignal, 2); |
2268 | 4078 MODULE_API EXFUN_NORETURN (Fthrow, 2); |
1706 | 4079 MODULE_API EXFUN (Fcall_with_condition_handler, MANY); |
853 | 4080 EXFUN (Ffunction_max_args, 1); |
4081 EXFUN (Ffunction_min_args, 1); | |
826 | 4082 |
1632 | 4083 MODULE_API DECLARE_DOESNT_RETURN (signal_error_1 (Lisp_Object, Lisp_Object)); |
563 | 4084 void maybe_signal_error_1 (Lisp_Object, Lisp_Object, Lisp_Object, |
578 | 4085 Error_Behavior); |
563 | 4086 Lisp_Object maybe_signal_continuable_error_1 (Lisp_Object, Lisp_Object, |
578 | 4087 Lisp_Object, Error_Behavior); |
1743 | 4088 MODULE_API DECLARE_DOESNT_RETURN (signal_ferror (Lisp_Object, const CIbyte *, |
4089 ...)) PRINTF_ARGS(2, 3); | |
578 | 4090 void maybe_signal_ferror (Lisp_Object, Lisp_Object, Error_Behavior, |
867 | 4091 const CIbyte *, ...) PRINTF_ARGS (4, 5); |
4092 Lisp_Object signal_continuable_ferror (Lisp_Object, const CIbyte *, ...) | |
442 | 4093 PRINTF_ARGS (2, 3); |
563 | 4094 Lisp_Object maybe_signal_continuable_ferror (Lisp_Object, Lisp_Object, |
578 | 4095 Error_Behavior, |
867 | 4096 const CIbyte *, ...) |
442 | 4097 PRINTF_ARGS (4, 5); |
563 | 4098 |
867 | 4099 Lisp_Object build_error_data (const CIbyte *reason, Lisp_Object frob); |
4100 DECLARE_DOESNT_RETURN (signal_error (Lisp_Object, const CIbyte *, | |
563 | 4101 Lisp_Object)); |
867 | 4102 void maybe_signal_error (Lisp_Object, const CIbyte *, Lisp_Object, |
578 | 4103 Lisp_Object, Error_Behavior); |
867 | 4104 Lisp_Object signal_continuable_error (Lisp_Object, const CIbyte *, |
563 | 4105 Lisp_Object); |
867 | 4106 Lisp_Object maybe_signal_continuable_error (Lisp_Object, const CIbyte *, |
563 | 4107 Lisp_Object, |
578 | 4108 Lisp_Object, Error_Behavior); |
1743 | 4109 DECLARE_DOESNT_RETURN (signal_ferror_with_frob (Lisp_Object, Lisp_Object, |
4110 const CIbyte *, ...)) | |
4111 PRINTF_ARGS(3, 4); | |
563 | 4112 void maybe_signal_ferror_with_frob (Lisp_Object, Lisp_Object, Lisp_Object, |
578 | 4113 Error_Behavior, |
867 | 4114 const CIbyte *, ...) PRINTF_ARGS (5, 6); |
563 | 4115 Lisp_Object signal_continuable_ferror_with_frob (Lisp_Object, Lisp_Object, |
867 | 4116 const CIbyte *, |
563 | 4117 ...) PRINTF_ARGS (3, 4); |
4118 Lisp_Object maybe_signal_continuable_ferror_with_frob (Lisp_Object, | |
4119 Lisp_Object, | |
4120 Lisp_Object, | |
578 | 4121 Error_Behavior, |
867 | 4122 const CIbyte *, ...) |
442 | 4123 PRINTF_ARGS (5, 6); |
867 | 4124 DECLARE_DOESNT_RETURN (signal_error_2 (Lisp_Object, const CIbyte *, |
563 | 4125 Lisp_Object, Lisp_Object)); |
867 | 4126 void maybe_signal_error_2 (Lisp_Object, const CIbyte *, Lisp_Object, |
578 | 4127 Lisp_Object, Lisp_Object, Error_Behavior); |
867 | 4128 Lisp_Object signal_continuable_error_2 (Lisp_Object, const CIbyte *, |
563 | 4129 Lisp_Object, Lisp_Object); |
867 | 4130 Lisp_Object maybe_signal_continuable_error_2 (Lisp_Object, const CIbyte *, |
563 | 4131 Lisp_Object, Lisp_Object, |
4132 Lisp_Object, | |
578 | 4133 Error_Behavior); |
563 | 4134 |
4135 | |
1927 | 4136 MODULE_API DECLARE_DOESNT_RETURN (signal_malformed_list_error (Lisp_Object)); |
4137 MODULE_API DECLARE_DOESNT_RETURN (signal_malformed_property_list_error | |
4138 (Lisp_Object)); | |
4139 MODULE_API DECLARE_DOESNT_RETURN (signal_circular_list_error (Lisp_Object)); | |
4140 MODULE_API DECLARE_DOESNT_RETURN (signal_circular_property_list_error | |
4141 (Lisp_Object)); | |
436 | 4142 |
867 | 4143 DECLARE_DOESNT_RETURN (syntax_error (const CIbyte *reason, |
609 | 4144 Lisp_Object frob)); |
867 | 4145 DECLARE_DOESNT_RETURN (syntax_error_2 (const CIbyte *reason, |
609 | 4146 Lisp_Object frob1, |
442 | 4147 Lisp_Object frob2)); |
867 | 4148 void maybe_syntax_error (const CIbyte *, Lisp_Object, Lisp_Object, |
578 | 4149 Error_Behavior); |
867 | 4150 DECLARE_DOESNT_RETURN (sferror (const CIbyte *reason, Lisp_Object frob)); |
4151 DECLARE_DOESNT_RETURN (sferror_2 (const CIbyte *reason, Lisp_Object frob1, | |
563 | 4152 Lisp_Object frob2)); |
867 | 4153 void maybe_sferror (const CIbyte *, Lisp_Object, Lisp_Object, |
578 | 4154 Error_Behavior); |
1632 | 4155 MODULE_API DECLARE_DOESNT_RETURN (invalid_argument (const CIbyte *reason, |
4156 Lisp_Object frob)); | |
4157 MODULE_API DECLARE_DOESNT_RETURN (invalid_argument_2 (const CIbyte *reason, | |
4158 Lisp_Object frob1, | |
4159 Lisp_Object frob2)); | |
867 | 4160 void maybe_invalid_argument (const CIbyte *, Lisp_Object, Lisp_Object, |
578 | 4161 Error_Behavior); |
1632 | 4162 MODULE_API DECLARE_DOESNT_RETURN (invalid_operation (const CIbyte *reason, |
4163 Lisp_Object frob)); | |
4164 MODULE_API DECLARE_DOESNT_RETURN (invalid_operation_2 (const CIbyte *reason, | |
4165 Lisp_Object frob1, | |
4166 Lisp_Object frob2)); | |
4167 MODULE_API void maybe_invalid_operation (const CIbyte *, Lisp_Object, | |
4168 Lisp_Object, Error_Behavior); | |
867 | 4169 DECLARE_DOESNT_RETURN (invalid_state (const CIbyte *reason, |
563 | 4170 Lisp_Object frob)); |
867 | 4171 DECLARE_DOESNT_RETURN (invalid_state_2 (const CIbyte *reason, |
563 | 4172 Lisp_Object frob1, |
4173 Lisp_Object frob2)); | |
867 | 4174 void maybe_invalid_state (const CIbyte *, Lisp_Object, Lisp_Object, |
609 | 4175 Error_Behavior); |
867 | 4176 DECLARE_DOESNT_RETURN (invalid_change (const CIbyte *reason, |
563 | 4177 Lisp_Object frob)); |
867 | 4178 DECLARE_DOESNT_RETURN (invalid_change_2 (const CIbyte *reason, |
563 | 4179 Lisp_Object frob1, |
4180 Lisp_Object frob2)); | |
867 | 4181 void maybe_invalid_change (const CIbyte *, Lisp_Object, Lisp_Object, |
609 | 4182 Error_Behavior); |
1632 | 4183 MODULE_API DECLARE_DOESNT_RETURN (invalid_constant (const CIbyte *reason, |
4184 Lisp_Object frob)); | |
867 | 4185 DECLARE_DOESNT_RETURN (invalid_constant_2 (const CIbyte *reason, |
563 | 4186 Lisp_Object frob1, |
4187 Lisp_Object frob2)); | |
867 | 4188 void maybe_invalid_constant (const CIbyte *, Lisp_Object, Lisp_Object, |
578 | 4189 Error_Behavior); |
867 | 4190 DECLARE_DOESNT_RETURN (wtaerror (const CIbyte *reason, Lisp_Object frob)); |
1632 | 4191 MODULE_API DECLARE_DOESNT_RETURN (out_of_memory (const CIbyte *reason, |
4192 Lisp_Object frob)); | |
867 | 4193 DECLARE_DOESNT_RETURN (stack_overflow (const CIbyte *reason, |
442 | 4194 Lisp_Object frob)); |
1743 | 4195 MODULE_API DECLARE_DOESNT_RETURN (printing_unreadable_object (const CIbyte *, |
4196 ...)) | |
4197 PRINTF_ARGS (1, 2); | |
442 | 4198 |
436 | 4199 Lisp_Object signal_void_function_error (Lisp_Object); |
4200 Lisp_Object signal_invalid_function_error (Lisp_Object); | |
4201 Lisp_Object signal_wrong_number_of_arguments_error (Lisp_Object, int); | |
4202 | |
428 | 4203 Lisp_Object run_hook_with_args_in_buffer (struct buffer *, int, Lisp_Object *, |
4204 enum run_hooks_condition); | |
4205 Lisp_Object run_hook_with_args (int, Lisp_Object *, enum run_hooks_condition); | |
4206 void va_run_hook_with_args (Lisp_Object, int, ...); | |
4207 void va_run_hook_with_args_in_buffer (struct buffer *, Lisp_Object, int, ...); | |
4208 Lisp_Object run_hook (Lisp_Object); | |
1706 | 4209 MODULE_API Lisp_Object apply1 (Lisp_Object, Lisp_Object); |
4210 MODULE_API Lisp_Object call0 (Lisp_Object); | |
4211 MODULE_API Lisp_Object call1 (Lisp_Object, Lisp_Object); | |
4212 MODULE_API Lisp_Object call2 (Lisp_Object, Lisp_Object, Lisp_Object); | |
4213 MODULE_API Lisp_Object call3 (Lisp_Object, Lisp_Object, Lisp_Object, | |
4214 Lisp_Object); | |
4215 MODULE_API Lisp_Object call4 (Lisp_Object, Lisp_Object, Lisp_Object, | |
4216 Lisp_Object, Lisp_Object); | |
4217 MODULE_API Lisp_Object call5 (Lisp_Object, Lisp_Object, Lisp_Object, | |
4218 Lisp_Object, Lisp_Object, Lisp_Object); | |
4219 MODULE_API Lisp_Object call6 (Lisp_Object, Lisp_Object, Lisp_Object, | |
4220 Lisp_Object, Lisp_Object, Lisp_Object, | |
4221 Lisp_Object); | |
4222 MODULE_API Lisp_Object call7 (Lisp_Object, Lisp_Object, Lisp_Object, | |
4223 Lisp_Object, Lisp_Object, Lisp_Object, | |
4224 Lisp_Object, Lisp_Object); | |
4225 MODULE_API Lisp_Object call8 (Lisp_Object, Lisp_Object, Lisp_Object, | |
4226 Lisp_Object, Lisp_Object, Lisp_Object, | |
4227 Lisp_Object, Lisp_Object, Lisp_Object); | |
428 | 4228 Lisp_Object call0_in_buffer (struct buffer *, Lisp_Object); |
4229 Lisp_Object call1_in_buffer (struct buffer *, Lisp_Object, Lisp_Object); | |
4230 Lisp_Object call2_in_buffer (struct buffer *, Lisp_Object, Lisp_Object, | |
4231 Lisp_Object); | |
4232 Lisp_Object call3_in_buffer (struct buffer *, Lisp_Object, Lisp_Object, | |
4233 Lisp_Object, Lisp_Object); | |
4234 Lisp_Object call4_in_buffer (struct buffer *, Lisp_Object, Lisp_Object, | |
4235 Lisp_Object, Lisp_Object, Lisp_Object); | |
4236 Lisp_Object call5_in_buffer (struct buffer *, Lisp_Object, Lisp_Object, | |
4237 Lisp_Object, Lisp_Object, Lisp_Object, | |
4238 Lisp_Object); | |
4239 Lisp_Object call6_in_buffer (struct buffer *, Lisp_Object, Lisp_Object, | |
4240 Lisp_Object, Lisp_Object, Lisp_Object, | |
4241 Lisp_Object, Lisp_Object); | |
4242 Lisp_Object eval_in_buffer (struct buffer *, Lisp_Object); | |
853 | 4243 |
4244 struct call_trapping_problems_result | |
4245 { | |
4246 int caught_error, caught_throw; | |
4247 Lisp_Object error_conditions, data; | |
4248 Lisp_Object backtrace; | |
4249 Lisp_Object thrown_tag; | |
4250 Lisp_Object thrown_value; | |
4251 }; | |
4252 | |
4253 #define NO_INHIBIT_ERRORS (1<<0) | |
4254 #define NO_INHIBIT_THROWS (1<<1) | |
4255 #define INTERNAL_INHIBIT_ERRORS (1<<0) | |
4256 #define INTERNAL_INHIBIT_THROWS (1<<1) | |
4257 #define INHIBIT_WARNING_ISSUE (1<<2) | |
4258 #define ISSUE_WARNINGS_AT_DEBUG_LEVEL (1<<3) | |
4259 #define INHIBIT_QUIT (1<<4) | |
4260 #define UNINHIBIT_QUIT (1<<5) | |
4261 #define INHIBIT_GC (1<<6) | |
4262 #define INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION (1<<7) | |
4263 #define INHIBIT_EXISTING_CODING_SYSTEM_DELETION (1<<8) | |
4264 #define INHIBIT_EXISTING_CHARSET_DELETION (1<<9) | |
4265 #define INHIBIT_PERMANENT_DISPLAY_OBJECT_CREATION (1<<10) | |
4266 #define INHIBIT_CODING_SYSTEM_CREATION (1<<11) | |
4267 #define INHIBIT_CHARSET_CREATION (1<<12) | |
4268 #define INHIBIT_EXISTING_BUFFER_TEXT_MODIFICATION (1<<13) | |
4269 #define INHIBIT_ANY_CHANGE_AFFECTING_REDISPLAY (1<<14) | |
4270 #define INHIBIT_ENTERING_DEBUGGER (1<<15) | |
4271 #define CALL_WITH_SUSPENDED_ERRORS (1<<16) | |
1333 | 4272 #define POSTPONE_WARNING_ISSUE (1<<17) |
853 | 4273 |
4274 enum check_allowed_operation | |
4275 { | |
4276 OPERATION_DELETE_OBJECT, | |
4277 OPERATION_CREATE_OBJECT, | |
4278 OPERATION_MODIFY_BUFFER_TEXT, | |
1429 | 4279 OPERATION_MODIFY_OBJECT_PROPERTY |
853 | 4280 }; |
4281 | |
4282 int get_inhibit_flags (void); | |
4283 void check_allowed_operation (int what, Lisp_Object obj, Lisp_Object prop); | |
4284 void note_object_created (Lisp_Object obj); | |
4285 void note_object_deleted (Lisp_Object obj); | |
4286 Lisp_Object call_with_condition_handler (Lisp_Object (*handler) (Lisp_Object, | |
4287 Lisp_Object, | |
4288 Lisp_Object), | |
4289 Lisp_Object handler_arg, | |
4290 Lisp_Object (*fun) (Lisp_Object), | |
4291 Lisp_Object arg); | |
1318 | 4292 int set_trapping_problems_flags (int flags); |
853 | 4293 Lisp_Object call_trapping_problems (Lisp_Object warning_class, |
2367 | 4294 const Ascbyte *warning_string, |
853 | 4295 int flags, |
4296 struct call_trapping_problems_result | |
4297 *problem, | |
4298 Lisp_Object (*fun) (void *), | |
4299 void *arg); | |
4300 Lisp_Object va_call_trapping_problems (Lisp_Object warning_class, | |
2367 | 4301 const Ascbyte *warning_string, |
853 | 4302 int flags, |
4303 struct call_trapping_problems_result | |
4304 *problem, | |
4305 lisp_fn_t fun, int nargs, ...); | |
2367 | 4306 Lisp_Object call0_trapping_problems (const Ascbyte *, Lisp_Object, int); |
4307 Lisp_Object call1_trapping_problems (const Ascbyte *, Lisp_Object, Lisp_Object, | |
853 | 4308 int); |
2367 | 4309 Lisp_Object call2_trapping_problems (const Ascbyte *, Lisp_Object, Lisp_Object, |
853 | 4310 Lisp_Object, int); |
2367 | 4311 Lisp_Object call3_trapping_problems (const Ascbyte *, Lisp_Object, Lisp_Object, |
853 | 4312 Lisp_Object, Lisp_Object, int); |
2367 | 4313 Lisp_Object call4_trapping_problems (const Ascbyte *, Lisp_Object, Lisp_Object, |
853 | 4314 Lisp_Object, Lisp_Object, Lisp_Object, |
4315 int); | |
2367 | 4316 Lisp_Object call5_trapping_problems (const Ascbyte *, Lisp_Object, Lisp_Object, |
853 | 4317 Lisp_Object, Lisp_Object, Lisp_Object, |
4318 Lisp_Object, int); | |
2367 | 4319 Lisp_Object eval_in_buffer_trapping_problems (const Ascbyte *, struct buffer *, |
853 | 4320 Lisp_Object, int); |
1333 | 4321 Lisp_Object run_hook_trapping_problems (Lisp_Object, Lisp_Object, int); |
4322 Lisp_Object safe_run_hook_trapping_problems (Lisp_Object, Lisp_Object, int); | |
4323 Lisp_Object run_hook_with_args_in_buffer_trapping_problems (Lisp_Object, | |
4324 struct buffer *, | |
4325 int nargs, | |
853 | 4326 Lisp_Object *args, |
4327 enum | |
4328 run_hooks_condition | |
4329 cond, int flags); | |
1333 | 4330 Lisp_Object run_hook_with_args_trapping_problems (Lisp_Object, |
853 | 4331 int nargs, |
4332 Lisp_Object *args, | |
4333 enum run_hooks_condition | |
4334 cond, | |
4335 int flags); | |
1333 | 4336 Lisp_Object va_run_hook_with_args_trapping_problems (Lisp_Object, |
853 | 4337 Lisp_Object hook_var, |
4338 int nargs, ...); | |
1333 | 4339 Lisp_Object va_run_hook_with_args_in_buffer_trapping_problems (Lisp_Object, |
4340 struct buffer *, | |
4341 Lisp_Object, | |
853 | 4342 int nargs, ...); |
4343 Lisp_Object call_with_suspended_errors (lisp_fn_t, Lisp_Object, | |
4344 Lisp_Object, | |
578 | 4345 Error_Behavior, int, ...); |
428 | 4346 /* C Code should be using internal_catch, record_unwind_p, condition_case_1 */ |
1318 | 4347 int proper_redisplay_wrapping_in_place (void); |
428 | 4348 Lisp_Object internal_catch (Lisp_Object, Lisp_Object (*) (Lisp_Object), |
853 | 4349 Lisp_Object, int * volatile, |
2532 | 4350 Lisp_Object * volatile, |
853 | 4351 Lisp_Object * volatile); |
428 | 4352 Lisp_Object condition_case_1 (Lisp_Object, |
4353 Lisp_Object (*) (Lisp_Object), | |
4354 Lisp_Object, | |
4355 Lisp_Object (*) (Lisp_Object, Lisp_Object), | |
4356 Lisp_Object); | |
4357 Lisp_Object condition_case_3 (Lisp_Object, Lisp_Object, Lisp_Object); | |
1632 | 4358 MODULE_API Lisp_Object unbind_to_1 (int, Lisp_Object); |
771 | 4359 #define unbind_to(obj) unbind_to_1 (obj, Qnil) |
428 | 4360 void specbind (Lisp_Object, Lisp_Object); |
1632 | 4361 MODULE_API int record_unwind_protect (Lisp_Object (*) (Lisp_Object), |
4362 Lisp_Object); | |
771 | 4363 int record_unwind_protect_freeing_dynarr (void *ptr); |
1333 | 4364 int record_unwind_protect_restoring_int (int *addr, int val); |
802 | 4365 int internal_bind_int (int *addr, int newval); |
4366 int internal_bind_lisp_object (Lisp_Object *addr, Lisp_Object newval); | |
970 | 4367 void do_autoload (Lisp_Object, Lisp_Object); /* GCPROs both arguments */ |
428 | 4368 Lisp_Object un_autoload (Lisp_Object); |
4369 void warn_when_safe_lispobj (Lisp_Object, Lisp_Object, Lisp_Object); | |
1632 | 4370 MODULE_API void warn_when_safe (Lisp_Object, Lisp_Object, const CIbyte *, |
4371 ...) PRINTF_ARGS (3, 4); | |
1292 | 4372 extern int backtrace_with_internal_sections; |
428 | 4373 |
1315 | 4374 extern Lisp_Object Vstack_trace_on_error; |
428 | 4375 |
4376 /* Defined in event-stream.c */ | |
826 | 4377 EXFUN (Faccept_process_output, 3); |
4378 EXFUN (Fadd_timeout, 4); | |
4379 EXFUN (Fdisable_timeout, 1); | |
4380 EXFUN (Fdiscard_input, 0); | |
4381 EXFUN (Fdispatch_event, 1); | |
4382 EXFUN (Fenqueue_eval_event, 2); | |
4383 EXFUN (Fnext_event, 2); | |
4384 EXFUN (Fread_key_sequence, 3); | |
4385 EXFUN (Fsit_for, 2); | |
4386 EXFUN (Fsleep_for, 1); | |
4387 | |
428 | 4388 void wait_delaying_user_input (int (*) (void *), void *); |
1268 | 4389 int detect_input_pending (int how_many); |
428 | 4390 void reset_this_command_keys (Lisp_Object, int); |
4391 Lisp_Object enqueue_misc_user_event (Lisp_Object, Lisp_Object, Lisp_Object); | |
4392 Lisp_Object enqueue_misc_user_event_pos (Lisp_Object, Lisp_Object, | |
4393 Lisp_Object, int, int, int, int); | |
442 | 4394 extern int modifier_keys_are_sticky; |
428 | 4395 |
4396 /* Defined in event-Xt.c */ | |
4397 void signal_special_Xt_user_event (Lisp_Object, Lisp_Object, Lisp_Object); | |
4398 | |
4399 | |
4400 /* Defined in events.c */ | |
826 | 4401 EXFUN (Fcopy_event, 2); |
2862 | 4402 EXFUN (Fevent_to_character, 4); |
826 | 4403 |
428 | 4404 void clear_event_resource (void); |
4405 Lisp_Object allocate_event (void); | |
4406 | |
771 | 4407 EXFUN (Fevent_x_pixel, 1); |
4408 EXFUN (Fevent_y_pixel, 1); | |
4409 | |
4410 | |
4411 /* Defined in file-coding.c */ | |
4412 EXFUN (Fcoding_category_list, 0); | |
4413 EXFUN (Fcoding_category_system, 1); | |
4414 EXFUN (Fcoding_priority_list, 0); | |
4415 EXFUN (Fcoding_system_description, 1); | |
4416 EXFUN (Fcoding_system_documentation, 1); | |
4417 EXFUN (Fcoding_system_list, 1); | |
4418 EXFUN (Fcoding_system_name, 1); | |
4419 EXFUN (Fcoding_system_p, 1); | |
4420 EXFUN (Fcoding_system_property, 2); | |
4421 EXFUN (Fcoding_system_type, 1); | |
4422 EXFUN (Fcopy_coding_system, 2); | |
4423 EXFUN (Fdecode_big5_char, 1); | |
4424 EXFUN (Fdecode_coding_region, 4); | |
4425 EXFUN (Fdecode_shift_jis_char, 1); | |
4426 EXFUN (Fdefine_coding_system_alias, 2); | |
4427 EXFUN (Fdetect_coding_region, 3); | |
4428 EXFUN (Fdefault_encoding_detection_enabled_p, 0); | |
4429 EXFUN (Fencode_big5_char, 1); | |
4430 EXFUN (Fencode_coding_region, 4); | |
4431 EXFUN (Fencode_shift_jis_char, 1); | |
4432 EXFUN (Ffind_coding_system, 1); | |
4433 EXFUN (Fget_coding_system, 1); | |
4434 EXFUN (Fmake_coding_system, 4); | |
4435 EXFUN (Fset_coding_category_system, 2); | |
4436 EXFUN (Fset_coding_priority_list, 1); | |
4437 EXFUN (Fsubsidiary_coding_system, 2); | |
4438 | |
4439 extern Lisp_Object Qshift_jis, Qiso2022, Qbig5, Qccl; | |
4440 extern Lisp_Object Qcharset_g0; | |
4441 extern Lisp_Object Qcharset_g1, Qcharset_g2, Qcharset_g3, Qcoding_system_error; | |
4442 extern Lisp_Object Qcoding_systemp, Qcr, Qcrlf, Qdecode, Qencode; | |
4443 extern Lisp_Object Qeol_cr, Qeol_crlf, Qeol_lf, Qeol_type, Qescape_quoted; | |
4444 extern Lisp_Object Qforce_g0_on_output, Qforce_g1_on_output; | |
4445 extern Lisp_Object Qforce_g2_on_output, Qforce_g3_on_output; | |
4446 extern Lisp_Object Qinput_charset_conversion, Qlf, Qlock_shift; | |
4447 extern Lisp_Object Qmnemonic, Qno_ascii_cntl, Qno_ascii_eol; | |
4448 extern Lisp_Object Qno_conversion, Qraw_text; | |
4449 extern Lisp_Object Qno_iso6429, Qoutput_charset_conversion; | |
4450 extern Lisp_Object Qpost_read_conversion, Qpre_write_conversion, Qseven; | |
4451 extern Lisp_Object Qshort, Vcoding_system_for_read; | |
4452 extern Lisp_Object Vcoding_system_for_write; | |
4453 extern Lisp_Object Vfile_name_coding_system, Vkeyboard_coding_system; | |
4454 extern Lisp_Object Vterminal_coding_system; | |
4455 extern Lisp_Object Qcanonicalize_after_coding; | |
4456 int coding_system_is_for_text_file (Lisp_Object coding_system); | |
4457 Lisp_Object find_coding_system_for_text_file (Lisp_Object name, int eol_wrap); | |
1632 | 4458 MODULE_API Lisp_Object get_coding_system_for_text_file (Lisp_Object name, |
4459 int eol_wrap); | |
771 | 4460 int coding_system_is_binary (Lisp_Object coding_system); |
4461 | |
4462 | |
428 | 4463 /* Defined in fileio.c */ |
826 | 4464 EXFUN (Fdirectory_file_name, 1); |
4465 EXFUN (Fdo_auto_save, 2); | |
4466 EXFUN (Fexpand_file_name, 2); | |
4467 EXFUN (Ffile_accessible_directory_p, 1); | |
4468 EXFUN (Ffile_directory_p, 1); | |
4469 EXFUN (Ffile_executable_p, 1); | |
4470 EXFUN (Ffile_exists_p, 1); | |
4471 EXFUN (Ffile_name_absolute_p, 1); | |
4472 EXFUN (Ffile_name_as_directory, 1); | |
4473 EXFUN (Ffile_name_directory, 1); | |
4474 EXFUN (Ffile_name_nondirectory, 1); | |
4475 EXFUN (Ffile_readable_p, 1); | |
4476 EXFUN (Ffile_symlink_p, 1); | |
4477 EXFUN (Ffile_truename, 2); | |
4478 EXFUN (Ffind_file_name_handler, 2); | |
4479 EXFUN (Finsert_file_contents_internal, 7); | |
4480 EXFUN (Fmake_temp_name, 1); | |
4481 EXFUN (Fsubstitute_in_file_name, 1); | |
4482 EXFUN (Funhandled_file_name_directory, 1); | |
4483 EXFUN (Fverify_visited_file_modtime, 1); | |
4484 | |
428 | 4485 void record_auto_save (void); |
4486 void force_auto_save_soon (void); | |
563 | 4487 DECLARE_DOESNT_RETURN (report_error_with_errno (Lisp_Object errtype, |
867 | 4488 const CIbyte *string, |
563 | 4489 Lisp_Object data)); |
4490 DECLARE_DOESNT_RETURN (report_file_type_error (Lisp_Object errtype, | |
4491 Lisp_Object oserrmess, | |
867 | 4492 const CIbyte *string, |
563 | 4493 Lisp_Object data)); |
867 | 4494 DECLARE_DOESNT_RETURN (report_file_error (const CIbyte *, Lisp_Object)); |
428 | 4495 Lisp_Object lisp_strerror (int); |
4496 Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object); | |
4497 int internal_delete_file (Lisp_Object); | |
2526 | 4498 Ibyte *find_end_of_directory_component (const Ibyte *path, |
4499 Bytecount len); | |
428 | 4500 |
4501 /* Defined in filelock.c */ | |
826 | 4502 EXFUN (Funlock_buffer, 0); |
4503 | |
428 | 4504 void lock_file (Lisp_Object); |
4505 void unlock_file (Lisp_Object); | |
4506 void unlock_all_files (void); | |
4507 void unlock_buffer (struct buffer *); | |
4508 | |
4509 /* Defined in floatfns.c */ | |
826 | 4510 EXFUN (Ftruncate, 1); |
4511 | |
428 | 4512 double extract_float (Lisp_Object); |
4513 | |
4514 /* Defined in fns.c */ | |
1632 | 4515 MODULE_API EXFUN (Fappend, MANY); |
826 | 4516 EXFUN (Fassoc, 2); |
4517 EXFUN (Fassq, 2); | |
4518 EXFUN (Fcanonicalize_lax_plist, 2); | |
4519 EXFUN (Fcanonicalize_plist, 2); | |
4520 EXFUN (Fcheck_valid_plist, 1); | |
4521 EXFUN (Fconcat, MANY); | |
4522 EXFUN (Fcopy_alist, 1); | |
4523 EXFUN (Fcopy_list, 1); | |
4524 EXFUN (Fcopy_sequence, 1); | |
4525 EXFUN (Fcopy_tree, 2); | |
4526 EXFUN (Fdelete, 2); | |
4527 EXFUN (Fdelq, 2); | |
4528 EXFUN (Fdestructive_alist_to_plist, 1); | |
4529 EXFUN (Felt, 2); | |
1632 | 4530 MODULE_API EXFUN (Fequal, 2); |
4531 MODULE_API EXFUN (Fget, 3); | |
826 | 4532 EXFUN (Flast, 2); |
4533 EXFUN (Flax_plist_get, 3); | |
4534 EXFUN (Flax_plist_remprop, 2); | |
1632 | 4535 MODULE_API EXFUN (Flength, 1); |
826 | 4536 EXFUN (Fmapcar, 2); |
4537 EXFUN (Fmember, 2); | |
4538 EXFUN (Fmemq, 2); | |
4539 EXFUN (Fnconc, MANY); | |
1632 | 4540 MODULE_API EXFUN (Fnreverse, 1); |
826 | 4541 EXFUN (Fnthcdr, 2); |
4542 EXFUN (Fold_assq, 2); | |
4543 EXFUN (Fold_equal, 2); | |
4544 EXFUN (Fold_member, 2); | |
4545 EXFUN (Fold_memq, 2); | |
4546 EXFUN (Fplist_get, 3); | |
4547 EXFUN (Fplist_member, 2); | |
4548 EXFUN (Fplist_put, 3); | |
1632 | 4549 MODULE_API EXFUN (Fprovide, 1); |
4550 MODULE_API EXFUN (Fput, 3); | |
826 | 4551 EXFUN (Frassq, 2); |
4552 EXFUN (Fremassq, 2); | |
4553 EXFUN (Freplace_list, 2); | |
1632 | 4554 MODULE_API EXFUN (Freverse, 1); |
1268 | 4555 EXFUN (Fsafe_length, 1); |
826 | 4556 EXFUN (Fsort, 2); |
4557 EXFUN (Fstring_equal, 2); | |
4558 EXFUN (Fstring_lessp, 2); | |
4559 EXFUN (Fsubstring, 3); | |
4560 EXFUN (Fvalid_plist_p, 1); | |
4561 | |
428 | 4562 Lisp_Object list_sort (Lisp_Object, Lisp_Object, |
4563 int (*) (Lisp_Object, Lisp_Object, Lisp_Object)); | |
4564 Lisp_Object merge (Lisp_Object, Lisp_Object, Lisp_Object); | |
4565 | |
4566 void bump_string_modiff (Lisp_Object); | |
4567 Lisp_Object memq_no_quit (Lisp_Object, Lisp_Object); | |
4568 Lisp_Object assoc_no_quit (Lisp_Object, Lisp_Object); | |
4569 Lisp_Object assq_no_quit (Lisp_Object, Lisp_Object); | |
4570 Lisp_Object rassq_no_quit (Lisp_Object, Lisp_Object); | |
4571 Lisp_Object delq_no_quit (Lisp_Object, Lisp_Object); | |
4572 Lisp_Object delq_no_quit_and_free_cons (Lisp_Object, Lisp_Object); | |
4573 Lisp_Object remassoc_no_quit (Lisp_Object, Lisp_Object); | |
4574 Lisp_Object remassq_no_quit (Lisp_Object, Lisp_Object); | |
4575 Lisp_Object remrassq_no_quit (Lisp_Object, Lisp_Object); | |
4576 | |
4577 int plists_differ (Lisp_Object, Lisp_Object, int, int, int); | |
4578 Lisp_Object internal_plist_get (Lisp_Object, Lisp_Object); | |
4579 void internal_plist_put (Lisp_Object *, Lisp_Object, Lisp_Object); | |
4580 int internal_remprop (Lisp_Object *, Lisp_Object); | |
4581 Lisp_Object external_plist_get (Lisp_Object *, Lisp_Object, | |
578 | 4582 int, Error_Behavior); |
428 | 4583 void external_plist_put (Lisp_Object *, Lisp_Object, |
578 | 4584 Lisp_Object, int, Error_Behavior); |
4585 int external_remprop (Lisp_Object *, Lisp_Object, int, Error_Behavior); | |
853 | 4586 int internal_equal_trapping_problems (Lisp_Object warning_class, |
2367 | 4587 const Ascbyte *warning_string, |
853 | 4588 int flags, |
4589 struct call_trapping_problems_result *p, | |
4590 int retval, | |
4591 Lisp_Object obj1, Lisp_Object obj2, | |
4592 int depth); | |
428 | 4593 int internal_equal (Lisp_Object, Lisp_Object, int); |
801 | 4594 int internal_equalp (Lisp_Object obj1, Lisp_Object obj2, int depth); |
428 | 4595 Lisp_Object concat2 (Lisp_Object, Lisp_Object); |
4596 Lisp_Object concat3 (Lisp_Object, Lisp_Object, Lisp_Object); | |
4597 Lisp_Object vconcat2 (Lisp_Object, Lisp_Object); | |
4598 Lisp_Object vconcat3 (Lisp_Object, Lisp_Object, Lisp_Object); | |
4599 Lisp_Object nconc2 (Lisp_Object, Lisp_Object); | |
4600 Lisp_Object bytecode_nconc2 (Lisp_Object *); | |
442 | 4601 void check_losing_bytecode (const char *, Lisp_Object); |
428 | 4602 |
771 | 4603 Lisp_Object add_suffix_to_symbol (Lisp_Object symbol, |
2367 | 4604 const Ascbyte *ascii_string); |
4605 Lisp_Object add_prefix_to_symbol (const Ascbyte *ascii_string, | |
771 | 4606 Lisp_Object symbol); |
4607 | |
826 | 4608 /* Defined in free-hook.c */ |
4609 EXFUN (Freally_free, 1); | |
4610 | |
428 | 4611 /* Defined in glyphs.c */ |
826 | 4612 EXFUN (Fmake_glyph_internal, 1); |
4613 | |
578 | 4614 Error_Behavior decode_error_behavior_flag (Lisp_Object); |
4615 Lisp_Object encode_error_behavior_flag (Error_Behavior); | |
428 | 4616 |
563 | 4617 /* Defined in glyphs-shared.c */ |
4618 void shared_resource_validate (Lisp_Object instantiator); | |
4619 Lisp_Object shared_resource_normalize (Lisp_Object inst, | |
4620 Lisp_Object console_type, | |
4621 Lisp_Object dest_mask, | |
4622 Lisp_Object tag); | |
4623 extern Lisp_Object Q_resource_type, Q_resource_id; | |
4624 | |
4625 /* Defined in gui.c */ | |
2367 | 4626 DECLARE_DOESNT_RETURN (gui_error (const Ascbyte *reason, |
563 | 4627 Lisp_Object frob)); |
2367 | 4628 DECLARE_DOESNT_RETURN (gui_error_2 (const Ascbyte *reason, |
569 | 4629 Lisp_Object frob0, Lisp_Object frob1)); |
428 | 4630 /* Defined in indent.c */ |
826 | 4631 EXFUN (Findent_to, 3); |
4632 EXFUN (Fvertical_motion, 3); | |
4633 | |
4634 int byte_spaces_at_point (struct buffer *, Bytebpos); | |
665 | 4635 int column_at_point (struct buffer *, Charbpos, int); |
793 | 4636 int string_column_at_point (Lisp_Object, Charbpos, int); |
428 | 4637 int current_column (struct buffer *); |
4638 void invalidate_current_column (void); | |
665 | 4639 Charbpos vmotion (struct window *, Charbpos, int, int *); |
4640 Charbpos vmotion_pixels (Lisp_Object, Charbpos, int, int, int *); | |
428 | 4641 |
771 | 4642 /* Defined in insdel.c */ |
4643 void set_buffer_point (struct buffer *buf, Charbpos pos, Bytebpos bipos); | |
4644 | |
826 | 4645 /* Defined in intl.c */ |
4646 EXFUN (Fgettext, 1); | |
4647 | |
428 | 4648 /* Defined in keymap.c */ |
826 | 4649 EXFUN (Fdefine_key, 3); |
4650 EXFUN (Fkey_description, 1); | |
4651 EXFUN (Flookup_key, 3); | |
4652 EXFUN (Fmake_sparse_keymap, 1); | |
4653 | |
793 | 4654 void where_is_to_char (Lisp_Object, Eistring *); |
428 | 4655 |
4656 /* Defined in lread.c */ | |
826 | 4657 EXFUN (Fread, 1); |
4658 | |
428 | 4659 void ebolify_bytecode_constants (Lisp_Object); |
4660 void close_load_descs (void); | |
4661 int locate_file (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object *, int); | |
4662 EXFUN (Flocate_file_clear_hashing, 1); | |
442 | 4663 int isfloat_string (const char *); |
1983 | 4664 #ifdef HAVE_RATIO |
4665 int isratio_string (const char *); | |
4666 #endif | |
428 | 4667 |
4668 /* Well, I've decided to enable this. -- ben */ | |
4669 /* And I've decided to make it work right. -- sb */ | |
4670 #define LOADHIST | |
4671 /* Define the following symbol to enable load history of dumped files */ | |
4672 #define LOADHIST_DUMPED | |
4673 /* Define the following symbol to enable load history of C source */ | |
4674 #define LOADHIST_BUILTIN | |
4675 | |
4676 #ifdef LOADHIST /* this is just a stupid idea */ | |
4677 #define LOADHIST_ATTACH(x) \ | |
4678 do { if (initialized) Vcurrent_load_list = Fcons (x, Vcurrent_load_list); } \ | |
4679 while (0) | |
4680 #else /*! LOADHIST */ | |
4681 # define LOADHIST_ATTACH(x) | |
4682 #endif /*! LOADHIST */ | |
4683 | |
826 | 4684 /* Defined in macros.c */ |
4685 EXFUN (Fexecute_kbd_macro, 2); | |
4686 | |
428 | 4687 /* Defined in marker.c */ |
826 | 4688 EXFUN (Fcopy_marker, 2); |
4689 EXFUN (Fmake_marker, 0); | |
4690 EXFUN (Fmarker_buffer, 1); | |
4691 EXFUN (Fmarker_position, 1); | |
4692 EXFUN (Fset_marker, 3); | |
4693 EXFUN (Fset_marker_insertion_type, 2); | |
4694 | |
4695 Bytebpos byte_marker_position (Lisp_Object); | |
665 | 4696 Charbpos marker_position (Lisp_Object); |
826 | 4697 void set_byte_marker_position (Lisp_Object, Bytebpos); |
665 | 4698 void set_marker_position (Lisp_Object, Charbpos); |
428 | 4699 void unchain_marker (Lisp_Object); |
4700 Lisp_Object noseeum_copy_marker (Lisp_Object, Lisp_Object); | |
4701 Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp_Object); | |
4702 #ifdef MEMORY_USAGE_STATS | |
4703 int compute_buffer_marker_usage (struct buffer *, struct overhead_stats *); | |
4704 #endif | |
771 | 4705 void init_buffer_markers (struct buffer *b); |
4706 void uninit_buffer_markers (struct buffer *b); | |
428 | 4707 |
4708 /* Defined in minibuf.c */ | |
4709 extern int minibuf_level; | |
867 | 4710 Charcount scmp_1 (const Ibyte *, const Ibyte *, Charcount, int); |
428 | 4711 #define scmp(s1, s2, len) scmp_1 (s1, s2, len, completion_ignore_case) |
4712 extern int completion_ignore_case; | |
867 | 4713 int regexp_ignore_completion_p (const Ibyte *, Lisp_Object, |
428 | 4714 Bytecount, Bytecount); |
4715 Lisp_Object clear_echo_area (struct frame *, Lisp_Object, int); | |
4716 Lisp_Object clear_echo_area_from_print (struct frame *, Lisp_Object, int); | |
867 | 4717 void echo_area_append (struct frame *, const Ibyte *, Lisp_Object, |
428 | 4718 Bytecount, Bytecount, Lisp_Object); |
867 | 4719 void echo_area_message (struct frame *, const Ibyte *, Lisp_Object, |
428 | 4720 Bytecount, Bytecount, Lisp_Object); |
4721 Lisp_Object echo_area_status (struct frame *); | |
4722 int echo_area_active (struct frame *); | |
4723 Lisp_Object echo_area_contents (struct frame *); | |
867 | 4724 void message_internal (const Ibyte *, Lisp_Object, Bytecount, Bytecount); |
4725 void message_append_internal (const Ibyte *, Lisp_Object, | |
428 | 4726 Bytecount, Bytecount); |
1632 | 4727 MODULE_API void message (const char *, ...) PRINTF_ARGS (1, 2); |
442 | 4728 void message_append (const char *, ...) PRINTF_ARGS (1, 2); |
4729 void message_no_translate (const char *, ...) PRINTF_ARGS (1, 2); | |
428 | 4730 void clear_message (void); |
4731 | |
771 | 4732 /* Defined in mule-charset.c */ |
826 | 4733 EXFUN (Fmake_charset, 3); |
4734 | |
771 | 4735 extern Lisp_Object Ql2r, Qr2l; |
4736 | |
428 | 4737 /* Defined in print.c */ |
826 | 4738 EXFUN (Fdisplay_error, 2); |
4739 EXFUN (Ferror_message_string, 1); | |
4740 EXFUN (Fprin1, 2); | |
4741 EXFUN (Fprin1_to_string, 2); | |
4742 EXFUN (Fprinc, 2); | |
4743 EXFUN (Fprint, 2); | |
4744 | |
771 | 4745 |
4746 /* Lower-level ways to output data: */ | |
4747 void print_internal (Lisp_Object, Lisp_Object, int); | |
428 | 4748 void debug_print (Lisp_Object); |
1204 | 4749 void debug_p4 (Lisp_Object obj); |
4750 void debug_p3 (Lisp_Object obj); | |
4751 void debug_short_backtrace (int); | |
4752 void debug_backtrace (void); | |
428 | 4753 /* NOTE: Do not call this with the data of a Lisp_String. Use princ. |
4754 * Note: stream should be defaulted before calling | |
4755 * (eg Qnil means stdout, not Vstandard_output, etc) */ | |
1632 | 4756 MODULE_API void write_c_string (Lisp_Object stream, const CIbyte *str); |
771 | 4757 /* Same goes for this function. */ |
1632 | 4758 MODULE_API void write_string (Lisp_Object stream, const Ibyte *str); |
428 | 4759 /* Same goes for this function. */ |
867 | 4760 void write_string_1 (Lisp_Object stream, const Ibyte *str, Bytecount size); |
826 | 4761 void write_eistring (Lisp_Object stream, const Eistring *ei); |
771 | 4762 |
4763 /* Higher-level (printf-style) ways to output data: */ | |
1632 | 4764 MODULE_API void write_fmt_string (Lisp_Object stream, const CIbyte *fmt, ...); |
4765 MODULE_API void write_fmt_string_lisp (Lisp_Object stream, const CIbyte *fmt, | |
4766 int nargs, ...); | |
867 | 4767 void stderr_out (const CIbyte *, ...) PRINTF_ARGS (1, 2); |
4768 void stderr_out_lisp (const CIbyte *, int nargs, ...); | |
4769 void stdout_out (const CIbyte *, ...) PRINTF_ARGS (1, 2); | |
1346 | 4770 void external_out (int dest, const CIbyte *fmt, ...) PRINTF_ARGS (2, 3); |
867 | 4771 void debug_out (const CIbyte *, ...) PRINTF_ARGS (1, 2); |
1743 | 4772 DECLARE_DOESNT_RETURN (fatal (const CIbyte *, ...)) PRINTF_ARGS(1, 2); |
771 | 4773 |
4774 /* Internal functions: */ | |
1261 | 4775 Lisp_Object canonicalize_printcharfun (Lisp_Object printcharfun); |
771 | 4776 void temp_output_buffer_setup (Lisp_Object); |
4777 void temp_output_buffer_show (Lisp_Object, Lisp_Object); | |
428 | 4778 void print_cons (Lisp_Object, Lisp_Object, int); |
4779 void print_vector (Lisp_Object, Lisp_Object, int); | |
4780 void print_string (Lisp_Object, Lisp_Object, int); | |
771 | 4781 void print_symbol (Lisp_Object, Lisp_Object, int); |
4782 void print_float (Lisp_Object, Lisp_Object, int); | |
603 | 4783 /* The number of bytes required to store the decimal printed |
4784 representation of an integral type. Add a few bytes for truncation, | |
4785 optional sign prefix, and null byte terminator. | |
614 | 4786 2.40824 == log (256) / log (10). |
4787 | |
4788 We don't use floating point since Sun cc (buggily?) cannot use | |
4789 floating point computations to define a compile-time integral | |
4790 constant. */ | |
603 | 4791 #define DECIMAL_PRINT_SIZE(integral_type) \ |
614 | 4792 (((2410824 * sizeof (integral_type)) / 1000000) + 3) |
577 | 4793 void long_to_string (char *, long); |
428 | 4794 extern int print_escape_newlines; |
1632 | 4795 extern MODULE_API int print_readably; |
428 | 4796 Lisp_Object internal_with_output_to_temp_buffer (Lisp_Object, |
4797 Lisp_Object (*) (Lisp_Object), | |
4798 Lisp_Object, Lisp_Object); | |
4799 void float_to_string (char *, double); | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
4800 void external_object_printer (Lisp_Object obj, Lisp_Object printcharfun, |
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
4801 int UNUSED (escapeflag)); |
428 | 4802 |
4803 /* Defined in rangetab.c */ | |
826 | 4804 EXFUN (Fclear_range_table, 1); |
4805 EXFUN (Fget_range_table, 3); | |
2421 | 4806 EXFUN (Fmake_range_table, 1); |
826 | 4807 EXFUN (Fput_range_table, 4); |
4808 | |
2421 | 4809 extern Lisp_Object Qstart_closed_end_open; |
4810 extern Lisp_Object Qstart_open_end_open; | |
4811 extern Lisp_Object Qstart_closed_end_closed; | |
4812 extern Lisp_Object Qstart_open_end_closed; | |
4813 | |
428 | 4814 void put_range_table (Lisp_Object, EMACS_INT, EMACS_INT, Lisp_Object); |
4815 int unified_range_table_bytes_needed (Lisp_Object); | |
4816 int unified_range_table_bytes_used (void *); | |
4817 void unified_range_table_copy_data (Lisp_Object, void *); | |
4818 Lisp_Object unified_range_table_lookup (void *, EMACS_INT, Lisp_Object); | |
4819 int unified_range_table_nentries (void *); | |
4820 void unified_range_table_get_range (void *, int, EMACS_INT *, EMACS_INT *, | |
4821 Lisp_Object *); | |
4822 | |
4823 /* Defined in search.c */ | |
826 | 4824 EXFUN (Fmatch_beginning, 1); |
4825 EXFUN (Fmatch_end, 1); | |
4826 EXFUN (Fskip_chars_backward, 3); | |
4827 EXFUN (Fskip_chars_forward, 3); | |
4828 EXFUN (Fstring_match, 4); | |
4829 | |
428 | 4830 struct re_pattern_buffer; |
4831 struct re_registers; | |
867 | 4832 Charbpos scan_buffer (struct buffer *, Ichar, Charbpos, Charbpos, EMACS_INT, |
826 | 4833 EMACS_INT *, int); |
665 | 4834 Charbpos find_next_newline (struct buffer *, Charbpos, int); |
4835 Charbpos find_next_newline_no_quit (struct buffer *, Charbpos, int); | |
826 | 4836 Bytebpos byte_find_next_newline_no_quit (struct buffer *, Bytebpos, int); |
867 | 4837 Bytecount byte_find_next_ichar_in_string (Lisp_Object, Ichar, Bytecount, |
826 | 4838 EMACS_INT); |
665 | 4839 Charbpos find_before_next_newline (struct buffer *, Charbpos, Charbpos, int); |
826 | 4840 struct re_pattern_buffer *compile_pattern (Lisp_Object pattern, |
4841 struct re_registers *regp, | |
4842 Lisp_Object translate, | |
4843 Lisp_Object searchobj, | |
4844 struct buffer *searchbuf, | |
4845 int posix, Error_Behavior errb); | |
867 | 4846 Bytecount fast_string_match (Lisp_Object, const Ibyte *, |
428 | 4847 Lisp_Object, Bytecount, |
578 | 4848 Bytecount, int, Error_Behavior, int); |
428 | 4849 Bytecount fast_lisp_string_match (Lisp_Object, Lisp_Object); |
507 | 4850 extern Fixnum warn_about_possibly_incompatible_back_references; |
502 | 4851 |
428 | 4852 |
4853 /* Defined in signal.c */ | |
4854 void init_interrupts_late (void); | |
4855 | |
4856 /* Defined in sound.c */ | |
826 | 4857 EXFUN (Fding, 3); |
4858 | |
428 | 4859 void init_device_sound (struct device *); |
2367 | 4860 DECLARE_DOESNT_RETURN (report_sound_error (const Ascbyte *, Lisp_Object)); |
428 | 4861 |
4862 /* Defined in specifier.c */ | |
826 | 4863 EXFUN (Fadd_spec_to_specifier, 5); |
4864 EXFUN (Fspecifier_spec_list, 4); | |
4865 | |
428 | 4866 Lisp_Object specifier_instance (Lisp_Object, Lisp_Object, Lisp_Object, |
578 | 4867 Error_Behavior, int, int, Lisp_Object); |
428 | 4868 Lisp_Object specifier_instance_no_quit (Lisp_Object, Lisp_Object, Lisp_Object, |
578 | 4869 Error_Behavior, int, Lisp_Object); |
428 | 4870 |
4871 /* Defined in symbols.c */ | |
826 | 4872 EXFUN (Fboundp, 1); |
4873 EXFUN (Fbuilt_in_variable_type, 1); | |
4874 EXFUN (Fdefault_boundp, 1); | |
4875 EXFUN (Fdefault_value, 1); | |
4876 EXFUN (Ffboundp, 1); | |
4877 EXFUN (Ffset, 2); | |
4878 EXFUN (Fintern, 2); | |
4879 EXFUN (Fintern_soft, 2); | |
4880 EXFUN (Fkill_local_variable, 1); | |
4881 EXFUN (Fset, 2); | |
4882 EXFUN (Fset_default, 2); | |
4883 EXFUN (Fsymbol_function, 1); | |
4884 EXFUN (Fsymbol_name, 1); | |
4885 EXFUN (Fsymbol_plist, 1); | |
4886 EXFUN (Fsymbol_value, 1); | |
4887 | |
867 | 4888 unsigned int hash_string (const Ibyte *, Bytecount); |
4889 Lisp_Object intern_int (const Ibyte *str); | |
1632 | 4890 MODULE_API Lisp_Object intern (const CIbyte *str); |
867 | 4891 Lisp_Object intern_converting_underscores_to_dashes (const CIbyte *str); |
4892 Lisp_Object oblookup (Lisp_Object, const Ibyte *, Bytecount); | |
428 | 4893 void map_obarray (Lisp_Object, int (*) (Lisp_Object, void *), void *); |
4894 Lisp_Object indirect_function (Lisp_Object, int); | |
4895 Lisp_Object symbol_value_in_buffer (Lisp_Object, Lisp_Object); | |
4896 void kill_buffer_local_variables (struct buffer *); | |
4897 int symbol_value_buffer_local_info (Lisp_Object, struct buffer *); | |
4898 Lisp_Object find_symbol_value (Lisp_Object); | |
4899 Lisp_Object find_symbol_value_quickly (Lisp_Object, int); | |
4900 Lisp_Object top_level_value (Lisp_Object); | |
4901 void reject_constant_symbols (Lisp_Object sym, Lisp_Object newval, | |
4902 int function_p, | |
4903 Lisp_Object follow_past_lisp_magic); | |
4904 | |
4905 /* Defined in syntax.c */ | |
665 | 4906 Charbpos scan_words (struct buffer *, Charbpos, int); |
826 | 4907 EXFUN (Fchar_syntax, 2); |
4908 EXFUN (Fforward_word, 2); | |
4909 extern Lisp_Object Vstandard_syntax_table; | |
4910 void signal_syntax_table_extent_changed (EXTENT extent); | |
4911 void signal_syntax_table_extent_adjust (struct buffer *buf); | |
4912 void init_buffer_syntax_cache (struct buffer *buf); | |
4913 void mark_buffer_syntax_cache (struct buffer *buf); | |
4914 void uninit_buffer_syntax_cache (struct buffer *buf); | |
4915 extern Lisp_Object Qsyntax_table; | |
428 | 4916 |
771 | 4917 /* Defined in sysdep.c */ |
4918 long get_random (void); | |
4919 void seed_random (long arg); | |
4920 | |
4921 /* Defined in text.c */ | |
867 | 4922 void find_charsets_in_ibyte_string (unsigned char *charsets, |
4923 const Ibyte *str, | |
771 | 4924 Bytecount len); |
867 | 4925 void find_charsets_in_ichar_string (unsigned char *charsets, |
4926 const Ichar *str, | |
771 | 4927 Charcount len); |
867 | 4928 int ibyte_string_displayed_columns (const Ibyte *str, Bytecount len); |
4929 int ichar_string_displayed_columns (const Ichar *str, Charcount len); | |
4930 Charcount ibyte_string_nonascii_chars (const Ibyte *str, Bytecount len); | |
4931 void convert_ibyte_string_into_ichar_dynarr (const Ibyte *str, | |
771 | 4932 Bytecount len, |
867 | 4933 Ichar_dynarr *dyn); |
4934 Charcount convert_ibyte_string_into_ichar_string (const Ibyte *str, | |
771 | 4935 Bytecount len, |
867 | 4936 Ichar *arr); |
4937 void convert_ichar_string_into_ibyte_dynarr (Ichar *arr, int nels, | |
4938 Ibyte_dynarr *dyn); | |
4939 Ibyte *convert_ichar_string_into_malloced_string (Ichar *arr, int nels, | |
771 | 4940 Bytecount *len_out); |
867 | 4941 Bytecount copy_text_between_formats (const Ibyte *src, Bytecount srclen, |
826 | 4942 Internal_Format srcfmt, |
4943 Lisp_Object srcobj, | |
867 | 4944 Ibyte *dst, Bytecount dstlen, |
826 | 4945 Internal_Format dstfmt, |
4946 Lisp_Object dstobj, | |
4947 Bytecount *src_used); | |
4948 Bytecount copy_buffer_text_out (struct buffer *buf, Bytebpos pos, | |
867 | 4949 Bytecount len, Ibyte *dst, Bytecount dstlen, |
826 | 4950 Internal_Format dstfmt, Lisp_Object dstobj, |
4951 Bytecount *src_used); | |
771 | 4952 |
4953 /* flags for get_buffer_pos_char(), get_buffer_range_char(), etc. */ | |
4954 /* At most one of GB_COERCE_RANGE and GB_NO_ERROR_IF_BAD should be | |
4955 specified. At most one of GB_NEGATIVE_FROM_END and GB_NO_ERROR_IF_BAD | |
4956 should be specified. */ | |
4957 | |
4958 #define GB_ALLOW_PAST_ACCESSIBLE (1 << 0) | |
4959 #define GB_ALLOW_NIL (1 << 1) | |
4960 #define GB_CHECK_ORDER (1 << 2) | |
4961 #define GB_COERCE_RANGE (1 << 3) | |
4962 #define GB_NO_ERROR_IF_BAD (1 << 4) | |
4963 #define GB_NEGATIVE_FROM_END (1 << 5) | |
4964 #define GB_HISTORICAL_STRING_BEHAVIOR (GB_NEGATIVE_FROM_END | GB_ALLOW_NIL) | |
4965 | |
4966 Charbpos get_buffer_pos_char (struct buffer *b, Lisp_Object pos, | |
4967 unsigned int flags); | |
4968 Bytebpos get_buffer_pos_byte (struct buffer *b, Lisp_Object pos, | |
4969 unsigned int flags); | |
4970 void get_buffer_range_char (struct buffer *b, Lisp_Object from, Lisp_Object to, | |
4971 Charbpos *from_out, Charbpos *to_out, | |
4972 unsigned int flags); | |
4973 void get_buffer_range_byte (struct buffer *b, Lisp_Object from, Lisp_Object to, | |
4974 Bytebpos *from_out, Bytebpos *to_out, | |
4975 unsigned int flags); | |
4976 Charcount get_string_pos_char (Lisp_Object string, Lisp_Object pos, | |
4977 unsigned int flags); | |
4978 Bytecount get_string_pos_byte (Lisp_Object string, Lisp_Object pos, | |
4979 unsigned int flags); | |
4980 void get_string_range_char (Lisp_Object string, Lisp_Object from, | |
4981 Lisp_Object to, Charcount *from_out, | |
4982 Charcount *to_out, unsigned int flags); | |
4983 void get_string_range_byte (Lisp_Object string, Lisp_Object from, | |
4984 Lisp_Object to, Bytecount *from_out, | |
4985 Bytecount *to_out, unsigned int flags); | |
826 | 4986 Charxpos get_buffer_or_string_pos_char (Lisp_Object object, Lisp_Object pos, |
4987 unsigned int flags); | |
4988 Bytexpos get_buffer_or_string_pos_byte (Lisp_Object object, Lisp_Object pos, | |
4989 unsigned int flags); | |
771 | 4990 void get_buffer_or_string_range_char (Lisp_Object object, Lisp_Object from, |
826 | 4991 Lisp_Object to, Charxpos *from_out, |
4992 Charxpos *to_out, unsigned int flags); | |
771 | 4993 void get_buffer_or_string_range_byte (Lisp_Object object, Lisp_Object from, |
826 | 4994 Lisp_Object to, Bytexpos *from_out, |
4995 Bytexpos *to_out, unsigned int flags); | |
4996 Charxpos buffer_or_string_accessible_begin_char (Lisp_Object object); | |
4997 Charxpos buffer_or_string_accessible_end_char (Lisp_Object object); | |
4998 Bytexpos buffer_or_string_accessible_begin_byte (Lisp_Object object); | |
4999 Bytexpos buffer_or_string_accessible_end_byte (Lisp_Object object); | |
5000 Charxpos buffer_or_string_absolute_begin_char (Lisp_Object object); | |
5001 Charxpos buffer_or_string_absolute_end_char (Lisp_Object object); | |
5002 Bytexpos buffer_or_string_absolute_begin_byte (Lisp_Object object); | |
5003 Bytexpos buffer_or_string_absolute_end_byte (Lisp_Object object); | |
5004 Charbpos charbpos_clip_to_bounds (Charbpos lower, Charbpos num, | |
5005 Charbpos upper); | |
5006 Bytebpos bytebpos_clip_to_bounds (Bytebpos lower, Bytebpos num, | |
5007 Bytebpos upper); | |
5008 Charxpos charxpos_clip_to_bounds (Charxpos lower, Charxpos num, | |
5009 Charxpos upper); | |
5010 Bytexpos bytexpos_clip_to_bounds (Bytexpos lower, Bytexpos num, | |
5011 Bytexpos upper); | |
5012 Charxpos buffer_or_string_clip_to_accessible_char (Lisp_Object object, | |
5013 Charxpos pos); | |
5014 Bytexpos buffer_or_string_clip_to_accessible_byte (Lisp_Object object, | |
5015 Bytexpos pos); | |
5016 Charxpos buffer_or_string_clip_to_absolute_char (Lisp_Object object, | |
5017 Charxpos pos); | |
5018 Bytexpos buffer_or_string_clip_to_absolute_byte (Lisp_Object object, | |
5019 Bytexpos pos); | |
5020 | |
771 | 5021 |
5022 #ifdef ENABLE_COMPOSITE_CHARS | |
5023 | |
867 | 5024 Ichar lookup_composite_char (Ibyte *str, int len); |
5025 Lisp_Object composite_char_string (Ichar ch); | |
771 | 5026 #endif /* ENABLE_COMPOSITE_CHARS */ |
5027 | |
5028 EXFUN (Ffind_charset, 1); | |
5029 EXFUN (Fget_charset, 1); | |
5030 EXFUN (Fcharset_list, 0); | |
5031 | |
5032 extern Lisp_Object Vcharset_ascii; | |
5033 extern Lisp_Object Vcharset_control_1; | |
5034 extern Lisp_Object Vcharset_latin_iso8859_1; | |
5035 extern Lisp_Object Vcharset_latin_iso8859_2; | |
5036 extern Lisp_Object Vcharset_latin_iso8859_3; | |
5037 extern Lisp_Object Vcharset_latin_iso8859_4; | |
5038 extern Lisp_Object Vcharset_thai_tis620; | |
5039 extern Lisp_Object Vcharset_greek_iso8859_7; | |
5040 extern Lisp_Object Vcharset_arabic_iso8859_6; | |
5041 extern Lisp_Object Vcharset_hebrew_iso8859_8; | |
5042 extern Lisp_Object Vcharset_katakana_jisx0201; | |
5043 extern Lisp_Object Vcharset_latin_jisx0201; | |
5044 extern Lisp_Object Vcharset_cyrillic_iso8859_5; | |
5045 extern Lisp_Object Vcharset_latin_iso8859_9; | |
5046 extern Lisp_Object Vcharset_japanese_jisx0208_1978; | |
5047 extern Lisp_Object Vcharset_chinese_gb2312; | |
5048 extern Lisp_Object Vcharset_japanese_jisx0208; | |
5049 extern Lisp_Object Vcharset_korean_ksc5601; | |
5050 extern Lisp_Object Vcharset_japanese_jisx0212; | |
5051 extern Lisp_Object Vcharset_chinese_cns11643_1; | |
5052 extern Lisp_Object Vcharset_chinese_cns11643_2; | |
5053 extern Lisp_Object Vcharset_chinese_big5_1; | |
5054 extern Lisp_Object Vcharset_chinese_big5_2; | |
5055 extern Lisp_Object Vcharset_composite; | |
5056 | |
867 | 5057 Ichar Lstream_get_ichar_1 (Lstream *stream, int first_char); |
5058 int Lstream_fput_ichar (Lstream *stream, Ichar ch); | |
5059 void Lstream_funget_ichar (Lstream *stream, Ichar ch); | |
5060 | |
5061 DECLARE_INLINE_HEADER (Ibyte *qxestrdup (const Ibyte *s)) | |
771 | 5062 { |
2367 | 5063 return (Ibyte *) xstrdup ((const Chbyte *) s); |
771 | 5064 } |
5065 | |
867 | 5066 DECLARE_INLINE_HEADER (Bytecount qxestrlen (const Ibyte *s)) |
771 | 5067 { |
2367 | 5068 return strlen ((const Chbyte *) s); |
771 | 5069 } |
5070 | |
867 | 5071 DECLARE_INLINE_HEADER (Charcount qxestrcharlen (const Ibyte *s)) |
771 | 5072 { |
5073 return bytecount_to_charcount (s, qxestrlen (s)); | |
5074 } | |
5075 | |
867 | 5076 DECLARE_INLINE_HEADER (int qxestrcmp (const Ibyte *s1, |
5077 const Ibyte *s2)) | |
771 | 5078 { |
2367 | 5079 return strcmp ((const Chbyte *) s1, (const Chbyte *) s2); |
771 | 5080 } |
5081 | |
2367 | 5082 DECLARE_INLINE_HEADER (int qxestrcmp_ascii (const Ibyte *s1, |
5083 const Ascbyte *s2)) | |
771 | 5084 { |
2367 | 5085 return strcmp ((const Chbyte *) s1, s2); |
771 | 5086 } |
5087 | |
867 | 5088 DECLARE_INLINE_HEADER (int qxestrncmp (const Ibyte *string1, |
5089 const Ibyte *string2, | |
771 | 5090 Bytecount count)) |
5091 { | |
2367 | 5092 return strncmp ((const Chbyte *) string1, (const Chbyte *) string2, |
771 | 5093 (size_t) count); |
5094 } | |
5095 | |
2367 | 5096 DECLARE_INLINE_HEADER (int qxestrncmp_ascii (const Ibyte *string1, |
5097 const Ascbyte *string2, | |
5098 Bytecount count)) | |
771 | 5099 { |
2367 | 5100 return strncmp ((const Chbyte *) string1, string2, (size_t) count); |
771 | 5101 } |
5102 | |
867 | 5103 DECLARE_INLINE_HEADER (Ibyte *qxestrcpy (Ibyte *strDest, |
2367 | 5104 const Ibyte *strSource)) |
771 | 5105 { |
2367 | 5106 return (Ibyte *) strcpy ((Chbyte *) strDest, (const Chbyte *) strSource); |
771 | 5107 } |
5108 | |
2367 | 5109 DECLARE_INLINE_HEADER (Ibyte *qxestrcpy_ascii (Ibyte *strDest, |
5110 const Ascbyte *strSource)) | |
771 | 5111 { |
2367 | 5112 return (Ibyte *) strcpy ((Chbyte *) strDest, strSource); |
771 | 5113 } |
5114 | |
867 | 5115 DECLARE_INLINE_HEADER (Ibyte *qxestrncpy (Ibyte *strDest, |
2367 | 5116 const Ibyte *strSource, |
5117 Bytecount count)) | |
771 | 5118 { |
2367 | 5119 return (Ibyte *) strncpy ((Chbyte *) strDest, (const Chbyte *) strSource, |
771 | 5120 (size_t) count); |
5121 } | |
5122 | |
2367 | 5123 DECLARE_INLINE_HEADER (Ibyte *qxestrncpy_ascii (Ibyte *strDest, |
5124 const Ascbyte *strSource, | |
5125 Bytecount count)) | |
771 | 5126 { |
2367 | 5127 return (Ibyte *) strncpy ((Chbyte *) strDest, strSource, (size_t) count); |
771 | 5128 } |
5129 | |
867 | 5130 DECLARE_INLINE_HEADER (Ibyte *qxestrcat (Ibyte *strDest, |
2367 | 5131 const Ibyte *strSource)) |
771 | 5132 { |
2367 | 5133 return (Ibyte *) strcat ((Chbyte *) strDest, (const Chbyte *) strSource); |
771 | 5134 } |
5135 | |
2367 | 5136 DECLARE_INLINE_HEADER (Ibyte *qxestrcat_ascii (Ibyte *strDest, |
5137 const Ascbyte *strSource)) | |
771 | 5138 { |
2367 | 5139 return (Ibyte *) strcat ((Chbyte *) strDest, strSource); |
771 | 5140 } |
5141 | |
867 | 5142 DECLARE_INLINE_HEADER (Ibyte *qxestrncat (Ibyte *strDest, |
2367 | 5143 const Ibyte *strSource, |
5144 Bytecount count)) | |
771 | 5145 { |
2367 | 5146 return (Ibyte *) strncat ((Chbyte *) strDest, (const Chbyte *) strSource, |
771 | 5147 (size_t) count); |
5148 } | |
5149 | |
2367 | 5150 DECLARE_INLINE_HEADER (Ibyte *qxestrncat_ascii (Ibyte *strDest, |
5151 const Ascbyte *strSource, | |
5152 Bytecount count)) | |
771 | 5153 { |
2367 | 5154 return (Ibyte *) strncat ((Chbyte *) strDest, strSource, (size_t) count); |
771 | 5155 } |
5156 | |
867 | 5157 DECLARE_INLINE_HEADER (Ibyte *qxestrchr (const Ibyte *s, Ichar c)) |
771 | 5158 { |
5159 assert (c >= 0 && c <= 255); | |
2367 | 5160 return (Ibyte *) strchr ((const Chbyte *) s, c); |
771 | 5161 } |
5162 | |
867 | 5163 DECLARE_INLINE_HEADER (Ibyte *qxestrrchr (const Ibyte *s, Ichar c)) |
771 | 5164 { |
5165 assert (c >= 0 && c <= 255); | |
2367 | 5166 return (Ibyte *) strrchr ((const Chbyte *) s, c); |
771 | 5167 } |
5168 | |
867 | 5169 DECLARE_INLINE_HEADER (Ibyte *qxestrstr (const Ibyte *string1, |
2367 | 5170 const Ibyte *string2)) |
771 | 5171 { |
2367 | 5172 return (Ibyte *) strstr ((const Chbyte *) string1, (const Chbyte *) string2); |
771 | 5173 } |
5174 | |
867 | 5175 DECLARE_INLINE_HEADER (Bytecount qxestrcspn (const Ibyte *string, |
5176 const CIbyte *strCharSet)) | |
771 | 5177 { |
2367 | 5178 return (Bytecount) strcspn ((const Chbyte *) string, strCharSet); |
771 | 5179 } |
5180 | |
867 | 5181 DECLARE_INLINE_HEADER (Bytecount qxestrspn (const Ibyte *string, |
5182 const CIbyte *strCharSet)) | |
771 | 5183 { |
2367 | 5184 return (Bytecount) strspn ((const Chbyte *) string, strCharSet); |
771 | 5185 } |
5186 | |
867 | 5187 DECLARE_INLINE_HEADER (Ibyte *qxestrpbrk (const Ibyte *string, |
2367 | 5188 const CIbyte *strCharSet)) |
771 | 5189 { |
2367 | 5190 return (Ibyte *) strpbrk ((const Chbyte *) string, strCharSet); |
771 | 5191 } |
5192 | |
867 | 5193 DECLARE_INLINE_HEADER (Ibyte *qxestrtok (Ibyte *strToken, |
2367 | 5194 const CIbyte *strDelimit)) |
771 | 5195 { |
2367 | 5196 return (Ibyte *) strtok ((Chbyte *) strToken, strDelimit); |
771 | 5197 } |
5198 | |
867 | 5199 DECLARE_INLINE_HEADER (double qxestrtod (const Ibyte *nptr, |
5200 Ibyte **endptr)) | |
771 | 5201 { |
2367 | 5202 return strtod ((const Chbyte *) nptr, (Chbyte **) endptr); |
771 | 5203 } |
5204 | |
867 | 5205 DECLARE_INLINE_HEADER (long qxestrtol (const Ibyte *nptr, Ibyte **endptr, |
771 | 5206 int base)) |
5207 { | |
2367 | 5208 return strtol ((const Chbyte *) nptr, (Chbyte **) endptr, base); |
771 | 5209 } |
5210 | |
867 | 5211 DECLARE_INLINE_HEADER (unsigned long qxestrtoul (const Ibyte *nptr, |
5212 Ibyte **endptr, | |
771 | 5213 int base)) |
5214 { | |
2367 | 5215 return strtoul ((const Chbyte *) nptr, (Chbyte **) endptr, base); |
771 | 5216 } |
5217 | |
867 | 5218 DECLARE_INLINE_HEADER (int qxeatoi (const Ibyte *string)) |
771 | 5219 { |
2367 | 5220 return atoi ((const Chbyte *) string); |
771 | 5221 } |
5222 | |
1204 | 5223 DECLARE_INLINE_HEADER (Ibyte *qxestrupr (Ibyte *s)) |
5224 { | |
2367 | 5225 return (Ibyte *) strupr ((Chbyte *) s); |
1204 | 5226 } |
5227 | |
5228 DECLARE_INLINE_HEADER (Ibyte *qxestrlwr (Ibyte *s)) | |
5229 { | |
2367 | 5230 return (Ibyte *) strlwr ((Chbyte *) s); |
1204 | 5231 } |
5232 | |
867 | 5233 int qxesprintf (Ibyte *buffer, const CIbyte *format, ...) |
771 | 5234 PRINTF_ARGS (2, 3); |
5235 | |
2367 | 5236 DECLARE_INLINE_HEADER (int qxesscanf_ascii_1 (Ibyte *buffer, |
5237 const Ascbyte *format, | |
5238 void *ptr)) | |
5239 { | |
5240 /* #### DAMNIT! No vsscanf! */ | |
5241 return sscanf ((Chbyte *) buffer, format, ptr); | |
5242 } | |
5243 | |
771 | 5244 /* Do not use POSIX locale routines. Not Mule-correct. */ |
5245 #define qxestrcoll DO NOT USE. | |
5246 #define qxestrxfrm DO NOT USE. | |
5247 | |
867 | 5248 int qxestrcasecmp (const Ibyte *s1, const Ibyte *s2); |
2367 | 5249 int qxestrcasecmp_ascii (const Ibyte *s1, const Ascbyte *s2); |
867 | 5250 int qxestrcasecmp_i18n (const Ibyte *s1, const Ibyte *s2); |
2367 | 5251 int ascii_strcasecmp (const Ascbyte *s1, const Ascbyte *s2); |
771 | 5252 int lisp_strcasecmp (Lisp_Object s1, Lisp_Object s2); |
5253 int lisp_strcasecmp_i18n (Lisp_Object s1, Lisp_Object s2); | |
867 | 5254 int qxestrncasecmp (const Ibyte *s1, const Ibyte *s2, Bytecount len); |
2367 | 5255 int qxestrncasecmp_ascii (const Ibyte *s1, const Ascbyte *s2, |
5256 Bytecount len); | |
867 | 5257 int qxestrncasecmp_i18n (const Ibyte *s1, const Ibyte *s2, Bytecount len); |
2367 | 5258 int ascii_strncasecmp (const Ascbyte *s1, const Ascbyte *s2, |
771 | 5259 Bytecount len); |
867 | 5260 int qxememcmp (const Ibyte *s1, const Ibyte *s2, Bytecount len); |
5261 int qxememcmp4 (const Ibyte *s1, Bytecount len1, | |
5262 const Ibyte *s2, Bytecount len2); | |
5263 int qxememcasecmp (const Ibyte *s1, const Ibyte *s2, Bytecount len); | |
5264 int qxememcasecmp4 (const Ibyte *s1, Bytecount len1, | |
5265 const Ibyte *s2, Bytecount len2); | |
5266 int qxetextcmp (const Ibyte *s1, Bytecount len1, | |
5267 const Ibyte *s2, Bytecount len2); | |
5268 int qxetextcmp_matching (const Ibyte *s1, Bytecount len1, | |
5269 const Ibyte *s2, Bytecount len2, | |
801 | 5270 Charcount *matching); |
867 | 5271 int qxetextcasecmp (const Ibyte *s1, Bytecount len1, |
5272 const Ibyte *s2, Bytecount len2); | |
5273 int qxetextcasecmp_matching (const Ibyte *s1, Bytecount len1, | |
5274 const Ibyte *s2, Bytecount len2, | |
801 | 5275 Charcount *matching); |
771 | 5276 |
5277 void buffer_mule_signal_inserted_region (struct buffer *buf, Charbpos start, | |
5278 Bytecount bytelength, | |
5279 Charcount charlength); | |
5280 void buffer_mule_signal_deleted_region (struct buffer *buf, Charbpos start, | |
826 | 5281 Charbpos end, Bytebpos byte_start, |
5282 Bytebpos byte_end); | |
771 | 5283 |
2367 | 5284 typedef struct |
5285 { | |
5286 const char *srctext; | |
5287 void *dst; | |
5288 Bytecount dst_size; | |
5289 } alloca_convert_vals; | |
5290 | |
5291 typedef struct | |
5292 { | |
5293 Dynarr_declare (alloca_convert_vals); | |
5294 } alloca_convert_vals_dynarr; | |
5295 | |
5296 extern alloca_convert_vals_dynarr *active_alloca_convert; | |
5297 | |
5298 MODULE_API int find_pos_of_existing_active_alloca_convert (const char * | |
5299 srctext); | |
5300 | |
771 | 5301 /* Defined in unicode.c */ |
1204 | 5302 extern const struct sized_memory_description to_unicode_description; |
5303 extern const struct sized_memory_description from_unicode_description; | |
771 | 5304 void init_charset_unicode_tables (Lisp_Object charset); |
5305 void free_charset_unicode_tables (Lisp_Object charset); | |
5306 void recalculate_unicode_precedence (void); | |
5307 extern Lisp_Object Qunicode; | |
5308 extern Lisp_Object Qutf_16, Qutf_8, Qucs_4, Qutf_7; | |
5309 #ifdef MEMORY_USAGE_STATS | |
5310 Bytecount compute_from_unicode_table_size (Lisp_Object charset, | |
5311 struct overhead_stats *stats); | |
5312 Bytecount compute_to_unicode_table_size (Lisp_Object charset, | |
5313 struct overhead_stats *stats); | |
5314 #endif /* MEMORY_USAGE_STATS */ | |
5315 | |
428 | 5316 /* Defined in undo.c */ |
826 | 5317 EXFUN (Fundo_boundary, 0); |
5318 | |
428 | 5319 Lisp_Object truncate_undo_list (Lisp_Object, int, int); |
5320 void record_extent (Lisp_Object, int); | |
665 | 5321 void record_insert (struct buffer *, Charbpos, Charcount); |
5322 void record_delete (struct buffer *, Charbpos, Charcount); | |
5323 void record_change (struct buffer *, Charbpos, Charcount); | |
428 | 5324 |
5325 /* Defined in unex*.c */ | |
814 | 5326 #ifdef WIN32_NATIVE |
867 | 5327 int unexec (Ibyte *, Ibyte *, uintptr_t, uintptr_t, uintptr_t); |
814 | 5328 #else |
5329 int unexec (Extbyte *, Extbyte *, uintptr_t, uintptr_t, uintptr_t); | |
5330 #endif | |
428 | 5331 #ifdef RUN_TIME_REMAP |
5332 int run_time_remap (char *); | |
5333 #endif | |
5334 | |
5335 /* Defined in vm-limit.c */ | |
442 | 5336 void memory_warnings (void *, void (*) (const char *)); |
428 | 5337 |
442 | 5338 /*--------------- prototypes for constant symbols ------------*/ |
5339 | |
826 | 5340 /* #### We should get rid of this and put the prototypes back up there in |
5341 #### the per-file stuff, where they belong. */ | |
5342 | |
771 | 5343 /* Use the following when you have to add a bunch of symbols. */ |
5344 | |
5345 /* | |
5346 | |
5347 (defun redo-symbols (beg end) | |
5348 "Snarf any symbols out of the region and print them into a temporary buffer, | |
5349 which is displayed when the function finishes. The symbols are laid out with | |
5350 `extern Lisp_Object ' before each one, with as many as can fit on one line | |
5351 \(the maximum line width is controlled by the constant `max-line-length' in the | |
5352 code)." | |
5353 (interactive "r") | |
5354 (save-excursion | |
5355 (goto-char beg) | |
5356 (let (syms) | |
5357 (while (re-search-forward "\\s-\\(Q[A-Za-z_0-9]+\\)" end t) | |
5358 (push (match-string 1) syms)) | |
5359 (setq syms (sort syms #'string-lessp)) | |
5360 (with-output-to-temp-buffer "*Symbols*" | |
5361 (let* ((col 0) | |
5362 (start "extern Lisp_Object ") | |
5363 (startlen (length start)) | |
5364 ;; with a default-width frame of 80 chars, you can only fit | |
5365 ;; 79 before wrapping. you can see this to a lower value if | |
5366 ;; you don't want it right up against the right margin. | |
5367 (max-line-length 79)) | |
5368 (dolist (sym syms) | |
5369 (cond (;; if something already on line (this will always be the | |
5370 ;; case except the very first iteration), see what | |
5371 ;; space we've got. (need to take into account 2 | |
5372 ;; for the comma+space, 1 for the semicolon at the | |
5373 ;; end.) if enough space, do it. | |
5374 (and (> col 0) (< (+ col (length sym) 2) | |
5375 (1- max-line-length))) | |
5376 (princ ", ") | |
5377 (princ sym) | |
5378 (incf col 2) | |
5379 (incf col (length sym))) | |
5380 (t | |
5381 ;; either we're first iteration or we ran out of space. | |
5382 ;; if the latter, terminate the previous line. this | |
5383 ;; loop is written on purpose so that it always prints | |
5384 ;; at least one item, even if that would go over. | |
5385 (when (> col 0) | |
5386 (princ ";\n") | |
5387 (setq col 0)) | |
5388 (princ start) | |
5389 (incf col startlen) | |
5390 (princ sym) | |
5391 (incf col (length sym))))) | |
5392 ;; finally terminate the last line. | |
5393 (princ ";\n")))))) | |
5394 | |
5395 */ | |
5396 | |
814 | 5397 extern Lisp_Object Qactivate_menubar_hook, Qand_optional, Qand_rest; |
5398 extern Lisp_Object Qarith_error, Qarrayp, Qautoload, Qbackground; | |
5399 extern Lisp_Object Qbackground_pixmap, Qbeginning_of_buffer, Qbitp, Qblinking; | |
5400 extern Lisp_Object Qbuffer_glyph_p, Qbuffer_live_p, Qbuffer_read_only; | |
5401 extern Lisp_Object Qbyte_code, Qcall_interactively, Qcategory_designator_p; | |
5402 extern Lisp_Object Qcategory_table_value_p, Qcdr, Qchar_or_string_p; | |
5403 extern Lisp_Object Qcharacterp, Qcircular_list, Qcircular_property_list; | |
5404 extern Lisp_Object Qcolor_pixmap_image_instance_p, Qcommandp; | |
5405 extern Lisp_Object Qcompletion_ignore_case, Qconsole_live_p, Qconst_specifier; | |
5406 extern Lisp_Object Qconversion_error, Qcurrent_menubar; | |
771 | 5407 extern Lisp_Object Qcyclic_variable_indirection, Qdefun, Qdevice_live_p, Qdim; |
5408 extern Lisp_Object Qdirection, Qdisabled, Qdisabled_command_hook; | |
930 | 5409 extern Lisp_Object Qdisplay_table, Qdll_error, Qdomain_error, Qediting_error; |
771 | 5410 extern Lisp_Object Qend_of_buffer, Qend_of_file, Qend_open, Qerror; |
5411 extern Lisp_Object Qerror_conditions, Qerror_lacks_explanatory_string; | |
5412 extern Lisp_Object Qerror_message, Qevent_live_p, Qexit, Qextent_live_p; | |
996 | 5413 extern Lisp_Object Qexternal_debugging_output, Qfeaturep, Qfile_error; |
5414 extern Lisp_Object Qfile_name_sans_extension, Qfinal; | |
1111 | 5415 extern Lisp_Object Qforeground, Qformat, Qframe_live_p, Qgraphic; |
771 | 5416 extern Lisp_Object Qgui_error, Qicon_glyph_p, Qidentity, Qinhibit_quit; |
5417 extern Lisp_Object Qinhibit_read_only, Qinteger_char_or_marker_p; | |
1632 | 5418 extern Lisp_Object Qinteger_or_char_p, Qinteger_or_marker_p; |
5419 extern Lisp_Object Qinteractive, Qinternal_error; | |
771 | 5420 extern Lisp_Object Qinvalid_byte_code, Qinvalid_change, Qinvalid_constant; |
5421 extern Lisp_Object Qinvalid_function, Qinvalid_operation; | |
5422 extern Lisp_Object Qinvalid_read_syntax, Qinvalid_state, Qio_error, Qlambda; | |
1111 | 5423 extern Lisp_Object Qlayout, Qlist_formation_error, Qlistp, Qload; |
771 | 5424 extern Lisp_Object Qlong_name, Qmacro, Qmakunbound, Qmalformed_list; |
996 | 5425 extern Lisp_Object Qmalformed_property_list, Qmark, Qmodule; |
771 | 5426 extern Lisp_Object Qmono_pixmap_image_instance_p, Qmouse_leave_buffer_hook; |
5427 extern Lisp_Object Qnative_layout, Qnatnump, Qnetwork_error, Qno_catch; | |
1983 | 5428 extern Lisp_Object Qnonnegativep, Qnothing_image_instance_p; |
5429 extern Lisp_Object Qnumber_char_or_marker_p, Qnumberp, Qout_of_memory; | |
442 | 5430 extern Lisp_Object Qoverflow_error, Qpoint, Qpointer_glyph_p; |
771 | 5431 extern Lisp_Object Qpointer_image_instance_p, Qprint_length; |
563 | 5432 extern Lisp_Object Qprint_string_length, Qprinting_unreadable_object; |
1632 | 5433 extern Lisp_Object Qprogn, Qquit, Qquote, Qrange_error; |
771 | 5434 extern Lisp_Object Qread_char, Qread_from_minibuffer; |
5435 extern Lisp_Object Qreally_early_error_handler, Qregion_beginning; | |
5436 extern Lisp_Object Qregion_end, Qregistry, Qreverse_direction_charset; | |
5437 extern Lisp_Object Qrun_hooks, Qsans_modifiers, Qsave_buffers_kill_emacs; | |
5438 extern Lisp_Object Qself_insert_command, Qself_insert_defer_undo, Qsequencep; | |
5439 extern Lisp_Object Qset, Qsetting_constant, Qshort_name, Qsingularity_error; | |
5440 extern Lisp_Object Qsound_error, Qstack_overflow, Qstandard_input; | |
5441 extern Lisp_Object Qstandard_output, Qstart_open, Qstring_lessp; | |
5442 extern Lisp_Object Qstructure_formation_error, Qsubwindow; | |
1632 | 5443 extern Lisp_Object Qsubwindow_image_instance_p; |
771 | 5444 extern Lisp_Object Qtext_conversion_error, Qtext_image_instance_p, Qtop_level; |
1632 | 5445 extern Lisp_Object Qtrue_list_p, Qunderflow_error, Qunderline; |
771 | 5446 extern Lisp_Object Quser_files_and_directories, Qvalues; |
5447 extern Lisp_Object Qvariable_documentation, Qvariable_domain, Qvoid_function; | |
5448 extern Lisp_Object Qvoid_variable, Qwindow_live_p, Qwrong_number_of_arguments; | |
442 | 5449 extern Lisp_Object Qwrong_type_argument, Qyes_or_no_p; |
5450 | |
1632 | 5451 extern MODULE_API Lisp_Object Qintegerp, Qinvalid_argument, Qprocess_error; |
5452 extern MODULE_API Lisp_Object Qsyntax_error, Qt, Qunbound; | |
5453 | |
442 | 5454 #define SYMBOL(fou) extern Lisp_Object fou |
1632 | 5455 #define SYMBOL_MODULE_API(fou) extern MODULE_API Lisp_Object fou |
442 | 5456 #define SYMBOL_KEYWORD(la_cle_est_fou) extern Lisp_Object la_cle_est_fou |
5457 #define SYMBOL_GENERAL(tout_le_monde, est_fou) \ | |
5458 extern Lisp_Object tout_le_monde | |
5459 | |
5460 #include "general-slots.h" | |
5461 | |
5462 #undef SYMBOL | |
1632 | 5463 #undef SYMBOL_MODULE_API |
442 | 5464 #undef SYMBOL_KEYWORD |
5465 #undef SYMBOL_GENERAL | |
5466 | |
5467 /*--------------- prototypes for variables of type Lisp_Object ------------*/ | |
5468 | |
826 | 5469 /* #### We should get rid of this and put the prototypes back up there in |
5470 #### the per-file stuff, where they belong. */ | |
5471 | |
446 | 5472 extern Lisp_Object Vactivate_menubar_hook; |
5473 extern Lisp_Object Vautoload_queue, Vblank_menubar; | |
771 | 5474 extern Lisp_Object Vcommand_history; |
428 | 5475 extern Lisp_Object Vcommand_line_args, Vconfigure_info_directory; |
5476 extern Lisp_Object Vconfigure_site_directory, Vconfigure_site_module_directory; | |
5477 extern Lisp_Object Vconsole_list, Vcontrolling_terminal; | |
5478 extern Lisp_Object Vcurrent_compiled_function_annotation, Vcurrent_load_list; | |
5479 extern Lisp_Object Vcurrent_mouse_event, Vcurrent_prefix_arg, Vdata_directory; | |
434 | 5480 extern Lisp_Object Vdirectory_sep_char, Vdisabled_command_hook; |
5481 extern Lisp_Object Vdoc_directory, Vinternal_doc_file_name; | |
428 | 5482 extern Lisp_Object Vecho_area_buffer, Vemacs_major_version; |
5483 extern Lisp_Object Vemacs_minor_version, Vexec_directory, Vexec_path; | |
5484 extern Lisp_Object Vexecuting_macro, Vfeatures, Vfile_domain; | |
1927 | 5485 extern Lisp_Object Vinvocation_directory, Vinvocation_name; |
771 | 5486 extern Lisp_Object Vlast_command, Vlast_command_char; |
428 | 5487 extern Lisp_Object Vlast_command_event, Vlast_input_event; |
2548 | 5488 extern Lisp_Object Vload_file_name_internal, Vload_history; |
428 | 5489 extern Lisp_Object Vload_path, Vmark_even_if_inactive, Vmenubar_configuration; |
5490 extern Lisp_Object Vminibuf_preprompt, Vminibuf_prompt, Vminibuffer_zero; | |
5491 extern Lisp_Object Vmodule_directory, Vmswindows_downcase_file_names; | |
5492 extern Lisp_Object Vmswindows_get_true_file_attributes, Vobarray; | |
5493 extern Lisp_Object Vprint_length, Vprint_level, Vprocess_environment; | |
5494 extern Lisp_Object Vrecent_keys_ring, Vshell_file_name, Vsite_directory; | |
5495 extern Lisp_Object Vsite_module_directory; | |
5496 extern Lisp_Object Vstandard_input, Vstandard_output, Vstdio_str; | |
771 | 5497 extern Lisp_Object Vsynchronous_sounds, Vsystem_name; |
428 | 5498 extern Lisp_Object Vthis_command_keys, Vunread_command_event; |
5499 extern Lisp_Object Vx_initial_argv_list; | |
5500 | |
1927 | 5501 extern MODULE_API Lisp_Object Vinhibit_quit, Vquit_flag; |
5502 | |
1743 | 5503 END_C_DECLS |
1650 | 5504 |
440 | 5505 #endif /* INCLUDED_lisp_h_ */ |