XEmacs 21.4.4 "Artificial Intelligence".
[chise/xemacs-chise.git.1] / src / lisp.h
index c820d52..4aee0e1 100644 (file)
@@ -1,7 +1,7 @@
 /* Fundamental definitions for XEmacs Lisp interpreter.
    Copyright (C) 1985-1987, 1992-1995 Free Software Foundation, Inc.
    Copyright (C) 1993-1996 Richard Mlynarik.
-   Copyright (C) 1995, 1996 Ben Wing.
+   Copyright (C) 1995, 1996, 2000 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -22,13 +22,15 @@ Boston, MA 02111-1307, USA.  */
 
 /* Synched up with: FSF 19.30. */
 
-#ifndef _XEMACS_LISP_H_
-#define _XEMACS_LISP_H_
+#ifndef INCLUDED_lisp_h_
+#define INCLUDED_lisp_h_
 
 /************************************************************************/
 /*                       general definitions                           */
 /************************************************************************/
 
+/* ------------------------ include files ------------------- */
+
 /* We include the following generally useful header files so that you
    don't have to worry about prototypes when using the standard C
    library functions and macros.  These files shouldn't be excessively
@@ -39,12 +41,11 @@ Boston, MA 02111-1307, USA.  */
 #include <stdio.h>             /* NULL, etc. */
 #include <ctype.h>
 #include <stdarg.h>
+#include <stddef.h>            /* offsetof */
+#include <sys/types.h>
+#include <limits.h>
 
-#ifdef __lucid
-# include <sysent.h>
-#endif
-
-/* ---- Dynamic arrays ---- */
+/* ------------------------ dynamic arrays ------------------- */
 
 #define Dynarr_declare(type)   \
   type *base;                  \
@@ -60,22 +61,27 @@ typedef struct dynarr
 
 void *Dynarr_newf (int elsize);
 void Dynarr_resize (void *dy, int size);
-void Dynarr_insert_many (void *d, CONST void *el, int len, int start);
+void Dynarr_insert_many (void *d, const void *el, int len, int start);
 void Dynarr_delete_many (void *d, int start, int len);
 void Dynarr_free (void *d);
 
-#define Dynarr_new(type) ((type##_dynarr *) Dynarr_newf (sizeof(type)))
+#define Dynarr_new(type) ((type##_dynarr *) Dynarr_newf (sizeof (type)))
+#define Dynarr_new2(dynarr_type, type) \
+  ((dynarr_type *) Dynarr_newf (sizeof (type)))
 #define Dynarr_at(d, pos) ((d)->base[pos])
 #define Dynarr_atp(d, pos) (&Dynarr_at (d, pos))
+#define Dynarr_begin(d) Dynarr_atp (d, 0)
+#define Dynarr_end(d) Dynarr_atp (d, Dynarr_length (d))
+#define Dynarr_sizeof(d) ((d)->cur * (d)->elsize)
 #define Dynarr_length(d) ((d)->cur)
 #define Dynarr_largest(d) ((d)->largest)
 #define Dynarr_reset(d) ((d)->cur = 0)
 #define Dynarr_add_many(d, el, len) Dynarr_insert_many (d, el, len, (d)->cur)
 #define Dynarr_insert_many_at_start(d, el, len)        \
   Dynarr_insert_many (d, el, len, 0)
-#define Dynarr_add_literal_string(d, s) Dynarr_add_many (d, s, sizeof(s) - 1)
+#define Dynarr_add_literal_string(d, s) Dynarr_add_many (d, s, sizeof (s) - 1)
 #define Dynarr_add_lisp_string(d, s) do {              \
-  struct Lisp_String *dyna_ls_s = XSTRING (s);         \
+  Lisp_String *dyna_ls_s = XSTRING (s);                        \
   Dynarr_add_many (d, (char *) string_data (dyna_ls_s),        \
                   string_length (dyna_ls_s));          \
 } while (0)
@@ -90,16 +96,11 @@ void Dynarr_free (void *d);
 #define Dynarr_increment(d) ((d)->cur++)
 #define Dynarr_set_size(d, n) ((d)->cur = n)
 
-/* Minimum size in elements for dynamic array when resized; default is 32 */
-extern int Dynarr_min_size;
-
 #ifdef MEMORY_USAGE_STATS
 struct overhead_stats;
 size_t Dynarr_memory_usage (void *d, struct overhead_stats *stats);
 #endif
 
-#include "symsinit.h"          /* compiler warning suppression */
-
 /* Also define min() and max(). (Some compilers put them in strange
    places that won't be referenced by the above include files, such
    as 'macros.h' under Solaris.) */
@@ -112,19 +113,17 @@ size_t Dynarr_memory_usage (void *d, struct overhead_stats *stats);
 #endif
 
 /* Memory allocation */
-void malloc_warning (CONST char *);
+void malloc_warning (const char *);
 void *xmalloc (size_t size);
 void *xmalloc_and_zero (size_t size);
 void *xrealloc (void *, size_t size);
-char *xstrdup (CONST char *);
+char *xstrdup (const char *);
 /* generally useful */
-#define countof(x) ((int) (sizeof(x)/sizeof(x[0])))
-#define slot_offset(type, slot_name) \
-  ((unsigned) (((char *) (&(((type *)0)->slot_name))) - ((char *)0)))
+#define countof(x) ((int) (sizeof(x)/sizeof((x)[0])))
 #define xnew(type) ((type *) xmalloc (sizeof (type)))
 #define xnew_array(type, len) ((type *) xmalloc ((len) * sizeof (type)))
 #define xnew_and_zero(type) ((type *) xmalloc_and_zero (sizeof (type)))
-#define xzero(lvalue) ((void) memset (&(lvalue), 0, sizeof (lvalue)))
+#define xzero(lvalue) ((void) memset (&(lvalue), '\0', sizeof (lvalue)))
 #define xnew_array_and_zero(type, len) ((type *) xmalloc_and_zero ((len) * sizeof (type)))
 #define XREALLOC_ARRAY(ptr, type, len) ((void) (ptr = (type *) xrealloc (ptr, (len) * sizeof (type))))
 #define alloca_array(type, len) ((type *) alloca ((len) * sizeof (type)))
@@ -136,21 +135,16 @@ char *xstrdup (CONST char *);
    macro will realloc BASEVAR as necessary so that it can hold at
    least NEEDED_SIZE objects.  The reallocing is done by doubling,
    which ensures constant amortized time per element. */
-#define DO_REALLOC(basevar, sizevar, needed_size, type)        do      \
-{                                                              \
-  /* Avoid side-effectualness. */                              \
-  /* Dammit! Macros suffer from dynamic scope! */              \
-  /* We demand inline functions! */                            \
+#define DO_REALLOC(basevar, sizevar, needed_size, type)        do {    \
   size_t do_realloc_needed_size = (needed_size);               \
-  size_t do_realloc_newsize = 0;                               \
-  while ((sizevar) < (do_realloc_needed_size)) {               \
-    do_realloc_newsize = 2*(sizevar);                          \
-    if (do_realloc_newsize < 32)                               \
-      do_realloc_newsize = 32;                                 \
-    (sizevar) = do_realloc_newsize;                            \
-  }                                                            \
-  if (do_realloc_newsize)                                      \
-    XREALLOC_ARRAY (basevar, type, do_realloc_newsize);                \
+  if ((sizevar) < do_realloc_needed_size)                      \
+    {                                                          \
+      if ((sizevar) < 32)                                      \
+       (sizevar) = 32;                                         \
+      while ((sizevar) < do_realloc_needed_size)               \
+       (sizevar) *= 2;                                         \
+      XREALLOC_ARRAY (basevar, type, (sizevar));               \
+    }                                                          \
 } while (0)
 
 #ifdef ERROR_CHECK_MALLOC
@@ -163,7 +157,6 @@ void xfree_1 (void *);
 } while (0)
 #else
 void xfree (void *);
-#define xfree_1 xfree
 #endif /* ERROR_CHECK_MALLOC */
 
 #ifndef PRINTF_ARGS
@@ -178,13 +171,13 @@ void xfree (void *);
 #ifndef DOESNT_RETURN
 # if defined __GNUC__
 #  if ((__GNUC__ > 2) || (__GNUC__ == 2) && (__GNUC_MINOR__ >= 5))
-#   define DOESNT_RETURN void volatile
+#   define DOESNT_RETURN void
 #   define DECLARE_DOESNT_RETURN(decl) \
-           extern void volatile decl __attribute__ ((noreturn))
+           extern void decl __attribute__ ((noreturn))
 #   define DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS(decl,str,idx) \
      /* Should be able to state multiple independent __attribute__s, but  \
         the losing syntax doesn't work that way, and screws losing cpp */ \
-           extern void volatile decl \
+           extern void decl \
                   __attribute__ ((noreturn, format (printf, str, idx)))
 #  else
 #   define DOESNT_RETURN void volatile
@@ -200,20 +193,42 @@ void xfree (void *);
 # endif /* GNUC */
 #endif
 
+/* No type has a greater alignment requirement than max_align_t.
+   (except perhaps for types we don't use, like long double) */
+typedef union
+{
+  struct { long l; } l;
+  struct { void *p; } p;
+  struct { void (*f)(void); } f;
+  struct { double d; } d;
+} max_align_t;
+
 #ifndef ALIGNOF
 # if defined (__GNUC__) && (__GNUC__ >= 2)
-#  define ALIGNOF(x) __alignof (x)
+/* gcc has an extension that gives us exactly what we want. */
+#  define ALIGNOF(type) __alignof__ (type)
+# elif ! defined (__cplusplus)
+/* The following is mostly portable, except that:
+   - it doesn't work for inside out declarations like void (*) (void).
+     (so just call ALIGNOF with a typedef'ed name)
+   - it doesn't work with C++.  The C++ committee has decided,
+     in its infinite wisdom, that:
+     "Types must be declared in declarations, not in expressions." */
+#  define ALIGNOF(type) offsetof (struct { char c; type member; }, member)
 # else
-#  define ALIGNOF(x) sizeof (x)
+/* C++ is annoying, but it has a big bag of tricks.
+   The following doesn't have the "inside out" declaration bug C does. */
+template<typename T> struct alignment_trick { char c; T member; };
+#  define ALIGNOF(type) offsetof (alignment_trick<type>, member)
 # endif
-#endif
+#endif /* ALIGNOF */
 
 #define ALIGN_SIZE(len, unit) \
   ((((len) + (unit) - 1) / (unit)) * (unit))
 
 /* #### Yuck, this is kind of evil */
 #define ALIGN_PTR(ptr, unit) \
-  ((void *) ALIGN_SIZE ((long) (ptr), unit))
+  ((void *) ALIGN_SIZE ((size_t) (ptr), unit))
 
 #ifndef DO_NOTHING
 #define DO_NOTHING do {} while (0)
@@ -231,7 +246,7 @@ void xfree (void *);
 #ifdef USE_ASSERTIONS
 /* Highly dubious kludge */
 /*   (thanks, Jamie, I feel better now -- ben) */
-DECLARE_DOESNT_RETURN (assert_failed (CONST char *, int, CONST char *));
+void assert_failed (const char *, int, const char *);
 # define abort() (assert_failed (__FILE__, __LINE__, "abort()"))
 # define assert(x) ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, #x))
 #else
@@ -249,6 +264,37 @@ DECLARE_DOESNT_RETURN (assert_failed (CONST char *, int, CONST char *));
 /*#define REGISTER register*/
 /*#endif*/
 
+
+/* EMACS_INT is the underlying integral type into which a Lisp_Object must fit.
+   In particular, it must be large enough to contain a pointer.
+   config.h can override this, e.g. to use `long long' for bigger lisp ints.
+
+   #### In point of fact, it would NOT be a good idea for config.h to mess
+   with EMACS_INT.  A lot of code makes the basic assumption that EMACS_INT
+   is the size of a pointer. */
+
+#ifndef SIZEOF_EMACS_INT
+# define SIZEOF_EMACS_INT SIZEOF_VOID_P
+#endif
+
+#ifndef EMACS_INT
+# if   SIZEOF_EMACS_INT == SIZEOF_LONG
+#  define EMACS_INT long
+# elif SIZEOF_EMACS_INT == SIZEOF_INT
+#  define EMACS_INT int
+# elif SIZEOF_EMACS_INT == SIZEOF_LONG_LONG
+#  define EMACS_INT long long
+# else
+#  error Unable to determine suitable type for EMACS_INT
+# endif
+#endif
+
+#ifndef EMACS_UINT
+# define EMACS_UINT unsigned EMACS_INT
+#endif
+
+#define BITS_PER_EMACS_INT (SIZEOF_EMACS_INT * BITS_PER_CHAR)
+
 \f
 /************************************************************************/
 /*                               typedefs                              */
@@ -259,15 +305,50 @@ DECLARE_DOESNT_RETURN (assert_failed (CONST char *, int, CONST char *));
    maybe for simple structures like Dynarrs); that keeps them private
    to the routines that actually use them. */
 
+/* ------------------------------- */
+/*     basic char/int typedefs     */
+/* ------------------------------- */
+
+/* The definitions we put here use typedefs to attribute specific meaning
+   to types that by themselves are pretty general.  Stuff pointed to by a
+   char * or unsigned char * will nearly always be one of four types:
+   a) pointer to internally-formatted text; b) pointer to text in some
+   external format, which can be defined as all formats other than the
+   internal one; c) pure ASCII text; d) binary data that is not meant to
+   be interpreted as text. [A fifth possible type "e) a general pointer
+   to memory" should be replaced with void *.]  Using these more specific
+   types rather than the general ones helps avoid the confusions that
+   occur when the semantics of a char * argument being studied are unclear. */
+
+typedef unsigned char UChar;
+
 /* The data representing the text in a buffer is logically a set
    of Bufbytes, declared as follows. */
 
-typedef unsigned char Bufbyte;
+typedef UChar Bufbyte;
+
+/* Explicitly signed or unsigned versions: */
+typedef UChar UBufbyte;
+typedef char  SBufbyte;
 
-/* The data representing a string in "external" format (simple
-   binary format) is logically a set of Extbytes, declared as follows. */
+/* The data representing a string in "external" format (binary or any
+   external encoding) is logically a set of Extbytes, declared as
+   follows.  Extbyte is guaranteed to be just a char, so for example
+   strlen (Extbyte *) is OK.  Extbyte is only a documentation device
+   for referring to external text. */
+
+typedef char Extbyte;
+
+/* A byte in a string in binary format: */
+typedef char Char_Binary;
+typedef UChar UChar_Binary;
+
+/* A byte in a string in entirely US-ASCII format: (Nothing outside
+ the range 00 - 7F) */
+
+typedef char Char_ASCII;
+typedef UChar UChar_ASCII;
 
-typedef unsigned char Extbyte;
 
 /* To the user, a buffer is made up of characters, declared as follows.
    In the non-Mule world, characters and Bufbytes are equivalent.
@@ -277,23 +358,31 @@ typedef unsigned char Extbyte;
 typedef int Emchar;
 
 /* Different ways of referring to a position in a buffer.  We use
-   the typedefs in preference to 'int' to make it clearer what
+   the typedefs in preference to 'EMACS_INT' to make it clearer what
    sort of position is being used.  See extents.c for a description
    of the different positions.  We put them here instead of in
    buffer.h (where they rightfully belong) to avoid syntax errors
    in function prototypes. */
 
-typedef int Bufpos;
-typedef int Bytind;
-typedef int Memind;
+typedef EMACS_INT Bufpos;
+typedef EMACS_INT Bytind;
+typedef EMACS_INT Memind;
 
 /* Counts of bytes or chars */
 
-typedef int Bytecount;
-typedef int Charcount;
+typedef EMACS_INT Bytecount;
+typedef EMACS_INT Charcount;
 
 /* Length in bytes of a string in external format */
-typedef int Extcount;
+typedef EMACS_INT Extcount;
+
+/* ------------------------------- */
+/*     structure/other typedefs    */
+/* ------------------------------- */
+
+/* Counts of bytes or array elements */
+typedef EMACS_INT Memory_count;
+typedef EMACS_INT Element_count;
 
 typedef struct lstream Lstream;
 
@@ -323,20 +412,17 @@ struct extent;
 typedef struct extent *EXTENT;
 struct frame;                  /* "frame.h" */
 struct window;                  /* "window.h" */
-struct Lisp_Event;              /* "events.h" */
-typedef struct Lisp_Event Lisp_Event;
-struct Lisp_Face;
-typedef struct Lisp_Face Lisp_Face;
-struct Lisp_Process;            /* "process.c" */
-typedef struct Lisp_Process Lisp_Process;
+typedef struct Lisp_Event Lisp_Event; /* "events.h" */
+typedef struct Lisp_Face Lisp_Face;   /* "faces.h" */
+typedef struct Lisp_Process Lisp_Process; /* "procimpl.h" */
 struct stat;                    /* <sys/stat.h> */
-struct Lisp_Color_Instance;
 typedef struct Lisp_Color_Instance Lisp_Color_Instance;
-struct Lisp_Font_Instance;
 typedef struct Lisp_Font_Instance Lisp_Font_Instance;
-struct Lisp_Image_Instance;
 typedef struct Lisp_Image_Instance Lisp_Image_Instance;
+typedef struct Lisp_Gui_Item Lisp_Gui_Item;
 struct display_line;
+struct display_glyph_area;
+struct display_box;
 struct redisplay_info;
 struct window_mirror;
 struct scrollbar_instance;
@@ -406,47 +492,6 @@ typedef struct
   Dynarr_declare (struct console_type_entry);
 } console_type_entry_dynarr;
 
