emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 6a37ece 4/4: Port to 32-bit --with-wide-int


From: Paul Eggert
Subject: [Emacs-diffs] master 6a37ece 4/4: Port to 32-bit --with-wide-int
Date: Sat, 10 Jan 2015 21:42:43 +0000

branch: master
commit 6a37ecee0884ff30ac7666e6502e2a9d2608f291
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Port to 32-bit --with-wide-int
    
    Prefer symbol indexes to struct Lisp_Symbol * casted and then
    widened, as the latter had trouble with GCC on Fedora 21 when
    configured --with-wide-int and when used in static initializers.
    * lib-src/make-docfile.c (write_globals): Define and use symbols like
    iQnil (a small integer, like 0) rather than aQnil (an address
    constant).
    * src/alloc.c (garbage_collect_1, which_symbols):
    * src/lread.c (init_obarray):
    Prefer builtin_lisp_symbol when it can be used.
    * src/dispextern.h (struct image_type.type):
    * src/font.c (font_property_table.key):
    * src/frame.c (struct frame_parm_table.sym):
    * src/keyboard.c (scroll_bar_parts, struct event_head):
    * src/xdisp.c (struct props.name):
    Use the index of a builtin symbol rather than its address.
    All uses changed.
    * src/lisp.h (TAG_SYMPTR, XSYMBOL_INIT): Remove, replacing with ...
    (TAG_SYMOFFSET, SYMBOL_INDEX): ... new macros that deal with
    symbol indexes rather than pointers, and which work better on MSB
    hosts because they shift right before tagging.  All uses changed.
    (DEFINE_LISP_SYMBOL_BEGIN, DEFINE_LISP_SYMBOL_END):
    No longer noops on wide-int hosts, since they work now.
    (builtin_lisp_symbol): New function.
---
 lib-src/ChangeLog      |    5 +++
 lib-src/make-docfile.c |    8 ++--
 src/ChangeLog          |   22 +++++++++++++
 src/alloc.c            |    4 +-
 src/dispextern.h       |    4 +-
 src/font.c             |   38 +++++++++++-----------
 src/frame.c            |   82 ++++++++++++++++++++++++------------------------
 src/image.c            |   33 ++++++++++---------
 src/keyboard.c         |   57 ++++++++++++++++-----------------
 src/lisp.h             |   39 ++++++++++++-----------
 src/lread.c            |    2 +-
 src/xdisp.c            |   21 ++++++------
 12 files changed, 172 insertions(+), 143 deletions(-)

diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index ec4d16a..7403596 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,5 +1,10 @@
 2015-01-10  Paul Eggert  <address@hidden>
 
+       Port to 32-bit --with-wide-int
+       * make-docfile.c (write_globals): Define and use symbols like
+       iQnil (a small integer, like 0) rather than aQnil (an address
+       constant).
+
        Port to 32-bit Sun C 5.12 sparc
        * make-docfile.c (close_emacs_globals): Align lispsym to GCALIGNMENT.
        The alignment is required on all platforms; it just happens to have
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index 7c5c4bc..bc5420e 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -613,7 +613,7 @@ compare_globals (const void *a, const void *b)
   if (ga->type != gb->type)
     return ga->type - gb->type;
 
-  /* Consider "nil" to be the least, so that aQnil is firat.  That
+  /* Consider "nil" to be the least, so that iQnil is zero.  That
      way, Qnil's internal representation is zero, which is a bit faster.  */
   if (ga->type == SYMBOL)
     {
@@ -701,9 +701,9 @@ write_globals (void)
        }
       else if (globals[i].type == SYMBOL)
        printf (("DEFINE_LISP_SYMBOL_BEGIN (%s)\n"
-                "#define a%s (&lispsym[%d])\n"
-                "#define %s make_lisp_symbol (a%s)\n"
-                "DEFINE_LISP_SYMBOL_END (a%s)\n\n"),
+                "#define i%s %d\n"
+                "#define %s builtin_lisp_symbol (i%s)\n"
+                "DEFINE_LISP_SYMBOL_END (%s)\n\n"),
                globals[i].name, globals[i].name, symnum++,
                globals[i].name, globals[i].name, globals[i].name);
       else
diff --git a/src/ChangeLog b/src/ChangeLog
index 39775eb..14d582d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,27 @@
 2015-01-10  Paul Eggert  <address@hidden>
 
