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