comparison src/lisp.h @ 2367:ecf1ebac70d8

[xemacs-hg @ 2004-11-04 23:05:23 by ben] commit mega-patch configure.in: Turn off -Winline and -Wchar-subscripts. Use the right set of cflags when compiling modules. Rewrite ldap configuration to separate the inclusion of lber (needed in recent Cygwin) from the basic checks for the needed libraries. add a function for MAKE_JUNK_C; initially code was added to generate xemacs.def using this, but it will need to be rewritten. add an rm -f for junk.c to avoid weird Cygwin bug with cp -f onto an existing file. Sort list of auto-detected functions and eliminate unused checks for stpcpy, setlocale and getwd. Add autodetection of Cygwin scanf problems BETA: Rewrite section on configure to indicate what flags are important and what not. digest-doc.c, make-dump-id.c, profile.c, sorted-doc.c: Add proper decls for main(). make-msgfile.c: Document that this is old junk. Move proposal to text.c. make-msgfile.lex: Move proposal to text.c. make-mswin-unicode.pl: Convert error-generating code so that the entire message will be seen as a single unrecognized token. mule/mule-ccl.el: Update docs. lispref/mule.texi: Update CCL docs. ldap/eldap.c: Mule-ize. Use EXTERNAL_LIST_LOOP_2 instead of deleted EXTERNAL_LIST_LOOP. * XEmacs 21.5.18 "chestnut" is released. --------------------------------------------------------------- MULE-RELATED WORK: --------------------------------------------------------------- --------------------------- byte-char conversion --------------------------- buffer.c, buffer.h, insdel.c, text.c: Port FSF algorithm for byte-char conversion, replacing broken previous version. Track the char position of the gap. Add functions to do char-byte conversion downwards as well as upwards. Move comments about algorithm workings to internals manual. --------------------------- work on types --------------------------- alloc.c, console-x-impl.h, dump-data.c, dump-data.h, dumper.c, dialog-msw.c, dired-msw.c, doc.c, editfns.c, esd.c, event-gtk.h, event-msw.c, events.c, file-coding.c, file-coding.h, fns.c, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-shared.c, glyphs-x.c, glyphs.c, glyphs.h, gui.c, hpplay.c, imgproc.c, intl-win32.c, lrecord.h, lstream.c, keymap.c, lisp.h, libsst.c, linuxplay.c, miscplay.c, miscplay.h, mule-coding.c, nas.c, nt.c, ntheap.c, ntplay.c, objects-msw.c, objects-tty.c, objects-x.c, print.c, process-nt.c, process.c, redisplay.h, select-common.h, select-gtk.c, select-x.c, sgiplay.c, sound.c, sound.h, sunplay.c, sysfile.h, sysdep.c, syswindows.h, text.c, unexnt.c, win32.c, xgccache.c: Further work on types. This creates a full set of types for all the basic semantics of `char' that I have so far identified, so that its semantics can always be identified for the purposes of proper Mule-safe code, and the raw use of `char' always avoided. (1) More type renaming, for consistency of naming. Char_ASCII -> Ascbyte UChar_ASCII -> UAscbyte Char_Binary -> CBinbyte UChar_Binary -> Binbyte SChar_Binary -> SBinbyte (2) Introduce Rawbyte, CRawbyte, Boolbyte, Chbyte, UChbyte, and Bitbyte and use them. (3) New types Itext, Wexttext and Textcount for separating out the concepts of bytes and textual units (different under UTF-16 and UTF-32, which are potential internal encodings). (4) qxestr*_c -> qxestr*_ascii. lisp.h: New; goes with other qxe() functions. #### Maybe goes in a different section. lisp.h: Group generic int-type defs together with EMACS_INT defs. lisp.h: * lisp.h (WEXTTEXT_IS_WIDE) New defns. lisp.h: New type to replace places where int occurs as a boolean. It's signed because occasionally people may want to use -1 as an error value, and because unsigned ints are viral -- see comments in the internals manual against using them. dynarr.c: int -> Bytecount. --------------------------- Mule-izing --------------------------- device-x.c: Partially Mule-ize. dumper.c, dumper.h: Mule-ize. Use Rawbyte. Use stderr_out not printf. Use wext_*(). sysdep.c, syswindows.h, text.c: New Wexttext API for manipulation of external text that may be Unicode (e.g. startup code under Windows). emacs.c: Mule-ize. Properly deal with argv in external encoding. Use wext_*() and Wexttext. Use Rawbyte. #if 0 some old junk on SCO that is unlikely to be correct. Rewrite allocation code in run-temacs. emacs.c, symsinit.h, win32.c: Rename win32 init function and call it even earlier, to initialize mswindows_9x_p even earlier, for use in startup code (XEUNICODE_P). process.c: Use _wenviron not environ under Windows, to get Unicode environment variables. event-Xt.c: Mule-ize drag-n-drop related stuff. dragdrop.c, dragdrop.h, frame-x.c: Mule-ize. text.h: Add some more stand-in defines for particular kinds of conversion; use in Mule-ization work in frame-x.c etc. --------------------------- Freshening --------------------------- intl-auto-encap-win32.c, intl-auto-encap-win32.h: Regenerate. --------------------------- Unicode-work --------------------------- intl-win32.c, syswindows.h: Factor out common options to MultiByteToWideChar and WideCharToMultiByte. Add convert_unicode_to_multibyte_malloc() and convert_unicode_to_multibyte_dynarr() and use. Add stuff for alloca() conversion of multibyte/unicode. alloc.c: Use dfc_external_data_len() in case of unicode coding system. alloc.c, mule-charset.c: Don't zero out and reinit charset Unicode tables. This fucks up dump-time loading. Anyway, either we load them at dump time or run time, never both. unicode.c: Dump the blank tables as well. --------------------------------------------------------------- DOCUMENTATION, MOSTLY MULE-RELATED: --------------------------------------------------------------- EmacsFrame.c, emodules.c, event-Xt.c, fileio.c, input-method-xlib.c, mule-wnnfns.c, redisplay-gtk.c, redisplay-tty.c, redisplay-x.c, regex.c, sysdep.c: Add comment about Mule work needed. text.h: Add more documentation describing why DFC routines were not written to return their value. Add some other DFC documentation. console-msw.c, console-msw.h: Add pointer to docs in win32.c. emacs.c: Add comments on sources of doc info. text.c, charset.h, unicode.c, intl-win32.c, intl-encap-win32.c, text.h, file-coding.c, mule-coding.c: Collect background comments and related to text matters and internationalization, and proposals for work to be done, in text.c or Internals manual, stuff related to specific textual API's in text.h, and stuff related to internal implementation of Unicode conversion in unicode.c. Put lots of pointers to the comments to make them easier to find. s/mingw32.h, s/win32-common.h, s/win32-native.h, s/windowsnt.h, win32.c: Add bunches of new documentation on the different kinds of builds and environments under Windows and how they work. Collect this info in win32.c. Add pointers to these docs in the relevant s/* files. emacs.c: Document places with long comments. Remove comment about exiting, move to internals manual, put in pointer. event-stream.c: Move docs about event queues and focus to internals manual, put in pointer. events.h: Move docs about event stream callbacks to internals manual, put in pointer. profile.c, redisplay.c, signal.c: Move documentation to the Internals manual. process-nt.c: Add pointer to comment in win32-native.el. lisp.h: Add comments about some comment conventions. lisp.h: Add comment about the second argument. device-msw.c, redisplay-msw.c: @@#### comments are out-of-date. --------------------------------------------------------------- PDUMP WORK (MOTIVATED BY UNICODE CHANGES) --------------------------------------------------------------- alloc.c, buffer.c, bytecode.c, console-impl.h, console.c, device.c, dumper.c, lrecord.h, elhash.c, emodules.h, events.c, extents.c, frame.c, glyphs.c, glyphs.h, mule-charset.c, mule-coding.c, objects.c, profile.c, rangetab.c, redisplay.c, specifier.c, specifier.h, window.c, lstream.c, file-coding.h, file-coding.c: PDUMP: Properly implement dump_add_root_block(), which never worked before, and is necessary for dumping Unicode tables. Pdump name changes for accuracy: XD_STRUCT_PTR -> XD_BLOCK_PTR. XD_STRUCT_ARRAY -> XD_BLOCK_ARRAY. XD_C_STRING -> XD_ASCII_STRING. *_structure_* -> *_block_*. lrecord.h: some comments added about dump_add_root_block() vs dump_add_root_block_ptr(). extents.c: remove incorrect comment about pdump problems with gap array. --------------------------------------------------------------- ALLOCATION --------------------------------------------------------------- abbrev.c, alloc.c, bytecode.c, casefiddle.c, device-msw.c, device-x.c, dired-msw.c, doc.c, doprnt.c, dragdrop.c, editfns.c, emodules.c, file-coding.c, fileio.c, filelock.c, fns.c, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-x.c, gui-msw.c, gui-x.c, imgproc.c, intl-win32.c, lread.c, menubar-gtk.c, menubar.c, nt.c, objects-msw.c, objects-x.c, print.c, process-nt.c, process-unix.c, process.c, realpath.c, redisplay.c, search.c, select-common.c, symbols.c, sysdep.c, syswindows.h, text.c, text.h, ui-byhand.c: New macros {alloca,xnew}_{itext,{i,ext,raw,bin,asc}bytes} for more convenient allocation of these commonly requested items. Modify functions to use alloca_ibytes, alloca_array, alloca_extbytes, xnew_ibytes, etc. also XREALLOC_ARRAY, xnew. alloc.c: Rewrite the allocation functions to factor out repeated code. Add assertions for freeing dumped data. lisp.h: Moved down and consolidated with other allocation stuff. lisp.h, dynarr.c: New functions for allocation that's very efficient when mostly in LIFO order. lisp.h, text.c, text.h: Factor out some stuff for general use by alloca()-conversion funs. text.h, lisp.h: Fill out convenience routines for allocating various kinds of bytes and put them in lisp.h. Use them in place of xmalloc(), ALLOCA(). text.h: Fill out the convenience functions so the _MALLOC() kinds match the alloca() kinds. --------------------------------------------------------------- ERROR-CHECKING --------------------------------------------------------------- text.h: Create ASSERT_ASCTEXT_ASCII() and ASSERT_ASCTEXT_ASCII_LEN() from similar Eistring checkers and change the Eistring checkers to use them instead. --------------------------------------------------------------- MACROS IN LISP.H --------------------------------------------------------------- lisp.h: Redo GCPRO declarations. Create a "base" set of functions that can be used to generate any kind of gcpro sets -- regular, ngcpro, nngcpro, private ones used in GC_EXTERNAL_LIST_LOOP_2. buffer.c, callint.c, chartab.c, console-msw.c, device-x.c, dialog-msw.c, dired.c, extents.c, ui-gtk.c, rangetab.c, nt.c, mule-coding.c, minibuf.c, menubar-msw.c, menubar.c, menubar-gtk.c, lread.c, lisp.h, gutter.c, glyphs.c, glyphs-widget.c, fns.c, fileio.c, file-coding.c, specifier.c: Eliminate EXTERNAL_LIST_LOOP, which does not check for circularities. Use EXTERNAL_LIST_LOOP_2 instead or EXTERNAL_LIST_LOOP_3 or EXTERNAL_PROPERTY_LIST_LOOP_3 or GC_EXTERNAL_LIST_LOOP_2 (new macro). Removed/redid comments on EXTERNAL_LIST_LOOP. --------------------------------------------------------------- SPACING FIXES --------------------------------------------------------------- callint.c, hftctl.c, number-gmp.c, process-unix.c: Spacing fixes. --------------------------------------------------------------- FIX FOR GEOMETRY PROBLEM IN FIRST FRAME --------------------------------------------------------------- unicode.c: Add workaround for newlib bug in sscanf() [should be fixed by release 1.5.12 of Cygwin]. toolbar.c: bug fix for problem of initial frame being 77 chars wide on Windows. will be overridden by my other ws. --------------------------------------------------------------- FIX FOR LEAKING PROCESS HANDLES: --------------------------------------------------------------- process-nt.c: Fixes for leaking handles. Inspired by work done by Adrian Aichner <adrian@xemacs.org>. --------------------------------------------------------------- FIX FOR CYGWIN BUG (Unicode-related): --------------------------------------------------------------- unicode.c: Add workaround for newlib bug in sscanf() [should be fixed by release 1.5.12 of Cygwin]. --------------------------------------------------------------- WARNING FIXES: --------------------------------------------------------------- console-stream.c: `reinit' is unused. compiler.h, event-msw.c, frame-msw.c, intl-encap-win32.c, text.h: Add stuff to deal with ANSI-aliasing warnings I got. regex.c: Gather includes together to avoid warning. --------------------------------------------------------------- CHANGES TO INITIALIZATION ROUTINES: --------------------------------------------------------------- buffer.c, emacs.c, console.c, debug.c, device-x.c, device.c, dragdrop.c, emodules.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-tty.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, font-lock.c, frame-msw.c, glyphs-widget.c, glyphs.c, gui-x.c, insdel.c, lread.c, lstream.c, menubar-gtk.c, menubar-x.c, minibuf.c, mule-wnnfns.c, objects-msw.c, objects.c, print.c, scrollbar-x.c, search.c, select-x.c, text.c, undo.c, unicode.c, window.c, symsinit.h: Call reinit_*() functions directly from emacs.c, for clarity. Factor out some redundant init code. Move disallowed stuff that had crept into vars_of_glyphs() into complex_vars_of_glyphs(). Call init_eval_semi_early() from eval.c not in the middle of vars_of_() in emacs.c since there should be no order dependency in the latter calls. --------------------------------------------------------------- ARMAGEDDON: --------------------------------------------------------------- alloc.c, emacs.c, lisp.h, print.c: Rename inhibit_non_essential_printing_operations to inhibit_non_essential_conversion_operations. text.c: Assert on !inhibit_non_essential_conversion_operations. console-msw.c, print.c: Don't do conversion in SetConsoleTitle or FindWindow to avoid problems during armageddon. Put #errors for NON_ASCII_INTERNAL_FORMAT in places where problems would arise. --------------------------------------------------------------- CHANGES TO THE BUILD PROCEDURE: --------------------------------------------------------------- config.h.in, s/cxux.h, s/usg5-4-2.h, m/powerpc.h: Add comment about correct ordering of this file. Rearrange everything to follow this -- put all #undefs together and before the s&m files. Add undefs for HAVE_ALLOCA, C_ALLOCA, BROKEN_ALLOCA_IN_FUNCTION_CALLS, STACK_DIRECTION. Remove unused HAVE_STPCPY, HAVE_GETWD, HAVE_SETLOCALE. m/gec63.h: Deleted; totally broken, not used at all, not in FSF. m/7300.h, m/acorn.h, m/alliant-2800.h, m/alliant.h, m/altos.h, m/amdahl.h, m/apollo.h, m/att3b.h, m/aviion.h, m/celerity.h, m/clipper.h, m/cnvrgnt.h, m/convex.h, m/cydra5.h, m/delta.h, m/delta88k.h, m/dpx2.h, m/elxsi.h, m/ews4800r.h, m/gould.h, m/hp300bsd.h, m/hp800.h, m/hp9000s300.h, m/i860.h, m/ibmps2-aix.h, m/ibmrs6000.h, m/ibmrt-aix.h, m/ibmrt.h, m/intel386.h, m/iris4d.h, m/iris5d.h, m/iris6d.h, m/irist.h, m/isi-ov.h, m/luna88k.h, m/m68k.h, m/masscomp.h, m/mg1.h, m/mips-nec.h, m/mips-siemens.h, m/mips.h, m/news.h, m/nh3000.h, m/nh4000.h, m/ns32000.h, m/orion105.h, m/pfa50.h, m/plexus.h, m/pmax.h, m/powerpc.h, m/pyrmips.h, m/sequent-ptx.h, m/sequent.h, m/sgi-challenge.h, m/symmetry.h, m/tad68k.h, m/tahoe.h, m/targon31.h, m/tekxd88.h, m/template.h, m/tower32.h, m/tower32v3.h, m/ustation.h, m/vax.h, m/wicat.h, m/xps100.h: Delete C_ALLOCA, HAVE_ALLOCA, STACK_DIRECTION, BROKEN_ALLOCA_IN_FUNCTION_CALLS. All of this is auto-detected. When in doubt, I followed recent FSF sources, which also have these things deleted.
author ben
date Thu, 04 Nov 2004 23:08:28 +0000
parents 61855263cb07
children ab71ad6ff3dd
comparison
equal deleted inserted replaced
2366:2a392e0c390a 2367:ecf1ebac70d8
1 /* Fundamental definitions for XEmacs Lisp interpreter. 1 /* Fundamental definitions for XEmacs Lisp interpreter.
2 Copyright (C) 1985-1987, 1992-1995 Free Software Foundation, Inc. 2 Copyright (C) 1985-1987, 1992-1995 Free Software Foundation, Inc.
3 Copyright (C) 1993-1996 Richard Mlynarik. 3 Copyright (C) 1993-1996 Richard Mlynarik.
4 Copyright (C) 1995, 1996, 2000, 2001, 2002, 2003 Ben Wing. 4 Copyright (C) 1995, 1996, 2000, 2001, 2002, 2003, 2004 Ben Wing.
5 5
6 This file is part of XEmacs. 6 This file is part of XEmacs.
7 7
8 XEmacs is free software; you can redistribute it and/or modify it 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 9 under the terms of the GNU General Public License as published by the
54 #define INCLUDED_lisp_h_ 54 #define INCLUDED_lisp_h_
55 55
56 /************************************************************************/ 56 /************************************************************************/
57 /* general definitions */ 57 /* general definitions */
58 /************************************************************************/ 58 /************************************************************************/
59
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 */
59 93
60 /* -------------------------- include files --------------------- */ 94 /* -------------------------- include files --------------------- */
61 95
62 /* We include the following generally useful header files so that you 96 /* We include the following generally useful header files so that you
63 don't have to worry about prototypes when using the standard C 97 don't have to worry about prototypes when using the standard C
131 #define trapping_problems_checking_assert(assertion) 165 #define trapping_problems_checking_assert(assertion)
132 #define trapping_problems_checking_assert_at_line(assertion, file, line) 166 #define trapping_problems_checking_assert_at_line(assertion, file, line)
133 #define trapping_problems_checking_assert_with_message(assertion, msg) 167 #define trapping_problems_checking_assert_with_message(assertion, msg)
134 #endif 168 #endif
135 169
136 /* ------------------------ definition of EMACS_INT ------------------- */ 170 /************************************************************************/
137 171 /** Definitions of basic types **/
138 /* EMACS_INT is the underlying integral type into which a Lisp_Object must fit. 172 /************************************************************************/
139 In particular, it must be large enough to contain a pointer. 173
140 config.h can override this, e.g. to use `long long' for bigger lisp ints. 174 /* ------------- generic 8/16/32/64/128-bit integral types ------------ */
141
142 #### In point of fact, it would NOT be a good idea for config.h to mess
143 with EMACS_INT. A lot of code makes the basic assumption that EMACS_INT
144 is the size of a pointer. */
145
146 #ifndef SIZEOF_EMACS_INT
147 # define SIZEOF_EMACS_INT SIZEOF_VOID_P
148 #endif
149
150 #ifndef EMACS_INT
151 # if SIZEOF_EMACS_INT == SIZEOF_LONG
152 # define EMACS_INT long
153 # elif SIZEOF_EMACS_INT == SIZEOF_INT
154 # define EMACS_INT int
155 # elif SIZEOF_EMACS_INT == SIZEOF_LONG_LONG
156 # define EMACS_INT long long
157 # else
158 # error Unable to determine suitable type for EMACS_INT
159 # endif
160 #endif
161
162 #ifndef EMACS_UINT
163 # define EMACS_UINT unsigned EMACS_INT
164 #endif
165
166 #define BITS_PER_EMACS_INT (SIZEOF_EMACS_INT * BITS_PER_CHAR)
167 175
168 #if SIZEOF_SHORT == 2 176 #if SIZEOF_SHORT == 2
169 #define INT_16_BIT short 177 #define INT_16_BIT short
170 #define UINT_16_BIT unsigned short 178 #define UINT_16_BIT unsigned short
171 #elif SIZEOF_INT == 2 179 #elif SIZEOF_INT == 2
221 #if defined (INT_128_BIT) 229 #if defined (INT_128_BIT)
222 #define EFFICIENT_INT_128_BIT INT_128_BIT 230 #define EFFICIENT_INT_128_BIT INT_128_BIT
223 #define EFFICIENT_UINT_128_BIT UINT_128_BIT 231 #define EFFICIENT_UINT_128_BIT UINT_128_BIT
224 #endif 232 #endif
225 233
226 /* ------------------------ basic char/int typedefs ------------------- */ 234 #ifdef HAVE_INTTYPES_H
227 235 #include <inttypes.h>
228 /* The definitions we put here use typedefs to attribute specific meaning 236 #elif defined (HAVE_INTPTR_T_IN_SYS_TYPES_H)
229 to types that by themselves are pretty general. Stuff pointed to by a 237 /* included elsewhere */
230 char * or unsigned char * will nearly always be one of four types: 238 #elif SIZEOF_VOID_P == SIZEOF_INT
231 a) pointer to internally-formatted text; b) pointer to text in some 239 typedef int intptr_t;
232 external format, which can be defined as all formats other than the 240 typedef unsigned int uintptr_t;
233 internal one; c) pure ASCII text; d) binary data that is not meant to 241 #elif SIZEOF_VOID_P == SIZEOF_LONG
234 be interpreted as text. [A fifth possible type "e) a general pointer 242 typedef long intptr_t;
235 to memory" should be replaced with void *.] Using these more specific 243 typedef unsigned long uintptr_t;
236 types rather than the general ones helps avoid the confusions that 244 #elif defined (SIZEOF_LONG_LONG) && SIZEOF_VOID_P == SIZEOF_LONG_LONG
237 occur when the semantics of a char * argument being studied are unclear. 245 typedef long long intptr_t;
238 246 typedef unsigned long long uintptr_t;
239 Note that these typedefs are purely for documentation purposes; from 247 #else
248 /* Just pray. May break, may not. */
249 typedef long intptr_t;
250 typedef unsigned long uintptr_t;
251 #endif
252
253 /* ---------------------- definition of EMACS_INT --------------------- */
254
255 /* EMACS_INT is the underlying integral type into which a Lisp_Object must fit.
256 In particular, it must be large enough to contain a pointer.
257 config.h can override this, e.g. to use `long long' for bigger lisp ints.
258
259 #### In point of fact, it would NOT be a good idea for config.h to mess
260 with EMACS_INT. A lot of code makes the basic assumption that EMACS_INT
261 is the size of a pointer. */
262
263 #ifndef SIZEOF_EMACS_INT
264 # define SIZEOF_EMACS_INT SIZEOF_VOID_P
265 #endif
266
267 #ifndef EMACS_INT
268 # if SIZEOF_EMACS_INT == SIZEOF_LONG
269 # define EMACS_INT long
270 # elif SIZEOF_EMACS_INT == SIZEOF_INT
271 # define EMACS_INT int
272 # elif SIZEOF_EMACS_INT == SIZEOF_LONG_LONG
273 # define EMACS_INT long long
274 # else
275 # error Unable to determine suitable type for EMACS_INT
276 # endif
277 #endif
278
279 #ifndef EMACS_UINT
280 # define EMACS_UINT unsigned EMACS_INT
281 #endif
282
283 #define BITS_PER_EMACS_INT (SIZEOF_EMACS_INT * BITS_PER_CHAR)
284
285 /* -------------------------- basic byte typedefs --------------------- */
286
287 /* The definitions we put here and in the next section use typedefs to
288 attribute specific meaning to types that by themselves are pretty
289 general.
290
291 REMEMBER! These typedefs are purely for documentation purposes; from
240 the C code's perspective, they are exactly equivalent to `char *', 292 the C code's perspective, they are exactly equivalent to `char *',
241 `unsigned char *', etc., so you can freely use them with library 293 `unsigned char *', etc., so you can freely use them with library
242 functions declared as such. */ 294 functions declared as such.
295
296 (See also "Byte/Character Types" in text.c)
297
298 The basic semantics for `char':
299
300 a) [Ibyte] pointer to internally-formatted text
301 b) [Extbyte] pointer to text in some external format, which can be
302 defined as all formats other than the internal one
303 c) [Ascbyte] pure ASCII text
304 d) [Binbyte] binary data that is not meant to be interpreted as text
305 e) [Rawbyte] general data in memory, where we don't care about whether
306 it's text or binary
307 f) [Boolbyte] a zero or a one
308 g) [Bitbyte] a byte used for bit fields
309 h) [Chbyte] null-semantics `char *'; used when casting an argument to
310 an external API where the the other types may not be
311 appropriate
312
313
314 Prefixing codes:
315
316 C = plain char, when the base type is unsigned
317 U = unsigned
318 S = signed
319
320 Ideally, XEmacs code should NEVER directly use `char' or any type
321 derived from it. This is for Mule-cleanliness. If you find yourself
322 wanting or needing to use `char' and one of the above six semantics does
323 not apply, add a new type of semantics; don't use `char' directly.
324
325 See text.c under "Byte Types", and following sections.
326 */
243 327
244 /* The data representing the text in a buffer is logically a set 328 /* The data representing the text in a buffer is logically a set
245 of Ibytes, declared as follows. */ 329 of Ibytes, declared as follows. */
246 330
247 typedef unsigned char Ibyte; 331 typedef unsigned char Ibyte;
249 /* The following should be used when you are working with internal data 333 /* The following should be used when you are working with internal data
250 but for whatever reason need to have it declared a "char *". Examples 334 but for whatever reason need to have it declared a "char *". Examples
251 are function arguments whose values are most commonly literal strings, 335 are function arguments whose values are most commonly literal strings,
252 or where you have to apply a stdlib string function to internal data. 336 or where you have to apply a stdlib string function to internal data.
253 337
254 In general, you should avoid this where possible and use Ibyte instead, 338 In general, you should avoid this where possible and use Ascbyte if the
255 for consistency. For example, the new Mule workspace contains 339 text is just ASCII (e.g. string literals) or otherwise Ibyte, for
256 Ibyte versions of the stdlib string functions. */ 340 consistency. For example, the new Mule workspace contains Ibyte
341 versions of the stdlib string functions. */
257 342
258 typedef char CIbyte; 343 typedef char CIbyte;
259 344
260 /* The data representing a string in "external" format (binary or any 345 /* The data representing a string in "external" format (binary or any
261 external encoding) is logically a set of Extbytes, declared as 346 external encoding) is logically a set of Extbytes, declared as
264 for referring to external text. */ 349 for referring to external text. */
265 350
266 typedef char Extbyte; 351 typedef char Extbyte;
267 typedef unsigned char UExtbyte; 352 typedef unsigned char UExtbyte;
268 353
269 /* A byte in a string in binary format: */ 354 #define EXTTEXT_ZTERM_SIZE (sizeof (Extbyte))
270 typedef char Char_Binary;
271 typedef signed char SChar_Binary;
272 typedef unsigned char UChar_Binary;
273 355
274 /* A byte in a string in entirely US-ASCII format: (Nothing outside 356 /* A byte in a string in entirely US-ASCII format: (Nothing outside
275 the range 00 - 7F) */ 357 the range 00 - 7F) */
276 358
277 typedef char Char_ASCII; 359 typedef char Ascbyte;
278 typedef unsigned char UChar_ASCII; 360 typedef unsigned char UAscbyte;
361
362 /* A generic memory pointer, no text or binary semantics assumed.
363 In general, there should be no manipulation of the memory pointed to
364 by these pointers other than just copying it around. */
365
366 typedef unsigned char Rawbyte;
367 typedef char CRawbyte;
368
369 /* A byte in a string in binary (not meant as text) format: */
370
371 typedef unsigned char Binbyte;
372 typedef char CBinbyte;
373 typedef signed char SBinbyte;
374
375 /* A byte used to represent a boolean value: 0 or 1.
376 Normally use plain Boolint, and only use Boolbyte to save space. */
377
378 typedef char Boolbyte;
379
380 /* A byte composed of bitfields. Hardly ever used. */
381
382 typedef unsigned char Bitbyte;
383
384 /* A no-semantics `char'. Used (pretty-much) ONLY for casting arguments to
385 functions accepting a `char *', `unsigned char *', etc. where the other
386 types don't exactly apply and what you are logically concerned with is
387 the type of the function's argument and not its semantics.
388
389 DO NOT DO NOT DO NOT DO NOT use this as a sloppy replacement for one of
390 the other types. If you're not using this as part of casting an
391 argument to a function call, and you're not Ben Wing, you're using it
392 wrong. Go find another one of the types. */
393
394 typedef char Chbyte;
395 typedef unsigned char UChbyte;
396 typedef signed char SChbyte;
397
398 /* ------------------------ other text-related typedefs ------------------- */
279 399
280 /* To the user, a buffer is made up of characters. In the non-Mule world, 400 /* To the user, a buffer is made up of characters. In the non-Mule world,
281 characters and Ibytes are equivalent, restricted to the range 0 - 255. 401 characters and Ibytes are equivalent, restricted to the range 0 - 255.
282 In the Mule world, many more characters are possible (19 bits worth, 402 In the Mule world, many more characters are possible (19 bits worth,
283 more or less), and a character requires (typically) 1 to 4 Ibytes for 403 more or less), and a character requires (typically) 1 to 4 Ibytes for
307 value and look for that, than repeatedly convert each raw value in the 427 value and look for that, than repeatedly convert each raw value in the
308 buffer into a character. */ 428 buffer into a character. */
309 429
310 typedef int Raw_Ichar; 430 typedef int Raw_Ichar;
311 431
432 /* Internal text as a series of textual units (8-bit bytes in the old
433 "Mule" encoding -- still the standard internal encoding -- and in UTF-8,
434 but 16-bit bytes in UTF-16 and 32-bit bytes in UTF-32). See text.c. */
435
436 #ifdef UTF16_IBYTE_FORMAT
437 #define NON_ASCII_INTERNAL_FORMAT
438 typedef unsigned short Itext;
439 #else
440 typedef Ibyte Itext;
441 #endif
442 typedef EMACS_INT Textcount;
443
444 #define ITEXT_SIZE (sizeof (Itext))
445 /* Use this to emphasize that we are adding space for the zero-terminator */
446 #define ITEXT_ZTERM_SIZE ITEXT_SIZE
447
448 /* Wexttext is wchar_t on WIN32_NATIVE (and perhaps other systems that
449 support wchar_t's in library functions), and Extbyte otherwise. This is
450 used whenever we have to do any sort of manipulation of
451 externally-encoded strings -- generally a very bad idea, and unsafe, but
452 in some cases we have no choice (especially at startup, and esp. prior
453 to pdump, where we haven't loaded the Unicode tables necessary for
454 conversion under Windows). On platforms where the external encoding may
455 be Unicode (i.e. Windows), we always do our manipulations in Unicode,
456 converting to and from multibyte if necessary -- otherwise we'd have to
457 conditionalize on Unicode vs. multibyte all over the place, which is
458 just a nightmare. */
459 #ifdef WIN32_NATIVE
460 #define WEXTTEXT_IS_WIDE
461 typedef wchar_t Wexttext;
462 #else
463 typedef Extbyte Wexttext;
464 #endif
312 465
313 #if !defined (__cplusplus) || !defined (CPLUSPLUS_INTEGRAL_CLASSES_NOT_YET) 466 #if !defined (__cplusplus) || !defined (CPLUSPLUS_INTEGRAL_CLASSES_NOT_YET)
314 467
315 /* Counts of bytes or chars */ 468 /* Counts of bytes or chars */
316 469
795 948
796 /* Counts of elements */ 949 /* Counts of elements */
797 typedef EMACS_INT Elemcount; 950 typedef EMACS_INT Elemcount;
798 /* Hash codes */ 951 /* Hash codes */
799 typedef unsigned long Hashcode; 952 typedef unsigned long Hashcode;
800 953 /* Booleans */
801 #ifdef HAVE_INTTYPES_H 954 typedef int Boolint;
802 #include <inttypes.h>
803 #elif defined(HAVE_INTPTR_T_IN_SYS_TYPES_H)
804 /* included elsewhere */
805 #elif SIZEOF_VOID_P == SIZEOF_INT
806 typedef int intptr_t;
807 typedef unsigned int uintptr_t;
808 #elif SIZEOF_VOID_P == SIZEOF_LONG
809 typedef long intptr_t;
810 typedef unsigned long uintptr_t;
811 #elif defined(SIZEOF_LONG_LONG) && SIZEOF_VOID_P == SIZEOF_LONG_LONG
812 typedef long long intptr_t;
813 typedef unsigned long long uintptr_t;
814 #else
815 /* Just pray. May break, may not. */
816 typedef long intptr_t;
817 typedef unsigned long uintptr_t;
818 #endif
819 955
820 /* ------------------------ basic compiler defines ------------------- */ 956 /* ------------------------ basic compiler defines ------------------- */
821 957
822 #include "compiler.h" 958 #include "compiler.h"
823 959
905 and line of the inline function, which is not very useful. */ 1041 and line of the inline function, which is not very useful. */
906 1042
907 #ifdef USE_ASSERTIONS 1043 #ifdef USE_ASSERTIONS
908 /* Highly dubious kludge */ 1044 /* Highly dubious kludge */
909 /* (thanks, Jamie, I feel better now -- ben) */ 1045 /* (thanks, Jamie, I feel better now -- ben) */
910 MODULE_API void assert_failed (const char *, int, const char *); 1046 MODULE_API void assert_failed (const Ascbyte *, int, const Ascbyte *);
911 # define abort() (assert_failed (__FILE__, __LINE__, "abort()")) 1047 # define abort() (assert_failed (__FILE__, __LINE__, "abort()"))
912 # define assert(x) ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, #x)) 1048 # define assert(x) ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, #x))
913 # define assert_with_message(x, msg) \ 1049 # define assert_with_message(x, msg) \
914 ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, msg)) 1050 ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, msg))
915 # define assert_at_line(x, file, line) \ 1051 # define assert_at_line(x, file, line) \
924 # define assert_with_message(x, msg) 1060 # define assert_with_message(x, msg)
925 # define assert_at_line(x, file, line) assert (x) 1061 # define assert_at_line(x, file, line) assert (x)
926 # endif 1062 # endif
927 #endif 1063 #endif
928 1064
929 /* EMACS_INT is the underlying integral type into which a Lisp_Object must fit. 1065 /************************************************************************/
930 In particular, it must be large enough to contain a pointer. 1066 /** Memory allocation **/
931 config.h can override this, e.g. to use `long long' for bigger lisp ints. 1067 /************************************************************************/
932
933 #### In point of fact, it would NOT be a good idea for config.h to mess
934 with EMACS_INT. A lot of code makes the basic assumption that EMACS_INT
935 is the size of a pointer. */
936
937 #ifndef SIZEOF_EMACS_INT
938 # define SIZEOF_EMACS_INT SIZEOF_VOID_P
939 #endif
940 1068
941 /* ------------------------ simple memory allocation ------------------- */ 1069 /* ------------------------ simple memory allocation ------------------- */
942 1070
943 /* Memory allocation */ 1071 /* Basic memory allocation and freeing functions */
944 void malloc_warning (const char *); 1072 void malloc_warning (const Ascbyte *);
945 MODULE_API void *xmalloc (Bytecount size) ATTRIBUTE_MALLOC; 1073 MODULE_API void *xmalloc (Bytecount size) ATTRIBUTE_MALLOC;
946 MODULE_API void *xmalloc_and_zero (Bytecount size) ATTRIBUTE_MALLOC; 1074 MODULE_API void *xmalloc_and_zero (Bytecount size) ATTRIBUTE_MALLOC;
947 MODULE_API void *xrealloc (void *, Bytecount size) ATTRIBUTE_MALLOC; 1075 MODULE_API void *xrealloc (void *, Bytecount size) ATTRIBUTE_MALLOC;
948 MODULE_API char *xstrdup (const char *) ATTRIBUTE_MALLOC; 1076 MODULE_API Chbyte *xstrdup (const Chbyte *) ATTRIBUTE_MALLOC;
949 /* generally useful */ 1077
950 #define countof(x) ((int) (sizeof(x)/sizeof((x)[0]))) 1078 /* Basic free function */
951 #define xnew(type) ((type *) xmalloc (sizeof (type))) 1079
952 #define xnew_array(type, len) ((type *) xmalloc ((len) * sizeof (type))) 1080 MODULE_API void xfree_1 (void *);
953 #define xnew_and_zero(type) ((type *) xmalloc_and_zero (sizeof (type))) 1081 #ifdef ERROR_CHECK_MALLOC
954 #define xzero(lvalue) ((void) memset (&(lvalue), '\0', sizeof (lvalue))) 1082 /* This used to use a temporary variable, which both avoided the multiple
955 #define xnew_array_and_zero(type, len) ((type *) xmalloc_and_zero ((len) * sizeof (type))) 1083 evaluation and obviated the need for the TYPE argument. But that triggered
956 #define XREALLOC_ARRAY(ptr, type, len) ((void) (ptr = (type *) xrealloc (ptr, (len) * sizeof (type)))) 1084 complaints under strict aliasing. #### There should be a better way. */
957 #define alloca_new(type) ((type *) ALLOCA (sizeof (type))) 1085 #define xfree(lvalue, type) do \
958 #define alloca_array(type, len) ((type *) ALLOCA ((len) * sizeof (type))) 1086 { \
959 1087 xfree_1 (lvalue); \
960 MODULE_API void *xemacs_c_alloca (unsigned int size) ATTRIBUTE_MALLOC; 1088 VOIDP_CAST (lvalue) = (void *) 0xDEADBEEF; \
961 1089 } while (0)
962 MODULE_API int record_unwind_protect_freeing (void *ptr); 1090 #else
963 1091 #define xfree(lvalue,type) xfree_1 (lvalue)
964 DECLARE_INLINE_HEADER ( 1092 #endif /* ERROR_CHECK_MALLOC */
965 void * 1093
966 xmalloc_and_record_unwind (Bytecount size) 1094 /* ------------------------ stack allocation -------------------------- */
967 ) 1095
968 { 1096 /* Allocating excessively large blocks on the stack can cause crashes.
969 void *ptr = xmalloc (size);
970 record_unwind_protect_freeing (ptr);
971 return ptr;
972 }
973
974 /* Stack allocation.
975
976 Allocating excessively large blocks on the stack can cause crashes.
977 We provide MALLOC_OR_ALLOCA() below for places where it's likely that 1097 We provide MALLOC_OR_ALLOCA() below for places where it's likely that
978 large amounts will be allocated; it mallocs the block if it's too big. 1098 large amounts will be allocated; it mallocs the block if it's too big.
979 Unfortunately, that requires a call to unbind_to() at the end of the 1099 Unfortunately, that requires a call to unbind_to() at the end of the
980 function, and it's not feasible to rewrite all calls to alloca() this 1100 function, and it's not feasible to rewrite all calls to alloca() this
981 way. 1101 way.
1045 #define ALLOCA_FUNCALL_OK(size) xemacs_c_alloca (size) 1165 #define ALLOCA_FUNCALL_OK(size) xemacs_c_alloca (size)
1046 #else 1166 #else
1047 #define ALLOCA_FUNCALL_OK(size) ALLOCA (size) 1167 #define ALLOCA_FUNCALL_OK(size) ALLOCA (size)
1048 #endif 1168 #endif
1049 1169
1170 MODULE_API void *xemacs_c_alloca (unsigned int size) ATTRIBUTE_MALLOC;
1171
1172 MODULE_API int record_unwind_protect_freeing (void *ptr);
1173
1174 DECLARE_INLINE_HEADER (
1175 void *
1176 xmalloc_and_record_unwind (Bytecount size)
1177 )
1178 {
1179 void *ptr = xmalloc (size);
1180 record_unwind_protect_freeing (ptr);
1181 return ptr;
1182 }
1183
1050 /* WARNING: If you use this, you must unbind_to() at the end of your 1184 /* WARNING: If you use this, you must unbind_to() at the end of your
1051 function! */ 1185 function! */
1052 1186
1053 #define MALLOC_OR_ALLOCA(size) \ 1187 #define MALLOC_OR_ALLOCA(size) \
1054 (REGEX_MALLOC_CHECK (), \ 1188 (REGEX_MALLOC_CHECK (), \
1055 __temp_alloca_size__ = (size), \ 1189 __temp_alloca_size__ = (size), \
1056 __temp_alloca_size__ > MAX_ALLOCA_VS_MALLOC ? \ 1190 __temp_alloca_size__ > MAX_ALLOCA_VS_MALLOC ? \
1057 xmalloc_and_record_unwind (__temp_alloca_size__) : \ 1191 xmalloc_and_record_unwind (__temp_alloca_size__) : \
1058 (need_to_check_c_alloca ? xemacs_c_alloca (0) : 0, \ 1192 (need_to_check_c_alloca ? xemacs_c_alloca (0) : 0, \
1059 alloca (__temp_alloca_size__))) 1193 alloca (__temp_alloca_size__)))
1194
1195 /* -------------- convenience functions for memory allocation ------------- */
1196
1197 #define countof(x) ((int) (sizeof(x)/sizeof((x)[0])))
1198 #define xnew(type) ((type *) xmalloc (sizeof (type)))
1199 #define xnew_array(type, len) ((type *) xmalloc ((len) * sizeof (type)))
1200 #define xnew_and_zero(type) ((type *) xmalloc_and_zero (sizeof (type)))
1201 #define xzero(lvalue) ((void) memset (&(lvalue), '\0', sizeof (lvalue)))
1202 #define xnew_array_and_zero(type, len) ((type *) xmalloc_and_zero ((len) * sizeof (type)))
1203
1204 #define alloca_new(type) ((type *) ALLOCA (sizeof (type)))
1205 #define alloca_array(type, len) ((type *) ALLOCA ((len) * sizeof (type)))
1206
1207 #define alloca_itexts(num) alloca_array (Itext, num)
1208 #define alloca_ibytes(num) alloca_array (Ibyte, num)
1209 #define alloca_extbytes(num) alloca_array (Extbyte, num)
1210 #define alloca_rawbytes(num) alloca_array (Rawbyte, num)
1211 #define alloca_binbytes(num) alloca_array (Binbyte, num)
1212 #define alloca_ascbytes(num) alloca_array (Ascbyte, num)
1213 #define xmalloc_itexts(num) xnew_array (Itext, num)
1214 #define xnew_ibytes(num) xnew_array (Ibyte, num)
1215 #define xnew_extbytes(num) xnew_array (Extbyte, num)
1216 #define xnew_rawbytes(num) xnew_array (Rawbyte, num)
1217 #define xnew_binbytes(num) xnew_array (Binbyte, num)
1218 #define xnew_ascbytes(num) xnew_array (Ascbyte, num)
1219
1220 /* Make an alloca'd copy of a Ibyte * */
1221 #define IBYTE_STRING_TO_ALLOCA(p, lval) \
1222 do { \
1223 Ibyte **_bsta_ = (Ibyte **) &(lval); \
1224 const Ibyte *_bsta_2 = (p); \
1225 Bytecount _bsta_3 = qxestrlen (_bsta_2); \
1226 *_bsta_ = alloca_ibytes (1 + _bsta_3); \
1227 memcpy (*_bsta_, _bsta_2, 1 + _bsta_3); \
1228 } while (0)
1229
1230 /* ----------------- convenience functions for reallocation --------------- */
1231
1232 #define XREALLOC_ARRAY(ptr, type, len) \
1233 ((void) (ptr = (type *) xrealloc (ptr, (len) * sizeof (type))))
1060 1234
1061 /* also generally useful if you want to avoid arbitrary size limits 1235 /* also generally useful if you want to avoid arbitrary size limits
1062 but don't need a full dynamic array. Assumes that BASEVAR points 1236 but don't need a full dynamic array. Assumes that BASEVAR points
1063 to a malloced array of TYPE objects (or possibly a NULL pointer, 1237 to a malloced array of TYPE objects (or possibly a NULL pointer,
1064 if SIZEVAR is 0), with the total size stored in SIZEVAR. This 1238 if SIZEVAR is 0), with the total size stored in SIZEVAR. This
1076 (sizevar) *= 2; \ 1250 (sizevar) *= 2; \
1077 XREALLOC_ARRAY (basevar, type, (sizevar)); \ 1251 XREALLOC_ARRAY (basevar, type, (sizevar)); \
1078 } \ 1252 } \
1079 } while (0) 1253 } while (0)
1080 1254
1081 MODULE_API void xfree_1 (void *);
1082 #ifdef ERROR_CHECK_MALLOC
1083 #define xfree(lvalue,type) do \
1084 { \
1085 xfree_1 (lvalue); \
1086 lvalue = (type) 0xDEADBEEF; \
1087 } while (0)
1088 #else
1089 #define xfree(lvalue,type) xfree_1 (lvalue)
1090 #endif /* ERROR_CHECK_MALLOC */
1091
1092 /* ------------------------ dynamic arrays ------------------- */ 1255 /* ------------------------ dynamic arrays ------------------- */
1093 1256
1094 #ifdef ERROR_CHECK_STRUCTURES 1257 #ifdef ERROR_CHECK_STRUCTURES
1095 #define Dynarr_declare(type) \ 1258 #define Dynarr_declare(type) \
1096 type *base; \ 1259 type *base; \
1112 { 1275 {
1113 Dynarr_declare (void); 1276 Dynarr_declare (void);
1114 } Dynarr; 1277 } Dynarr;
1115 1278
1116 MODULE_API void *Dynarr_newf (int elsize); 1279 MODULE_API void *Dynarr_newf (int elsize);
1117 MODULE_API void Dynarr_resize (void *dy, int size); 1280 MODULE_API void Dynarr_resize (void *dy, Elemcount size);
1118 MODULE_API void Dynarr_insert_many (void *d, const void *el, int len, int start); 1281 MODULE_API void Dynarr_insert_many (void *d, const void *el, int len, int start);
1119 MODULE_API void Dynarr_delete_many (void *d, int start, int len); 1282 MODULE_API void Dynarr_delete_many (void *d, int start, int len);
1120 MODULE_API void Dynarr_free (void *d); 1283 MODULE_API void Dynarr_free (void *d);
1121 1284
1122 #define Dynarr_new(type) ((type##_dynarr *) Dynarr_newf (sizeof (type))) 1285 #define Dynarr_new(type) ((type##_dynarr *) Dynarr_newf (sizeof (type)))
1129 #define Dynarr_sizeof(d) ((d)->cur * (d)->elsize) 1292 #define Dynarr_sizeof(d) ((d)->cur * (d)->elsize)
1130 1293
1131 #ifdef ERROR_CHECK_STRUCTURES 1294 #ifdef ERROR_CHECK_STRUCTURES
1132 DECLARE_INLINE_HEADER ( 1295 DECLARE_INLINE_HEADER (
1133 Dynarr * 1296 Dynarr *
1134 Dynarr_verify_1 (void *d, const char *file, int line) 1297 Dynarr_verify_1 (void *d, const Ascbyte *file, int line)
1135 ) 1298 )
1136 { 1299 {
1137 Dynarr *dy = (Dynarr *) d; 1300 Dynarr *dy = (Dynarr *) d;
1138 assert_at_line (dy->cur >= 0 && dy->cur <= dy->largest && 1301 assert_at_line (dy->cur >= 0 && dy->cur <= dy->largest &&
1139 dy->largest <= dy->max, file, line); 1302 dy->largest <= dy->max, file, line);
1140 return dy; 1303 return dy;
1141 } 1304 }
1142 1305
1143 DECLARE_INLINE_HEADER ( 1306 DECLARE_INLINE_HEADER (
1144 Dynarr * 1307 Dynarr *
1145 Dynarr_verify_mod_1 (void *d, const char *file, int line) 1308 Dynarr_verify_mod_1 (void *d, const Ascbyte *file, int line)
1146 ) 1309 )
1147 { 1310 {
1148 Dynarr *dy = (Dynarr *) d; 1311 Dynarr *dy = (Dynarr *) d;
1149 assert_at_line (!dy->locked, file, line); 1312 assert_at_line (!dy->locked, file, line);
1150 assert_at_line (dy->cur >= 0 && dy->cur <= dy->largest && 1313 assert_at_line (dy->cur >= 0 && dy->cur <= dy->largest &&
1214 #ifdef MEMORY_USAGE_STATS 1377 #ifdef MEMORY_USAGE_STATS
1215 struct overhead_stats; 1378 struct overhead_stats;
1216 Bytecount Dynarr_memory_usage (void *d, struct overhead_stats *stats); 1379 Bytecount Dynarr_memory_usage (void *d, struct overhead_stats *stats);
1217 #endif 1380 #endif
1218 1381
1219 /* Counts of bytes or chars */ 1382 void *stack_like_malloc (Bytecount size);
1383 void stack_like_free (void *val);
1384
1385 /************************************************************************/
1386 /** Definitions of more complex types **/
1387 /************************************************************************/
1220 1388
1221 /* Note that the simplest typedefs are near the top of this file. */ 1389 /* Note that the simplest typedefs are near the top of this file. */
1222 1390
1223 /* We put typedefs here so that prototype declarations don't choke. 1391 /* We put typedefs here so that prototype declarations don't choke.
1224 Note that we don't actually declare the structures here (except 1392 Note that we don't actually declare the structures here (except
1669 the names: those with "EXTERNAL_" work with external lists, and those 1837 the names: those with "EXTERNAL_" work with external lists, and those
1670 without this prefix work with internal lists. The internal-list 1838 without this prefix work with internal lists. The internal-list
1671 macros will hit an assertion failure if the structure is ill-formed; 1839 macros will hit an assertion failure if the structure is ill-formed;
1672 the external-list macros will signal an error in this case, either a 1840 the external-list macros will signal an error in this case, either a
1673 malformed-list error or a circular-list error. 1841 malformed-list error or a circular-list error.
1674
1675 Note also that the simplest external list iterator, EXTERNAL_LIST_LOOP,
1676 does *NOT* check for circularities. Therefore, make sure you call
1677 QUIT each iteration or so. However, it's probably easier just to use
1678 EXTERNAL_LIST_LOOP_2, which is easier to use in any case.
1679 */ 1842 */
1680 1843
1681 /* LIST_LOOP and EXTERNAL_LIST_LOOP are the simplest macros. They don't 1844 /* LIST_LOOP is a simple, old-fashioned macro. It doesn't require brace
1682 require brace surrounding, and iterate through a list, which may or may 1845 surrounding, and iterates through a list, which may or may not known to
1683 not known to be syntactically correct. EXTERNAL_LIST_LOOP is for those 1846 be syntactically correct. It accepts two args, TAIL (set progressively
1684 not known to be correct, and it detects and signals a malformed list 1847 to each cons starting with the first), and LIST, the list to iterate
1685 error when encountering a problem. Circularities, however, are not 1848 over. TAIL needs to be defined by the caller.
1686 handled, and cause looping forever, so make sure to include a QUIT.
1687 These functions also accept two args, TAIL (set progressively to each
1688 cons starting with the first), and LIST, the list to iterate over.
1689 TAIL needs to be defined by the program.
1690 1849
1691 In each iteration, you can retrieve the current list item using XCAR 1850 In each iteration, you can retrieve the current list item using XCAR
1692 (tail), or destructively modify the list using XSETCAR (tail, 1851 (tail), or destructively modify the list using XSETCAR (tail,
1693 ...). */ 1852 ...). */
1694 1853
1695 #define LIST_LOOP(tail, list) \ 1854 #define LIST_LOOP(tail, list) \
1696 for (tail = list; \ 1855 for (tail = list; \
1697 !NILP (tail); \ 1856 !NILP (tail); \
1698 tail = XCDR (tail)) 1857 tail = XCDR (tail))
1699
1700 #define EXTERNAL_LIST_LOOP(tail, list) \
1701 for (tail = list; !NILP (tail); tail = XCDR (tail)) \
1702 if (!CONSP (tail)) \
1703 signal_malformed_list_error (list); \
1704 else
1705 1858
1706 /* The following macros are the "core" macros for list traversal. 1859 /* The following macros are the "core" macros for list traversal.
1707 1860
1708 *** ALL OF THESE MACROS MUST BE DECLARED INSIDE BRACES -- SEE ABOVE. *** 1861 *** ALL OF THESE MACROS MUST BE DECLARED INSIDE BRACES -- SEE ABOVE. ***
1709 1862
1754 #define EXTERNAL_LIST_LOOP_2(elt, list) \ 1907 #define EXTERNAL_LIST_LOOP_2(elt, list) \
1755 Lisp_Object elt, hare_##elt, tortoise_##elt; \ 1908 Lisp_Object elt, hare_##elt, tortoise_##elt; \
1756 EMACS_INT len_##elt; \ 1909 EMACS_INT len_##elt; \
1757 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len_##elt, hare_##elt, \ 1910 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len_##elt, hare_##elt, \
1758 tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH) 1911 tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH)
1912
1913
1914 #define GC_EXTERNAL_LIST_LOOP_2(elt, list) \
1915 do { \
1916 XGCDECL3 (elt); \
1917 Lisp_Object elt, hare_##elt, tortoise_##elt; \
1918 EMACS_INT len_##elt; \
1919 XGCPRO3 (elt, elt, hare_##elt, tortoise_##elt); \
1920 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len_##elt, hare_##elt, \
1921 tortoise_##elt, \
1922 CIRCULAR_LIST_SUSPICION_LENGTH)
1923
1924 #define END_GC_EXTERNAL_LIST_LOOP(elt) \
1925 XUNGCPRO (elt); \
1926 } \
1927 while (0)
1759 1928
1760 #define EXTERNAL_LIST_LOOP_3(elt, list, tail) \ 1929 #define EXTERNAL_LIST_LOOP_3(elt, list, tail) \
1761 Lisp_Object elt, tail, tortoise_##elt; \ 1930 Lisp_Object elt, tail, tortoise_##elt; \
1762 EMACS_INT len_##elt; \ 1931 EMACS_INT len_##elt; \
1763 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len_##elt, tail, \ 1932 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len_##elt, tail, \
2034 , \ 2203 , \
2035 (EQ (hare, tortoise) ? \ 2204 (EQ (hare, tortoise) ? \
2036 ((void) signal_circular_property_list_error (list)) : \ 2205 ((void) signal_circular_property_list_error (list)) : \
2037 ((void) 0))))) 2206 ((void) 0)))))
2038 2207
2039 /* For a property list (alternating keywords/values) that may not be
2040 in valid list format -- will signal an error if the list is not in
2041 valid format. CONSVAR is used to keep track of the iterations
2042 without modifying PLIST.
2043
2044 We have to be tricky to still keep the same C format.*/
2045 #define EXTERNAL_PROPERTY_LIST_LOOP(tail, key, value, plist) \
2046 for (tail = plist; \
2047 (CONSP (tail) && CONSP (XCDR (tail)) ? \
2048 (key = XCAR (tail), value = XCAR (XCDR (tail))) : \
2049 (key = Qunbound, value = Qunbound)), \
2050 !NILP (tail); \
2051 tail = XCDR (XCDR (tail))) \
2052 if (UNBOUNDP (key)) \
2053 Fsignal (Qmalformed_property_list, list1 (plist)); \
2054 else
2055
2056 #define PROPERTY_LIST_LOOP(tail, key, value, plist) \ 2208 #define PROPERTY_LIST_LOOP(tail, key, value, plist) \
2057 for (tail = plist; \ 2209 for (tail = plist; \
2058 NILP (tail) ? 0 : \ 2210 NILP (tail) ? 0 : \
2059 (key = XCAR (tail), tail = XCDR (tail), \ 2211 (key = XCAR (tail), tail = XCDR (tail), \
2060 value = XCAR (tail), tail = XCDR (tail), 1); \ 2212 value = XCAR (tail), tail = XCDR (tail), 1); \
2385 2537
2386 #ifdef ERROR_CHECK_TYPES 2538 #ifdef ERROR_CHECK_TYPES
2387 2539
2388 DECLARE_INLINE_HEADER ( 2540 DECLARE_INLINE_HEADER (
2389 Ichar 2541 Ichar
2390 XCHAR_1 (Lisp_Object obj, const char *file, int line) 2542 XCHAR_1 (Lisp_Object obj, const Ascbyte *file, int line)
2391 ) 2543 )
2392 { 2544 {
2393 assert_at_line (CHARP (obj), file, line); 2545 assert_at_line (CHARP (obj), file, line);
2394 return XCHARVAL (obj); 2546 return XCHARVAL (obj);
2395 } 2547 }
2453 #define XCHAR_OR_INT(x) XCHAR_OR_INT_1 (x, __FILE__, __LINE__) 2605 #define XCHAR_OR_INT(x) XCHAR_OR_INT_1 (x, __FILE__, __LINE__)
2454 #define XINT(x) XINT_1 (x, __FILE__, __LINE__) 2606 #define XINT(x) XINT_1 (x, __FILE__, __LINE__)
2455 2607
2456 DECLARE_INLINE_HEADER ( 2608 DECLARE_INLINE_HEADER (
2457 EMACS_INT 2609 EMACS_INT
2458 XINT_1 (Lisp_Object obj, const char *file, int line) 2610 XINT_1 (Lisp_Object obj, const Ascbyte *file, int line)
2459 ) 2611 )
2460 { 2612 {
2461 assert_at_line (INTP (obj), file, line); 2613 assert_at_line (INTP (obj), file, line);
2462 return XREALINT (obj); 2614 return XREALINT (obj);
2463 } 2615 }
2464 2616
2465 DECLARE_INLINE_HEADER ( 2617 DECLARE_INLINE_HEADER (
2466 EMACS_INT 2618 EMACS_INT
2467 XCHAR_OR_INT_1 (Lisp_Object obj, const char *file, int line) 2619 XCHAR_OR_INT_1 (Lisp_Object obj, const Ascbyte *file, int line)
2468 ) 2620 )
2469 { 2621 {
2470 assert_at_line (INTP (obj) || CHARP (obj), file, line); 2622 assert_at_line (INTP (obj) || CHARP (obj), file, line);
2471 return CHARP (obj) ? XCHAR (obj) : XINT (obj); 2623 return CHARP (obj) ? XCHAR (obj) : XINT (obj);
2472 } 2624 }
3093 and so some "This function can GC" comments may be inaccurate. 3245 and so some "This function can GC" comments may be inaccurate.
3094 */ 3246 */
3095 3247
3096 BEGIN_C_DECLS 3248 BEGIN_C_DECLS
3097 3249
3250 #define XGCDECL1(x) struct gcpro x##cpro1
3251 #define XGCDECL2(x) struct gcpro x##cpro1, x##cpro2
3252 #define XGCDECL3(x) struct gcpro x##cpro1, x##cpro2, x##cpro3
3253 #define XGCDECL4(x) struct gcpro x##cpro1, x##cpro2, x##cpro3, x##cpro4
3254 #define XGCDECL5(x) struct gcpro x##cpro1, x##cpro2, x##cpro3, x##cpro4, x##cpro5
3255
3098 #ifdef DEBUG_GCPRO 3256 #ifdef DEBUG_GCPRO
3099 3257
3100 MODULE_API void debug_gcpro1 (char *, int, struct gcpro *, Lisp_Object *); 3258 MODULE_API void debug_gcpro1 (Ascbyte *, int, struct gcpro *, Lisp_Object *);
3101 MODULE_API void debug_gcpro2 (char *, int, struct gcpro *, struct gcpro *, 3259 MODULE_API void debug_gcpro2 (Ascbyte *, int, struct gcpro *, struct gcpro *,
3102 Lisp_Object *, Lisp_Object *); 3260 Lisp_Object *, Lisp_Object *);
3103 MODULE_API void debug_gcpro3 (char *, int, struct gcpro *, struct gcpro *, 3261 MODULE_API void debug_gcpro3 (Ascbyte *, int, struct gcpro *, struct gcpro *,
3104 struct gcpro *, Lisp_Object *, Lisp_Object *, 3262 struct gcpro *, Lisp_Object *, Lisp_Object *,
3105 Lisp_Object *); 3263 Lisp_Object *);
3106 MODULE_API void debug_gcpro4 (char *, int, struct gcpro *, struct gcpro *, 3264 MODULE_API void debug_gcpro4 (Ascbyte *, int, struct gcpro *, struct gcpro *,
3107 struct gcpro *, struct gcpro *, Lisp_Object *, 3265 struct gcpro *, struct gcpro *, Lisp_Object *,
3108 Lisp_Object *, Lisp_Object *, Lisp_Object *); 3266 Lisp_Object *, Lisp_Object *, Lisp_Object *);
3109 MODULE_API void debug_gcpro5 (char *, int, struct gcpro *, struct gcpro *, 3267 MODULE_API void debug_gcpro5 (Ascbyte *, int, struct gcpro *, struct gcpro *,
3110 struct gcpro *, struct gcpro *, struct gcpro *, 3268 struct gcpro *, struct gcpro *, struct gcpro *,
3111 Lisp_Object *, Lisp_Object *, Lisp_Object *, 3269 Lisp_Object *, Lisp_Object *, Lisp_Object *,
3112 Lisp_Object *, Lisp_Object *); 3270 Lisp_Object *, Lisp_Object *);
3113 MODULE_API void debug_ungcpro(char *, int, struct gcpro *); 3271 MODULE_API void debug_ungcpro(Ascbyte *, int, struct gcpro *);
3114 3272
3115 #define GCPRO1(v) \ 3273 #define XGCPRO1(x,v) \
3116 debug_gcpro1 (__FILE__, __LINE__,&gcpro1,&v) 3274 debug_gcpro1 (__FILE__, __LINE__,&x##cpro1,&v)
3117 #define GCPRO2(v1,v2) \ 3275 #define XGCPRO2(x,v1,v2) \
3118 debug_gcpro2 (__FILE__, __LINE__,&gcpro1,&gcpro2,&v1,&v2) 3276 debug_gcpro2 (__FILE__, __LINE__,&x##cpro1,&x##cpro2,&v1,&v2)
3119 #define GCPRO3(v1,v2,v3) \ 3277 #define XGCPRO3(x,v1,v2,v3) \
3120 debug_gcpro3 (__FILE__, __LINE__,&gcpro1,&gcpro2,&gcpro3,&v1,&v2,&v3) 3278 debug_gcpro3 (__FILE__, __LINE__,&x##cpro1,&x##cpro2,&x##cpro3, \
3121 #define GCPRO4(v1,v2,v3,v4) \ 3279 &v1,&v2,&v3)
3122 debug_gcpro4 (__FILE__, __LINE__,&gcpro1,&gcpro2,&gcpro3,&gcpro4,\ 3280 #define XGCPRO4(x,v1,v2,v3,v4) \
3281 debug_gcpro4 (__FILE__, __LINE__,&x##cpro1,&x##cpro2,&x##cpro3, \
3282 &x##cpro4, \
3123 &v1,&v2,&v3,&v4) 3283 &v1,&v2,&v3,&v4)
3124 #define GCPRO5(v1,v2,v3,v4,v5) \ 3284 #define XGCPRO5(x,v1,v2,v3,v4,v5) \
3125 debug_gcpro5 (__FILE__, __LINE__,&gcpro1,&gcpro2,&gcpro3,&gcpro4,&gcpro5,\ 3285 debug_gcpro5 (__FILE__, __LINE__,&x##cpro1,&x##cpro2,&x##cpro3, \
3286 &x##cpro4,&x##cpro5, \
3126 &v1,&v2,&v3,&v4,&v5) 3287 &v1,&v2,&v3,&v4,&v5)
3127 #define UNGCPRO \ 3288 #define XUNGCPRO(x) \
3128 debug_ungcpro(__FILE__, __LINE__,&gcpro1) 3289 debug_ungcpro(__FILE__, __LINE__,&x##cpro1)
3129
3130 #define NGCPRO1(v) \
3131 debug_gcpro1 (__FILE__, __LINE__,&ngcpro1,&v)
3132 #define NGCPRO2(v1,v2) \
3133 debug_gcpro2 (__FILE__, __LINE__,&ngcpro1,&ngcpro2,&v1,&v2)
3134 #define NGCPRO3(v1,v2,v3) \
3135 debug_gcpro3 (__FILE__, __LINE__,&ngcpro1,&ngcpro2,&ngcpro3,&v1,&v2,&v3)
3136 #define NGCPRO4(v1,v2,v3,v4) \
3137 debug_gcpro4 (__FILE__, __LINE__,&ngcpro1,&ngcpro2,&ngcpro3,&ngcpro4,\
3138 &v1,&v2,&v3,&v4)
3139 #define NGCPRO5(v1,v2,v3,v4,v5) \
3140 debug_gcpro5 (__FILE__, __LINE__,&ngcpro1,&ngcpro2,&ngcpro3,&ngcpro4,\
3141 &ngcpro5,&v1,&v2,&v3,&v4,&v5)
3142 #define NUNGCPRO \
3143 debug_ungcpro(__FILE__, __LINE__,&ngcpro1)
3144
3145 #define NNGCPRO1(v) \
3146 debug_gcpro1 (__FILE__, __LINE__,&nngcpro1,&v)
3147 #define NNGCPRO2(v1,v2) \
3148 debug_gcpro2 (__FILE__, __LINE__,&nngcpro1,&nngcpro2,&v1,&v2)
3149 #define NNGCPRO3(v1,v2,v3) \
3150 debug_gcpro3 (__FILE__, __LINE__,&nngcpro1,&nngcpro2,&nngcpro3,&v1,&v2,&v3)
3151 #define NNGCPRO4(v1,v2,v3,v4) \
3152 debug_gcpro4 (__FILE__, __LINE__,&nngcpro1,&nngcpro2,&nngcpro3,&nngcpro4,\
3153 &v1,&v2,&v3,&v4)
3154 #define NNGCPRO5(v1,v2,v3,v4,v5) \
3155 debug_gcpro5 (__FILE__, __LINE__,&nngcpro1,&nngcpro2,&nngcpro3,&nngcpro4,\
3156 &nngcpro5,&v1,&v2,&v3,&v4,&v5)
3157 #define NNUNGCPRO \
3158 debug_ungcpro(__FILE__, __LINE__,&nngcpro1)
3159 3290
3160 #else /* ! DEBUG_GCPRO */ 3291 #else /* ! DEBUG_GCPRO */
3161 3292
3162 #define GCPRO1(var1) ((void) ( \ 3293 #define XGCPRO1(x, var1) ((void) ( \
3163 gcpro1.next = gcprolist, gcpro1.var = &var1, gcpro1.nvars = 1, \ 3294 x##cpro1.next = gcprolist, x##cpro1.var = &var1, x##cpro1.nvars = 1, \
3164 gcprolist = &gcpro1 )) 3295 gcprolist = &x##cpro1 ))
3165 3296
3166 #define GCPRO2(var1, var2) ((void) ( \ 3297 #define XGCPRO2(x, var1, var2) ((void) ( \
3167 gcpro1.next = gcprolist, gcpro1.var = &var1, gcpro1.nvars = 1, \ 3298 x##cpro1.next = gcprolist, x##cpro1.var = &var1, x##cpro1.nvars = 1, \
3168 gcpro2.next = &gcpro1, gcpro2.var = &var2, gcpro2.nvars = 1, \ 3299 x##cpro2.next = &x##cpro1, x##cpro2.var = &var2, x##cpro2.nvars = 1, \
3169 gcprolist = &gcpro2 )) 3300 gcprolist = &x##cpro2 ))
3170 3301
3171 #define GCPRO3(var1, var2, var3) ((void) ( \ 3302 #define XGCPRO3(x, var1, var2, var3) ((void) ( \
3172 gcpro1.next = gcprolist, gcpro1.var = &var1, gcpro1.nvars = 1, \ 3303 x##cpro1.next = gcprolist, x##cpro1.var = &var1, x##cpro1.nvars = 1, \
3173 gcpro2.next = &gcpro1, gcpro2.var = &var2, gcpro2.nvars = 1, \ 3304 x##cpro2.next = &x##cpro1, x##cpro2.var = &var2, x##cpro2.nvars = 1, \
3174 gcpro3.next = &gcpro2, gcpro3.var = &var3, gcpro3.nvars = 1, \ 3305 x##cpro3.next = &x##cpro2, x##cpro3.var = &var3, x##cpro3.nvars = 1, \
3175 gcprolist = &gcpro3 )) 3306 gcprolist = &x##cpro3 ))
3176 3307
3177 #define GCPRO4(var1, var2, var3, var4) ((void) ( \ 3308 #define XGCPRO4(x, var1, var2, var3, var4) ((void) ( \
3178 gcpro1.next = gcprolist, gcpro1.var = &var1, gcpro1.nvars = 1, \ 3309 x##cpro1.next = gcprolist, x##cpro1.var = &var1, x##cpro1.nvars = 1, \
3179 gcpro2.next = &gcpro1, gcpro2.var = &var2, gcpro2.nvars = 1, \ 3310 x##cpro2.next = &x##cpro1, x##cpro2.var = &var2, x##cpro2.nvars = 1, \
3180 gcpro3.next = &gcpro2, gcpro3.var = &var3, gcpro3.nvars = 1, \ 3311 x##cpro3.next = &x##cpro2, x##cpro3.var = &var3, x##cpro3.nvars = 1, \
3181 gcpro4.next = &gcpro3, gcpro4.var = &var4, gcpro4.nvars = 1, \ 3312 x##cpro4.next = &x##cpro3, x##cpro4.var = &var4, x##cpro4.nvars = 1, \
3182 gcprolist = &gcpro4 )) 3313 gcprolist = &x##cpro4 ))
3183 3314
3184 #define GCPRO5(var1, var2, var3, var4, var5) ((void) ( \ 3315 #define XGCPRO5(x, var1, var2, var3, var4, var5) ((void) ( \
3185 gcpro1.next = gcprolist, gcpro1.var = &var1, gcpro1.nvars = 1, \ 3316 x##cpro1.next = gcprolist, x##cpro1.var = &var1, x##cpro1.nvars = 1, \
3186 gcpro2.next = &gcpro1, gcpro2.var = &var2, gcpro2.nvars = 1, \ 3317 x##cpro2.next = &x##cpro1, x##cpro2.var = &var2, x##cpro2.nvars = 1, \
3187 gcpro3.next = &gcpro2, gcpro3.var = &var3, gcpro3.nvars = 1, \ 3318 x##cpro3.next = &x##cpro2, x##cpro3.var = &var3, x##cpro3.nvars = 1, \
3188 gcpro4.next = &gcpro3, gcpro4.var = &var4, gcpro4.nvars = 1, \ 3319 x##cpro4.next = &x##cpro3, x##cpro4.var = &var4, x##cpro4.nvars = 1, \
3189 gcpro5.next = &gcpro4, gcpro5.var = &var5, gcpro5.nvars = 1, \ 3320 x##cpro5.next = &x##cpro4, x##cpro5.var = &var5, x##cpro5.nvars = 1, \
3190 gcprolist = &gcpro5 )) 3321 gcprolist = &x##cpro5 ))
3191 3322
3192 #define GCPRO1_ARRAY(array, n) ((void) ( \ 3323 #define XGCPRO1_ARRAY(x, array, n) ((void) ( \
3193 gcpro1.next = gcprolist, gcpro1.var = array, gcpro1.nvars = n, \ 3324 x##cpro1.next = gcprolist, x##cpro1.var = array, x##cpro1.nvars = n, \
3194 gcprolist = &gcpro1 )) 3325 gcprolist = &x##cpro1 ))
3195 3326
3196 #define GCPRO2_ARRAY(array1, n1, array2, n2) ((void) ( \ 3327 #define XGCPRO2_ARRAY(x, array1, n1, array2, n2) ((void) ( \
3197 gcpro1.next = gcprolist, gcpro1.var = array1, gcpro1.nvars = n1, \ 3328 x##cpro1.next = gcprolist, x##cpro1.var = array1, x##cpro1.nvars = n1, \
3198 gcpro2.next = &gcpro1, gcpro2.var = array2, gcpro2.nvars = n2, \ 3329 x##cpro2.next = &x##cpro1, x##cpro2.var = array2, x##cpro2.nvars = n2, \
3199 gcprolist = &gcpro2 )) 3330 gcprolist = &x##cpro2 ))
3200 3331
3201 #define GCPRO3_ARRAY(array1, n1, array2, n2, array3, n3) ((void) ( \ 3332 #define XGCPRO3_ARRAY(x, array1, n1, array2, n2, array3, n3) ((void) ( \
3202 gcpro1.next = gcprolist, gcpro1.var = array1, gcpro1.nvars = n1, \ 3333 x##cpro1.next = gcprolist, x##cpro1.var = array1, x##cpro1.nvars = n1, \
3203 gcpro2.next = &gcpro1, gcpro2.var = array2, gcpro2.nvars = n2, \ 3334 x##cpro2.next = &x##cpro1, x##cpro2.var = array2, x##cpro2.nvars = n2, \
3204 gcpro3.next = &gcpro2, gcpro3.var = array3, gcpro3.nvars = n3, \ 3335 x##cpro3.next = &x##cpro2, x##cpro3.var = array3, x##cpro3.nvars = n3, \
3205 gcprolist = &gcpro3 )) 3336 gcprolist = &x##cpro3 ))
3206 3337
3207 #if defined (__cplusplus) && defined (ERROR_CHECK_GC) 3338 #if defined (__cplusplus) && defined (ERROR_CHECK_GC)
3208 /* We need to reset each gcpro to avoid triggering the assert() in 3339 /* We need to reset each gcpro to avoid triggering the assert() in
3209 ~gcpro(). This happens in UNGCPRO and longjmp(). */ 3340 ~gcpro(). This happens in UNGCPRO and longjmp(). */
3210 #define UNWIND_GCPRO_TO(val) \ 3341 #define UNWIND_GCPRO_TO(val) \
3224 } while (0) 3355 } while (0)
3225 #else 3356 #else
3226 #define UNWIND_GCPRO_TO(val) (gcprolist = (val)) 3357 #define UNWIND_GCPRO_TO(val) (gcprolist = (val))
3227 #endif /* defined (__cplusplus) && defined (ERROR_CHECK_GC) */ 3358 #endif /* defined (__cplusplus) && defined (ERROR_CHECK_GC) */
3228 3359
3229 #define UNGCPRO_1(gcpro1) UNWIND_GCPRO_TO (gcpro1.next) 3360 #define XUNGCPRO(x) UNWIND_GCPRO_TO (x##cpro1.next)
3230
3231 #define UNGCPRO UNGCPRO_1 (gcpro1)
3232
3233 #define NGCPRO1(var1) ((void) ( \
3234 ngcpro1.next = gcprolist, ngcpro1.var = &var1, ngcpro1.nvars = 1, \
3235 gcprolist = &ngcpro1 ))
3236
3237 #define NGCPRO2(var1, var2) ((void) ( \
3238 ngcpro1.next = gcprolist, ngcpro1.var = &var1, ngcpro1.nvars = 1, \
3239 ngcpro2.next = &ngcpro1, ngcpro2.var = &var2, ngcpro2.nvars = 1, \
3240 gcprolist = &ngcpro2 ))
3241
3242 #define NGCPRO3(var1, var2, var3) ((void) ( \
3243 ngcpro1.next = gcprolist, ngcpro1.var = &var1, ngcpro1.nvars = 1, \
3244 ngcpro2.next = &ngcpro1, ngcpro2.var = &var2, ngcpro2.nvars = 1, \
3245 ngcpro3.next = &ngcpro2, ngcpro3.var = &var3, ngcpro3.nvars = 1, \
3246 gcprolist = &ngcpro3 ))
3247
3248 #define NGCPRO4(var1, var2, var3, var4) ((void) ( \
3249 ngcpro1.next = gcprolist, ngcpro1.var = &var1, ngcpro1.nvars = 1, \
3250 ngcpro2.next = &ngcpro1, ngcpro2.var = &var2, ngcpro2.nvars = 1, \
3251 ngcpro3.next = &ngcpro2, ngcpro3.var = &var3, ngcpro3.nvars = 1, \
3252 ngcpro4.next = &ngcpro3, ngcpro4.var = &var4, ngcpro4.nvars = 1, \
3253 gcprolist = &ngcpro4 ))
3254
3255 #define NGCPRO5(var1, var2, var3, var4, var5) ((void) ( \
3256 ngcpro1.next = gcprolist, ngcpro1.var = &var1, ngcpro1.nvars = 1, \
3257 ngcpro2.next = &ngcpro1, ngcpro2.var = &var2, ngcpro2.nvars = 1, \
3258 ngcpro3.next = &ngcpro2, ngcpro3.var = &var3, ngcpro3.nvars = 1, \
3259 ngcpro4.next = &ngcpro3, ngcpro4.var = &var4, ngcpro4.nvars = 1, \
3260 ngcpro5.next = &ngcpro4, ngcpro5.var = &var5, ngcpro5.nvars = 1, \
3261 gcprolist = &ngcpro5 ))
3262
3263 #define NGCPRO1_ARRAY(array, n) ((void) ( \
3264 ngcpro1.next = gcprolist, ngcpro1.var = array, ngcpro1.nvars = n, \
3265 gcprolist = &ngcpro1 ))
3266
3267 #define NGCPRO2_ARRAY(array1, n1, array2, n2) ((void) ( \
3268 ngcpro1.next = gcprolist, ngcpro1.var = array1, ngcpro1.nvars = n1, \
3269 ngcpro2.next = &ngcpro1, ngcpro2.var = array2, ngcpro2.nvars = n2, \
3270 gcprolist = &ngcpro2 ))
3271
3272 #define NGCPRO3_ARRAY(array1, n1, array2, n2, array3, n3) ((void) ( \
3273 ngcpro1.next = gcprolist, ngcpro1.var = array1, ngcpro1.nvars = n1, \
3274 ngcpro2.next = &ngcpro1, ngcpro2.var = array2, ngcpro2.nvars = n2, \
3275 ngcpro3.next = &ngcpro2, ngcpro3.var = array3, ngcpro3.nvars = n3, \
3276 gcprolist = &ngcpro3 ))
3277
3278 #define NUNGCPRO UNGCPRO_1 (ngcpro1)
3279
3280 #define NNGCPRO1(var1) ((void) ( \
3281 nngcpro1.next = gcprolist, nngcpro1.var = &var1, nngcpro1.nvars = 1, \
3282 gcprolist = &nngcpro1 ))
3283
3284 #define NNGCPRO2(var1, var2) ((void) ( \
3285 nngcpro1.next = gcprolist, nngcpro1.var = &var1, nngcpro1.nvars = 1, \
3286 nngcpro2.next = &nngcpro1, nngcpro2.var = &var2, nngcpro2.nvars = 1, \
3287 gcprolist = &nngcpro2 ))
3288
3289 #define NNGCPRO3(var1, var2, var3) ((void) ( \
3290 nngcpro1.next = gcprolist, nngcpro1.var = &var1, nngcpro1.nvars = 1, \
3291 nngcpro2.next = &nngcpro1, nngcpro2.var = &var2, nngcpro2.nvars = 1, \
3292 nngcpro3.next = &nngcpro2, nngcpro3.var = &var3, nngcpro3.nvars = 1, \
3293 gcprolist = &nngcpro3 ))
3294
3295 #define NNGCPRO4(var1, var2, var3, var4) ((void) ( \
3296 nngcpro1.next = gcprolist, nngcpro1.var = &var1, nngcpro1.nvars = 1, \
3297 nngcpro2.next = &nngcpro1, nngcpro2.var = &var2, nngcpro2.nvars = 1, \
3298 nngcpro3.next = &nngcpro2, nngcpro3.var = &var3, nngcpro3.nvars = 1, \
3299 nngcpro4.next = &nngcpro3, nngcpro4.var = &var4, nngcpro4.nvars = 1, \
3300 gcprolist = &nngcpro4 ))
3301
3302 #define NNGCPRO5(var1, var2, var3, var4, var5) ((void) ( \
3303 nngcpro1.next = gcprolist, nngcpro1.var = &var1, nngcpro1.nvars = 1, \
3304 nngcpro2.next = &nngcpro1, nngcpro2.var = &var2, nngcpro2.nvars = 1, \
3305 nngcpro3.next = &nngcpro2, nngcpro3.var = &var3, nngcpro3.nvars = 1, \
3306 nngcpro4.next = &nngcpro3, nngcpro4.var = &var4, nngcpro4.nvars = 1, \
3307 nngcpro5.next = &nngcpro4, nngcpro5.var = &var5, nngcpro5.nvars = 1, \
3308 gcprolist = &nngcpro5 ))
3309
3310 #define NNGCPRO1_ARRAY(array, n) ((void) ( \
3311 nngcpro1.next = gcprolist, nngcpro1.var = array, nngcpro1.nvars = n, \
3312 gcprolist = &nngcpro1 ))
3313
3314 #define NNGCPRO2_ARRAY(array1, n1, array2, n2) ((void) ( \
3315 nngcpro1.next = gcprolist, nngcpro1.var = array1, nngcpro1.nvars = n1, \
3316 nngcpro2.next = &nngcpro1, nngcpro2.var = array2, nngcpro2.nvars = n2, \
3317 gcprolist = &nngcpro2 ))
3318
3319 #define NNGCPRO3_ARRAY(array1, n1, array2, n2, array3, n3) ((void) ( \
3320 nngcpro1.next = gcprolist, nngcpro1.var = array1, nngcpro1.nvars = n1, \
3321 nngcpro2.next = &nngcpro1, nngcpro2.var = array2, nngcpro2.nvars = n2, \
3322 nngcpro3.next = &nngcpro2, nngcpro3.var = array3, nngcpro3.nvars = n3, \
3323 gcprolist = &nngcpro3 ))
3324
3325 #define NNUNGCPRO UNGCPRO_1 (nngcpro1)
3326 3361
3327 #endif /* ! DEBUG_GCPRO */ 3362 #endif /* ! DEBUG_GCPRO */
3363
3364 #define GCDECL1 XGCDECL1 (g)
3365 #define GCDECL2 XGCDECL2 (g)
3366 #define GCDECL3 XGCDECL3 (g)
3367 #define GCDECL4 XGCDECL4 (g)
3368 #define GCDECL5 XGCDECL5 (g)
3369
3370 #define GCPRO1(a) XGCPRO1 (g,a)
3371 #define GCPRO2(a,b) XGCPRO2 (g,a,b)
3372 #define GCPRO3(a,b,c) XGCPRO3 (g,a,b,c)
3373 #define GCPRO4(a,b,c,d) XGCPRO4 (g,a,b,c,d)
3374 #define GCPRO5(a,b,c,d,e) XGCPRO5 (g,a,b,c,d,e)
3375
3376 #define GCPRO1_ARRAY(a1,n1) XGCPRO1_ARRAY(g,a1,n1)
3377 #define GCPRO2_ARRAY(a1,n1,a2,n2) XGCPRO2_ARRAY (g,a1,n1,a2,n2)
3378 #define GCPRO3_ARRAY(a1,n1,a2,n2,a3,n3) XGCPRO3_ARRAY (g,a1,n1,a2,n2,a3,n3)
3379
3380 #define UNGCPRO XUNGCPRO (g)
3381
3382 #define NGCDECL1 XGCDECL1 (ng)
3383 #define NGCDECL2 XGCDECL2 (ng)
3384 #define NGCDECL3 XGCDECL3 (ng)
3385 #define NGCDECL4 XGCDECL4 (ng)
3386 #define NGCDECL5 XGCDECL5 (ng)
3387
3388 #define NGCPRO1(a) XGCPRO1 (ng,a)
3389 #define NGCPRO2(a,b) XGCPRO2 (ng,a,b)
3390 #define NGCPRO3(a,b,c) XGCPRO3 (ng,a,b,c)
3391 #define NGCPRO4(a,b,c,d) XGCPRO4 (ng,a,b,c,d)
3392 #define NGCPRO5(a,b,c,d,e) XGCPRO5 (ng,a,b,c,d,e)
3393
3394 #define NGCPRO1_ARRAY(a1,n1) XGCPRO1_ARRAY(ng,a1,n1)
3395 #define NGCPRO2_ARRAY(a1,n1,a2,n2) XGCPRO2_ARRAY (ng,a1,n1,a2,n2)
3396 #define NGCPRO3_ARRAY(a1,n1,a2,n2,a3,n3) XGCPRO3_ARRAY (ng,a1,n1,a2,n2,a3,n3)
3397
3398 #define NUNGCPRO XUNGCPRO (ng)
3399
3400 #define NNGCDECL1 XGCDECL1 (nng)
3401 #define NNGCDECL2 XGCDECL2 (nng)
3402 #define NNGCDECL3 XGCDECL3 (nng)
3403 #define NNGCDECL4 XGCDECL4 (nng)
3404 #define NNGCDECL5 XGCDECL5 (nng)
3405
3406 #define NNGCPRO1(a) XGCPRO1 (nng,a)
3407 #define NNGCPRO2(a,b) XGCPRO2 (nng,a,b)
3408 #define NNGCPRO3(a,b,c) XGCPRO3 (nng,a,b,c)
3409 #define NNGCPRO4(a,b,c,d) XGCPRO4 (nng,a,b,c,d)
3410 #define NNGCPRO5(a,b,c,d,e) XGCPRO5 (nng,a,b,c,d,e)
3411
3412 #define NNGCPRO1_ARRAY(a1,n1) XGCPRO1_ARRAY(nng,a1,n1)
3413 #define NNGCPRO2_ARRAY(a1,n1,a2,n2) XGCPRO2_ARRAY (nng,a1,n1,a2,n2)
3414 #define NNGCPRO3_ARRAY(a1,n1,a2,n2,a3,n3) XGCPRO3_ARRAY (nng,a1,n1,a2,n2,a3,n3)
3415
3416 #define NNUNGCPRO XUNGCPRO (nng)
3328 3417
3329 /* Evaluate expr, UNGCPRO, and then return the value of expr. */ 3418 /* Evaluate expr, UNGCPRO, and then return the value of expr. */
3330 #define RETURN_UNGCPRO(expr) do \ 3419 #define RETURN_UNGCPRO(expr) do \
3331 { \ 3420 { \
3332 Lisp_Object ret_ungc_val = (expr); \ 3421 Lisp_Object ret_ungc_val = (expr); \
3358 3447
3359 #ifdef DEBUG_XEMACS 3448 #ifdef DEBUG_XEMACS
3360 3449
3361 /* Help debug crashes gc-marking a staticpro'ed object. */ 3450 /* Help debug crashes gc-marking a staticpro'ed object. */
3362 3451
3363 MODULE_API void staticpro_1 (Lisp_Object *, char *); 3452 MODULE_API void staticpro_1 (Lisp_Object *, Ascbyte *);
3364 MODULE_API void staticpro_nodump_1 (Lisp_Object *, char *); 3453 MODULE_API void staticpro_nodump_1 (Lisp_Object *, Ascbyte *);
3365 #define staticpro(ptr) staticpro_1 (ptr, #ptr) 3454 #define staticpro(ptr) staticpro_1 (ptr, #ptr)
3366 #define staticpro_nodump(ptr) staticpro_nodump_1 (ptr, #ptr) 3455 #define staticpro_nodump(ptr) staticpro_nodump_1 (ptr, #ptr)
3367 3456
3368 #ifdef HAVE_SHLIB 3457 #ifdef HAVE_SHLIB
3369 MODULE_API void unstaticpro_nodump_1 (Lisp_Object *, char *); 3458 MODULE_API void unstaticpro_nodump_1 (Lisp_Object *, Ascbyte *);
3370 #define unstaticpro_nodump(ptr) unstaticpro_nodump_1 (ptr, #ptr) 3459 #define unstaticpro_nodump(ptr) unstaticpro_nodump_1 (ptr, #ptr)
3371 #endif 3460 #endif
3372 3461
3373 #else 3462 #else
3374 3463
3745 EXFUN_NORETURN (Fkill_emacs, 1); 3834 EXFUN_NORETURN (Fkill_emacs, 1);
3746 EXFUN (Frunning_temacs_p, 0); 3835 EXFUN (Frunning_temacs_p, 0);
3747 EXFUN (Fforce_debugging_signal, 1); 3836 EXFUN (Fforce_debugging_signal, 1);
3748 3837
3749 SIGTYPE fatal_error_signal (int); 3838 SIGTYPE fatal_error_signal (int);
3750 Lisp_Object make_arg_list (int, Extbyte **); 3839 Lisp_Object make_arg_list (int, Wexttext **);
3751 void make_argc_argv (Lisp_Object, int *, Extbyte ***); 3840 void make_argc_argv (Lisp_Object, int *, Wexttext ***);
3752 void free_argc_argv (Extbyte **); 3841 void free_argc_argv (Wexttext **);
3753 Lisp_Object split_external_path (const Extbyte *path); 3842 Lisp_Object split_external_path (const Extbyte *path);
3754 Lisp_Object split_env_path (const CIbyte *evarname, const Ibyte *default_); 3843 Lisp_Object split_env_path (const CIbyte *evarname, const Ibyte *default_);
3755 3844
3756 /* Nonzero means don't do interactive redisplay and don't change tty modes */ 3845 /* Nonzero means don't do interactive redisplay and don't change tty modes */
3757 extern int noninteractive, noninteractive1; 3846 extern int noninteractive, noninteractive1;
3758 extern int inhibit_non_essential_printing_operations; 3847 extern int inhibit_non_essential_conversion_operations;
3759 extern int preparing_for_armageddon; 3848 extern int preparing_for_armageddon;
3760 extern Fixnum emacs_priority; 3849 extern Fixnum emacs_priority;
3761 extern int suppress_early_error_handler_backtrace; 3850 extern int suppress_early_error_handler_backtrace;
3762 void debug_break (void); 3851 void debug_break (void);
3763 int debug_can_access_memory (void *ptr, Bytecount len); 3852 int debug_can_access_memory (void *ptr, Bytecount len);
3996 Lisp_Object handler_arg, 4085 Lisp_Object handler_arg,
3997 Lisp_Object (*fun) (Lisp_Object), 4086 Lisp_Object (*fun) (Lisp_Object),
3998 Lisp_Object arg); 4087 Lisp_Object arg);
3999 int set_trapping_problems_flags (int flags); 4088 int set_trapping_problems_flags (int flags);
4000 Lisp_Object call_trapping_problems (Lisp_Object warning_class, 4089 Lisp_Object call_trapping_problems (Lisp_Object warning_class,
4001 const char *warning_string, 4090 const Ascbyte *warning_string,
4002 int flags, 4091 int flags,
4003 struct call_trapping_problems_result 4092 struct call_trapping_problems_result
4004 *problem, 4093 *problem,
4005 Lisp_Object (*fun) (void *), 4094 Lisp_Object (*fun) (void *),
4006 void *arg); 4095 void *arg);
4007 Lisp_Object va_call_trapping_problems (Lisp_Object warning_class, 4096 Lisp_Object va_call_trapping_problems (Lisp_Object warning_class,
4008 const char *warning_string, 4097 const Ascbyte *warning_string,
4009 int flags, 4098 int flags,
4010 struct call_trapping_problems_result 4099 struct call_trapping_problems_result
4011 *problem, 4100 *problem,
4012 lisp_fn_t fun, int nargs, ...); 4101 lisp_fn_t fun, int nargs, ...);
4013 Lisp_Object call0_trapping_problems (const char *, Lisp_Object, int); 4102 Lisp_Object call0_trapping_problems (const Ascbyte *, Lisp_Object, int);
4014 Lisp_Object call1_trapping_problems (const char *, Lisp_Object, Lisp_Object, 4103 Lisp_Object call1_trapping_problems (const Ascbyte *, Lisp_Object, Lisp_Object,
4015 int); 4104 int);
4016 Lisp_Object call2_trapping_problems (const char *, Lisp_Object, Lisp_Object, 4105 Lisp_Object call2_trapping_problems (const Ascbyte *, Lisp_Object, Lisp_Object,
4017 Lisp_Object, int); 4106 Lisp_Object, int);
4018 Lisp_Object call3_trapping_problems (const char *, Lisp_Object, Lisp_Object, 4107 Lisp_Object call3_trapping_problems (const Ascbyte *, Lisp_Object, Lisp_Object,
4019 Lisp_Object, Lisp_Object, int); 4108 Lisp_Object, Lisp_Object, int);
4020 Lisp_Object call4_trapping_problems (const char *, Lisp_Object, Lisp_Object, 4109 Lisp_Object call4_trapping_problems (const Ascbyte *, Lisp_Object, Lisp_Object,
4021 Lisp_Object, Lisp_Object, Lisp_Object, 4110 Lisp_Object, Lisp_Object, Lisp_Object,
4022 int); 4111 int);
4023 Lisp_Object call5_trapping_problems (const char *, Lisp_Object, Lisp_Object, 4112 Lisp_Object call5_trapping_problems (const Ascbyte *, Lisp_Object, Lisp_Object,
4024 Lisp_Object, Lisp_Object, Lisp_Object, 4113 Lisp_Object, Lisp_Object, Lisp_Object,
4025 Lisp_Object, int); 4114 Lisp_Object, int);
4026 Lisp_Object eval_in_buffer_trapping_problems (const char *, struct buffer *, 4115 Lisp_Object eval_in_buffer_trapping_problems (const Ascbyte *, struct buffer *,
4027 Lisp_Object, int); 4116 Lisp_Object, int);
4028 Lisp_Object run_hook_trapping_problems (Lisp_Object, Lisp_Object, int); 4117 Lisp_Object run_hook_trapping_problems (Lisp_Object, Lisp_Object, int);
4029 Lisp_Object safe_run_hook_trapping_problems (Lisp_Object, Lisp_Object, int); 4118 Lisp_Object safe_run_hook_trapping_problems (Lisp_Object, Lisp_Object, int);
4030 Lisp_Object run_hook_with_args_in_buffer_trapping_problems (Lisp_Object, 4119 Lisp_Object run_hook_with_args_in_buffer_trapping_problems (Lisp_Object,
4031 struct buffer *, 4120 struct buffer *,
4286 int, Error_Behavior); 4375 int, Error_Behavior);
4287 void external_plist_put (Lisp_Object *, Lisp_Object, 4376 void external_plist_put (Lisp_Object *, Lisp_Object,
4288 Lisp_Object, int, Error_Behavior); 4377 Lisp_Object, int, Error_Behavior);
4289 int external_remprop (Lisp_Object *, Lisp_Object, int, Error_Behavior); 4378 int external_remprop (Lisp_Object *, Lisp_Object, int, Error_Behavior);
4290 int internal_equal_trapping_problems (Lisp_Object warning_class, 4379 int internal_equal_trapping_problems (Lisp_Object warning_class,
4291 const char *warning_string, 4380 const Ascbyte *warning_string,
4292 int flags, 4381 int flags,
4293 struct call_trapping_problems_result *p, 4382 struct call_trapping_problems_result *p,
4294 int retval, 4383 int retval,
4295 Lisp_Object obj1, Lisp_Object obj2, 4384 Lisp_Object obj1, Lisp_Object obj2,
4296 int depth); 4385 int depth);
4303 Lisp_Object nconc2 (Lisp_Object, Lisp_Object); 4392 Lisp_Object nconc2 (Lisp_Object, Lisp_Object);
4304 Lisp_Object bytecode_nconc2 (Lisp_Object *); 4393 Lisp_Object bytecode_nconc2 (Lisp_Object *);
4305 void check_losing_bytecode (const char *, Lisp_Object); 4394 void check_losing_bytecode (const char *, Lisp_Object);
4306 4395
4307 Lisp_Object add_suffix_to_symbol (Lisp_Object symbol, 4396 Lisp_Object add_suffix_to_symbol (Lisp_Object symbol,
4308 const Char_ASCII *ascii_string); 4397 const Ascbyte *ascii_string);
4309 Lisp_Object add_prefix_to_symbol (const Char_ASCII *ascii_string, 4398 Lisp_Object add_prefix_to_symbol (const Ascbyte *ascii_string,
4310 Lisp_Object symbol); 4399 Lisp_Object symbol);
4311 4400
4312 /* Defined in free-hook.c */ 4401 /* Defined in free-hook.c */
4313 EXFUN (Freally_free, 1); 4402 EXFUN (Freally_free, 1);
4314 4403
4325 Lisp_Object dest_mask, 4414 Lisp_Object dest_mask,
4326 Lisp_Object tag); 4415 Lisp_Object tag);
4327 extern Lisp_Object Q_resource_type, Q_resource_id; 4416 extern Lisp_Object Q_resource_type, Q_resource_id;
4328 4417
4329 /* Defined in gui.c */ 4418 /* Defined in gui.c */
4330 DECLARE_DOESNT_RETURN (gui_error (const char *reason, 4419 DECLARE_DOESNT_RETURN (gui_error (const Ascbyte *reason,
4331 Lisp_Object frob)); 4420 Lisp_Object frob));
4332 DECLARE_DOESNT_RETURN (gui_error_2 (const char *reason, 4421 DECLARE_DOESNT_RETURN (gui_error_2 (const Ascbyte *reason,
4333 Lisp_Object frob0, Lisp_Object frob1)); 4422 Lisp_Object frob0, Lisp_Object frob1));
4334 /* Defined in indent.c */ 4423 /* Defined in indent.c */
4335 EXFUN (Findent_to, 3); 4424 EXFUN (Findent_to, 3);
4336 EXFUN (Fvertical_motion, 3); 4425 EXFUN (Fvertical_motion, 3);
4337 4426
4553 4642
4554 /* Defined in sound.c */ 4643 /* Defined in sound.c */
4555 EXFUN (Fding, 3); 4644 EXFUN (Fding, 3);
4556 4645
4557 void init_device_sound (struct device *); 4646 void init_device_sound (struct device *);
4558 DECLARE_DOESNT_RETURN (report_sound_error (const Char_ASCII *, Lisp_Object)); 4647 DECLARE_DOESNT_RETURN (report_sound_error (const Ascbyte *, Lisp_Object));
4559 4648
4560 /* Defined in specifier.c */ 4649 /* Defined in specifier.c */
4561 EXFUN (Fadd_spec_to_specifier, 5); 4650 EXFUN (Fadd_spec_to_specifier, 5);
4562 EXFUN (Fspecifier_spec_list, 4); 4651 EXFUN (Fspecifier_spec_list, 4);
4563 4652
4756 int Lstream_fput_ichar (Lstream *stream, Ichar ch); 4845 int Lstream_fput_ichar (Lstream *stream, Ichar ch);
4757 void Lstream_funget_ichar (Lstream *stream, Ichar ch); 4846 void Lstream_funget_ichar (Lstream *stream, Ichar ch);
4758 4847
4759 DECLARE_INLINE_HEADER (Ibyte *qxestrdup (const Ibyte *s)) 4848 DECLARE_INLINE_HEADER (Ibyte *qxestrdup (const Ibyte *s))
4760 { 4849 {
4761 return (Ibyte *) xstrdup ((const char *) s); 4850 return (Ibyte *) xstrdup ((const Chbyte *) s);
4762 } 4851 }
4763 4852
4764 DECLARE_INLINE_HEADER (Bytecount qxestrlen (const Ibyte *s)) 4853 DECLARE_INLINE_HEADER (Bytecount qxestrlen (const Ibyte *s))
4765 { 4854 {
4766 return strlen ((const char *) s); 4855 return strlen ((const Chbyte *) s);
4767 } 4856 }
4768 4857
4769 DECLARE_INLINE_HEADER (Charcount qxestrcharlen (const Ibyte *s)) 4858 DECLARE_INLINE_HEADER (Charcount qxestrcharlen (const Ibyte *s))
4770 { 4859 {
4771 return bytecount_to_charcount (s, qxestrlen (s)); 4860 return bytecount_to_charcount (s, qxestrlen (s));
4772 } 4861 }
4773 4862
4774 DECLARE_INLINE_HEADER (int qxestrcmp (const Ibyte *s1, 4863 DECLARE_INLINE_HEADER (int qxestrcmp (const Ibyte *s1,
4775 const Ibyte *s2)) 4864 const Ibyte *s2))
4776 { 4865 {
4777 return strcmp ((const char *) s1, (const char *) s2); 4866 return strcmp ((const Chbyte *) s1, (const Chbyte *) s2);
4778 } 4867 }
4779 4868
4780 DECLARE_INLINE_HEADER (int qxestrcmp_c (const Ibyte *s1, 4869 DECLARE_INLINE_HEADER (int qxestrcmp_ascii (const Ibyte *s1,
4781 const char *s2)) 4870 const Ascbyte *s2))
4782 { 4871 {
4783 return strcmp ((const char *) s1, s2); 4872 return strcmp ((const Chbyte *) s1, s2);
4784 } 4873 }
4785 4874
4786 DECLARE_INLINE_HEADER (int qxestrncmp (const Ibyte *string1, 4875 DECLARE_INLINE_HEADER (int qxestrncmp (const Ibyte *string1,
4787 const Ibyte *string2, 4876 const Ibyte *string2,
4788 Bytecount count)) 4877 Bytecount count))
4789 { 4878 {
4790 return strncmp ((const char *) string1, (const char *) string2, 4879 return strncmp ((const Chbyte *) string1, (const Chbyte *) string2,
4791 (size_t) count); 4880 (size_t) count);
4792 } 4881 }
4793 4882
4794 DECLARE_INLINE_HEADER (int qxestrncmp_c (const Ibyte *string1, 4883 DECLARE_INLINE_HEADER (int qxestrncmp_ascii (const Ibyte *string1,
4795 const char *string2, 4884 const Ascbyte *string2,
4796 Bytecount count)) 4885 Bytecount count))
4797 { 4886 {
4798 return strncmp ((const char *) string1, string2, (size_t) count); 4887 return strncmp ((const Chbyte *) string1, string2, (size_t) count);
4799 } 4888 }
4800 4889
4801 DECLARE_INLINE_HEADER (Ibyte *qxestrcpy (Ibyte *strDest, 4890 DECLARE_INLINE_HEADER (Ibyte *qxestrcpy (Ibyte *strDest,
4802 const Ibyte *strSource)) 4891 const Ibyte *strSource))
4803 { 4892 {
4804 return (Ibyte *) strcpy ((char *) strDest, (const char *) strSource); 4893 return (Ibyte *) strcpy ((Chbyte *) strDest, (const Chbyte *) strSource);
4805 } 4894 }
4806 4895
4807 DECLARE_INLINE_HEADER (Ibyte *qxestrcpy_c (Ibyte *strDest, 4896 DECLARE_INLINE_HEADER (Ibyte *qxestrcpy_ascii (Ibyte *strDest,
4808 const char *strSource)) 4897 const Ascbyte *strSource))
4809 { 4898 {
4810 return (Ibyte *) strcpy ((char *) strDest, strSource); 4899 return (Ibyte *) strcpy ((Chbyte *) strDest, strSource);
4811 } 4900 }
4812 4901
4813 DECLARE_INLINE_HEADER (Ibyte *qxestrncpy (Ibyte *strDest, 4902 DECLARE_INLINE_HEADER (Ibyte *qxestrncpy (Ibyte *strDest,
4814 const Ibyte *strSource, 4903 const Ibyte *strSource,
4815 Bytecount count)) 4904 Bytecount count))
4816 { 4905 {
4817 return (Ibyte *) strncpy ((char *) strDest, (const char *) strSource, 4906 return (Ibyte *) strncpy ((Chbyte *) strDest, (const Chbyte *) strSource,
4818 (size_t) count); 4907 (size_t) count);
4819 } 4908 }
4820 4909
4821 DECLARE_INLINE_HEADER (Ibyte *qxestrncpy_c (Ibyte *strDest, 4910 DECLARE_INLINE_HEADER (Ibyte *qxestrncpy_ascii (Ibyte *strDest,
4822 const char *strSource, 4911 const Ascbyte *strSource,
4823 Bytecount count)) 4912 Bytecount count))
4824 { 4913 {
4825 return (Ibyte *) strncpy ((char *) strDest, strSource, (size_t) count); 4914 return (Ibyte *) strncpy ((Chbyte *) strDest, strSource, (size_t) count);
4826 } 4915 }
4827 4916
4828 DECLARE_INLINE_HEADER (Ibyte *qxestrcat (Ibyte *strDest, 4917 DECLARE_INLINE_HEADER (Ibyte *qxestrcat (Ibyte *strDest,
4829 const Ibyte *strSource)) 4918 const Ibyte *strSource))
4830 { 4919 {
4831 return (Ibyte *) strcat ((char *) strDest, (const char *) strSource); 4920 return (Ibyte *) strcat ((Chbyte *) strDest, (const Chbyte *) strSource);
4832 } 4921 }
4833 4922
4834 DECLARE_INLINE_HEADER (Ibyte *qxestrcat_c (Ibyte *strDest, 4923 DECLARE_INLINE_HEADER (Ibyte *qxestrcat_ascii (Ibyte *strDest,
4835 const char *strSource)) 4924 const Ascbyte *strSource))
4836 { 4925 {
4837 return (Ibyte *) strcat ((char *) strDest, strSource); 4926 return (Ibyte *) strcat ((Chbyte *) strDest, strSource);
4838 } 4927 }
4839 4928
4840 DECLARE_INLINE_HEADER (Ibyte *qxestrncat (Ibyte *strDest, 4929 DECLARE_INLINE_HEADER (Ibyte *qxestrncat (Ibyte *strDest,
4841 const Ibyte *strSource, 4930 const Ibyte *strSource,
4842 Bytecount count)) 4931 Bytecount count))
4843 { 4932 {
4844 return (Ibyte *) strncat ((char *) strDest, (const char *) strSource, 4933 return (Ibyte *) strncat ((Chbyte *) strDest, (const Chbyte *) strSource,
4845 (size_t) count); 4934 (size_t) count);
4846 } 4935 }
4847 4936
4848 DECLARE_INLINE_HEADER (Ibyte *qxestrncat_c (Ibyte *strDest, 4937 DECLARE_INLINE_HEADER (Ibyte *qxestrncat_ascii (Ibyte *strDest,
4849 const char *strSource, 4938 const Ascbyte *strSource,
4850 Bytecount count)) 4939 Bytecount count))
4851 { 4940 {
4852 return (Ibyte *) strncat ((char *) strDest, strSource, (size_t) count); 4941 return (Ibyte *) strncat ((Chbyte *) strDest, strSource, (size_t) count);
4853 } 4942 }
4854 4943
4855 DECLARE_INLINE_HEADER (Ibyte *qxestrchr (const Ibyte *s, Ichar c)) 4944 DECLARE_INLINE_HEADER (Ibyte *qxestrchr (const Ibyte *s, Ichar c))
4856 { 4945 {
4857 assert (c >= 0 && c <= 255); 4946 assert (c >= 0 && c <= 255);
4858 return (Ibyte *) strchr ((const char *) s, c); 4947 return (Ibyte *) strchr ((const Chbyte *) s, c);
4859 } 4948 }
4860 4949
4861 DECLARE_INLINE_HEADER (Ibyte *qxestrrchr (const Ibyte *s, Ichar c)) 4950 DECLARE_INLINE_HEADER (Ibyte *qxestrrchr (const Ibyte *s, Ichar c))
4862 { 4951 {
4863 assert (c >= 0 && c <= 255); 4952 assert (c >= 0 && c <= 255);
4864 return (Ibyte *) strrchr ((const char *) s, c); 4953 return (Ibyte *) strrchr ((const Chbyte *) s, c);
4865 } 4954 }
4866 4955
4867 DECLARE_INLINE_HEADER (Ibyte *qxestrstr (const Ibyte *string1, 4956 DECLARE_INLINE_HEADER (Ibyte *qxestrstr (const Ibyte *string1,
4868 const Ibyte *string2)) 4957 const Ibyte *string2))
4869 { 4958 {
4870 return (Ibyte *) strstr ((const char *) string1, (const char *) string2); 4959 return (Ibyte *) strstr ((const Chbyte *) string1, (const Chbyte *) string2);
4871 } 4960 }
4872 4961
4873 DECLARE_INLINE_HEADER (Bytecount qxestrcspn (const Ibyte *string, 4962 DECLARE_INLINE_HEADER (Bytecount qxestrcspn (const Ibyte *string,
4874 const CIbyte *strCharSet)) 4963 const CIbyte *strCharSet))
4875 { 4964 {
4876 return (Bytecount) strcspn ((const char *) string, strCharSet); 4965 return (Bytecount) strcspn ((const Chbyte *) string, strCharSet);
4877 } 4966 }
4878 4967
4879 DECLARE_INLINE_HEADER (Bytecount qxestrspn (const Ibyte *string, 4968 DECLARE_INLINE_HEADER (Bytecount qxestrspn (const Ibyte *string,
4880 const CIbyte *strCharSet)) 4969 const CIbyte *strCharSet))
4881 { 4970 {
4882 return (Bytecount) strspn ((const char *) string, strCharSet); 4971 return (Bytecount) strspn ((const Chbyte *) string, strCharSet);
4883 } 4972 }
4884 4973
4885 DECLARE_INLINE_HEADER (Ibyte *qxestrpbrk (const Ibyte *string, 4974 DECLARE_INLINE_HEADER (Ibyte *qxestrpbrk (const Ibyte *string,
4886 const CIbyte *strCharSet)) 4975 const CIbyte *strCharSet))
4887 { 4976 {
4888 return (Ibyte *) strpbrk ((const char *) string, strCharSet); 4977 return (Ibyte *) strpbrk ((const Chbyte *) string, strCharSet);
4889 } 4978 }
4890 4979
4891 DECLARE_INLINE_HEADER (Ibyte *qxestrtok (Ibyte *strToken, 4980 DECLARE_INLINE_HEADER (Ibyte *qxestrtok (Ibyte *strToken,
4892 const CIbyte *strDelimit)) 4981 const CIbyte *strDelimit))
4893 { 4982 {
4894 return (Ibyte *) strtok ((char *) strToken, strDelimit); 4983 return (Ibyte *) strtok ((Chbyte *) strToken, strDelimit);
4895 } 4984 }
4896 4985
4897 DECLARE_INLINE_HEADER (double qxestrtod (const Ibyte *nptr, 4986 DECLARE_INLINE_HEADER (double qxestrtod (const Ibyte *nptr,
4898 Ibyte **endptr)) 4987 Ibyte **endptr))
4899 { 4988 {
4900 return strtod ((const char *) nptr, (char **) endptr); 4989 return strtod ((const Chbyte *) nptr, (Chbyte **) endptr);
4901 } 4990 }
4902 4991
4903 DECLARE_INLINE_HEADER (long qxestrtol (const Ibyte *nptr, Ibyte **endptr, 4992 DECLARE_INLINE_HEADER (long qxestrtol (const Ibyte *nptr, Ibyte **endptr,
4904 int base)) 4993 int base))
4905 { 4994 {
4906 return strtol ((const char *) nptr, (char **) endptr, base); 4995 return strtol ((const Chbyte *) nptr, (Chbyte **) endptr, base);
4907 } 4996 }
4908 4997
4909 DECLARE_INLINE_HEADER (unsigned long qxestrtoul (const Ibyte *nptr, 4998 DECLARE_INLINE_HEADER (unsigned long qxestrtoul (const Ibyte *nptr,
4910 Ibyte **endptr, 4999 Ibyte **endptr,
4911 int base)) 5000 int base))
4912 { 5001 {
4913 return strtoul ((const char *) nptr, (char **) endptr, base); 5002 return strtoul ((const Chbyte *) nptr, (Chbyte **) endptr, base);
4914 } 5003 }
4915 5004
4916 DECLARE_INLINE_HEADER (int qxeatoi (const Ibyte *string)) 5005 DECLARE_INLINE_HEADER (int qxeatoi (const Ibyte *string))
4917 { 5006 {
4918 return atoi ((const char *) string); 5007 return atoi ((const Chbyte *) string);
4919 } 5008 }
4920 5009
4921 DECLARE_INLINE_HEADER (Ibyte *qxestrupr (Ibyte *s)) 5010 DECLARE_INLINE_HEADER (Ibyte *qxestrupr (Ibyte *s))
4922 { 5011 {
4923 return (Ibyte *) strupr ((char *) s); 5012 return (Ibyte *) strupr ((Chbyte *) s);
4924 } 5013 }
4925 5014
4926 DECLARE_INLINE_HEADER (Ibyte *qxestrlwr (Ibyte *s)) 5015 DECLARE_INLINE_HEADER (Ibyte *qxestrlwr (Ibyte *s))
4927 { 5016 {
4928 return (Ibyte *) strlwr ((char *) s); 5017 return (Ibyte *) strlwr ((Chbyte *) s);
4929 } 5018 }
4930 5019
4931 int qxesprintf (Ibyte *buffer, const CIbyte *format, ...) 5020 int qxesprintf (Ibyte *buffer, const CIbyte *format, ...)
4932 PRINTF_ARGS (2, 3); 5021 PRINTF_ARGS (2, 3);
5022
5023 DECLARE_INLINE_HEADER (int qxesscanf_ascii_1 (Ibyte *buffer,
5024 const Ascbyte *format,
5025 void *ptr))
5026 {
5027 /* #### DAMNIT! No vsscanf! */
5028 return sscanf ((Chbyte *) buffer, format, ptr);
5029 }
4933 5030
4934 /* Do not use POSIX locale routines. Not Mule-correct. */ 5031 /* Do not use POSIX locale routines. Not Mule-correct. */
4935 #define qxestrcoll DO NOT USE. 5032 #define qxestrcoll DO NOT USE.
4936 #define qxestrxfrm DO NOT USE. 5033 #define qxestrxfrm DO NOT USE.
4937 5034
4938 int qxestrcasecmp (const Ibyte *s1, const Ibyte *s2); 5035 int qxestrcasecmp (const Ibyte *s1, const Ibyte *s2);
4939 int qxestrcasecmp_c (const Ibyte *s1, const Char_ASCII *s2); 5036 int qxestrcasecmp_ascii (const Ibyte *s1, const Ascbyte *s2);
4940 int qxestrcasecmp_i18n (const Ibyte *s1, const Ibyte *s2); 5037 int qxestrcasecmp_i18n (const Ibyte *s1, const Ibyte *s2);
4941 int ascii_strcasecmp (const Char_ASCII *s1, const Char_ASCII *s2); 5038 int ascii_strcasecmp (const Ascbyte *s1, const Ascbyte *s2);
4942 int lisp_strcasecmp (Lisp_Object s1, Lisp_Object s2); 5039 int lisp_strcasecmp (Lisp_Object s1, Lisp_Object s2);
4943 int lisp_strcasecmp_i18n (Lisp_Object s1, Lisp_Object s2); 5040 int lisp_strcasecmp_i18n (Lisp_Object s1, Lisp_Object s2);
4944 int qxestrncasecmp (const Ibyte *s1, const Ibyte *s2, Bytecount len); 5041 int qxestrncasecmp (const Ibyte *s1, const Ibyte *s2, Bytecount len);
4945 int qxestrncasecmp_c (const Ibyte *s1, const Char_ASCII *s2, Bytecount len); 5042 int qxestrncasecmp_ascii (const Ibyte *s1, const Ascbyte *s2,
5043 Bytecount len);
4946 int qxestrncasecmp_i18n (const Ibyte *s1, const Ibyte *s2, Bytecount len); 5044 int qxestrncasecmp_i18n (const Ibyte *s1, const Ibyte *s2, Bytecount len);
4947 int ascii_strncasecmp (const Char_ASCII *s1, const Char_ASCII *s2, 5045 int ascii_strncasecmp (const Ascbyte *s1, const Ascbyte *s2,
4948 Bytecount len); 5046 Bytecount len);
4949 int qxememcmp (const Ibyte *s1, const Ibyte *s2, Bytecount len); 5047 int qxememcmp (const Ibyte *s1, const Ibyte *s2, Bytecount len);
4950 int qxememcmp4 (const Ibyte *s1, Bytecount len1, 5048 int qxememcmp4 (const Ibyte *s1, Bytecount len1,
4951 const Ibyte *s2, Bytecount len2); 5049 const Ibyte *s2, Bytecount len2);
4952 int qxememcasecmp (const Ibyte *s1, const Ibyte *s2, Bytecount len); 5050 int qxememcasecmp (const Ibyte *s1, const Ibyte *s2, Bytecount len);
4967 Bytecount bytelength, 5065 Bytecount bytelength,
4968 Charcount charlength); 5066 Charcount charlength);
4969 void buffer_mule_signal_deleted_region (struct buffer *buf, Charbpos start, 5067 void buffer_mule_signal_deleted_region (struct buffer *buf, Charbpos start,
4970 Charbpos end, Bytebpos byte_start, 5068 Charbpos end, Bytebpos byte_start,
4971 Bytebpos byte_end); 5069 Bytebpos byte_end);
5070
5071 typedef struct
5072 {
5073 const char *srctext;
5074 void *dst;
5075 Bytecount dst_size;
5076 } alloca_convert_vals;
5077
5078 typedef struct
5079 {
5080 Dynarr_declare (alloca_convert_vals);
5081 } alloca_convert_vals_dynarr;
5082
5083 extern alloca_convert_vals_dynarr *active_alloca_convert;
5084
5085 MODULE_API int find_pos_of_existing_active_alloca_convert (const char *
5086 srctext);
4972 5087
4973 /* Defined in unicode.c */ 5088 /* Defined in unicode.c */
4974 extern const struct sized_memory_description to_unicode_description; 5089 extern const struct sized_memory_description to_unicode_description;
4975 extern const struct sized_memory_description from_unicode_description; 5090 extern const struct sized_memory_description from_unicode_description;
4976 void init_charset_unicode_tables (Lisp_Object charset); 5091 void init_charset_unicode_tables (Lisp_Object charset);