+       Port to 32-bit --with-wide-int
+       Prefer symbol indexes to struct Lisp_Symbol * casted and then
+       widened, as the latter had trouble with GCC on Fedora 21 when
+       configured --with-wide-int and when used in static initializers.
+       * alloc.c (garbage_collect_1, which_symbols):
+       * lread.c (init_obarray):
+       Prefer builtin_lisp_symbol when it can be used.
+       * dispextern.h (struct image_type.type):
+       * font.c (font_property_table.key):
+       * frame.c (struct frame_parm_table.sym):
+       * keyboard.c (scroll_bar_parts, struct event_head):
+       * xdisp.c (struct props.name):
+       Use the index of a builtin symbol rather than its address.
+       All uses changed.
+       * lisp.h (TAG_SYMPTR, XSYMBOL_INIT): Remove, replacing with ...
+       (TAG_SYMOFFSET, SYMBOL_INDEX): ... new macros that deal with
+       symbol indexes rather than pointers, and which work better on MSB
+       hosts because they shift right before tagging.  All uses changed.
+       (DEFINE_LISP_SYMBOL_BEGIN, DEFINE_LISP_SYMBOL_END):
+       No longer noops on wide-int hosts, since they work now.
+       (builtin_lisp_symbol): New function.
+
        Port to HAVE_FREETYPE && !HAVE_XFT
        * dispextern.h (struct face.extra) [HAVE_FREETYPE && !HAVE_XFT]:
        * font.h (syms_of_xftfont) [HAVE_FREETYPE && !HAVE_XFT]:
diff --git a/src/alloc.c b/src/alloc.c
index 712c8f7..7c93733 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -5630,7 +5630,7 @@ garbage_collect_1 (void *end)
   mark_buffer (&buffer_local_symbols);
 
   for (i = 0; i < ARRAYELTS (lispsym); i++)
-    mark_object (make_lisp_symbol (&lispsym[i]));
+    mark_object (builtin_lisp_symbol (i));
 
   for (i = 0; i < staticidx; i++)
     mark_object (*staticvec[i]);