-/* Need to declare this here. */
-enum external_data_format
-{
-  /* Binary format.  This is the simplest format and is what we
-     use in the absence of a more appropriate format.  This converts
-     according to the `binary' coding system:
-
-     a) On input, bytes 0 - 255 are converted into characters 0 - 255.
-     b) On output, characters 0 - 255 are converted into bytes 0 - 255
-        and other characters are converted into `X'.
-   */
-  FORMAT_BINARY,
-
-  /* Format used for filenames.  In the original Mule, this is
-     user-definable with the `pathname-coding-system' variable.
-     For the moment, we just use the `binary' coding system. */
-  FORMAT_FILENAME,
-
-  /* Format used for output to the terminal.  This should be controlled
-     by the `terminal-coding-system' variable.  Under kterm, this will
-     be some ISO2022 system.  On some DOS machines, this is Shift-JIS. */
-  FORMAT_TERMINAL,
-
-  /* Format used for input from the terminal.  This should be controlled
-     by the `keyboard-coding-system' variable. */
-  FORMAT_KEYBOARD,
-
-  /* Format used for the external Unix environment -- argv[], stuff
-     from getenv(), stuff from the /etc/passwd file, etc.
-
-     Perhaps should be the same as FORMAT_FILENAME. */
-  FORMAT_OS,
-
-  /* Compound-text format.  This is the standard X format used for
-     data stored in properties, selections, and the like.  This is
-     an 8-bit no-lock-shift ISO2022 coding system. */
-  FORMAT_CTEXT
-};
-
-#define FORMAT_NATIVE FORMAT_FILENAME
-
 enum run_hooks_condition
 {
   RUN_HOOKS_TO_COMPLETION,
@@ -464,6 +509,14 @@ enum toolbar_pos
 };
 #endif
 
+enum edge_style
+{
+  EDGE_ETCHED_IN,
+  EDGE_ETCHED_OUT,
+  EDGE_BEVEL_IN,
+  EDGE_BEVEL_OUT
+};
+
 #ifndef ERROR_CHECK_TYPECHECK
 
 typedef enum error_behavior
@@ -506,59 +559,10 @@ enum munge_me_out_the_door
 /*                  Definition of Lisp_Object data type                */
 /************************************************************************/
 
-#ifdef USE_MINIMAL_TAGBITS
-# define LRECORD_CONS
-# define LRECORD_VECTOR
-# define LRECORD_SYMBOL
-# define LRECORD_STRING
-#endif
-
 /* Define the fundamental Lisp data structures */
 
 /* This is the set of Lisp data types */
 
-#ifndef USE_MINIMAL_TAGBITS
-
-enum Lisp_Type
-{
-  /* XRECORD_LHEADER (object) points to a struct lrecord_header
-     lheader->implementation determines the type (and GC behavior)
-     of the object. */
-  Lisp_Type_Record,
-
-  /* Integer.  XINT(obj) is the integer value. */
-  Lisp_Type_Int,
-
-#ifndef LRECORD_CONS
-  /* Cons.  XCONS (object) points to a struct Lisp_Cons. */
-  Lisp_Type_Cons,
-#endif
-
-#ifndef LRECORD_STRING
-  /* String.  XSTRING (object) points to a struct Lisp_String.
-     The length of the string, and its contents, are stored therein. */
-  Lisp_Type_String,
-#endif
-
-#ifndef LRECORD_VECTOR
-  /* Vector of Lisp objects.  XVECTOR(object) points to a struct Lisp_Vector.
-     The length of the vector, and its contents, are stored therein. */
-  Lisp_Type_Vector,
-#endif /* !LRECORD_VECTOR */
-
-#ifndef LRECORD_SYMBOL
-  /* Symbol.  XSYMBOL (object) points to a struct Lisp_Symbol. */
-  Lisp_Type_Symbol,
-#endif /* !LRECORD_SYMBOL */
-
-  Lisp_Type_Char
-};
-
-# define POINTER_TYPE_P(type) \
-  ((type) != Lisp_Type_Int && (type) != Lisp_Type_Char)
-
-#else /* USE_MINIMAL_TAGBITS */
-
 enum Lisp_Type
 {
   Lisp_Type_Record,
@@ -569,54 +573,20 @@ enum Lisp_Type
 
 #define POINTER_TYPE_P(type) ((type) == Lisp_Type_Record)
 
-#endif /* USE_MINIMAL_TAGBITS */
-
-/* EMACS_INT is the underlying integral type into which a Lisp_Object must fit.
-   In particular, it must be large enough to contain a pointer.
-   config.h can override this, e.g. to use `long long' for bigger lisp ints. */
-
-#ifndef SIZEOF_EMACS_INT
-# define SIZEOF_EMACS_INT SIZEOF_VOID_P
-#endif
-
-#ifndef EMACS_INT
-# if   SIZEOF_EMACS_INT == SIZEOF_LONG
-#  define EMACS_INT long
-# elif SIZEOF_EMACS_INT == SIZEOF_INT
-#  define EMACS_INT int
-# elif SIZEOF_EMACS_INT == SIZEOF_LONG_LONG
-#  define EMACS_INT long long
-# else
-#  error Unable to determine suitable type for EMACS_INT
-# endif
-#endif
-
-#ifndef EMACS_UINT
-# define EMACS_UINT unsigned EMACS_INT
-#endif
-
-#define BITS_PER_EMACS_INT (SIZEOF_EMACS_INT * BITS_PER_CHAR)
-
 /* Overridden by m/next.h */
 #ifndef ASSERT_VALID_POINTER
 # define ASSERT_VALID_POINTER(pnt) (assert ((((EMACS_UINT) pnt) & 3) == 0))
 #endif
 
-#ifdef USE_MINIMAL_TAGBITS
-# define GCMARKBITS  0
-# define GCTYPEBITS  2
-# define GCBITS      2
-# define INT_GCBITS  1
-#else
-# define GCMARKBITS  1
-# define GCTYPEBITS  3
-# define GCBITS      4
-# define INT_GCBITS  GCBITS
-#endif
+#define GCMARKBITS  0
+#define GCTYPEBITS  2
+#define GCBITS      2
+#define INT_GCBITS  1
 
 #define INT_VALBITS (BITS_PER_EMACS_INT - INT_GCBITS)
 #define VALBITS (BITS_PER_EMACS_INT - GCBITS)
-#define EMACS_INT_MAX ((1UL << INT_VALBITS) -1UL)
+#define EMACS_INT_MAX ((EMACS_INT) ((1UL << (INT_VALBITS - 1)) -1UL))
+#define EMACS_INT_MIN (-(EMACS_INT_MAX) - 1)
 
 #ifdef USE_UNION_TYPE
 # include "lisp-union.h"
@@ -624,25 +594,7 @@ enum Lisp_Type
 # include "lisp-disunion.h"
 #endif /* !USE_UNION_TYPE */
 
-#ifdef HAVE_SHM
-/* In this representation, data is found in two widely separated segments.  */
-extern int pure_size;
-# define XPNTR(x) \
-  ((void *)(XPNTRVAL(x)) | (XPNTRVAL(x) > pure_size ? DATA_SEG_BITS : PURE_SEG_BITS)))
-#else /* not HAVE_SHM */
-# ifdef DATA_SEG_BITS
-/* This case is used for the rt-pc and hp-pa.
-   In the diffs I was given, it checked for ptr = 0
-   and did not adjust it in that case.
-   But I don't think that zero should ever be found
-   in a Lisp object whose data type says it points to something.
- */
-#  define XPNTR(x) ((void *)((XPNTRVAL(x)) | DATA_SEG_BITS))
-# else /* not DATA_SEG_BITS */
-#  define XPNTR(x) ((void *) (XPNTRVAL(x)))
-# endif /* not DATA_SEG_BITS */
-#endif /* not HAVE_SHM */
-
+#define XPNTR(x) ((void *) XPNTRVAL(x))
 
 /* WARNING WARNING WARNING.  You must ensure on your own that proper
    GC protection is provided for the elements in this array. */
@@ -651,11 +603,16 @@ typedef struct
   Dynarr_declare (Lisp_Object);
 } Lisp_Object_dynarr;
 
+typedef struct
+{
+  Dynarr_declare (Lisp_Object *);
+} Lisp_Object_ptr_dynarr;
+
 /* Close your eyes now lest you vomit or spontaneously combust ... */
 
 #define HACKEQ_UNSAFE(obj1, obj2)                              \
-  (EQ (obj1, obj2) || (!POINTER_TYPE_P (XGCTYPE (obj1))                \
-                      && !POINTER_TYPE_P (XGCTYPE (obj2))      \
+  (EQ (obj1, obj2) || (!POINTER_TYPE_P (XTYPE (obj1))          \
+                      && !POINTER_TYPE_P (XTYPE (obj2))        \
                       && XCHAR_OR_INT (obj1) == XCHAR_OR_INT (obj2)))
 
 #ifdef DEBUG_XEMACS
@@ -672,12 +629,12 @@ int eq_with_ebola_notice (Lisp_Object, Lisp_Object);
 
 \f
 /************************************************************************/
-/*                  Definitions of basic Lisp objects                  */
+/**                 Definitions of basic Lisp objects                 **/
 /************************************************************************/
 
 #include "lrecord.h"
 
-/*********** unbound ***********/
+/*------------------------------ unbound -------------------------------*/
 
 /* Qunbound is a special Lisp_Object (actually of type
    symbol-value-forward), that can never be visible to
@@ -685,17 +642,14 @@ int eq_with_ebola_notice (Lisp_Object, Lisp_Object);
    to mean "no such value". */
 
 #define UNBOUNDP(val) EQ (val, Qunbound)
-#define GC_UNBOUNDP(val) GC_EQ (val, Qunbound)
 
-/*********** cons ***********/
+/*------------------------------- cons ---------------------------------*/
 
 /* In a cons, the markbit of the car is the gc mark bit */
 
 struct Lisp_Cons
 {
-#ifdef LRECORD_CONS
   struct lrecord_header lheader;
-#endif
   Lisp_Object car, cdr;
 };
 typedef struct Lisp_Cons Lisp_Cons;
@@ -712,40 +666,19 @@ struct Lisp_Buffer_Cons
 };
 #endif
 
-#ifdef LRECORD_CONS
-
 DECLARE_LRECORD (cons, Lisp_Cons);
 #define XCONS(x) XRECORD (x, cons, Lisp_Cons)
 #define XSETCONS(x, p) XSETRECORD (x, p, cons)
 #define CONSP(x) RECORDP (x, cons)
-#define GC_CONSP(x) GC_RECORDP (x, cons)
 #define CHECK_CONS(x) CHECK_RECORD (x, cons)
 #define CONCHECK_CONS(x) CONCHECK_RECORD (x, cons)
 
 #define CONS_MARKED_P(c) MARKED_RECORD_HEADER_P(&((c)->lheader))
 #define MARK_CONS(c) MARK_RECORD_HEADER (&((c)->lheader))
 
-#else /* ! LRECORD_CONS */
-
-DECLARE_NONRECORD (cons, Lisp_Type_Cons, Lisp_Cons);
-#define XCONS(a) XNONRECORD (a, cons, Lisp_Type_Cons, Lisp_Cons)
-#define XSETCONS(c, p) XSETOBJ (c, Lisp_Type_Cons, p)
-#define CONSP(x) (XTYPE (x) == Lisp_Type_Cons)
-#define GC_CONSP(x) (XGCTYPE (x) == Lisp_Type_Cons)
-#define CHECK_CONS(x) CHECK_NONRECORD (x, Lisp_Type_Cons, Qconsp)
-#define CONCHECK_CONS(x) CONCHECK_NONRECORD (x, Lisp_Type_Cons, Qconsp)
-
-/* Define these because they're used in a few places, inside and
-   out of alloc.c */
-#define CONS_MARKED_P(c) XMARKBIT (c->car)
-#define MARK_CONS(c) XMARK (c->car)
-
-#endif /* ! LRECORD_CONS */
-
 extern Lisp_Object Qnil;
 
 #define NILP(x)  EQ (x, Qnil)
-#define GC_NILP(x)  GC_EQ (x, Qnil)
 #define XCAR(a) (XCONS (a)->car)
 #define XCDR(a) (XCONS (a)->cdr)
 #define LISTP(x) (CONSP(x) || NILP(x))
@@ -760,23 +693,175 @@ extern Lisp_Object Qnil;
     x = wrong_type_argument (Qlistp, x);       \
 } while (0)
 
-/* For a list that's known to be in valid list format --
-   will abort() if the list is not in valid format */
+/*---------------------- list traversal macros -------------------------*/
+
+/* Note: These macros are for traversing through a list in some format,
+   and executing code that you specify on each member of the list.
+
+   There are two kinds of macros, those requiring surrounding braces, and
+   those not requiring this.  Which type of macro will be indicated.
+   The general format for using a brace-requiring macro is
+
+   {
+     LIST_LOOP_3 (elt, list, tail)
+       execute_code_here;
+   }
+
+   or
+
+   {
+     LIST_LOOP_3 (elt, list, tail)
+       {
+         execute_code_here;
+       }
+   }
+
+   You can put variable declarations between the brace and beginning of
+   macro, but NOTHING ELSE.
+
+   The brace-requiring macros typically declare themselves any arguments
+   that are initialized and iterated by the macros.  If for some reason
+   you need to declare these arguments yourself (e.g. to do something on
+   them before the iteration starts, use the _NO_DECLARE versions of the
+   macros.)
+*/
+
+/* There are two basic kinds of macros: those that handle "internal" lists
+   that are known to be correctly structured (i.e. first element is a cons
+   or nil, and the car of each cons is also a cons or nil, and there are
+   no circularities), and those that handle "external" lists, where the
+   list may have any sort of invalid formation.  This is reflected in
+   the names: those with "EXTERNAL_" work with external lists, and those
+   without this prefix work with internal lists.  The internal-list
+   macros will hit an assertion failure if the structure is ill-formed;
+   the external-list macros will signal an error in this case, either a
+   malformed-list error or a circular-list error.
+
+   Note also that the simplest external list iterator, EXTERNAL_LIST_LOOP,
+   does *NOT* check for circularities.  Therefore, make sure you call
+   QUIT each iteration or so.  However, it's probably easier just to use
+   EXTERNAL_LIST_LOOP_2, which is easier to use in any case.
+*/
+
+/* LIST_LOOP and EXTERNAL_LIST_LOOP are the simplest macros.  They don't
+   require brace surrounding, and iterate through a list, which may or may
+   not known to be syntactically correct.  EXTERNAL_LIST_LOOP is for those
+   not known to be correct, and it detects and signals a malformed list
+   error when encountering a problem.  Circularities, however, are not
+   handled, and cause looping forever, so make sure to include a QUIT.
+   These functions also accept two args, TAIL (set progressively to each
+   cons starting with the first), and LIST, the list to iterate over.
+   TAIL needs to be defined by the program.
+
+   In each iteration, you can retrieve the current list item using XCAR
+   (tail), or destructively modify the list using XSETCAR (tail,
+   ...). */
+
 #define LIST_LOOP(tail, list)          \
   for (tail = list;                    \
        !NILP (tail);                   \
        tail = XCDR (tail))
 
+#define EXTERNAL_LIST_LOOP(tail, list)                 \
+  for (tail = list; !NILP (tail); tail = XCDR (tail))  \
+     if (!CONSP (tail))                                        \
+       signal_malformed_list_error (list);             \
+     else
+
+/* The following macros are the "core" macros for list traversal.
+
+   *** ALL OF THESE MACROS MUST BE DECLARED INSIDE BRACES -- SEE ABOVE. ***
+
+   LIST_LOOP_2 and EXTERNAL_LIST_LOOP_2 are the standard, most-often used
+   macros.  They take two arguments, an element variable ELT and the list
+   LIST.  ELT is automatically declared, and set to each element in turn
+   from LIST.
+
+   LIST_LOOP_3 and EXTERNAL_LIST_LOOP_3 are the same, but they have a third
+   argument TAIL, another automatically-declared variable.  At each iteration,
+   this one points to the cons cell for which ELT is the car.
+
+   EXTERNAL_LIST_LOOP_4 is like EXTERNAL_LIST_LOOP_3 but takes an additional
+   LEN argument, again automatically declared, which counts the number of
+   iterations gone by.  It is 0 during the first iteration.
+
+   EXTERNAL_LIST_LOOP_4_NO_DECLARE is like EXTERNAL_LIST_LOOP_4 but none
+   of the variables are automatically declared, and so you need to declare
+   them yourself. (ELT and TAIL are Lisp_Objects, and LEN is an EMACS_INT.)
+*/
+
 #define LIST_LOOP_2(elt, list)         \
-  Lisp_Object tail##elt;               \
-  LIST_LOOP_3(elt, list, tail##elt)
+  LIST_LOOP_3(elt, list, unused_tail_##elt)
 
 #define LIST_LOOP_3(elt, list, tail)   \
+  Lisp_Object elt, tail;               \
   for (tail = list;                    \
        NILP (tail) ?                   \
         0 : (elt = XCAR (tail), 1);    \
        tail = XCDR (tail))
 
+/* The following macros are for traversing lisp lists.
+   Signal an error if LIST is not properly acyclic and nil-terminated.
+
+   Use tortoise/hare algorithm to check for cycles, but only if it
+   looks like the list is getting too long.  Not only is the hare
+   faster than the tortoise; it even gets a head start! */
+
+/* Optimized and safe macros for looping over external lists.  */
+#define CIRCULAR_LIST_SUSPICION_LENGTH 1024
+
+#define EXTERNAL_LIST_LOOP_1(list)                                     \
+Lisp_Object ELL1_elt, ELL1_hare, ELL1_tortoise;                                \
+EMACS_INT ELL1_len;                                                    \
+PRIVATE_EXTERNAL_LIST_LOOP_6 (ELL1_elt, list, ELL1_len, ELL1_hare,     \
+                     ELL1_tortoise, CIRCULAR_LIST_SUSPICION_LENGTH)
+
+#define EXTERNAL_LIST_LOOP_2(elt, list)                                        \
+Lisp_Object elt, hare_##elt, tortoise_##elt;                           \
+EMACS_INT len_##elt;                                                   \
+PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len_##elt, hare_##elt,                \
+                     tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH)
+
+#define EXTERNAL_LIST_LOOP_3(elt, list, tail)                          \
+Lisp_Object elt, tail, tortoise_##elt;                                 \
+EMACS_INT len_##elt;                                                   \
+PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len_##elt, tail,              \
+                     tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH)
+
+#define EXTERNAL_LIST_LOOP_4_NO_DECLARE(elt, list, tail, len)          \
+Lisp_Object tortoise_##elt;                                            \
+PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len, tail,                    \
+                     tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH)
+
+#define EXTERNAL_LIST_LOOP_4(elt, list, tail, len)                     \
+Lisp_Object elt, tail, tortoise_##elt;                                 \
+EMACS_INT len;                                                         \
+PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len, tail,                    \
+                     tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH)
+
+
+#define PRIVATE_EXTERNAL_LIST_LOOP_6(elt, list, len, hare,             \
+                                    tortoise, suspicion_length)        \
+  for (tortoise = hare = list, len = 0;                                        \
+                                                                       \
+       (CONSP (hare) ? ((elt = XCAR (hare)), 1) :                      \
+       (NILP (hare) ? 0 :                                              \
+        (signal_malformed_list_error (list), 0)));                     \
+                                                                       \
+       hare = XCDR (hare),                                             \
+        (void)                                                         \
+        ((++len > suspicion_length)                                    \
+         &&                                                            \
+         ((((len & 1) != 0) && (tortoise = XCDR (tortoise), 0)),       \
+          (EQ (hare, tortoise) && (signal_circular_list_error (list), 0)))))
+
+/* GET_LIST_LENGTH and GET_EXTERNAL_LIST_LENGTH:
+
+   These two macros return the length of LIST (either an internal or external
+   list, according to which macro is used), stored into LEN (which must
+   be declared by the caller).  Circularities are trapped in external lists
+   (and cause errors).  Neither macro need be declared inside brackets. */
+
 #define GET_LIST_LENGTH(list, len) do {                \
   Lisp_Object GLL_tail;                                \
   for (GLL_tail = list, len = 0;               \
@@ -785,11 +870,11 @@ extern Lisp_Object Qnil;
     DO_NOTHING;                                        \
 } while (0)
 
