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