@@ -7019,7 +7019,7 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max)
      {
        for (int i = 0; i < ARRAYELTS (lispsym); i++)
         {
-          Lisp_Object sym = make_lisp_symbol (&lispsym[i]);
+          Lisp_Object sym = builtin_lisp_symbol (i);
           if (symbol_uses_obj (sym, obj))
             {
               found = Fcons (sym, found);
diff --git a/src/dispextern.h b/src/dispextern.h
index 161f252..e9e6f70 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2906,8 +2906,8 @@ struct redisplay_interface
 
 struct image_type
 {
-  /* A symbol uniquely identifying the image type, e.g., 'jpeg'.  */
-  struct Lisp_Symbol *type;
+  /* Index of a symbol uniquely identifying the image type, e.g., 'jpeg'.  */
+  int type;
 
   /* Check that SPEC is a valid image specification for the given
      image type.  Value is true if SPEC is valid.  */
diff --git a/src/font.c b/src/font.c
index 60134b1..a68c3c7 100644
--- a/src/font.c
+++ b/src/font.c
@@ -639,30 +639,30 @@ font_prop_validate_otf (Lisp_Object prop, Lisp_Object val)
    values.  */
 static const struct
 {
-  /* Pointer to the key symbol.  */
-  struct Lisp_Symbol *key;
+  /* Index of the key symbol.  */
+  int key;
   /* Function to validate PROP's value VAL, or NULL if any value is
      ok.  The value is VAL or its regularized value if VAL is valid,
      and Qerror if not.  */
   Lisp_Object (*validator) (Lisp_Object prop, Lisp_Object val);
 } font_property_table[] =
-  { { XSYMBOL_INIT (QCtype), font_prop_validate_symbol },
-    { XSYMBOL_INIT (QCfoundry), font_prop_validate_symbol },
-    { XSYMBOL_INIT (QCfamily), font_prop_validate_symbol },
-    { XSYMBOL_INIT (QCadstyle), font_prop_validate_symbol },
-    { XSYMBOL_INIT (QCregistry), font_prop_validate_symbol },
-    { XSYMBOL_INIT (QCweight), font_prop_validate_style },
-    { XSYMBOL_INIT (QCslant), font_prop_validate_style },
-    { XSYMBOL_INIT (QCwidth), font_prop_validate_style },
-    { XSYMBOL_INIT (QCsize), font_prop_validate_non_neg },
-    { XSYMBOL_INIT (QCdpi), font_prop_validate_non_neg },
-    { XSYMBOL_INIT (QCspacing), font_prop_validate_spacing },
-    { XSYMBOL_INIT (QCavgwidth), font_prop_validate_non_neg },
+  { { SYMBOL_INDEX (QCtype), font_prop_validate_symbol },
+    { SYMBOL_INDEX (QCfoundry), font_prop_validate_symbol },
+    { SYMBOL_INDEX (QCfamily), font_prop_validate_symbol },
+    { SYMBOL_INDEX (QCadstyle), font_prop_validate_symbol },
+    { SYMBOL_INDEX (QCregistry), font_prop_validate_symbol },
+    { SYMBOL_INDEX (QCweight), font_prop_validate_style },
+    { SYMBOL_INDEX (QCslant), font_prop_validate_style },
+    { SYMBOL_INDEX (QCwidth), font_prop_validate_style },
+    { SYMBOL_INDEX (QCsize), font_prop_validate_non_neg },
+    { SYMBOL_INDEX (QCdpi), font_prop_validate_non_neg },
+    { SYMBOL_INDEX (QCspacing), font_prop_validate_spacing },
+    { SYMBOL_INDEX (QCavgwidth), font_prop_validate_non_neg },
     /* The order of the above entries must match with enum
        font_property_index.  */
-    { XSYMBOL_INIT (QClang), font_prop_validate_symbol },
-    { XSYMBOL_INIT (QCscript), font_prop_validate_symbol },
-    { XSYMBOL_INIT (QCotf), font_prop_validate_otf }
+    { SYMBOL_INDEX (QClang), font_prop_validate_symbol },
+    { SYMBOL_INDEX (QCscript), font_prop_validate_symbol },
+    { SYMBOL_INDEX (QCotf), font_prop_validate_otf }
   };
 
 /* Return an index number of font property KEY or -1 if KEY is not an
@@ -674,7 +674,7 @@ get_font_prop_index (Lisp_Object key)
   int i;
 
   for (i = 0; i < ARRAYELTS (font_property_table); i++)
-    if (EQ (key, make_lisp_symbol (font_property_table[i].key)))
+    if (EQ (key, builtin_lisp_symbol (font_property_table[i].key)))
       return i;
   return -1;
 }
@@ -691,7 +691,7 @@ font_prop_validate (int idx, Lisp_Object prop, Lisp_Object 
val)
   if (NILP (val))
     return val;
   if (NILP (prop))
-    prop = make_lisp_symbol (font_property_table[idx].key);
+    prop = builtin_lisp_symbol (font_property_table[idx].key);
   else
     {
       idx = get_font_prop_index (prop);
diff --git a/src/frame.c b/src/frame.c
index fb9bf2e..3d2ffbf 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -2925,48 +2925,48 @@ or bottommost possible position (that stays within the 
screen).  */)
 
 struct frame_parm_table {
   const char *name;
-  struct Lisp_Symbol *sym;
+  int sym;
 };
 
 static const struct frame_parm_table frame_parms[] =
 {
-  {"auto-raise",               XSYMBOL_INIT (Qauto_raise)},
-  {"auto-lower",               XSYMBOL_INIT (Qauto_lower)},
-  {"background-color",         0},
-  {"border-color",             XSYMBOL_INIT (Qborder_color)},
-  {"border-width",             XSYMBOL_INIT (Qborder_width)},
-  {"cursor-color",             XSYMBOL_INIT (Qcursor_color)},
-  {"cursor-type",              XSYMBOL_INIT (Qcursor_type)},
-  {"font",                     0},
-  {"foreground-color",         0},
-  {"icon-name",                        XSYMBOL_INIT (Qicon_name)},
-  {"icon-type",                        XSYMBOL_INIT (Qicon_type)},
-  {"internal-border-width",    XSYMBOL_INIT (Qinternal_border_width)},
-  {"right-divider-width",      XSYMBOL_INIT (Qright_divider_width)},
-  {"bottom-divider-width",     XSYMBOL_INIT (Qbottom_divider_width)},
-  {"menu-bar-lines",           XSYMBOL_INIT (Qmenu_bar_lines)},
-  {"mouse-color",              XSYMBOL_INIT (Qmouse_color)},
-  {"name",                     XSYMBOL_INIT (Qname)},
-  {"scroll-bar-width",         XSYMBOL_INIT (Qscroll_bar_width)},
-  {"scroll-bar-height",                XSYMBOL_INIT (Qscroll_bar_height)},
-  {"title",                    XSYMBOL_INIT (Qtitle)},
-  {"unsplittable",             XSYMBOL_INIT (Qunsplittable)},
-  {"vertical-scroll-bars",     XSYMBOL_INIT (Qvertical_scroll_bars)},
-  {"horizontal-scroll-bars",   XSYMBOL_INIT (Qhorizontal_scroll_bars)},
-  {"visibility",               XSYMBOL_INIT (Qvisibility)},
-  {"tool-bar-lines",           XSYMBOL_INIT (Qtool_bar_lines)},
-  {"scroll-bar-foreground",    XSYMBOL_INIT (Qscroll_bar_foreground)},
-  {"scroll-bar-background",    XSYMBOL_INIT (Qscroll_bar_background)},
-  {"screen-gamma",             XSYMBOL_INIT (Qscreen_gamma)},
-  {"line-spacing",             XSYMBOL_INIT (Qline_spacing)},
-  {"left-fringe",              XSYMBOL_INIT (Qleft_fringe)},
-  {"right-fringe",             XSYMBOL_INIT (Qright_fringe)},
-  {"wait-for-wm",              XSYMBOL_INIT (Qwait_for_wm)},
-  {"fullscreen",                XSYMBOL_INIT (Qfullscreen)},
-  {"font-backend",             XSYMBOL_INIT (Qfont_backend)},
-  {"alpha",                    XSYMBOL_INIT (Qalpha)},
-  {"sticky",                   XSYMBOL_INIT (Qsticky)},
-  {"tool-bar-position",                XSYMBOL_INIT (Qtool_bar_position)},
+  {"auto-raise",               SYMBOL_INDEX (Qauto_raise)},
+  {"auto-lower",               SYMBOL_INDEX (Qauto_lower)},
+  {"background-color",         -1},
+  {"border-color",             SYMBOL_INDEX (Qborder_color)},
+  {"border-width",             SYMBOL_INDEX (Qborder_width)},
+  {"cursor-color",             SYMBOL_INDEX (Qcursor_color)},
+  {"cursor-type",              SYMBOL_INDEX (Qcursor_type)},
+  {"font",                     -1},
+  {"foreground-color",         -1},
+  {"icon-name",                        SYMBOL_INDEX (Qicon_name)},
+  {"icon-type",                        SYMBOL_INDEX (Qicon_type)},
+  {"internal-border-width",    SYMBOL_INDEX (Qinternal_border_width)},
+  {"right-divider-width",      SYMBOL_INDEX (Qright_divider_width)},
+  {"bottom-divider-width",     SYMBOL_INDEX (Qbottom_divider_width)},
+  {"menu-bar-lines",           SYMBOL_INDEX (Qmenu_bar_lines)},
+  {"mouse-color",              SYMBOL_INDEX (Qmouse_color)},
+  {"name",                     SYMBOL_INDEX (Qname)},
+  {"scroll-bar-width",         SYMBOL_INDEX (Qscroll_bar_width)},
+  {"scroll-bar-height",                SYMBOL_INDEX (Qscroll_bar_height)},
+  {"title",                    SYMBOL_INDEX (Qtitle)},
+  {"unsplittable",             SYMBOL_INDEX (Qunsplittable)},
+  {"vertical-scroll-bars",     SYMBOL_INDEX (Qvertical_scroll_bars)},
+  {"horizontal-scroll-bars",   SYMBOL_INDEX (Qhorizontal_scroll_bars)},
+  {"visibility",               SYMBOL_INDEX (Qvisibility)},
+  {"tool-bar-lines",           SYMBOL_INDEX (Qtool_bar_lines)},
+  {"scroll-bar-foreground",    SYMBOL_INDEX (Qscroll_bar_foreground)},
+  {"scroll-bar-background",    SYMBOL_INDEX (Qscroll_bar_background)},
+  {"screen-gamma",             SYMBOL_INDEX (Qscreen_gamma)},
+  {"line-spacing",             SYMBOL_INDEX (Qline_spacing)},
+  {"left-fringe",              SYMBOL_INDEX (Qleft_fringe)},
+  {"right-fringe",             SYMBOL_INDEX (Qright_fringe)},
+  {"wait-for-wm",              SYMBOL_INDEX (Qwait_for_wm)},
+  {"fullscreen",                SYMBOL_INDEX (Qfullscreen)},
+  {"font-backend",             SYMBOL_INDEX (Qfont_backend)},
+  {"alpha",                    SYMBOL_INDEX (Qalpha)},
+  {"sticky",                   SYMBOL_INDEX (Qsticky)},
+  {"tool-bar-position",                SYMBOL_INDEX (Qtool_bar_position)},
 };
 
 #ifdef HAVE_WINDOW_SYSTEM
@@ -4824,9 +4824,9 @@ syms_of_frame (void)
 
     for (i = 0; i < ARRAYELTS (frame_parms); i++)
       {
-       Lisp_Object v = (frame_parms[i].sym
-                        ? make_lisp_symbol (frame_parms[i].sym)
-                        : intern_c_string (frame_parms[i].name));
+       Lisp_Object v = (frame_parms[i].sym < 0
+                        ? intern_c_string (frame_parms[i].name)
+                        : builtin_lisp_symbol (frame_parms[i].sym));
        Fput (v, Qx_frame_parameter, make_number (i));
       }
   }
diff --git a/src/image.c b/src/image.c
index addb932..5d08a89 100644
--- a/src/image.c
+++ b/src/image.c
@@ -548,8 +548,8 @@ static struct image_type *
 define_image_type (struct image_type *type)
 {
   struct image_type *p = NULL;
-  struct Lisp_Symbol *new_type = type->type;
-  bool type_valid = 1;
+  int new_type = type->type;
+  bool type_valid = true;
 
   block_input ();
 
@@ -561,14 +561,15 @@ define_image_type (struct image_type *type)
     {
 #if defined HAVE_NTGUI && defined WINDOWSNT
       /* If we failed to load the library before, don't try again.  */
-      Lisp_Object tested = Fassq (make_lisp_symbol (new_type), Vlibrary_cache);
+      Lisp_Object tested = Fassq (builtin_lisp_symbol (new_type),
+                                 Vlibrary_cache);
       if (CONSP (tested) && NILP (XCDR (tested)))
-       type_valid = 0;
+       type_valid = false;
       else
 #endif
        {
          type_valid = type->init ();
-         CACHE_IMAGE_TYPE (make_lisp_symbol (new_type),
+         CACHE_IMAGE_TYPE (builtin_lisp_symbol (new_type),
                            type_valid ? Qt : Qnil);
        }
     }
@@ -1747,7 +1748,7 @@ lookup_image (struct frame *f, Lisp_Object spec)
 
          /* Do image transformations and compute masks, unless we
             don't have the image yet.  */
-         if (!EQ (make_lisp_symbol (img->type->type), Qpostscript))
+         if (!EQ (builtin_lisp_symbol (img->type->type), Qpostscript))
            postprocess_image (f, img);
        }
 
@@ -2332,7 +2333,7 @@ static const struct image_keyword xbm_format[XBM_LAST] =
 
 static struct image_type xbm_type =
 {
-  XSYMBOL_INIT (Qxbm),
+  SYMBOL_INDEX (Qxbm),
   xbm_image_p,
   xbm_load,
   x_clear_image,
@@ -3138,7 +3139,7 @@ static bool init_xpm_functions (void);
 
 static struct image_type xpm_type =
 {
-  XSYMBOL_INIT (Qxpm),
+  SYMBOL_INDEX (Qxpm),
   xpm_image_p,
   xpm_load,
   x_clear_image,
@@ -5066,7 +5067,7 @@ static const struct image_keyword pbm_format[PBM_LAST] =
 
 static struct image_type pbm_type =
 {
-  XSYMBOL_INIT (Qpbm),
+  SYMBOL_INDEX (Qpbm),
   pbm_image_p,
   pbm_load,
   x_clear_image,
@@ -5453,7 +5454,7 @@ static bool init_png_functions (void);
 
 static struct image_type png_type =
 {
-  XSYMBOL_INIT (Qpng),
+  SYMBOL_INDEX (Qpng),
   png_image_p,
   png_load,
   x_clear_image,
@@ -6105,7 +6106,7 @@ static bool init_jpeg_functions (void);
 
 static struct image_type jpeg_type =
 {
-  XSYMBOL_INIT (Qjpeg),
+  SYMBOL_INDEX (Qjpeg),
   jpeg_image_p,
   jpeg_load,
   x_clear_image,
@@ -6705,7 +6706,7 @@ static bool init_tiff_functions (void);
 
 static struct image_type tiff_type =
 {
-  XSYMBOL_INIT (Qtiff),
+  SYMBOL_INDEX (Qtiff),
   tiff_image_p,
   tiff_load,
   x_clear_image,
@@ -7164,7 +7165,7 @@ static bool init_gif_functions (void);
 
 static struct image_type gif_type =
 {
-  XSYMBOL_INIT (Qgif),
+  SYMBOL_INDEX (Qgif),
   gif_image_p,
   gif_load,
   gif_clear_image,
@@ -7851,7 +7852,7 @@ static bool init_imagemagick_functions (void);
 
 static struct image_type imagemagick_type =
   {
-    XSYMBOL_INIT (Qimagemagick),
+    SYMBOL_INDEX (Qimagemagick),
     imagemagick_image_p,
     imagemagick_load,
     imagemagick_clear_image,
@@ -8623,7 +8624,7 @@ static bool init_svg_functions (void);
 
 static struct image_type svg_type =
 {
-  XSYMBOL_INIT (Qsvg),
+  SYMBOL_INDEX (Qsvg),
   svg_image_p,
   svg_load,
   x_clear_image,
@@ -9039,7 +9040,7 @@ static const struct image_keyword gs_format[GS_LAST] =
 
 static struct image_type gs_type =
 {
-  XSYMBOL_INIT (Qpostscript),
+  SYMBOL_INDEX (Qpostscript),
   gs_image_p,
   gs_load,
   gs_clear_image,
diff --git a/src/keyboard.c b/src/keyboard.c
index 2a50003..5411aff 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5164,17 +5164,17 @@ static const char *const lispy_drag_n_drop_names[] =
   "drag-n-drop"
 };
 
-/* An array of scroll bar parts, indexed by an enum scroll_bar_part value.
-   Note that Qnil corresponds to scroll_bar_nowhere and should not appear
-   in Lisp events.  */
-static struct Lisp_Symbol *const scroll_bar_parts[] = {
-  XSYMBOL_INIT (Qnil), XSYMBOL_INIT (Qabove_handle), XSYMBOL_INIT (Qhandle),
-  XSYMBOL_INIT (Qbelow_handle), XSYMBOL_INIT (Qup), XSYMBOL_INIT (Qdown),
-  XSYMBOL_INIT (Qtop), XSYMBOL_INIT (Qbottom), XSYMBOL_INIT (Qend_scroll),
-  XSYMBOL_INIT (Qratio), XSYMBOL_INIT (Qbefore_handle),
-  XSYMBOL_INIT (Qhorizontal_handle), XSYMBOL_INIT (Qafter_handle),
-  XSYMBOL_INIT (Qleft), XSYMBOL_INIT (Qright), XSYMBOL_INIT (Qleftmost),
-  XSYMBOL_INIT (Qrightmost), XSYMBOL_INIT (Qend_scroll), XSYMBOL_INIT (Qratio)
+/* An array of symbol indexes of scroll bar parts, indexed by an enum
+   scroll_bar_part value.  Note that Qnil corresponds to
+   scroll_bar_nowhere and should not appear in Lisp events.  */
+static short const scroll_bar_parts[] = {
+  SYMBOL_INDEX (Qnil), SYMBOL_INDEX (Qabove_handle), SYMBOL_INDEX (Qhandle),
+  SYMBOL_INDEX (Qbelow_handle), SYMBOL_INDEX (Qup), SYMBOL_INDEX (Qdown),
+  SYMBOL_INDEX (Qtop), SYMBOL_INDEX (Qbottom), SYMBOL_INDEX (Qend_scroll),
+  SYMBOL_INDEX (Qratio), SYMBOL_INDEX (Qbefore_handle),
+  SYMBOL_INDEX (Qhorizontal_handle), SYMBOL_INDEX (Qafter_handle),
+  SYMBOL_INDEX (Qleft), SYMBOL_INDEX (Qright), SYMBOL_INDEX (Qleftmost),
+  SYMBOL_INDEX (Qrightmost), SYMBOL_INDEX (Qend_scroll), SYMBOL_INDEX (Qratio)
 };
 
 /* A vector, indexed by button number, giving the down-going location
@@ -5448,7 +5448,7 @@ make_scroll_bar_position (struct input_event *ev, 
Lisp_Object type)
 {
   return list5 (ev->frame_or_window, type, Fcons (ev->x, ev->y),
                make_number (ev->timestamp),
-               make_lisp_symbol (scroll_bar_parts[ev->part]));
+               builtin_lisp_symbol (scroll_bar_parts[ev->part]));
 }
 
 /* Given a struct input_event, build the lisp event which represents
@@ -6087,7 +6087,7 @@ make_lispy_movement (struct frame *frame, Lisp_Object 
bar_window, enum scroll_ba
     {
       Lisp_Object part_sym;
 
-      part_sym = make_lisp_symbol (scroll_bar_parts[part]);
+      part_sym = builtin_lisp_symbol (scroll_bar_parts[part]);
       return list2 (Qscroll_bar_movement,
                    list5 (bar_window,
                           Qvertical_scroll_bar,
@@ -10986,28 +10986,27 @@ init_keyboard (void)
 
 /* This type's only use is in syms_of_keyboard, to put properties on the
    event header symbols.  */
-struct event_head {
-  struct Lisp_Symbol *var;
-  struct Lisp_Symbol *kind;
+struct event_head
+{
+  short var;
+  short kind;
 };
 
-
-
 static const struct event_head head_table[] = {
-  {XSYMBOL_INIT (Qmouse_movement),      XSYMBOL_INIT (Qmouse_movement)},
-  {XSYMBOL_INIT (Qscroll_bar_movement), XSYMBOL_INIT (Qmouse_movement)},
+  {SYMBOL_INDEX (Qmouse_movement),      SYMBOL_INDEX (Qmouse_movement)},
+  {SYMBOL_INDEX (Qscroll_bar_movement), SYMBOL_INDEX (Qmouse_movement)},
 
   /* Some of the event heads.  */
-  {XSYMBOL_INIT (Qswitch_frame),        XSYMBOL_INIT (Qswitch_frame)},
+  {SYMBOL_INDEX (Qswitch_frame),        SYMBOL_INDEX (Qswitch_frame)},
 
-  {XSYMBOL_INIT (Qfocus_in),            XSYMBOL_INIT (Qfocus_in)},
-  {XSYMBOL_INIT (Qfocus_out),           XSYMBOL_INIT (Qfocus_out)},
-  {XSYMBOL_INIT (Qdelete_frame),        XSYMBOL_INIT (Qdelete_frame)},
-  {XSYMBOL_INIT (Qiconify_frame),       XSYMBOL_INIT (Qiconify_frame)},
-  {XSYMBOL_INIT (Qmake_frame_visible),  XSYMBOL_INIT (Qmake_frame_visible)},
+  {SYMBOL_INDEX (Qfocus_in),            SYMBOL_INDEX (Qfocus_in)},
+  {SYMBOL_INDEX (Qfocus_out),           SYMBOL_INDEX (Qfocus_out)},
+  {SYMBOL_INDEX (Qdelete_frame),        SYMBOL_INDEX (Qdelete_frame)},
+  {SYMBOL_INDEX (Qiconify_frame),       SYMBOL_INDEX (Qiconify_frame)},
+  {SYMBOL_INDEX (Qmake_frame_visible),  SYMBOL_INDEX (Qmake_frame_visible)},
   /* `select-window' should be handled just like `switch-frame'
      in read_key_sequence.  */
-  {XSYMBOL_INIT (Qselect_window),       XSYMBOL_INIT (Qswitch_frame)}
+  {SYMBOL_INDEX (Qselect_window),       SYMBOL_INDEX (Qswitch_frame)}
 };
 
 void
@@ -11180,8 +11179,8 @@ syms_of_keyboard (void)
     for (i = 0; i < ARRAYELTS (head_table); i++)
       {
        const struct event_head *p = &head_table[i];
-       Lisp_Object var = make_lisp_symbol (p->var);
-       Lisp_Object kind = make_lisp_symbol (p->kind);
+       Lisp_Object var = builtin_lisp_symbol (p->var);
+       Lisp_Object kind = builtin_lisp_symbol (p->kind);
        Fput (var, Qevent_kind, kind);
        Fput (var, Qevent_symbol_elements, list1 (var));
       }
diff --git a/src/lisp.h b/src/lisp.h
index ab72bf1..1fa1deb 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -725,25 +725,20 @@ struct Lisp_Symbol
 #define TAG_PTR(tag, ptr) \
   ((USE_LSB_TAG ? (tag) : (EMACS_UINT) (tag) << VALBITS) + (uintptr_t) (ptr))
 
-/* Yield an integer that tags PTR as a symbol.  */
-#define TAG_SYMPTR(ptr)                                            \
+/* Yield an integer that contains a symbol tag along with OFFSET.
+   OFFSET should be the offset in bytes from 'lispsym' to the symbol.  */
+#define TAG_SYMOFFSET(offset)                              \
   TAG_PTR (Lisp_Symbol,                                            \
-          ((uintptr_t) ((char *) (ptr) - (char *) lispsym) \
-           >> (USE_LSB_TAG ? 0 : GCTYPEBITS)))
+          ((uintptr_t) (offset) >> (USE_LSB_TAG ? 0 : GCTYPEBITS)))
 
 /* Declare extern constants for Lisp symbols.  These can be helpful
    when using a debugger like GDB, on older platforms where the debug
-   format does not represent C macros.  However, they don't work with
-   GCC if INTPTR_MAX != EMACS_INT_MAX.  */
-#if EMACS_INT_MAX == INTPTR_MAX
-# define DEFINE_LISP_SYMBOL_BEGIN(name) \
-    DEFINE_GDB_SYMBOL_BEGIN (Lisp_Object, name)
-# define DEFINE_LISP_SYMBOL_END(name) \
-    DEFINE_GDB_SYMBOL_END (LISP_INITIALLY (TAG_SYMPTR (name)))
-#else
-# define DEFINE_LISP_SYMBOL_BEGIN(name) /* empty */
-# define DEFINE_LISP_SYMBOL_END(name) /* empty */
-#endif
+   format does not represent C macros.  */
+#define DEFINE_LISP_SYMBOL_BEGIN(name) \
+   DEFINE_GDB_SYMBOL_BEGIN (Lisp_Object, name)
+#define DEFINE_LISP_SYMBOL_END(name) \
+   DEFINE_GDB_SYMBOL_END (LISP_INITIALLY (TAG_SYMOFFSET (i##name \
+                                                        * sizeof *lispsym)))
 
 #include "globals.h"
 
@@ -973,9 +968,9 @@ XSTRING (Lisp_Object a)
   return XUNTAG (a, Lisp_String);
 }
 
-/* XSYMBOL_INIT (Qfoo) is like XSYMBOL (Qfoo), except it is valid in
-   static initializers, and SYM must be a C-defined symbol.  */
-#define XSYMBOL_INIT(sym) a##sym
+/* The index of the C-defined Lisp symbol SYM.
+   This can be used in a static initializer.  */
+#define SYMBOL_INDEX(sym) i##sym
 
 INLINE struct Lisp_Float *
 XFLOAT (Lisp_Object a)
@@ -1054,12 +1049,18 @@ make_lisp_ptr (void *ptr, enum Lisp_Type type)
 INLINE Lisp_Object
 make_lisp_symbol (struct Lisp_Symbol *sym)
 {
-  Lisp_Object a = XIL (TAG_SYMPTR (sym));
+  Lisp_Object a = XIL (TAG_SYMOFFSET ((char *) sym - (char *) lispsym));
   eassert (XSYMBOL (a) == sym);
   return a;
 }
 
 INLINE Lisp_Object
+builtin_lisp_symbol (int index)
+{
+  return make_lisp_symbol (lispsym + index);
+}
+
+INLINE Lisp_Object
 make_lisp_proc (struct Lisp_Process *p)
 {
   return make_lisp_ptr (p, Lisp_Vectorlike);
diff --git a/src/lread.c b/src/lread.c
index 3240524..7f7bd89 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -4058,7 +4058,7 @@ init_obarray (void)
   staticpro (&initial_obarray);
 
   for (int i = 0; i < ARRAYELTS (lispsym); i++)
-    define_symbol (make_lisp_symbol (&lispsym[i]), defsym_name[i]);
+    define_symbol (builtin_lisp_symbol (i), defsym_name[i]);
 
   DEFSYM (Qunbound, "unbound");
 
diff --git a/src/xdisp.c b/src/xdisp.c
index 36babfa..31702ed 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -622,8 +622,8 @@ enum prop_handled
 
 struct props
 {
-  /* The name of the property.  */
-  struct Lisp_Symbol *name;
+  /* The symbol index of the name of the property.  */
+  short name;
 
   /* A unique index for the property.  */
   enum prop_idx idx;
@@ -644,14 +644,14 @@ static enum prop_handled handle_fontified_prop (struct it 
*);
 
 static struct props it_props[] =
 {
-  {XSYMBOL_INIT (Qfontified),          FONTIFIED_PROP_IDX,     
handle_fontified_prop},
+  {SYMBOL_INDEX (Qfontified),  FONTIFIED_PROP_IDX,     handle_fontified_prop},
   /* Handle `face' before `display' because some sub-properties of
      `display' need to know the face.  */
-  {XSYMBOL_INIT (Qface),               FACE_PROP_IDX,          
handle_face_prop},
-  {XSYMBOL_INIT (Qdisplay),            DISPLAY_PROP_IDX,       
handle_display_prop},
-  {XSYMBOL_INIT (Qinvisible),          INVISIBLE_PROP_IDX,     
handle_invisible_prop},
-  {XSYMBOL_INIT (Qcomposition),        COMPOSITION_PROP_IDX,   
handle_composition_prop},
-  {NULL,               0,                      NULL}
+  {SYMBOL_INDEX (Qface),       FACE_PROP_IDX,          handle_face_prop},
+  {SYMBOL_INDEX (Qdisplay),    DISPLAY_PROP_IDX,       handle_display_prop},
+  {SYMBOL_INDEX (Qinvisible),  INVISIBLE_PROP_IDX,     handle_invisible_prop},
+  {SYMBOL_INDEX (Qcomposition),        COMPOSITION_PROP_IDX, 
handle_composition_prop},
+  {0,                          0,                      NULL}
 };
 
 /* Value is the position described by X.  If X is a marker, value is
@@ -3516,7 +3516,8 @@ compute_stop_pos (struct it *it)
 
       /* Get properties here.  */
       for (p = it_props; p->handler; ++p)
-       values_here[p->idx] = textget (iv->plist, make_lisp_symbol (p->name));
+       values_here[p->idx] = textget (iv->plist,
+                                      builtin_lisp_symbol (p->name));
 
       /* Look for an interval following iv that has different
         properties.  */
@@ -3529,7 +3530,7 @@ compute_stop_pos (struct it *it)
          for (p = it_props; p->handler; ++p)
            {
              Lisp_Object new_value = textget (next_iv->plist,
-                                              make_lisp_symbol (p->name));
+                                              builtin_lisp_symbol (p->name));
              if (!EQ (values_here[p->idx], new_value))
                break;
            }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]