-#define GET_EXTERNAL_LIST_LENGTH(list, len)            \
-do {                                                   \
-  Lisp_Object GELL_elt, GELL_tail;                     \
-  EXTERNAL_LIST_LOOP_4 (GELL_elt, list, GELL_tail, len)        \
-    ;                                                  \
+#define GET_EXTERNAL_LIST_LENGTH(list, len)                            \
+do {                                                                   \
+  Lisp_Object GELL_elt, GELL_tail;                                     \
+  EXTERNAL_LIST_LOOP_4_NO_DECLARE (GELL_elt, list, GELL_tail, len)     \
+    ;                                                                  \
 } while (0)
 
 /* For a list that's known to be in valid list format, where we may
@@ -800,158 +885,165 @@ do {                                                    \
        !NILP (consvar) ? (nextconsvar = XCDR (consvar), 1) :0; \
        consvar = nextconsvar)
 
-/* Delete all elements of external list LIST
-   satisfying CONDITION, an expression referring to variable ELT */
-#define EXTERNAL_LIST_LOOP_DELETE_IF(elt, list, condition) do {        \
-  Lisp_Object prev_tail_##list = Qnil;                         \
-  Lisp_Object tail_##list;                                     \
-  int len_##list;                                              \
-  EXTERNAL_LIST_LOOP_4 (elt, list, tail_##list, len_##list)    \
+/* LIST_LOOP_DELETE_IF and EXTERNAL_LIST_LOOP_DELETE_IF:
+
+   These two macros delete all elements of LIST (either an internal or
+   external list, according to which macro is used) satisfying
+   CONDITION, a C expression referring to variable ELT.  ELT is
+   automatically declared.  Circularities are trapped in external
+   lists (and cause errors).  Neither macro need be declared inside
+   brackets. */
+
+#define LIST_LOOP_DELETE_IF(elt, list, condition) do {         \
+  /* Do not use ##list when creating new variables because     \
+     that may not be just a variable name. */                  \
+  Lisp_Object prev_tail_##elt = Qnil;                          \
+  LIST_LOOP_3 (elt, list, tail_##elt)                          \
     {                                                          \
       if (condition)                                           \
        {                                                       \
-         if (NILP (prev_tail_##list))                          \
-           list = XCDR (tail_##list);                          \
+         if (NILP (prev_tail_##elt))                           \
+           list = XCDR (tail_##elt);                           \
          else                                                  \
-           XCDR (prev_tail_##list) = XCDR (tail_##list);       \
-          /* Keep tortoise from ever passing hare. */          \
-         len_##list = 0;                                       \
+           XCDR (prev_tail_##elt) = XCDR (tail_##elt); \
        }                                                       \
       else                                                     \
-       prev_tail_##list = tail_##list;                         \
+       prev_tail_##elt = tail_##elt;                           \
     }                                                          \
 } while (0)
 
-/* Delete all elements of true non-circular list LIST
-   satisfying CONDITION, an expression referring to variable ELT */
-#define LIST_LOOP_DELETE_IF(elt, list, condition) do {         \
-  Lisp_Object prev_tail_##list = Qnil;                         \
-  Lisp_Object tail_##list;                                     \
-  LIST_LOOP_3 (elt, list, tail_##list)                         \
+#define EXTERNAL_LIST_LOOP_DELETE_IF(elt, list, condition) do {        \
+  Lisp_Object prev_tail_##elt = Qnil;                          \
+  EXTERNAL_LIST_LOOP_4 (elt, list, tail_##elt, len_##elt)      \
     {                                                          \
       if (condition)                                           \
        {                                                       \
-         if (NILP (prev_tail_##list))                          \
-           list = XCDR (tail_##list);                          \
+         if (NILP (prev_tail_##elt))                           \
+           list = XCDR (tail_##elt);                           \
          else                                                  \
-           XCDR (prev_tail_##list) = XCDR (tail_##list);       \
+           XCDR (prev_tail_##elt) = XCDR (tail_##elt);         \
+          /* Keep tortoise from ever passing hare. */          \
+         len_##elt = 0;                                        \
        }                                                       \
       else                                                     \
-       prev_tail_##list = tail_##list;                         \
+       prev_tail_##elt = tail_##elt;                           \
     }                                                          \
 } while (0)
 
-/* For a list that may not be in valid list format --
-   will signal an error if the list is not in valid format */
-#define EXTERNAL_LIST_LOOP(tail, list)                 \
-  for (tail = list; !NILP (tail); tail = XCDR (tail))  \
-     if (!CONSP (tail))                                        \
-       signal_malformed_list_error (list);             \
-     else
 
+/* Macros for looping over external alists.
 
-/* The following macros are for traversing lisp lists.
-   Signal an error if LIST is not properly acyclic and nil-terminated.
-
-   Use tortoise/hare algorithm to check for cycles, but only if it
-   looks like the list is getting too long.  Not only is the hare
-   faster than the tortoise; it even gets a head start! */
-
-/* Optimized and safe macros for looping over external lists.  */
-#define CIRCULAR_LIST_SUSPICION_LENGTH 1024
-
-#define EXTERNAL_LIST_LOOP_1(list)                                     \
-Lisp_Object ELL1_elt, ELL1_hare, ELL1_tortoise;                                \
-int ELL1_len;                                                          \
-EXTERNAL_LIST_LOOP_6(ELL1_elt, list, ELL1_len, ELL1_hare,              \
-                    ELL1_tortoise, CIRCULAR_LIST_SUSPICION_LENGTH)
+   *** ALL OF THESE MACROS MUST BE DECLARED INSIDE BRACES -- SEE ABOVE. ***
 
-#define EXTERNAL_LIST_LOOP_2(elt, list)                                        \
-Lisp_Object hare_##elt, tortoise_##elt;                                        \
-int len_##elt;                                                         \
-EXTERNAL_LIST_LOOP_6(elt, list, len_##elt, hare_##elt,                 \
-                    tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH)
+   EXTERNAL_ALIST_LOOP_4 is similar to EXTERNAL_LIST_LOOP_2, but it
+   assumes the elements are aconses (the elements in an alist) and
+   sets two additional argument variables ELT_CAR and ELT_CDR to the
+   car and cdr of the acons.  All of the variables ELT, ELT_CAR and
+   ELT_CDR are automatically declared.
 
-#define EXTERNAL_LIST_LOOP_3(elt, list, tail)                          \
-Lisp_Object tortoise_##elt;                                            \
-int len_##elt;                                                         \
-EXTERNAL_LIST_LOOP_6(elt, list, len_##elt, tail,                       \
-                    tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH)
-
-#define EXTERNAL_LIST_LOOP_4(elt, list, tail, len)                     \
-Lisp_Object tortoise_##elt;                                            \
-EXTERNAL_LIST_LOOP_6(elt, list, len, tail,                             \
-                    tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH)
-
-
-#define EXTERNAL_LIST_LOOP_6(elt, list, len, hare,             \
-                             tortoise, suspicion_length)       \
-  for (tortoise = hare = list, len = 0;                                \
-                                                               \
-       (CONSP (hare) ? ((elt = XCAR (hare)), 1) :              \
-       (NILP (hare) ? 0 :                                      \
-        (signal_malformed_list_error (list), 0)));             \
-                                                               \
-       hare = XCDR (hare),                                     \
-        ((++len < suspicion_length) ?                          \
-         ((void) 0) :                                          \
-         (((len & 1) ?                                         \
-           ((void) (tortoise = XCDR (tortoise))) :             \
-           ((void) 0))                                         \
-          ,                                                    \
-          (EQ (hare, tortoise) ?                               \
-           ((void) signal_circular_list_error (list)) :        \
-           ((void) 0)))))
+   EXTERNAL_ALIST_LOOP_5 adds a TAIL argument to EXTERNAL_ALIST_LOOP_4,
+   just like EXTERNAL_LIST_LOOP_3 does, and again TAIL is automatically
+   declared.
 
+   EXTERNAL_ALIST_LOOP_6 adds a LEN argument to EXTERNAL_ALIST_LOOP_5,
+   just like EXTERNAL_LIST_LOOP_4 does, and again LEN is automatically
+   declared.
 
+   EXTERNAL_ALIST_LOOP_6_NO_DECLARE does not declare any of its arguments,
+   just like EXTERNAL_LIST_LOOP_4_NO_DECLARE, and so these must be declared
+   manually.
+ */
 
 /* Optimized and safe macros for looping over external alists. */
-#define EXTERNAL_ALIST_LOOP_4(elt, elt_car, elt_cdr, list)             \
-Lisp_Object hare_##elt, tortoise_##elt;                                        \
-int len_##elt;                                                         \
-EXTERNAL_ALIST_LOOP_8 (elt, elt_car, elt_cdr, list,                    \
-                      len_##elt, hare_##elt, tortoise_##elt,           \
+#define EXTERNAL_ALIST_LOOP_4(elt, elt_car, elt_cdr, list)     \
+Lisp_Object elt, elt_car, elt_cdr;                             \
+Lisp_Object hare_##elt, tortoise_##elt;                                \
+EMACS_INT len_##elt;                                           \
+PRIVATE_EXTERNAL_ALIST_LOOP_8 (elt, elt_car, elt_cdr, list,    \
+                      len_##elt, hare_##elt, tortoise_##elt,   \
                       CIRCULAR_LIST_SUSPICION_LENGTH)
 
 #define EXTERNAL_ALIST_LOOP_5(elt, elt_car, elt_cdr, list, tail)       \
+Lisp_Object elt, elt_car, elt_cdr, tail;                               \
 Lisp_Object tortoise_##elt;                                            \
-int len_##elt;                                                         \
-EXTERNAL_ALIST_LOOP_8(elt, elt_car, elt_cdr, list,                     \
-                     len_##elt, tail, tortoise_##elt,                  \
-                     CIRCULAR_LIST_SUSPICION_LENGTH)
+EMACS_INT len_##elt;                                                   \
+PRIVATE_EXTERNAL_ALIST_LOOP_8 (elt, elt_car, elt_cdr, list,            \
+                      len_##elt, tail, tortoise_##elt,                 \
+                      CIRCULAR_LIST_SUSPICION_LENGTH)                  \
 
 #define EXTERNAL_ALIST_LOOP_6(elt, elt_car, elt_cdr, list, tail, len)  \
+Lisp_Object elt, elt_car, elt_cdr, tail;                               \
+EMACS_INT len;                                                         \
 Lisp_Object tortoise_##elt;                                            \
-EXTERNAL_ALIST_LOOP_8(elt, elt_car, elt_cdr, list,                     \
-                     len, tail, tortoise_##elt,                        \
-                     CIRCULAR_LIST_SUSPICION_LENGTH)
+PRIVATE_EXTERNAL_ALIST_LOOP_8 (elt, elt_car, elt_cdr, list,            \
+                      len, tail, tortoise_##elt,                       \
+                      CIRCULAR_LIST_SUSPICION_LENGTH)
 
+#define EXTERNAL_ALIST_LOOP_6_NO_DECLARE(elt, elt_car, elt_cdr, list,  \
+                                        tail, len)                     \
+Lisp_Object tortoise_##elt;                                            \
+PRIVATE_EXTERNAL_ALIST_LOOP_8 (elt, elt_car, elt_cdr, list,            \
+                      len, tail, tortoise_##elt,                       \
+                      CIRCULAR_LIST_SUSPICION_LENGTH)
 
-#define EXTERNAL_ALIST_LOOP_8(elt, elt_car, elt_cdr, list, len, hare,  \
-                             tortoise, suspicion_length)               \
-EXTERNAL_LIST_LOOP_6(elt, list, len, hare, tortoise, suspicion_length) \
+
+#define PRIVATE_EXTERNAL_ALIST_LOOP_8(elt, elt_car, elt_cdr, list, len, \
+                                     hare, tortoise, suspicion_length) \
+PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len, hare, tortoise,          \
+                             suspicion_length)                         \
   if (CONSP (elt) ? (elt_car = XCAR (elt), elt_cdr = XCDR (elt), 0) :1)        \
     continue;                                                          \
   else
 
+/* Macros for looping over external property lists.
+
+   *** ALL OF THESE MACROS MUST BE DECLARED INSIDE BRACES -- SEE ABOVE. ***
+
+   EXTERNAL_PROPERTY_LIST_LOOP_3 maps over an external list assumed to
+   be a property list, consisting of alternating pairs of keys
+   (typically symbols or keywords) and values.  Each iteration
+   processes one such pair out of LIST, assigning the two elements to
+   KEY and VALUE respectively.  Malformed lists and circularities are
+   trapped as usual, and in addition, property lists with an odd number
+   of elements also signal an error.
+
+   EXTERNAL_PROPERTY_LIST_LOOP_4 adds a TAIL argument to
+   EXTERNAL_PROPERTY_LIST_LOOP_3, just like EXTERNAL_LIST_LOOP_3 does,
+   and again TAIL is automatically declared.
+
+   EXTERNAL_PROPERTY_LIST_LOOP_5 adds a LEN argument to
+   EXTERNAL_PROPERTY_LIST_LOOP_4, just like EXTERNAL_LIST_LOOP_4 does,
+   and again LEN is automatically declared.  Note that in this case,
+   LEN counts the iterations, NOT the total number of list elements
+   processed, which is 2 * LEN.
+
+   EXTERNAL_PROPERTY_LIST_LOOP_5_NO_DECLARE does not declare any of its
+   arguments, just like EXTERNAL_LIST_LOOP_4_NO_DECLARE, and so these
+   must be declared manually.  */
 
 /* Optimized and safe macros for looping over external property lists. */
 #define EXTERNAL_PROPERTY_LIST_LOOP_3(key, value, list)                        \
 Lisp_Object key, value, hare_##key, tortoise_##key;                    \
-int len_##key;                                                         \
-EXTERNAL_PROPERTY_LIST_LOOP_7(key, value, list, len_##key, hare_##key,\
+EMACS_INT len_##key;                                                   \
+EXTERNAL_PROPERTY_LIST_LOOP_7 (key, value, list, len_##key, hare_##key,        \
                     tortoise_##key, CIRCULAR_LIST_SUSPICION_LENGTH)
 
 #define EXTERNAL_PROPERTY_LIST_LOOP_4(key, value, list, tail)          \
 Lisp_Object key, value, tail, tortoise_##key;                          \
-int len_##key;                                                         \
-EXTERNAL_PROPERTY_LIST_LOOP_7(key, value, list, len_##key, tail,       \
+EMACS_INT len_##key;                                                   \
+EXTERNAL_PROPERTY_LIST_LOOP_7 (key, value, list, len_##key, tail,      \
                     tortoise_##key, CIRCULAR_LIST_SUSPICION_LENGTH)
 
 #define EXTERNAL_PROPERTY_LIST_LOOP_5(key, value, list, tail, len)     \
 Lisp_Object key, value, tail, tortoise_##key;                          \
-int len;                                                               \
-EXTERNAL_PROPERTY_LIST_LOOP_7(key, value, list, len, tail,             \
+EMACS_INT len;                                                         \
+EXTERNAL_PROPERTY_LIST_LOOP_7 (key, value, list, len, tail,            \
+                    tortoise_##key, CIRCULAR_LIST_SUSPICION_LENGTH)
+
+#define EXTERNAL_PROPERTY_LIST_LOOP_5_NO_DECLARE(key, value, list,     \
+                                                tail, len)             \
+Lisp_Object tortoise_##key;                                            \
+EXTERNAL_PROPERTY_LIST_LOOP_7 (key, value, list, len, tail,            \
                     tortoise_##key, CIRCULAR_LIST_SUSPICION_LENGTH)
 
 
@@ -962,7 +1054,8 @@ EXTERNAL_PROPERTY_LIST_LOOP_7(key, value, list, len, tail,         \
        ((CONSP (hare) &&                                               \
         (key = XCAR (hare),                                            \
          hare = XCDR (hare),                                           \
-         CONSP (hare))) ?                                              \
+         (CONSP (hare) ? 1 :                                           \
+          (signal_malformed_property_list_error (list), 0)))) ?        \
        (value = XCAR (hare), 1) :                                      \
        (NILP (hare) ? 0 :                                              \
         (signal_malformed_property_list_error (list), 0)));            \
@@ -1003,12 +1096,12 @@ EXTERNAL_PROPERTY_LIST_LOOP_7(key, value, list, len, tail,              \
        )
 
 /* Return 1 if LIST is properly acyclic and nil-terminated, else 0. */
-INLINE int TRUE_LIST_P (Lisp_Object object);
-INLINE int
+INLINE_HEADER int TRUE_LIST_P (Lisp_Object object);
+INLINE_HEADER int
 TRUE_LIST_P (Lisp_Object object)
 {
   Lisp_Object hare, tortoise;
-  int len;
+  EMACS_INT len;
 
   for (hare = tortoise = object, len = 0;
        CONSP (hare);
@@ -1030,7 +1123,7 @@ TRUE_LIST_P (Lisp_Object object)
 #define CHECK_TRUE_LIST(list) do {                     \
   Lisp_Object CTL_list = (list);                       \
   Lisp_Object CTL_hare, CTL_tortoise;                  \
-  int CTL_len;                                         \
+  EMACS_INT CTL_len;                                   \
                                                        \
   for (CTL_hare = CTL_tortoise = CTL_list, CTL_len = 0;        \
        CONSP (CTL_hare);                               \
@@ -1049,47 +1142,28 @@ TRUE_LIST_P (Lisp_Object object)
     signal_malformed_list_error (CTL_list);            \
 } while (0)
 
-/*********** string ***********/
-
-/* In a string, the markbit of the plist is used as the gc mark bit */
+/*------------------------------ string --------------------------------*/
 
 struct Lisp_String
 {
-#ifdef LRECORD_STRING
   struct lrecord_header lheader;
-#endif
   Bytecount size;
   Bufbyte *data;
   Lisp_Object plist;
 };
 typedef struct Lisp_String Lisp_String;
 
-#ifdef LRECORD_STRING
-
 DECLARE_LRECORD (string, Lisp_String);
 #define XSTRING(x) XRECORD (x, string, Lisp_String)
 #define XSETSTRING(x, p) XSETRECORD (x, p, string)
 #define STRINGP(x) RECORDP (x, string)
-#define GC_STRINGP(x) GC_RECORDP (x, string)
 #define CHECK_STRING(x) CHECK_RECORD (x, string)
 #define CONCHECK_STRING(x) CONCHECK_RECORD (x, string)
 
-#else /* ! LRECORD_STRING */
-
-DECLARE_NONRECORD (string, Lisp_Type_String, Lisp_String);
-#define XSTRING(x) XNONRECORD (x, string, Lisp_Type_String, Lisp_String)
-#define XSETSTRING(x, p) XSETOBJ (x, Lisp_Type_String, p)
-#define STRINGP(x) (XTYPE (x) == Lisp_Type_String)
-#define GC_STRINGP(x) (XGCTYPE (x) == Lisp_Type_String)
-#define CHECK_STRING(x) CHECK_NONRECORD (x, Lisp_Type_String, Qstringp)
-#define CONCHECK_STRING(x) CONCHECK_NONRECORD (x, Lisp_Type_String, Qstringp)
-
-#endif /* ! LRECORD_STRING */
-
 #ifdef MULE
 
-Charcount bytecount_to_charcount (CONST Bufbyte *ptr, Bytecount len);
-Bytecount charcount_to_bytecount (CONST Bufbyte *ptr, Charcount len);
+Charcount bytecount_to_charcount (const Bufbyte *ptr, Bytecount len);
+Bytecount charcount_to_bytecount (const Bufbyte *ptr, Charcount len);
 
 #else /* not MULE */
 
@@ -1108,14 +1182,14 @@ Bytecount charcount_to_bytecount (CONST Bufbyte *ptr, Charcount len);
 #define string_byte_addr(s, i) (&((s)->data[i]))
 #define set_string_length(s, len) ((void) ((s)->size = (len)))
 #define set_string_data(s, ptr) ((void) ((s)->data = (ptr)))
-#define set_string_byte(s, i, c) ((void) ((s)->data[i] = (c)))
+#define set_string_byte(s, i, b) ((void) ((s)->data[i] = (b)))
 
 void resize_string (Lisp_String *s, Bytecount pos, Bytecount delta);
 
 #ifdef MULE
 
-INLINE Charcount string_char_length (Lisp_String *s);
-INLINE Charcount
+INLINE_HEADER Charcount string_char_length (Lisp_String *s);
+INLINE_HEADER Charcount
 string_char_length (Lisp_String *s)
 {
   return bytecount_to_charcount (string_data (s), string_length (s));
@@ -1130,17 +1204,38 @@ void set_string_char (Lisp_String *s, Charcount i, Emchar c);
 # define string_char_length(s) string_length (s)
 # define string_char(s, i) ((Emchar) string_byte (s, i))
 # define string_char_addr(s, i) string_byte_addr (s, i)
-# define set_string_char(s, i, c) set_string_byte (s, i, c)
+# define set_string_char(s, i, c) set_string_byte (s, i, (Bufbyte)c)
 
 #endif /* not MULE */
 
-/*********** vector ***********/
+/* Return the true aligned size of a struct whose last member is a
+   variable-length array field.  (this is known as the "struct hack") */
+/* Implementation: in practice, structtype and fieldtype usually have
+   the same alignment, but we can't be sure.  We need to use
+   ALIGN_SIZE to be absolutely sure of getting the correct alignment.
+   To help the compiler's optimizer, we use a ternary expression that
+   only a very stupid compiler would fail to correctly simplify. */
+#define FLEXIBLE_ARRAY_STRUCT_SIZEOF(structtype,       \
+                                    fieldtype,         \
+                                    fieldname,         \
+                                    array_length)      \
+(ALIGNOF (structtype) == ALIGNOF (fieldtype)           \
+ ? (offsetof (structtype, fieldname) +                 \
+    (offsetof (structtype, fieldname[1]) -             \
+     offsetof (structtype, fieldname[0])) *            \
+    (array_length))                                    \
+ : (ALIGN_SIZE                                         \
+    ((offsetof (structtype, fieldname) +               \
+      (offsetof (structtype, fieldname[1]) -           \
+       offsetof (structtype, fieldname[0])) *          \
+      (array_length)),                                 \
+     ALIGNOF (structtype))))
+
+/*------------------------------ vector --------------------------------*/
 
 struct Lisp_Vector
 {
-#ifdef LRECORD_VECTOR
   struct lcrecord_header header;
-#endif
   long size;
   /* next is now chained through v->contents[size], terminated by Qzero.
      This means that pure vectors don't need a "next" */
@@ -1149,37 +1244,19 @@ struct Lisp_Vector
 };
 typedef struct Lisp_Vector Lisp_Vector;
 
-#ifdef LRECORD_VECTOR
-
 DECLARE_LRECORD (vector, Lisp_Vector);
 #define XVECTOR(x) XRECORD (x, vector, Lisp_Vector)
 #define XSETVECTOR(x, p) XSETRECORD (x, p, vector)
 #define VECTORP(x) RECORDP (x, vector)
-#define GC_VECTORP(x) GC_RECORDP (x, vector)
 #define CHECK_VECTOR(x) CHECK_RECORD (x, vector)
 #define CONCHECK_VECTOR(x) CONCHECK_RECORD (x, vector)
 
-#else
-
-DECLARE_NONRECORD (vector, Lisp_Type_Vector, Lisp_Vector);
-#define XVECTOR(x) XNONRECORD (x, vector, Lisp_Type_Vector, Lisp_Vector)
-#define XSETVECTOR(x, p) XSETOBJ (x, Lisp_Type_Vector, p)
-#define VECTORP(x) (XTYPE (x) == Lisp_Type_Vector)
-#define GC_VECTORP(x) (XGCTYPE (x) == Lisp_Type_Vector)
-#define CHECK_VECTOR(x) CHECK_NONRECORD (x, Lisp_Type_Vector, Qvectorp)
-#define CONCHECK_VECTOR(x) CONCHECK_NONRECORD (x, Lisp_Type_Vector, Qvectorp)
-
-#endif
-
 #define vector_length(v) ((v)->size)
 #define XVECTOR_LENGTH(s) vector_length (XVECTOR (s))
 #define vector_data(v) ((v)->contents)
 #define XVECTOR_DATA(s) vector_data (XVECTOR (s))
-#ifndef LRECORD_VECTOR
-# define vector_next(v) ((v)->contents[(v)->size])
-#endif
 
-/*********** bit vector ***********/
+/*---------------------------- bit vectors -----------------------------*/
 
 #if (LONGBITS < 16)
 #error What the hell?!
@@ -1209,12 +1286,10 @@ DECLARE_LRECORD (bit_vector, Lisp_Bit_Vector);
 #define XBIT_VECTOR(x) XRECORD (x, bit_vector, Lisp_Bit_Vector)
 #define XSETBIT_VECTOR(x, p) XSETRECORD (x, p, bit_vector)
 #define BIT_VECTORP(x) RECORDP (x, bit_vector)
-#define GC_BIT_VECTORP(x) GC_RECORDP (x, bit_vector)
 #define CHECK_BIT_VECTOR(x) CHECK_RECORD (x, bit_vector)
 #define CONCHECK_BIT_VECTOR(x) CONCHECK_RECORD (x, bit_vector)
 
 #define BITP(x) (INTP (x) && (XINT (x) == 0 || XINT (x) == 1))
-#define GC_BITP(x) (GC_INTP (x) && (XINT (x) == 0 || XINT (x) == 1))
 
 #define CHECK_BIT(x) do {              \
   if (!BITP (x))                       \
@@ -1229,94 +1304,74 @@ DECLARE_LRECORD (bit_vector, Lisp_Bit_Vector);
 #define bit_vector_length(v) ((v)->size)
 #define bit_vector_next(v) ((v)->next)
 
-INLINE int bit_vector_bit (Lisp_Bit_Vector *v, int i);
-INLINE int
-bit_vector_bit (Lisp_Bit_Vector *v, int i)
+INLINE_HEADER int bit_vector_bit (Lisp_Bit_Vector *v, size_t n);
+INLINE_HEADER int
+bit_vector_bit (Lisp_Bit_Vector *v, size_t n)
 {
-  unsigned int ui = (unsigned int) i;
-
-  return (((v)->bits[ui >> LONGBITS_LOG2] >> (ui & (LONGBITS_POWER_OF_2 - 1)))
+  return ((v->bits[n >> LONGBITS_LOG2] >> (n & (LONGBITS_POWER_OF_2 - 1)))
          & 1);
 }
 
-INLINE void set_bit_vector_bit (Lisp_Bit_Vector *v, int i, int value);
-INLINE void
-set_bit_vector_bit (Lisp_Bit_Vector *v, int i, int value)
+INLINE_HEADER void set_bit_vector_bit (Lisp_Bit_Vector *v, size_t n, int value);
+INLINE_HEADER void
+set_bit_vector_bit (Lisp_Bit_Vector *v, size_t n, int value)
 {
-  unsigned int ui = (unsigned int) i;
   if (value)
-    (v)->bits[ui >> LONGBITS_LOG2] |= (1U << (ui & (LONGBITS_POWER_OF_2 - 1)));
+    v->bits[n >> LONGBITS_LOG2] |= (1UL << (n & (LONGBITS_POWER_OF_2 - 1)));
   else
-    (v)->bits[ui >> LONGBITS_LOG2] &= ~(1U << (ui & (LONGBITS_POWER_OF_2 - 1)));
+    v->bits[n >> LONGBITS_LOG2] &= ~(1UL << (n & (LONGBITS_POWER_OF_2 - 1)));
 }
 
 /* Number of longs required to hold LEN bits */
 #define BIT_VECTOR_LONG_STORAGE(len) \
-  ((len + LONGBITS_POWER_OF_2 - 1) >> LONGBITS_LOG2)
+  (((len) + LONGBITS_POWER_OF_2 - 1) >> LONGBITS_LOG2)
 
+/*------------------------------ symbol --------------------------------*/
 
-/*********** symbol ***********/
-
-/* In a symbol, the markbit of the plist is used as the gc mark bit */
-
+typedef struct Lisp_Symbol Lisp_Symbol;
 struct Lisp_Symbol
 {
-#ifdef LRECORD_SYMBOL
   struct lrecord_header lheader;
-#endif
   /* next symbol in this obarray bucket */
-  struct Lisp_Symbol *next;
-  struct Lisp_String *name;
+  Lisp_Symbol *next;
+  Lisp_String *name;
   Lisp_Object value;
   Lisp_Object function;
-  /* non-nil if the symbol is interned in Vobarray */
-  Lisp_Object obarray;
   Lisp_Object plist;
 };
-typedef struct Lisp_Symbol Lisp_Symbol;
 
-#define SYMBOL_IS_KEYWORD(sym) (string_byte (XSYMBOL(sym)->name, 0) == ':')
+#define SYMBOL_IS_KEYWORD(sym)                                         \
+  ((string_byte (symbol_name (XSYMBOL (sym)), 0) == ':')               \
+   && EQ (sym, oblookup (Vobarray,                                     \
+                        string_data (symbol_name (XSYMBOL (sym))),     \
+                        string_length (symbol_name (XSYMBOL (sym))))))
 #define KEYWORDP(obj) (SYMBOLP (obj) && SYMBOL_IS_KEYWORD (obj))
 
-#ifdef LRECORD_SYMBOL
-
 DECLARE_LRECORD (symbol, Lisp_Symbol);
 #define XSYMBOL(x) XRECORD (x, symbol, Lisp_Symbol)
 #define XSETSYMBOL(x, p) XSETRECORD (x, p, symbol)
 #define SYMBOLP(x) RECORDP (x, symbol)
-#define GC_SYMBOLP(x) GC_RECORDP (x, symbol)
 #define CHECK_SYMBOL(x) CHECK_RECORD (x, symbol)
 #define CONCHECK_SYMBOL(x) CONCHECK_RECORD (x, symbol)
 
-#else
-
-DECLARE_NONRECORD (symbol, Lisp_Type_Symbol, Lisp_Symbol);
-#define XSYMBOL(x) XNONRECORD (x, symbol, Lisp_Type_Symbol, Lisp_Symbol)
-#define XSETSYMBOL(s, p) XSETOBJ ((s), Lisp_Type_Symbol, (p))
-#define SYMBOLP(x) (XTYPE (x) == Lisp_Type_Symbol)
-#define GC_SYMBOLP(x) (XGCTYPE (x) == Lisp_Type_Symbol)
-#define CHECK_SYMBOL(x) CHECK_NONRECORD (x, Lisp_Type_Symbol, Qsymbolp)
-#define CONCHECK_SYMBOL(x) CONCHECK_NONRECORD (x, Lisp_Type_Symbol, Qsymbolp)
-
-#endif
-
 #define symbol_next(s) ((s)->next)
 #define symbol_name(s) ((s)->name)
 #define symbol_value(s) ((s)->value)
 #define symbol_function(s) ((s)->function)
 #define symbol_plist(s) ((s)->plist)
 
-/*********** subr ***********/
+/*------------------------------- subr ---------------------------------*/
 
 typedef Lisp_Object (*lisp_fn_t) (void);
 
 struct Lisp_Subr
 {
   struct lrecord_header lheader;
-  short min_args, max_args;
-  CONST char *prompt;
-  CONST char *doc;
-  CONST char *name;
+  short min_args;
+  short max_args;
+  const char *prompt;
+  const char *doc;
+  const char *name;
   lisp_fn_t subr_fn;
 };
 typedef struct Lisp_Subr Lisp_Subr;
@@ -1325,30 +1380,32 @@ DECLARE_LRECORD (subr, Lisp_Subr);
 #define XSUBR(x) XRECORD (x, subr, Lisp_Subr)
 #define XSETSUBR(x, p) XSETRECORD (x, p, subr)
 #define SUBRP(x) RECORDP (x, subr)
-#define GC_SUBRP(x) GC_RECORDP (x, subr)
 #define CHECK_SUBR(x) CHECK_RECORD (x, subr)
 #define CONCHECK_SUBR(x) CONCHECK_RECORD (x, subr)
 
-#define subr_function(subr) (subr)->subr_fn
-#define subr_name(subr) (subr)->name
+#define subr_function(subr) ((subr)->subr_fn)
+#define SUBR_FUNCTION(subr,max_args) \
+  ((Lisp_Object (*) (EXFUN_##max_args)) (subr)->subr_fn)
+#define subr_name(subr) ((subr)->name)
+
+/*------------------------------ marker --------------------------------*/
 
-/*********** marker ***********/
 
+typedef struct Lisp_Marker Lisp_Marker;
 struct Lisp_Marker
 {
   struct lrecord_header lheader;
-  struct Lisp_Marker *next, *prev;
+  Lisp_Marker *next;
+  Lisp_Marker *prev;
   struct buffer *buffer;
   Memind memind;
   char insertion_type;
 };
-typedef struct Lisp_Marker Lisp_Marker;
 
 DECLARE_LRECORD (marker, Lisp_Marker);
 #define XMARKER(x) XRECORD (x, marker, Lisp_Marker)
 #define XSETMARKER(x, p) XSETRECORD (x, p, marker)
 #define MARKERP(x) RECORDP (x, marker)
-#define GC_MARKERP(x) GC_RECORDP (x, marker)
 #define CHECK_MARKER(x) CHECK_RECORD (x, marker)
 #define CONCHECK_MARKER(x) CONCHECK_RECORD (x, marker)
 
@@ -1358,15 +1415,14 @@ DECLARE_LRECORD (marker, Lisp_Marker);
 #define marker_next(m) ((m)->next)
 #define marker_prev(m) ((m)->prev)
 
-/*********** char ***********/
+/*------------------------------- char ---------------------------------*/
 
 #define CHARP(x) (XTYPE (x) == Lisp_Type_Char)
-#define GC_CHARP(x) (XGCTYPE (x) == Lisp_Type_Char)
 
 #ifdef ERROR_CHECK_TYPECHECK
 
-INLINE Emchar XCHAR (Lisp_Object obj);
-INLINE Emchar
+INLINE_HEADER Emchar XCHAR (Lisp_Object obj);
+INLINE_HEADER Emchar
 XCHAR (Lisp_Object obj)
 {
   assert (CHARP (obj));
@@ -1375,7 +1431,7 @@ XCHAR (Lisp_Object obj)
 
 #else
 
-#define XCHAR(x) XCHARVAL (x)
+#define XCHAR(x) ((Emchar)XCHARVAL (x))
 
 #endif
 
@@ -1383,7 +1439,7 @@ XCHAR (Lisp_Object obj)
 #define CONCHECK_CHAR(x) CONCHECK_NONRECORD (x, Lisp_Type_Char, Qcharacterp)
 
 
-/*********** float ***********/
+/*------------------------------ float ---------------------------------*/
 
 #ifdef LISP_FLOAT_TYPE
 
@@ -1403,7 +1459,6 @@ DECLARE_LRECORD (float, Lisp_Float);
 #define XFLOAT(x) XRECORD (x, float, Lisp_Float)
 #define XSETFLOAT(x, p) XSETRECORD (x, p, float)
 #define FLOATP(x) RECORDP (x, float)
-#define GC_FLOATP(x) GC_RECORDP (x, float)
 #define CHECK_FLOAT(x) CHECK_RECORD (x, float)
 #define CONCHECK_FLOAT(x) CONCHECK_RECORD (x, float)
 
@@ -1423,44 +1478,38 @@ DECLARE_LRECORD (float, Lisp_Float);
 } while (0)
 
 # define INT_OR_FLOATP(x) (INTP (x) || FLOATP (x))
-# define GC_INT_OR_FLOATP(x) (GC_INTP (x) || GC_FLOATP (x))
 
 #else /* not LISP_FLOAT_TYPE */
 
 #define XFLOAT(x) --- error!  No float support. ---
 #define XSETFLOAT(x, p) --- error!  No float support. ---
 #define FLOATP(x) 0
-#define GC_FLOATP(x) 0
 #define CHECK_FLOAT(x) --- error!  No float support. ---
 #define CONCHECK_FLOAT(x) --- error!  No float support. ---
 
 #define XFLOATINT(n) XINT(n)
 #define CHECK_INT_OR_FLOAT CHECK_INT
 #define CONCHECK_INT_OR_FLOAT CONCHECK_INT
-#define INT_OR_FLOATP(x) (INTP (x))
-# define GC_INT_OR_FLOATP(x) (GC_INTP (x))
+#define INT_OR_FLOATP(x) INTP (x)
 
 #endif /* not LISP_FLOAT_TYPE */
 
-/*********** int ***********/
-
-#define GC_INTP(x) INTP (x)
+/*-------------------------------- int ---------------------------------*/
 
 #define ZEROP(x) EQ (x, Qzero)
-#define GC_ZEROP(x) GC_EQ (x, Qzero)
 
 #ifdef ERROR_CHECK_TYPECHECK
 
-INLINE EMACS_INT XINT (Lisp_Object obj);
-INLINE EMACS_INT
+INLINE_HEADER EMACS_INT XINT (Lisp_Object obj);
+INLINE_HEADER EMACS_INT
 XINT (Lisp_Object obj)
 {
   assert (INTP (obj));
   return XREALINT (obj);
 }
 
-INLINE EMACS_INT XCHAR_OR_INT (Lisp_Object obj);
-INLINE EMACS_INT
+INLINE_HEADER EMACS_INT XCHAR_OR_INT (Lisp_Object obj);
+INLINE_HEADER EMACS_INT
 XCHAR_OR_INT (Lisp_Object obj)
 {
   assert (INTP (obj) || CHARP (obj));
@@ -1485,7 +1534,6 @@ XCHAR_OR_INT (Lisp_Object obj)
 } while (0)
 
 #define NATNUMP(x) (INTP (x) && XINT (x) >= 0)
-#define GC_NATNUMP(x) (GC_INTP (x) && XINT (x) >= 0)
 
 #define CHECK_NATNUM(x) do {                   \
   if (!NATNUMP (x))                            \
@@ -1528,12 +1576,18 @@ XCHAR_OR_INT (Lisp_Object obj)
 } while (0)
 
 
-/*********** pure space ***********/
+/*--------------------------- readonly objects -------------------------*/
+
+#define CHECK_C_WRITEABLE(obj)                                 \
+  do { if (c_readonly (obj)) c_write_error (obj); } while (0)
 
-#define CHECK_IMPURE(obj)                                      \
-  do { if (purified (obj)) pure_write_error (obj); } while (0)
+#define CHECK_LISP_WRITEABLE(obj)                                      \
+  do { if (lisp_readonly (obj)) lisp_write_error (obj); } while (0)
 
-/*********** structures ***********/
+#define C_READONLY(obj) (C_READONLY_RECORD_HEADER_P(XRECORD_LHEADER (obj)))
+#define LISP_READONLY(obj) (LISP_READONLY_RECORD_HEADER_P(XRECORD_LHEADER (obj)))
+
+/*----------------------------- structrures ----------------------------*/
 
 typedef struct structure_keyword_entry structure_keyword_entry;
 struct structure_keyword_entry
@@ -1574,7 +1628,7 @@ void define_structure_type_keyword (struct structure_type *st,
                                                     Lisp_Object value,
                                                     Error_behavior errb));
 
-/*********** weak lists ***********/
+/*---------------------------- weak lists ------------------------------*/
 
 enum weak_list_type
 {
@@ -1586,7 +1640,10 @@ enum weak_list_type
   /* element disappears if it's a cons and its car is unmarked. */
   WEAK_LIST_KEY_ASSOC,
   /* element disappears if it's a cons and its cdr is unmarked. */
-  WEAK_LIST_VALUE_ASSOC
+  WEAK_LIST_VALUE_ASSOC,
+  /* element disappears if it's a cons and neither its car nor
+     its cdr is marked. */
+  WEAK_LIST_FULL_ASSOC
 };
 
 struct weak_list
@@ -1601,7 +1658,6 @@ DECLARE_LRECORD (weak_list, struct weak_list);
 #define XWEAK_LIST(x) XRECORD (x, weak_list, struct weak_list)
 #define XSETWEAK_LIST(x, p) XSETRECORD (x, p, weak_list)
 #define WEAK_LISTP(x) RECORDP (x, weak_list)
-#define GC_WEAK_LISTP(x) GC_RECORDP (x, weak_list)
 #define CHECK_WEAK_LIST(x) CHECK_RECORD (x, weak_list)
 #define CONCHECK_WEAK_LIST(x) CONCHECK_RECORD (x, weak_list)
 
@@ -1610,31 +1666,29 @@ DECLARE_LRECORD (weak_list, struct weak_list);
 
 Lisp_Object make_weak_list (enum weak_list_type type);
 /* The following two are only called by the garbage collector */
-int finish_marking_weak_lists (int (*obj_marked_p) (Lisp_Object),
-                              void (*markobj) (Lisp_Object));
-void prune_weak_lists (int (*obj_marked_p) (Lisp_Object));
+int finish_marking_weak_lists (void);
+void prune_weak_lists (void);
 
-/*********** lcrecord lists ***********/
+/*-------------------------- lcrecord-list -----------------------------*/
 
 struct lcrecord_list
 {
   struct lcrecord_header header;
   Lisp_Object free;
   size_t size;
-  CONST struct lrecord_implementation *implementation;
+  const struct lrecord_implementation *implementation;
 };
 
 DECLARE_LRECORD (lcrecord_list, struct lcrecord_list);
 #define XLCRECORD_LIST(x) XRECORD (x, lcrecord_list, struct lcrecord_list)
 #define XSETLCRECORD_LIST(x, p) XSETRECORD (x, p, lcrecord_list)
 #define LCRECORD_LISTP(x) RECORDP (x, lcrecord_list)
-#define GC_LCRECORD_LISTP(x) GC_RECORDP (x, lcrecord_list)
 /* #define CHECK_LCRECORD_LIST(x) CHECK_RECORD (x, lcrecord_list)
    Lcrecord lists should never escape to the Lisp level, so
    functions should not be doing this. */
 
 Lisp_Object make_lcrecord_list (size_t size,
-                               CONST struct lrecord_implementation
+                               const struct lrecord_implementation
                                *implementation);
 Lisp_Object allocate_managed_lcrecord (Lisp_Object lcrecord_list);
 void free_managed_lcrecord (Lisp_Object lcrecord_list, Lisp_Object lcrecord);
@@ -1693,16 +1747,23 @@ Lisp_Object,Lisp_Object,Lisp_Object
 /* Can't be const, because then subr->doc is read-only and
    Snarf_documentation chokes */
 
-#ifdef USE_INDEXED_LRECORD_IMPLEMENTATION
-# define subr_lheader_initializer { 0, 0, 0 }
-#else
-# define subr_lheader_initializer { lrecord_subr }
-#endif
-
 #define DEFUN(lname, Fname, min_args, max_args, prompt, arglist)       \
   Lisp_Object Fname (EXFUN_##max_args);                                        \
-  static struct Lisp_Subr S##Fname = { subr_lheader_initializer,       \
-       min_args, max_args, prompt, 0, lname, (lisp_fn_t) Fname };      \
+  static struct Lisp_Subr S##Fname =                                   \
+  {                                                                    \
+    { /* struct lrecord_header */                                      \
+      lrecord_type_subr, /* lrecord_type_index */                      \
+      1, /* mark bit */                                                        \
+      1, /* c_readonly bit */                                          \
+      1  /* lisp_readonly bit */                                       \
+    },                                                                 \
+    min_args,                                                          \
+    max_args,                                                          \
+    prompt,                                                            \
+    0, /* doc string */                                                \
+    lname,                                                             \
+    (lisp_fn_t) Fname                                                  \
+  };                                                                   \
   Lisp_Object Fname (DEFUN_##max_args arglist)
 
 /* Heavy ANSI C preprocessor hackery to get DEFUN to declare a
@@ -1739,6 +1800,12 @@ Lisp_Object,Lisp_Object,Lisp_Object
 extern int specpdl_depth_counter;
 #define specpdl_depth() specpdl_depth_counter
 
+
+#define CHECK_FUNCTION(fun) do {               \
+ while (NILP (Ffunctionp (fun)))               \
+   signal_invalid_function_error (fun);                \
+ } while (0)
+
 \f
 /************************************************************************/
 /*                        Checking for QUIT                            */
@@ -1800,8 +1867,8 @@ void signal_quit (void);
 #define HASH9(a,b,c,d,e,f,g,h,i) (GOOD_HASH * HASH8 (a,b,c,d,e,f,g,h) + (i))
 
 #define LISP_HASH(obj) ((unsigned long) LISP_TO_VOID (obj))
-unsigned long string_hash (CONST void *xv);
-unsigned long memory_hash (CONST void *xv, size_t size);
+unsigned long string_hash (const char *xv);
+unsigned long memory_hash (const void *xv, size_t size);
 unsigned long internal_hash (Lisp_Object obj, int depth);
 unsigned long internal_array_hash (Lisp_Object *arr, int size, int depth);
 
@@ -1814,10 +1881,10 @@ unsigned long internal_array_hash (Lisp_Object *arr, int size, int depth);
 #ifdef HAVE_LIBINTL_H
 #include <libintl.h>
 #else
-char *dgettext       (CONST char *, CONST char *);
-char *gettext        (CONST char *);
-char *textdomain     (CONST char *);
-char *bindtextdomain (CONST char *, CONST char *);
+char *dgettext       (const char *, const char *);
+char *gettext        (const char *);
+char *textdomain     (const char *);
+char *bindtextdomain (const char *, const char *);
 #endif /* HAVE_LIBINTL_H */
 
 #define GETTEXT(x)  gettext(x)
@@ -1844,7 +1911,7 @@ extern EMACS_INT consing_since_gc;
 
 /* threshold for doing another gc */
 
-extern EMACS_INT gc_cons_threshold;
+extern Fixnum gc_cons_threshold;
 
 /* Structure for recording stack slots that need marking */
 
@@ -1932,7 +1999,7 @@ void debug_ungcpro(char *, int, struct gcpro *);
 #define NNGCPRO5(v1,v2,v3,v4,v5) \
  debug_gcpro5 (__FILE__, __LINE__,&nngcpro1,&nngcpro2,&nngcpro3,&nngcpro4,\
               &nngcpro5,&v1,&v2,&v3,&v4,&v5)
-#define NUNNGCPRO \
+#define NNUNGCPRO \
  debug_ungcpro(__FILE__, __LINE__,&nngcpro1)
 
 #else /* ! DEBUG_GCPRO */
@@ -1959,8 +2026,7 @@ void debug_ungcpro(char *, int, struct gcpro *);
   gcpro4.next = &gcpro3,   gcpro4.var = &var4, gcpro4.nvars = 1,       \
   gcprolist = &gcpro4 ))
 
-#define GCPRO5(var1, var2, var3, var4, var5)                           \
-  ((void) (                                                            \
+#define GCPRO5(var1, var2, var3, var4, var5) ((void) (                 \
   gcpro1.next = gcprolist, gcpro1.var = &var1, gcpro1.nvars = 1,       \
   gcpro2.next = &gcpro1,   gcpro2.var = &var2, gcpro2.nvars = 1,       \
   gcpro3.next = &gcpro2,   gcpro3.var = &var3, gcpro3.nvars = 1,       \
@@ -1992,8 +2058,7 @@ void debug_ungcpro(char *, int, struct gcpro *);
   ngcpro4.next = &ngcpro3,  ngcpro4.var = &var4, ngcpro4.nvars = 1,    \
   gcprolist = &ngcpro4 ))
 
-#define NGCPRO5(var1, var2, var3, var4, var5)                          \
-  ((void) (                                                            \
+#define NGCPRO5(var1, var2, var3, var4, var5) ((void) (                        \
   ngcpro1.next = gcprolist, ngcpro1.var = &var1, ngcpro1.nvars = 1,    \
   ngcpro2.next = &ngcpro1,  ngcpro2.var = &var2, ngcpro2.nvars = 1,    \
   ngcpro3.next = &ngcpro2,  ngcpro3.var = &var3, ngcpro3.nvars = 1,    \
@@ -2025,8 +2090,7 @@ void debug_ungcpro(char *, int, struct gcpro *);
   nngcpro4.next = &nngcpro3, nngcpro4.var = &var4, nngcpro4.nvars = 1, \
   gcprolist = &nngcpro4 ))
 
-#define NNGCPRO5(var1, var2, var3, var4, var5)                         \
-  ((void) (                                                            \
+#define NNGCPRO5(var1, var2, var3, var4, var5) ((void) (               \
   nngcpro1.next = gcprolist, nngcpro1.var = &var1, nngcpro1.nvars = 1, \
   nngcpro2.next = &nngcpro1, nngcpro2.var = &var2, nngcpro2.nvars = 1, \
   nngcpro3.next = &nngcpro2, nngcpro3.var = &var3, nngcpro3.nvars = 1, \
@@ -2041,7 +2105,7 @@ void debug_ungcpro(char *, int, struct gcpro *);
 /* Another try to fix SunPro C compiler warnings */
 /* "end-of-loop code not reached" */
 /* "statement not reached */
-#ifdef __SUNPRO_C
+#if defined __SUNPRO_C || defined __USLC__
 #define RETURN_SANS_WARNINGS if (1) return
 #define RETURN_NOT_REACHED(value)
 #else
@@ -2085,9 +2149,65 @@ void debug_ungcpro(char *, int, struct gcpro *);
     RETURN_SANS_WARNINGS ret_nunb_val; \
 } while (0)
 
+extern Lisp_Object_ptr_dynarr *staticpros;
+
 /* Call staticpro (&var) to protect static variable `var'. */
 void staticpro (Lisp_Object *);
 
+/* Call staticpro_nodump (&var) to protect static variable `var'. */
+/* var will not be saved at dump time */
+void staticpro_nodump (Lisp_Object *);
+
+/* dump_add_root_struct_ptr (&var, &desc) dumps the structure pointed to by `var'. */
+#ifdef PDUMP
+void dump_add_root_struct_ptr (void *, const struct struct_description *);
+#else
+#define dump_add_root_struct_ptr(varaddr,descaddr) DO_NOTHING
+#endif
+
+/* dump_add_opaque (&var, size) dumps the opaque static structure `var'. */
+#ifdef PDUMP
+void dump_add_opaque (void *, size_t);
+#else
+#define dump_add_opaque(varaddr,size) DO_NOTHING
+#endif
+
+/* Call dump_add_opaque_int (&int_var) to dump `int_var', of type `int'. */
+#ifdef PDUMP
+#define dump_add_opaque_int(int_varaddr) do {  \
+  int *dao_ = (int_varaddr); /* type check */  \
+  dump_add_opaque (dao_, sizeof (*dao_));      \
+} while (0)
+#else
+#define dump_add_opaque_int(int_varaddr) DO_NOTHING
+#endif
+
+/* Call dump_add_opaque_fixnum (&fixnum_var) to dump `fixnum_var', of type `Fixnum'. */
+#ifdef PDUMP
+#define dump_add_opaque_fixnum(fixnum_varaddr) do {    \
+  Fixnum *dao_ = (fixnum_varaddr); /* type check */    \
+  dump_add_opaque (dao_, sizeof (*dao_));              \
+} while (0)
+#else
+#define dump_add_opaque_fixnum(fixnum_varaddr) DO_NOTHING
+#endif
+
+/* Call dump_add_root_object (&var) to ensure that var is properly updated after pdump. */
+#ifdef PDUMP
+void dump_add_root_object (Lisp_Object *);
+#else
+#define dump_add_root_object(varaddr) DO_NOTHING
+#endif
+
+/* Call dump_add_root_object (&var) to ensure that var is properly updated after
+   pdump.  var must point to a linked list of objects out of which
+   some may not be dumped */
+#ifdef PDUMP
+void dump_add_weak_object_chain (Lisp_Object *);
+#else
+#define dump_add_weak_object_chain(varaddr) DO_NOTHING
+#endif
+
 /* Nonzero means Emacs has already been initialized.
    Used during startup to detect startup of dumped Emacs.  */
 extern int initialized;
@@ -2137,7 +2257,7 @@ struct overhead_stats
 #endif
 #endif
 #ifndef IS_ANY_SEP
-#define IS_ANY_SEP(c) (IS_DIRECTORY_SEP (c))
+#define IS_ANY_SEP(c) IS_DIRECTORY_SEP (c)
 #endif
 
 #ifdef HAVE_INTTYPES_H
@@ -2157,15 +2277,35 @@ typedef long intptr_t;
 typedef unsigned long uintptr_t;
 #endif
 
+\f
+/************************************************************************/
+/*                              prototypes                              */
+/************************************************************************/
+
+/* NOTE: Prototypes should go HERE, not in various header files, unless
+   they specifically reference a type that's not defined in lisp.h.
+   (And even then, you might consider adding the type to lisp.h.)
+
+   The idea is that header files typically contain the innards of objects,
+   and we want to minimize the number of "dependencies" of one file on
+   the specifics of such objects.  Putting prototypes here minimizes the
+   number of header files that need to be included -- good for a number
+   of reasons. --ben */
+
+/*--------------- prototypes for various public c functions ------------*/
+
+/* Prototypes for all init/syms_of/vars_of initialization functions. */
+#include "symsinit.h"
+
 /* Defined in alloc.c */
 void release_breathing_space (void);
 Lisp_Object noseeum_cons (Lisp_Object, Lisp_Object);
-Lisp_Object make_vector (EMACS_INT, Lisp_Object);
+Lisp_Object make_vector (size_t, Lisp_Object);
 Lisp_Object vector1 (Lisp_Object);
 Lisp_Object vector2 (Lisp_Object, Lisp_Object);
 Lisp_Object vector3 (Lisp_Object, Lisp_Object, Lisp_Object);
-Lisp_Object make_bit_vector (EMACS_INT, Lisp_Object);
-Lisp_Object make_bit_vector_from_byte_vector (unsigned char *, EMACS_INT);
+Lisp_Object make_bit_vector (size_t, Lisp_Object);
+Lisp_Object make_bit_vector_from_byte_vector (unsigned char *, size_t);
 Lisp_Object noseeum_make_marker (void);
 void garbage_collect_1 (void);
 Lisp_Object acons (Lisp_Object, Lisp_Object, Lisp_Object);
@@ -2184,33 +2324,38 @@ extern int purify_flag;
 extern int gc_currently_forbidden;
 Lisp_Object restore_gc_inhibit (Lisp_Object);
 extern EMACS_INT gc_generation_number[1];
-int purified (Lisp_Object);
-Lisp_Object build_string (CONST char *);
-Lisp_Object build_ext_string (CONST char *, enum external_data_format);
-Lisp_Object build_translated_string (CONST char *);
-Lisp_Object make_string (CONST Bufbyte *, Bytecount);
-Lisp_Object make_ext_string (CONST Extbyte *, EMACS_INT,
-                            enum external_data_format);
+int c_readonly (Lisp_Object);
+int lisp_readonly (Lisp_Object);
+Lisp_Object build_string (const char *);
+Lisp_Object build_ext_string (const char *, Lisp_Object);
+Lisp_Object build_translated_string (const char *);
+Lisp_Object make_string (const Bufbyte *, Bytecount);
+Lisp_Object make_ext_string (const Extbyte *, EMACS_INT, Lisp_Object);
 Lisp_Object make_uninit_string (Bytecount);
 Lisp_Object make_float (double);
-size_t purespace_usage (void);
-void report_pure_usage (int, int);
-Lisp_Object make_pure_string (CONST Bufbyte *, Bytecount, Lisp_Object, int);
-Lisp_Object make_pure_pname (CONST Bufbyte *, Bytecount, int);
-Lisp_Object pure_cons (Lisp_Object, Lisp_Object);
-Lisp_Object pure_list (int, Lisp_Object *);
-Lisp_Object make_pure_vector (size_t, Lisp_Object);
+Lisp_Object make_string_nocopy (const Bufbyte *, Bytecount);
 void free_cons (Lisp_Cons *);
 void free_list (Lisp_Object);
 void free_alist (Lisp_Object);
 void mark_conses_in_list (Lisp_Object);
 void free_marker (Lisp_Marker *);
 int object_dead_p (Lisp_Object);
+void mark_object (Lisp_Object obj);
+int marked_p (Lisp_Object obj);
 
 #ifdef MEMORY_USAGE_STATS
 size_t malloced_storage_size (void *, size_t, struct overhead_stats *);
 size_t fixed_type_block_overhead (size_t);
 #endif
+#ifdef PDUMP
+void pdump (void);
+int pdump_load (const char *);
+
+extern char *pdump_start, *pdump_end;
+#define DUMPEDP(adr) ((((char *)(adr)) < pdump_end) && (((char *)(adr)) >= pdump_start))
+#else
+#define DUMPEDP(adr) 0
+#endif
 
 /* Defined in buffer.c */
 Lisp_Object make_buffer (struct buffer *);
@@ -2220,19 +2365,24 @@ extern int find_file_compare_truenames;
 extern int find_file_use_truenames;
 
 /* Defined in callproc.c */
-char *egetenv (CONST char *);
+char *egetenv (const char *);
 
 /* Defined in console.c */
 void stuff_buffered_input (Lisp_Object);
 
+/* Defined in console-msw.c */
+EXFUN (Fmswindows_message_box, 3);
+extern int mswindows_message_outputted;
+
 /* Defined in data.c */
-DECLARE_DOESNT_RETURN (pure_write_error (Lisp_Object));
+DECLARE_DOESNT_RETURN (c_write_error (Lisp_Object));
+DECLARE_DOESNT_RETURN (lisp_write_error (Lisp_Object));
 DECLARE_DOESNT_RETURN (args_out_of_range (Lisp_Object, Lisp_Object));
 DECLARE_DOESNT_RETURN (args_out_of_range_3 (Lisp_Object, Lisp_Object,
                                            Lisp_Object));
 Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object);
 DECLARE_DOESNT_RETURN (dead_wrong_type_argument (Lisp_Object, Lisp_Object));
-void check_int_range (int, int, int);
+void check_int_range (EMACS_INT, EMACS_INT, EMACS_INT);
 
 enum arith_comparison {
   arith_equal,
@@ -2247,7 +2397,7 @@ Lisp_Object word_to_lisp (unsigned int);
 unsigned int lisp_to_word (Lisp_Object);
 
 /* Defined in dired.c */
-Lisp_Object make_directory_hash_table (CONST char *);
+Lisp_Object make_directory_hash_table (const char *);
 Lisp_Object wasteful_word_to_lisp (unsigned int);
 
 /* Defined in doc.c */
@@ -2255,32 +2405,32 @@ Lisp_Object unparesseuxify_doc_string (int, EMACS_INT, char *, Lisp_Object);
 Lisp_Object read_doc_string (Lisp_Object);
 
 /* Defined in doprnt.c */
-Bytecount emacs_doprnt_c (Lisp_Object, CONST Bufbyte *, Lisp_Object,
+Bytecount emacs_doprnt_c (Lisp_Object, const Bufbyte *, Lisp_Object,
                          Bytecount, ...);
-Bytecount emacs_doprnt_va (Lisp_Object, CONST Bufbyte *, Lisp_Object,
+Bytecount emacs_doprnt_va (Lisp_Object, const Bufbyte *, Lisp_Object,
                           Bytecount, va_list);
-Bytecount emacs_doprnt_lisp (Lisp_Object, CONST Bufbyte *, Lisp_Object,
-                            Bytecount, int, CONST Lisp_Object *);
-Bytecount emacs_doprnt_lisp_2 (Lisp_Object, CONST Bufbyte *, Lisp_Object,
+Bytecount emacs_doprnt_lisp (Lisp_Object, const Bufbyte *, Lisp_Object,
+                            Bytecount, int, const Lisp_Object *);
+Bytecount emacs_doprnt_lisp_2 (Lisp_Object, const Bufbyte *, Lisp_Object,
                               Bytecount, int, ...);
-Lisp_Object emacs_doprnt_string_c (CONST Bufbyte *, Lisp_Object,
+Lisp_Object emacs_doprnt_string_c (const Bufbyte *, Lisp_Object,
                                   Bytecount, ...);
-Lisp_Object emacs_doprnt_string_va (CONST Bufbyte *, Lisp_Object,
+Lisp_Object emacs_doprnt_string_va (const Bufbyte *, Lisp_Object,
                                    Bytecount, va_list);
-Lisp_Object emacs_doprnt_string_lisp (CONST Bufbyte *, Lisp_Object,
-                                     Bytecount, int, CONST Lisp_Object *);
-Lisp_Object emacs_doprnt_string_lisp_2 (CONST Bufbyte *, Lisp_Object,
+Lisp_Object emacs_doprnt_string_lisp (const Bufbyte *, Lisp_Object,
+                                     Bytecount, int, const Lisp_Object *);
+Lisp_Object emacs_doprnt_string_lisp_2 (const Bufbyte *, Lisp_Object,
                                        Bytecount, int, ...);
 
 /* Defined in editfns.c */
 void uncache_home_directory (void);
-char *get_home_directory (void);
-char *user_login_name (int *);
+Extbyte *get_home_directory (void);
+char *user_login_name (uid_t *);
 Bufpos bufpos_clip_to_bounds (Bufpos, Bufpos, Bufpos);
 Bytind bytind_clip_to_bounds (Bytind, Bytind, Bytind);
 void buffer_insert1 (struct buffer *, Lisp_Object);
-Lisp_Object make_string_from_buffer (struct buffer *, int, int);
-Lisp_Object make_string_from_buffer_no_extents (struct buffer *, int, int);
+Lisp_Object make_string_from_buffer (struct buffer *, Bufpos, Charcount);
+Lisp_Object make_string_from_buffer_no_extents (struct buffer *, Bufpos, Charcount);
 Lisp_Object save_excursion_save (void);
 Lisp_Object save_restriction_save (void);
 Lisp_Object save_excursion_restore (Lisp_Object);
@@ -2290,64 +2440,132 @@ Lisp_Object save_restriction_restore (Lisp_Object);
 Lisp_Object save_current_buffer_restore (Lisp_Object);
 
 /* Defined in emacs.c */
-DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS (fatal (CONST char *,
+DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS (fatal (const char *,
                                                           ...), 1, 2);
-int stderr_out (CONST char *, ...) PRINTF_ARGS (1, 2);
-int stdout_out (CONST char *, ...) PRINTF_ARGS (1, 2);
+int stderr_out (const char *, ...) PRINTF_ARGS (1, 2);
+int stdout_out (const char *, ...) PRINTF_ARGS (1, 2);
 SIGTYPE fatal_error_signal (int);
-Lisp_Object make_arg_list (int, char **);
-void make_argc_argv (Lisp_Object, int *, char ***);
-void free_argc_argv (char **);
-Lisp_Object decode_env_path (CONST char *, CONST char *);
-Lisp_Object decode_path (CONST char *);
+Lisp_Object make_arg_list (int, Extbyte **);
+void make_argc_argv (Lisp_Object, int *, Extbyte ***);
+void free_argc_argv (Extbyte **);
+Lisp_Object decode_env_path (const char *, const char *);
+Lisp_Object decode_path (const char *);
 /* Nonzero means don't do interactive redisplay and don't change tty modes */
-extern int noninteractive;
+extern int noninteractive, noninteractive1;
+extern int fatal_error_in_progress;
 extern int preparing_for_armageddon;
-extern int emacs_priority;
+extern Fixnum emacs_priority;
 extern int running_asynch_code;
 extern int suppress_early_error_handler_backtrace;
 
 /* Defined in eval.c */
 DECLARE_DOESNT_RETURN (signal_error (Lisp_Object, Lisp_Object));
-void maybe_signal_error (Lisp_Object, Lisp_Object, Lisp_Object, Error_behavior);
+void maybe_signal_error (Lisp_Object, Lisp_Object, Lisp_Object,
+                        Error_behavior);
 Lisp_Object maybe_signal_continuable_error (Lisp_Object, Lisp_Object,
                                            Lisp_Object, Error_behavior);
-DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS (error (CONST char *,
+DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS (type_error (Lisp_Object,
+                                                             const char *,
+                                                             ...), 2, 3);
+void maybe_type_error (Lisp_Object, Lisp_Object, Error_behavior, const char *,
+                      ...) PRINTF_ARGS (4, 5);
+Lisp_Object continuable_type_error (Lisp_Object, const char *, ...)
+     PRINTF_ARGS (2, 3);
+Lisp_Object maybe_continuable_type_error (Lisp_Object, Lisp_Object,
+                                         Error_behavior,
+                                         const char *, ...)
+     PRINTF_ARGS (4, 5);
+DECLARE_DOESNT_RETURN (signal_type_error (Lisp_Object, const char *,
+                                         Lisp_Object));
+void maybe_signal_type_error (Lisp_Object, const char *, Lisp_Object,
+                             Lisp_Object, Error_behavior);
+Lisp_Object signal_type_continuable_error (Lisp_Object, const char *,
+                                          Lisp_Object);
+Lisp_Object maybe_signal_type_continuable_error (Lisp_Object, const char *,
+                                                Lisp_Object,
+                                                Lisp_Object, Error_behavior);
+DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS (type_error_with_frob
+                                                 (Lisp_Object, Lisp_Object,
+                                                  const char *,
+                                                  ...), 3, 4);
+void maybe_type_error_with_frob (Lisp_Object, Lisp_Object, Lisp_Object,
+                                Error_behavior,
+                                const char *, ...) PRINTF_ARGS (5, 6);
+Lisp_Object continuable_type_error_with_frob (Lisp_Object, Lisp_Object,
+                                             const char *,
+                                             ...) PRINTF_ARGS (3, 4);
+Lisp_Object maybe_continuable_type_error_with_frob
+(Lisp_Object, Lisp_Object, Lisp_Object, Error_behavior, const char *, ...)
+     PRINTF_ARGS (5, 6);
+DECLARE_DOESNT_RETURN (signal_type_error_2 (Lisp_Object, const char *,
+                                           Lisp_Object, Lisp_Object));
+void maybe_signal_type_error_2 (Lisp_Object, const char *, Lisp_Object,
+                               Lisp_Object, Lisp_Object, Error_behavior);
+Lisp_Object signal_type_continuable_error_2 (Lisp_Object, const char *,
+                                            Lisp_Object, Lisp_Object);
+Lisp_Object maybe_signal_type_continuable_error_2 (Lisp_Object, const char *,
+                                                  Lisp_Object, Lisp_Object,
+                                                  Lisp_Object,
+                                                  Error_behavior);
+DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS (error (const char *,
                                                           ...), 1, 2);
-void maybe_error (Lisp_Object, Error_behavior, CONST char *,
+void maybe_error (Lisp_Object, Error_behavior, const char *,
                  ...) PRINTF_ARGS (3, 4);
-Lisp_Object continuable_error (CONST char *, ...) PRINTF_ARGS (1, 2);
+Lisp_Object continuable_error (const char *, ...) PRINTF_ARGS (1, 2);
 Lisp_Object maybe_continuable_error (Lisp_Object, Error_behavior,
-                                    CONST char *, ...) PRINTF_ARGS (3, 4);
-DECLARE_DOESNT_RETURN (signal_simple_error (CONST char *, Lisp_Object));
-void maybe_signal_simple_error (CONST char *, Lisp_Object,
+                                    const char *, ...) PRINTF_ARGS (3, 4);
+DECLARE_DOESNT_RETURN (signal_simple_error (const char *, Lisp_Object));
+void maybe_signal_simple_error (const char *, Lisp_Object,
                                Lisp_Object, Error_behavior);
-Lisp_Object signal_simple_continuable_error (CONST char *, Lisp_Object);
-Lisp_Object maybe_signal_simple_continuable_error (CONST char *, Lisp_Object,
+Lisp_Object signal_simple_continuable_error (const char *, Lisp_Object);
+Lisp_Object maybe_signal_simple_continuable_error (const char *, Lisp_Object,
                                                   Lisp_Object, Error_behavior);
 DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS (error_with_frob
-                                                   (Lisp_Object, CONST char *,
+                                                   (Lisp_Object, const char *,
                                                     ...), 2, 3);
 void maybe_error_with_frob (Lisp_Object, Lisp_Object, Error_behavior,
-                           CONST char *, ...) PRINTF_ARGS (4, 5);
-Lisp_Object continuable_error_with_frob (Lisp_Object, CONST char *,
+                           const char *, ...) PRINTF_ARGS (4, 5);
+Lisp_Object continuable_error_with_frob (Lisp_Object, const char *,
                                         ...) PRINTF_ARGS (2, 3);
 Lisp_Object maybe_continuable_error_with_frob
-(Lisp_Object, Lisp_Object, Error_behavior, CONST char *, ...) PRINTF_ARGS (4, 5);
-DECLARE_DOESNT_RETURN (signal_simple_error_2 (CONST char *,
+(Lisp_Object, Lisp_Object, Error_behavior, const char *, ...) PRINTF_ARGS (4, 5);
+DECLARE_DOESNT_RETURN (signal_simple_error_2 (const char *,
                                              Lisp_Object, Lisp_Object));
-void maybe_signal_simple_error_2 (CONST char *, Lisp_Object, Lisp_Object,
+void maybe_signal_simple_error_2 (const char *, Lisp_Object, Lisp_Object,
                                  Lisp_Object, Error_behavior);
-Lisp_Object signal_simple_continuable_error_2 (CONST char *,
+Lisp_Object signal_simple_continuable_error_2 (const char *,
                                               Lisp_Object, Lisp_Object);
-Lisp_Object maybe_signal_simple_continuable_error_2 (CONST char *, Lisp_Object,
+Lisp_Object maybe_signal_simple_continuable_error_2 (const char *, Lisp_Object,
                                                     Lisp_Object, Lisp_Object,
                                                     Error_behavior);
-void signal_malformed_list_error (Lisp_Object);
-void signal_malformed_property_list_error (Lisp_Object);
-void signal_circular_list_error (Lisp_Object);
-void signal_circular_property_list_error (Lisp_Object);
-void signal_void_function_error (Lisp_Object);
+DECLARE_DOESNT_RETURN (signal_malformed_list_error (Lisp_Object));
+DECLARE_DOESNT_RETURN (signal_malformed_property_list_error (Lisp_Object));
+DECLARE_DOESNT_RETURN (signal_circular_list_error (Lisp_Object));
+DECLARE_DOESNT_RETURN (signal_circular_property_list_error (Lisp_Object));
+
+DECLARE_DOESNT_RETURN (syntax_error (const char *reason, Lisp_Object frob));
+DECLARE_DOESNT_RETURN (syntax_error_2 (const char *reason, Lisp_Object frob1,
+                                      Lisp_Object frob2));
+DECLARE_DOESNT_RETURN (invalid_argument (const char *reason,
+                                        Lisp_Object frob));
+DECLARE_DOESNT_RETURN (invalid_argument_2 (const char *reason,
+                                          Lisp_Object frob1,
+                                          Lisp_Object frob2));
+DECLARE_DOESNT_RETURN (invalid_operation (const char *reason,
+                                         Lisp_Object frob));
+DECLARE_DOESNT_RETURN (invalid_operation_2 (const char *reason,
+                                           Lisp_Object frob1,
+                                           Lisp_Object frob2));
+DECLARE_DOESNT_RETURN (invalid_change (const char *reason,
+                                      Lisp_Object frob));
+DECLARE_DOESNT_RETURN (invalid_change_2 (const char *reason,
+                                        Lisp_Object frob1,
+                                        Lisp_Object frob2));
+
+Lisp_Object signal_void_function_error (Lisp_Object);
+Lisp_Object signal_invalid_function_error (Lisp_Object);
+Lisp_Object signal_wrong_number_of_arguments_error (Lisp_Object, int);
+
 Lisp_Object run_hook_with_args_in_buffer (struct buffer *, int, Lisp_Object *,
                                          enum run_hooks_condition);
 Lisp_Object run_hook_with_args (int, Lisp_Object *, enum run_hooks_condition);
@@ -2387,13 +2605,13 @@ Lisp_Object call6_in_buffer (struct buffer *, Lisp_Object, Lisp_Object,
 Lisp_Object eval_in_buffer (struct buffer *, Lisp_Object);
 Lisp_Object call0_with_handler (Lisp_Object, Lisp_Object);
 Lisp_Object call1_with_handler (Lisp_Object, Lisp_Object, Lisp_Object);
-Lisp_Object eval_in_buffer_trapping_errors (CONST char *, struct buffer *,
+Lisp_Object eval_in_buffer_trapping_errors (const char *, struct buffer *,
                                            Lisp_Object);
-Lisp_Object run_hook_trapping_errors (CONST char *, Lisp_Object);
-Lisp_Object safe_run_hook_trapping_errors (CONST char *, Lisp_Object, int);
-Lisp_Object call0_trapping_errors (CONST char *, Lisp_Object);
-Lisp_Object call1_trapping_errors (CONST char *, Lisp_Object, Lisp_Object);
-Lisp_Object call2_trapping_errors (CONST char *,
+Lisp_Object run_hook_trapping_errors (const char *, Lisp_Object);
+Lisp_Object safe_run_hook_trapping_errors (const char *, Lisp_Object, int);
+Lisp_Object call0_trapping_errors (const char *, Lisp_Object);
+Lisp_Object call1_trapping_errors (const char *, Lisp_Object, Lisp_Object);
+Lisp_Object call2_trapping_errors (const char *,
                                   Lisp_Object, Lisp_Object, Lisp_Object);
 Lisp_Object call_with_suspended_errors (lisp_fn_t, volatile Lisp_Object, Lisp_Object,
                                        Error_behavior, int, ...);
@@ -2412,7 +2630,7 @@ void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object);
 void do_autoload (Lisp_Object, Lisp_Object);
 Lisp_Object un_autoload (Lisp_Object);
 void warn_when_safe_lispobj (Lisp_Object, Lisp_Object, Lisp_Object);
-void warn_when_safe (Lisp_Object, Lisp_Object, CONST char *,
+void warn_when_safe (Lisp_Object, Lisp_Object, const char *,
                     ...) PRINTF_ARGS (3, 4);
 
 
@@ -2423,38 +2641,39 @@ void reset_this_command_keys (Lisp_Object, int);
 Lisp_Object enqueue_misc_user_event (Lisp_Object, Lisp_Object, Lisp_Object);
 Lisp_Object enqueue_misc_user_event_pos (Lisp_Object, Lisp_Object,
                                         Lisp_Object, int, int, int, int);
+extern int modifier_keys_are_sticky;
 
 /* Defined in event-Xt.c */
+void enqueue_Xt_dispatch_event (Lisp_Object event);
 void signal_special_Xt_user_event (Lisp_Object, Lisp_Object, Lisp_Object);
 
 
 /* Defined in events.c */
 void clear_event_resource (void);
 Lisp_Object allocate_event (void);
-int event_to_character (Lisp_Event *, int, int, int);
 
 /* Defined in fileio.c */
 void record_auto_save (void);
 void force_auto_save_soon (void);
-DECLARE_DOESNT_RETURN (report_file_error (CONST char *, Lisp_Object));
-void maybe_report_file_error (CONST char *, Lisp_Object,
+DECLARE_DOESNT_RETURN (report_file_error (const char *, Lisp_Object));
+void maybe_report_file_error (const char *, Lisp_Object,
                              Lisp_Object, Error_behavior);
-DECLARE_DOESNT_RETURN (signal_file_error (CONST char *, Lisp_Object));
-void maybe_signal_file_error (CONST char *, Lisp_Object,
+DECLARE_DOESNT_RETURN (signal_file_error (const char *, Lisp_Object));
+void maybe_signal_file_error (const char *, Lisp_Object,
                              Lisp_Object, Error_behavior);
-DECLARE_DOESNT_RETURN (signal_double_file_error (CONST char *, CONST char *,
+DECLARE_DOESNT_RETURN (signal_double_file_error (const char *, const char *,
                                                 Lisp_Object));
-void maybe_signal_double_file_error (CONST char *, CONST char *,
+void maybe_signal_double_file_error (const char *, const char *,
                                     Lisp_Object, Lisp_Object, Error_behavior);
-DECLARE_DOESNT_RETURN (signal_double_file_error_2 (CONST char *, CONST char *,
+DECLARE_DOESNT_RETURN (signal_double_file_error_2 (const char *, const char *,
                                                   Lisp_Object, Lisp_Object));
-void maybe_signal_double_file_error_2 (CONST char *, CONST char *,
+void maybe_signal_double_file_error_2 (const char *, const char *,
                                       Lisp_Object, Lisp_Object, Lisp_Object,
                                       Error_behavior);
 Lisp_Object lisp_strerror (int);
 Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object);
-int read_allowing_quit (int, void *, size_t);
-int write_allowing_quit (int, CONST void *, size_t);
+ssize_t read_allowing_quit (int, void *, size_t);
+ssize_t write_allowing_quit (int, const void *, size_t);
 int internal_delete_file (Lisp_Object);
 
 /* Defined in filelock.c */
@@ -2485,7 +2704,6 @@ Lisp_Object remassoc_no_quit (Lisp_Object, Lisp_Object);
 Lisp_Object remassq_no_quit (Lisp_Object, Lisp_Object);
 Lisp_Object remrassq_no_quit (Lisp_Object, Lisp_Object);
 
-void pure_put (Lisp_Object, Lisp_Object, Lisp_Object);
 int plists_differ (Lisp_Object, Lisp_Object, int, int, int);
 Lisp_Object internal_plist_get (Lisp_Object, Lisp_Object);
 void internal_plist_put (Lisp_Object *, Lisp_Object, Lisp_Object);
@@ -2502,10 +2720,7 @@ Lisp_Object vconcat2 (Lisp_Object, Lisp_Object);
 Lisp_Object vconcat3 (Lisp_Object, Lisp_Object, Lisp_Object);
 Lisp_Object nconc2 (Lisp_Object, Lisp_Object);
 Lisp_Object bytecode_nconc2 (Lisp_Object *);
-void check_losing_bytecode (CONST char *, Lisp_Object);
-
-/* Defined in getloadavg.c */
-int getloadavg (double[], int);
+void check_losing_bytecode (const char *, Lisp_Object);
 
 /* Defined in glyphs.c */
 Error_behavior decode_error_behavior_flag (Lisp_Object);
@@ -2514,6 +2729,7 @@ Lisp_Object encode_error_behavior_flag (Error_behavior);
 /* Defined in indent.c */
 int bi_spaces_at_point (struct buffer *, Bytind);
 int column_at_point (struct buffer *, Bufpos, int);
+int string_column_at_point (Lisp_String *, Bufpos, int);
 int current_column (struct buffer *);
 void invalidate_current_column (void);
 Bufpos vmotion (struct window *, Bufpos, int, int *);
@@ -2525,8 +2741,9 @@ void where_is_to_char (Lisp_Object, char *);
 /* Defined in lread.c */
 void ebolify_bytecode_constants (Lisp_Object);
 void close_load_descs (void);
-int locate_file (Lisp_Object, Lisp_Object, CONST char *, Lisp_Object *, int);
-int isfloat_string (CONST char *);
+int locate_file (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object *, int);
+EXFUN (Flocate_file_clear_hashing, 1);
+int isfloat_string (const char *);
 
 /* Well, I've decided to enable this. -- ben */
 /* And I've decided to make it work right.  -- sb */
@@ -2563,32 +2780,32 @@ extern int popup_menu_titles;
 
 /* Defined in minibuf.c */
 extern int minibuf_level;
-Charcount scmp_1 (CONST Bufbyte *, CONST Bufbyte *, Charcount, int);
+Charcount scmp_1 (const Bufbyte *, const Bufbyte *, Charcount, int);
 #define scmp(s1, s2, len) scmp_1 (s1, s2, len, completion_ignore_case)
 extern int completion_ignore_case;
-int regexp_ignore_completion_p (CONST Bufbyte *, Lisp_Object,
+int regexp_ignore_completion_p (const Bufbyte *, Lisp_Object,
                                Bytecount, Bytecount);
 Lisp_Object clear_echo_area (struct frame *, Lisp_Object, int);
 Lisp_Object clear_echo_area_from_print (struct frame *, Lisp_Object, int);
-void echo_area_append (struct frame *, CONST Bufbyte *, Lisp_Object,
+void echo_area_append (struct frame *, const Bufbyte *, Lisp_Object,
                       Bytecount, Bytecount, Lisp_Object);
-void echo_area_message (struct frame *, CONST Bufbyte *, Lisp_Object,
+void echo_area_message (struct frame *, const Bufbyte *, Lisp_Object,
                        Bytecount, Bytecount, Lisp_Object);
 Lisp_Object echo_area_status (struct frame *);
 int echo_area_active (struct frame *);
 Lisp_Object echo_area_contents (struct frame *);
-void message_internal (CONST Bufbyte *, Lisp_Object, Bytecount, Bytecount);
-void message_append_internal (CONST Bufbyte *, Lisp_Object,
+void message_internal (const Bufbyte *, Lisp_Object, Bytecount, Bytecount);
+void message_append_internal (const Bufbyte *, Lisp_Object,
                              Bytecount, Bytecount);
-void message (CONST char *, ...) PRINTF_ARGS (1, 2);
-void message_append (CONST char *, ...) PRINTF_ARGS (1, 2);
-void message_no_translate (CONST char *, ...) PRINTF_ARGS (1, 2);
+void message (const char *, ...) PRINTF_ARGS (1, 2);
+void message_append (const char *, ...) PRINTF_ARGS (1, 2);
+void message_no_translate (const char *, ...) PRINTF_ARGS (1, 2);
 void clear_message (void);
 
 /* Defined in print.c */
 void write_string_to_stdio_stream (FILE *, struct console *,
-                                  CONST Bufbyte *, Bytecount, Bytecount,
-                                  enum external_data_format);
+                                  const Bufbyte *, Bytecount, Bytecount,
+                                  Lisp_Object, int);
 void debug_print (Lisp_Object);
 void debug_short_backtrace (int);
 void temp_output_buffer_setup (Lisp_Object);
@@ -2596,13 +2813,13 @@ void temp_output_buffer_show (Lisp_Object, Lisp_Object);
 /* NOTE: Do not call this with the data of a Lisp_String.  Use princ.
  * Note: stream should be defaulted before calling
  *  (eg Qnil means stdout, not Vstandard_output, etc) */
-void write_c_string (CONST char *, Lisp_Object);
+void write_c_string (const char *, Lisp_Object);
 /* Same goes for this function. */
-void write_string_1 (CONST Bufbyte *, Bytecount, Lisp_Object);
+void write_string_1 (const Bufbyte *, Bytecount, Lisp_Object);
 void print_cons (Lisp_Object, Lisp_Object, int);
 void print_vector (Lisp_Object, Lisp_Object, int);
 void print_string (Lisp_Object, Lisp_Object, int);
-void long_to_string (char *, long);
+char *long_to_string (char *, long);
 void print_internal (Lisp_Object, Lisp_Object, int);
 void print_symbol (Lisp_Object, Lisp_Object, int);
 void print_float (Lisp_Object, Lisp_Object, int);
@@ -2615,7 +2832,7 @@ void float_to_string (char *, double);
 void internal_object_printer (Lisp_Object, Lisp_Object, int);
 
 /* Defined in profile.c */
-void mark_profiling_info (void (*) (Lisp_Object));
+void mark_profiling_info (void);
 void profile_increase_call_count (Lisp_Object);
 extern int profiling_active;
 extern int profiling_redisplay_flag;
@@ -2637,10 +2854,11 @@ Bufpos scan_buffer (struct buffer *, Emchar, Bufpos, Bufpos, EMACS_INT, EMACS_IN
 Bufpos find_next_newline (struct buffer *, Bufpos, int);
 Bufpos find_next_newline_no_quit (struct buffer *, Bufpos, int);
 Bytind bi_find_next_newline_no_quit (struct buffer *, Bytind, int);
+Bytind bi_find_next_emchar_in_string (Lisp_String*, Emchar, Bytind, EMACS_INT);
 Bufpos find_before_next_newline (struct buffer *, Bufpos, Bufpos, int);
 struct re_pattern_buffer *compile_pattern (Lisp_Object, struct re_registers *,
-                                          char *, int, Error_behavior);
-Bytecount fast_string_match (Lisp_Object,  CONST Bufbyte *,
+                                          Lisp_Object, int, Error_behavior);
+Bytecount fast_string_match (Lisp_Object,  const Bufbyte *,
                             Lisp_Object, Bytecount,
                             Bytecount, int, Error_behavior, int);
 Bytecount fast_lisp_string_match (Lisp_Object, Lisp_Object);
@@ -2662,9 +2880,9 @@ Lisp_Object specifier_instance_no_quit (Lisp_Object, Lisp_Object, Lisp_Object,
                                        Error_behavior, int, Lisp_Object);
 
 /* Defined in symbols.c */
-int hash_string (CONST Bufbyte *, Bytecount);
-Lisp_Object intern (CONST char *);
-Lisp_Object oblookup (Lisp_Object, CONST Bufbyte *, Bytecount);
+int hash_string (const Bufbyte *, Bytecount);
+Lisp_Object intern (const char *);
+Lisp_Object oblookup (Lisp_Object, const Bufbyte *, Bytecount);
 void map_obarray (Lisp_Object, int (*) (Lisp_Object, void *), void *);
 Lisp_Object indirect_function (Lisp_Object, int);
 Lisp_Object symbol_value_in_buffer (Lisp_Object, Lisp_Object);
@@ -2678,7 +2896,7 @@ void reject_constant_symbols (Lisp_Object sym, Lisp_Object newval,
                              Lisp_Object follow_past_lisp_magic);
 
 /* Defined in syntax.c */
-int scan_words (struct buffer *, int, int);
+Bufpos scan_words (struct buffer *, Bufpos, int);
 
 /* Defined in undo.c */
 Lisp_Object truncate_undo_list (Lisp_Object, int, int);
@@ -2694,14 +2912,15 @@ int run_time_remap (char *);
 #endif
 
 /* Defined in vm-limit.c */
-void memory_warnings (void *, void (*) (CONST char *));
+void memory_warnings (void *, void (*) (const char *));
 
 /* Defined in window.c */
 Lisp_Object save_window_excursion_unwind (Lisp_Object);
 Lisp_Object display_buffer (Lisp_Object, Lisp_Object, Lisp_Object);
 
-/* The following were machine generated 19980312 */
+/*--------------- prototypes for Lisp primitives in C ------------*/
 
+/* The following were machine generated 19980312 */
 
 EXFUN (Faccept_process_output, 3);
 EXFUN (Fadd1, 1);
@@ -2730,6 +2949,7 @@ EXFUN (Fcdr, 1);
 EXFUN (Fchar_after, 2);
 EXFUN (Fchar_to_string, 1);
 EXFUN (Fcheck_valid_plist, 1);
+EXFUN (Fvalid_plist_p, 1);
 EXFUN (Fclear_range_table, 1);
 EXFUN (Fcoding_category_list, 0);
 EXFUN (Fcoding_category_system, 1);
@@ -2759,7 +2979,9 @@ EXFUN (Fdecode_shift_jis_char, 1);
 EXFUN (Fdefault_boundp, 1);
 EXFUN (Fdefault_value, 1);
 EXFUN (Fdefine_key, 3);
+EXFUN (Fdelete, 2);
 EXFUN (Fdelete_region, 3);
+EXFUN (Fdelete_process, 1);
 EXFUN (Fdelq, 2);
 EXFUN (Fdestructive_alist_to_plist, 1);
 EXFUN (Fdetect_coding_region, 3);
@@ -2809,6 +3031,7 @@ EXFUN (Fforward_char, 2);
 EXFUN (Fforward_line, 2);
 EXFUN (Ffset, 2);
 EXFUN (Ffuncall, MANY);
+EXFUN (Ffunctionp, 1);
 EXFUN (Fgeq, MANY);
 EXFUN (Fget, 3);
 EXFUN (Fget_buffer_process, 1);
@@ -2830,12 +3053,16 @@ EXFUN (Fintern_soft, 2);
 EXFUN (Fkey_description, 1);
 EXFUN (Fkill_emacs, 1);
 EXFUN (Fkill_local_variable, 1);
+EXFUN (Flast, 2);
 EXFUN (Flax_plist_get, 3);
 EXFUN (Flax_plist_remprop, 2);
 EXFUN (Flength, 1);
 EXFUN (Fleq, MANY);
 EXFUN (Flist, MANY);
 EXFUN (Flistp, 1);
+EXFUN (Flist_modules, 0);
+EXFUN (Fload_module, 3);
+EXFUN (Flookup_key, 3);
 EXFUN (Flss, MANY);
 EXFUN (Fmake_byte_code, MANY);
 EXFUN (Fmake_coding_system, 4);
@@ -2868,6 +3095,7 @@ EXFUN (Fold_equal, 2);
 EXFUN (Fold_member, 2);
 EXFUN (Fold_memq, 2);
 EXFUN (Fplist_get, 3);
+EXFUN (Fplist_member, 2);
 EXFUN (Fplist_put, 3);
 EXFUN (Fplus, MANY);
 EXFUN (Fpoint, 1);
@@ -2883,7 +3111,6 @@ EXFUN (Fprint, 2);
 EXFUN (Fprocess_status, 1);
 EXFUN (Fprogn, UNEVALLED);
 EXFUN (Fprovide, 1);
-EXFUN (Fpurecopy, 1);
 EXFUN (Fput, 3);
 EXFUN (Fput_range_table, 4);
 EXFUN (Fput_text_property, 5);
@@ -2894,6 +3121,7 @@ EXFUN (Fread_key_sequence, 3);
 EXFUN (Freally_free, 1);
 EXFUN (Frem, 2);
 EXFUN (Fremassq, 2);
+EXFUN (Freplace_list, 2);
 EXFUN (Fselected_frame, 1);
 EXFUN (Fset, 2);
 EXFUN (Fset_coding_category_system, 2);
@@ -2942,91 +3170,120 @@ EXFUN (Fverify_visited_file_modtime, 1);
 EXFUN (Fvertical_motion, 3);
 EXFUN (Fwiden, 1);
 
-
-extern Lisp_Object Q_style, Qactually_requested, Qactivate_menubar_hook;
-extern Lisp_Object Qafter, Qall, Qand;
-extern Lisp_Object Qarith_error, Qarrayp, Qassoc, Qat, Qautodetect, Qautoload;
-extern Lisp_Object Qbackground, Qbackground_pixmap, Qbad_variable, Qbefore;
-extern Lisp_Object Qbeginning_of_buffer, Qbig5, Qbinary, Qbitmap, Qbitp, Qblinking;
-extern Lisp_Object Qboolean, Qbottom, Qbuffer, Qbuffer_file_coding_system;
-extern Lisp_Object Qbuffer_glyph_p, Qbuffer_live_p, Qbuffer_read_only, Qbutton;
-extern Lisp_Object Qbyte_code, Qcall_interactively, Qcategory;
+/*--------------- prototypes for constant symbols  ------------*/
+
+extern Lisp_Object Q_style;
+extern Lisp_Object Qactivate_menubar_hook;
+extern Lisp_Object Qarith_error;
+extern Lisp_Object Qarrayp, Qautoload;
+extern Lisp_Object Qbackground, Qbackground_pixmap;
+extern Lisp_Object Qbeginning_of_buffer, Qbig5;
+extern Lisp_Object Qbitp, Qblinking;
+extern Lisp_Object Qbuffer_glyph_p, Qbuffer_live_p, Qbuffer_read_only;
+extern Lisp_Object Qbyte_code, Qcall_interactively;
 extern Lisp_Object Qcategory_designator_p, Qcategory_table_value_p, Qccl, Qcdr;
-extern Lisp_Object Qchannel, Qchar, Qchar_or_string_p, Qcharacter, Qcharacterp;
-extern Lisp_Object Qchars, Qcharset_g0, Qcharset_g1, Qcharset_g2, Qcharset_g3;
+extern Lisp_Object Qchar_or_string_p, Qcharacterp;
+extern Lisp_Object Qcharset_g0, Qcharset_g1, Qcharset_g2, Qcharset_g3;
 extern Lisp_Object Qcircular_list, Qcircular_property_list;
-extern Lisp_Object Qcoding_system_error, Qcoding_system_p;
-extern Lisp_Object Qcolor, Qcolor_pixmap_image_instance_p;
-extern Lisp_Object Qcolumns, Qcommand, Qcommandp, Qcompletion_ignore_case;
-extern Lisp_Object Qconsole, Qconsole_live_p, Qconst_specifier, Qcr, Qcritical;
-extern Lisp_Object Qcrlf, Qctext, Qcurrent_menubar, Qcursor;
-extern Lisp_Object Qcyclic_variable_indirection, Qdata, Qdead, Qdecode;
-extern Lisp_Object Qdefault, Qdefun, Qdelete, Qdelq, Qdevice, Qdevice_live_p;
-extern Lisp_Object Qdim, Qdimension, Qdisabled, Qdisplay, Qdisplay_table;
-extern Lisp_Object Qdoc_string, Qdomain_error, Qdynarr_overhead;
-extern Lisp_Object Qempty, Qencode, Qend_of_buffer, Qend_of_file, Qend_open;
-extern Lisp_Object Qeol_cr, Qeol_crlf, Qeol_lf, Qeol_type, Qeq, Qeql, Qequal;
+extern Lisp_Object Qcoding_system_error;
+extern Lisp_Object Qcolor_pixmap_image_instance_p;
+extern Lisp_Object Qcommandp, Qcompletion_ignore_case;
+extern Lisp_Object Qconsole_live_p, Qconst_specifier, Qcr;
+extern Lisp_Object Qcrlf, Qcurrent_menubar, Qctext;
+extern Lisp_Object Qcyclic_variable_indirection, Qdecode;
+extern Lisp_Object Qdefun, Qdevice_live_p;
+extern Lisp_Object Qdim, Qdisabled, Qdisplay_table;
+extern Lisp_Object Qdomain_error;
+extern Lisp_Object Qediting_error;
+extern Lisp_Object Qencode, Qend_of_buffer, Qend_of_file, Qend_open;
+extern Lisp_Object Qeol_cr, Qeol_crlf, Qeol_lf, Qeol_type;
 extern Lisp_Object Qerror, Qerror_conditions, Qerror_message, Qescape_quoted;
-extern Lisp_Object Qeval, Qevent_live_p, Qexit, Qextent_live_p, Qextents;
-extern Lisp_Object Qexternal_debugging_output, Qface, Qfeaturep, Qfile_error;
-extern Lisp_Object Qfont, Qforce_g0_on_output, Qforce_g1_on_output;
+extern Lisp_Object Qevent_live_p, Qexit, Qextent_live_p;
+extern Lisp_Object Qexternal_debugging_output, Qfeaturep;
+extern Lisp_Object Qfile_error;
+extern Lisp_Object Qforce_g0_on_output, Qforce_g1_on_output;
 extern Lisp_Object Qforce_g2_on_output, Qforce_g3_on_output, Qforeground;
-extern Lisp_Object Qformat, Qframe, Qframe_live_p, Qfunction, Qgap_overhead;
-extern Lisp_Object Qgeneric, Qgeometry, Qglobal, Qheight, Qhighlight, Qicon;
-extern Lisp_Object Qicon_glyph_p, Qid, Qidentity, Qimage, Qinfo, Qinherit;
+extern Lisp_Object Qformat, Qframe_live_p;
+extern Lisp_Object Qicon_glyph_p, Qidentity;
 extern Lisp_Object Qinhibit_quit, Qinhibit_read_only;
-extern Lisp_Object Qinput_charset_conversion, Qinteger;
+extern Lisp_Object Qinput_charset_conversion;
 extern Lisp_Object Qinteger_char_or_marker_p, Qinteger_or_char_p;
-extern Lisp_Object Qinteger_or_marker_p, Qintegerp, Qinteractive, Qinternal;
-extern Lisp_Object Qinvalid_function, Qinvalid_read_syntax, Qio_error;
-extern Lisp_Object Qiso2022, Qkey, Qkey_assoc, Qkeymap, Qlambda, Qleft, Qlf;
-extern Lisp_Object Qlist, Qlistp, Qload, Qlock_shift, Qmacro, Qmagic;
-extern Lisp_Object Qmalformed_list, Qmalformed_property_list;
-extern Lisp_Object Qmalloc_overhead, Qmark, Qmarkers;
-extern Lisp_Object Qmax, Qmemory, Qmessage, Qminus, Qmnemonic, Qmodifiers;
-extern Lisp_Object Qmono_pixmap_image_instance_p, Qmotion;
-extern Lisp_Object Qmouse_leave_buffer_hook, Qmswindows, Qname, Qnas, Qnatnump;
+extern Lisp_Object Qinteger_or_marker_p, Qintegerp, Qinteractive;
+extern Lisp_Object Qinternal_error, Qinvalid_argument;
+extern Lisp_Object Qinvalid_change, Qinvalid_function, Qinvalid_operation;
+extern Lisp_Object Qinvalid_read_syntax, Qinvalid_state;
+extern Lisp_Object Qio_error;
+extern Lisp_Object Qiso2022;
+extern Lisp_Object Qlambda, Qlayout;
+extern Lisp_Object Qlf;
+extern Lisp_Object Qlist_formation_error;
+extern Lisp_Object Qlistp, Qload, Qlock_shift, Qmacro;
+extern Lisp_Object Qmakunbound, Qmalformed_list, Qmalformed_property_list;
+extern Lisp_Object Qmark;
+extern Lisp_Object Qmnemonic;
+extern Lisp_Object Qmono_pixmap_image_instance_p;
+extern Lisp_Object Qmouse_leave_buffer_hook;
+extern Lisp_Object Qnas, Qnatnump, Qnative_layout;
 extern Lisp_Object Qno_ascii_cntl, Qno_ascii_eol, Qno_catch;
-extern Lisp_Object Qno_conversion, Qno_iso6429, Qnone, Qnot, Qnothing;
-extern Lisp_Object Qnothing_image_instance_p, Qnotice;
-extern Lisp_Object Qnumber_char_or_marker_p, Qnumber_or_marker_p, Qnumberp;
-extern Lisp_Object Qobject, Qold_assoc, Qold_delete, Qold_delq, Qold_rassoc;
-extern Lisp_Object Qold_rassq, Qonly, Qor, Qother, Qoutput_charset_conversion;
-extern Lisp_Object Qoverflow_error, Qpath, Qpoint, Qpointer, Qpointer_glyph_p;
+extern Lisp_Object Qno_conversion, Qno_iso6429;
+extern Lisp_Object Qnothing_image_instance_p;
+extern Lisp_Object Qnumber_char_or_marker_p, Qnumberp;
+extern Lisp_Object Qoutput_charset_conversion;
+extern Lisp_Object Qoverflow_error, Qpoint, Qpointer_glyph_p;
 extern Lisp_Object Qpointer_image_instance_p, Qpost_read_conversion;
-extern Lisp_Object Qpre_write_conversion, Qprint, Qprint_length;
-extern Lisp_Object Qprint_string_length, Qprocess, Qprogn, Qprovide, Qquit;
-extern Lisp_Object Qquote, Qrange_error, Qrassoc, Qrassq, Qread_char;
+extern Lisp_Object Qpre_write_conversion, Qprint_length;
+extern Lisp_Object Qprint_string_length, Qprogn, Qquit;
+extern Lisp_Object Qquote, Qrange_error, Qread_char;
 extern Lisp_Object Qread_from_minibuffer, Qreally_early_error_handler;
-extern Lisp_Object Qregion_beginning, Qregion_end, Qrequire, Qresource;
-extern Lisp_Object Qreturn, Qreverse, Qright, Qrun_hooks, Qsans_modifiers;
-extern Lisp_Object Qsave_buffers_kill_emacs, Qsearch, Qself_insert_command;
-extern Lisp_Object Qsequencep, Qsetting_constant, Qseven, Qshift_jis, Qshort;
-extern Lisp_Object Qsignal, Qsimple, Qsingularity_error, Qsize, Qspace;
-extern Lisp_Object Qspecifier, Qstandard_input, Qstandard_output, Qstart_open;
-extern Lisp_Object Qstream, Qstring, Qstring_lessp;
-extern Lisp_Object Qsubwindow_image_instance_p, Qsymbol, Qsyntax, Qt, Qtest;
-extern Lisp_Object Qtext, Qtext_image_instance_p, Qtimeout, Qtimestamp;
-extern Lisp_Object Qtoolbar, Qtop, Qtop_level, Qtrue_list_p, Qtty, Qtype;
-extern Lisp_Object Qunbound, Qundecided, Qundefined, Qunderflow_error;
-extern Lisp_Object Qunderline, Qunimplemented, Quser_files_and_directories;
-extern Lisp_Object Qvalue_assoc, Qvalues;
-extern Lisp_Object Qvariable_documentation, Qvariable_domain, Qvector;
-extern Lisp_Object Qvoid_function, Qvoid_variable, Qwarning, Qwidth, Qwindow;
-extern Lisp_Object Qwindow_live_p, Qwindow_system, Qwrong_number_of_arguments;
-extern Lisp_Object Qwrong_type_argument, Qx, Qy, Qyes_or_no_p;
-extern Lisp_Object Vactivate_menubar_hook, Vascii_canon_table;
-extern Lisp_Object Vascii_downcase_table, Vascii_eqv_table;
-extern Lisp_Object Vascii_upcase_table, Vautoload_queue, Vbinary_process_input;
-extern Lisp_Object Vbinary_process_output, Vblank_menubar;
+extern Lisp_Object Qregion_beginning, Qregion_end;
+extern Lisp_Object Qrun_hooks, Qsans_modifiers;
+extern Lisp_Object Qsave_buffers_kill_emacs;
+extern Lisp_Object Qself_insert_command, Qself_insert_defer_undo;
+extern Lisp_Object Qsequencep, Qset, Qsetting_constant;
+extern Lisp_Object Qseven, Qshift_jis, Qshort;
+extern Lisp_Object Qsingularity_error;
+extern Lisp_Object Qstandard_input, Qstandard_output;
+extern Lisp_Object Qstart_open;
+extern Lisp_Object Qstring_lessp, Qsubwindow;
+extern Lisp_Object Qsubwindow_image_instance_p;
+extern Lisp_Object Qsyntax_error, Qt;
+extern Lisp_Object Qtext_image_instance_p;
+extern Lisp_Object Qtop_level;
+extern Lisp_Object Qtrue_list_p;
+extern Lisp_Object Qunbound, Qunderflow_error;
+extern Lisp_Object Qunderline, Quser_files_and_directories;
+extern Lisp_Object Qvalues;
+extern Lisp_Object Qvariable_documentation, Qvariable_domain;
+extern Lisp_Object Qvoid_function, Qvoid_variable;
+extern Lisp_Object Qwindow_live_p, Qwrong_number_of_arguments;
+extern Lisp_Object Qwrong_type_argument, Qyes_or_no_p;
+extern Lisp_Object Qgtk;
+
+#define SYMBOL(fou) extern Lisp_Object fou
+#define SYMBOL_KEYWORD(la_cle_est_fou) extern Lisp_Object la_cle_est_fou
+#define SYMBOL_GENERAL(tout_le_monde, est_fou) \
+  extern Lisp_Object tout_le_monde
+
+#include "general-slots.h"
+
+#undef SYMBOL
+#undef SYMBOL_KEYWORD
+#undef SYMBOL_GENERAL
+
+/*--------------- prototypes for variables of type Lisp_Object  ------------*/
+
+extern Lisp_Object Vactivate_menubar_hook;
+extern Lisp_Object Vautoload_queue, Vblank_menubar;
 extern Lisp_Object Vcharset_ascii, Vcharset_composite, Vcharset_control_1;
 extern Lisp_Object Vcoding_system_for_read, Vcoding_system_for_write;
 extern Lisp_Object Vcoding_system_hash_table, Vcommand_history;
 extern Lisp_Object Vcommand_line_args, Vconfigure_info_directory;
+extern Lisp_Object Vconfigure_site_directory, Vconfigure_site_module_directory;
 extern Lisp_Object Vconsole_list, Vcontrolling_terminal;
 extern Lisp_Object Vcurrent_compiled_function_annotation, Vcurrent_load_list;
 extern Lisp_Object Vcurrent_mouse_event, Vcurrent_prefix_arg, Vdata_directory;
-extern Lisp_Object Vdisabled_command_hook, Vdoc_directory, Vinternal_doc_file_name;
+extern Lisp_Object Vdirectory_sep_char, Vdisabled_command_hook;
+extern Lisp_Object Vdoc_directory, Vinternal_doc_file_name;
 extern Lisp_Object Vecho_area_buffer, Vemacs_major_version;
 extern Lisp_Object Vemacs_minor_version, Vexec_directory, Vexec_path;
 extern Lisp_Object Vexecuting_macro, Vfeatures, Vfile_domain;
@@ -3038,19 +3295,15 @@ extern Lisp_Object Vload_file_name_internal;
 extern Lisp_Object Vload_file_name_internal_the_purecopy, Vload_history;
 extern Lisp_Object Vload_path, Vmark_even_if_inactive, Vmenubar_configuration;
 extern Lisp_Object Vminibuf_preprompt, Vminibuf_prompt, Vminibuffer_zero;
-extern Lisp_Object Vmirror_ascii_canon_table, Vmirror_ascii_downcase_table;
-extern Lisp_Object Vmirror_ascii_eqv_table, Vmirror_ascii_upcase_table;
-extern Lisp_Object Vmswindows_downcase_file_names;
+extern Lisp_Object Vmodule_directory, Vmswindows_downcase_file_names;
 extern Lisp_Object Vmswindows_get_true_file_attributes, Vobarray;
 extern Lisp_Object Vprint_length, Vprint_level, Vprocess_environment;
-extern Lisp_Object Vpure_uninterned_symbol_table, Vquit_flag;
+extern Lisp_Object Vquit_flag;
 extern Lisp_Object Vrecent_keys_ring, Vshell_file_name, Vsite_directory;
+extern Lisp_Object Vsite_module_directory;
 extern Lisp_Object Vstandard_input, Vstandard_output, Vstdio_str;
 extern Lisp_Object Vsynchronous_sounds, Vsystem_name, Vterminal_coding_system;
 extern Lisp_Object Vthis_command_keys, Vunread_command_event;
-extern Lisp_Object Vwin32_generate_fake_inodes, Vwin32_pipe_read_delay;
 extern Lisp_Object Vx_initial_argv_list;
 
-extern Lisp_Object Qmakunbound, Qset;
-
-#endif /* _XEMACS_LISP_H_ */
+#endif /* INCLUDED_lisp_h_ */