Simplify export of symbols to GDB; fix related .gdbinit bugs.
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 26 Jul 2012 08:12:03 +0000 (01:12 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 26 Jul 2012 08:12:03 +0000 (01:12 -0700)
* etc/emacs-buffer.gdb ($tagmask, $valmask): Remove.
(ygetptr): Adjust to recent changes in lisp.h and emacs.c,
by using VALMASK instead of $valmask, CHECK_LISP_OBJECT_TYPE
instead of gdb_use_union, and DATA_SEG_BITS instead of
gdb_data_seg_bits.  Also, use $ptr.i rather than $ptr.u.val.
* src/.gdbinit (xgetptr, xgetint, xgettype): Don't use "set $bugfix =
$bugfix.i", as this doesn't work (with GDB 7.4.1, anyway).
(xgetptr, xgetint, xgettype, xcoding, xcharset, xprintbytestr):
Adjust to changes in lisp.h and emacs.c, by using
CHECK_LISP_OBJECT_TYPE rather than gdb_use_struct, VALMASK instead
of $valmask, DATA_SEG_BITS instead of gdb_data_seg_bits,
INTTYPEBITS instead of gdb_gctypebits - 1, USE_LSB_TAG instead of
gdb_use_lsb, (1 << GCTYPEBITS) - 1 instead of $tagmask, VALBITS
instead of gdb_valbits.
(xvectype, xvector, xpr, xprintstr, xbacktrace): Similarly, use
PSEUDOVECTOR_FLAG instead of PVEC_FLAG, and ARRAY_MARK_FLAG
instead of gdb_array_mark_flag.
(xboolvector): Get size from $->size, not $->header.size.
Use BOOL_VECTOR_BITS_PER_CHAR rather than mystery constants.
(xreload, hook-run, hookpost-run): Remove.
* src/emacs.c: Include <verify.h>.
(gdb_use_lsb, gdb_use_struct, gdb_valbits, gdb_gctypebits)
(gdb_data_seg_bits, PVEC_FLAG, gdb_array_mark_flag, gdb_pvec_type):
Remove.
(gdb_CHECK_LISP_OBJECT_TYPE, gdb_DATA_SEG_BITS, gdb_GCTYPEBITS)
(gdb_USE_LSB_TAG): New enum constants.
(CHECK_LISP_OBJECT_TYPE, DATA_SEG_BITS, GCTYPEBITS, USE_LSB_TAG):
Also define these as enum constants, so they're visible to GDB.
(ARRAY_MARK_FLAG_VAL, PSEUDOVECTOR_FLAG_VAL, VALMASK_VAL): New macros.
(ARRAY_MARK_FLAG, PSEUDOVECTOR_FLAG, VALMASK): Also define these
as constants, so they're visible to GDB.
* src/lisp.h (VALBITS, INTTYPEBITS, FIXNUM_BITS, PSEUDOVECTOR_SIZE_BITS)
(PSEUDOVECTOR_SIZE_MASK, PVEC_TYPE_MASK, BOOL_VECTOR_BITS_PER_CHAR):
Now enum constants, not macros, so they're visible to GDB.
(CHECK_LISP_OBJECT_TYPE, DATA_SEG_BITS): Default to 0, as this is
more convenient now.  All uses changed.
(VALMASK) [USE_LSB_TAG]: Also define in this case.
* src/mem-limits.h (EXCEEDS_LISP_PTR): Adjust to DATA_SEG_BITS change.

etc/ChangeLog
etc/emacs-buffer.gdb
src/.gdbinit
src/ChangeLog
src/emacs.c
src/lisp.h
src/mem-limits.h

index 15cc006..1d7438b 100644 (file)
@@ -1,3 +1,12 @@
+2012-07-26  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Simplify export of symbols to GDB.
+       * emacs-buffer.gdb ($tagmask, $valmask): Remove.
+       (ygetptr): Adjust to recent changes in lisp.h and emacs.c,
+       by using VALMASK instead of $valmask, CHECK_LISP_OBJECT_TYPE
+       instead of gdb_use_union, and DATA_SEG_BITS instead of
+       gdb_data_seg_bits.  Also, use $ptr.i rather than $ptr.u.val.
+
 2012-07-20  Eli Zaretskii  <eliz@gnu.org>
 
        * tutorials/TUTORIAL.he: Make the first sentence display correctly
index 80f69c5..f2584a2 100644 (file)
 
 # Code:
 
-# Force loading of symbols, enough to give us gdb_valbits etc.
+# Force loading of symbols, enough to give us VALMASK etc.
 set main
 
 # When nonzero, display some extra diagnostics in various commands
 set $yverbose = 1
 set $yfile_buffers_only = 0
 
-set $tagmask = (((long)1 << gdb_gctypebits) - 1)
-# The consing_since_gc business widens the 1 to EMACS_INT,
-# a symbol not directly visible to GDB.
-set $valmask = gdb_use_lsb ? ~($tagmask) : ((consing_since_gc - consing_since_gc + 1) << gdb_valbits) - 1
-
 define ygetptr
   set $ptr = $arg0
-  set $ptr = (gdb_use_union ? $ptr.u.val : $ptr & $valmask) | gdb_data_seg_bits
+  set $ptr = ((CHECK_LISP_OBJECT_TYPE ? $ptr.i : $ptr) & VALMASK) | DATA_SEG_BITS
 end
 
 define ybuffer-list
index 379a14b..c044b40 100644 (file)
@@ -17,7 +17,7 @@
 # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 # Boston, MA 02110-1301, USA.
 
-# Force loading of symbols, enough to give us gdb_valbits etc.
+# Force loading of symbols, enough to give us VALBITS etc.
 set main
 # With some compilers, we need this to give us struct Lisp_Symbol etc.:
 set Fmake_symbol
@@ -43,32 +43,21 @@ handle SIGUSR2 noprint pass
 # debugging.
 handle SIGALRM ignore
 
-# $valmask and $tagmask are mask values set up by the xreload macro below.
-
 # Use $bugfix so that the value isn't a constant.
 # Using a constant runs into GDB bugs sometimes.
 define xgetptr
-  set $bugfix = $arg0
-  if gdb_use_struct
-    set $bugfix = $bugfix.i
-  end
-  set $ptr = $bugfix & $valmask | gdb_data_seg_bits
+  set $bugfix = CHECK_LISP_OBJECT_TYPE ? $arg0.i : $arg0
+  set $ptr = ($bugfix & VALMASK) | DATA_SEG_BITS
 end
 
 define xgetint
-  set $bugfix = $arg0
-  if gdb_use_struct
-    set $bugfix = $bugfix.i
-  end
-  set $int = gdb_use_lsb ? $bugfix >> (gdb_gctypebits - 1) : $bugfix << (gdb_gctypebits - 1) >> (gdb_gctypebits - 1)
+  set $bugfix = CHECK_LISP_OBJECT_TYPE ? $arg0.i : $arg0
+  set $int = USE_LSB_TAG ? $bugfix >> INTTYPEBITS : $bugfix << INTTYPEBITS >> INTTYPEBITS
 end
 
 define xgettype
-  set $bugfix = $arg0
-  if gdb_use_struct
-    set $bugfix = $bugfix.i
-  end
-  set $type = (enum Lisp_Type) (gdb_use_lsb ? $bugfix & $tagmask : $bugfix >> gdb_valbits)
+  set $bugfix = CHECK_LISP_OBJECT_TYPE ? $arg0.i : $arg0
+  set $type = (enum Lisp_Type) (USE_LSB_TAG ? $bugfix & (1 << GCTYPEBITS) - 1 : $bugfix >> VALBITS)
 end
 
 # Set up something to print out s-expressions.
@@ -652,7 +641,7 @@ end
 define xvectype
   xgetptr $
   set $size = ((struct Lisp_Vector *) $ptr)->header.size
-  output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag
+  output ($size & PSEUDOVECTOR_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~ARRAY_MARK_FLAG
   echo \n
 end
 document xvectype
@@ -738,7 +727,7 @@ end
 define xvector
   xgetptr $
   print (struct Lisp_Vector *) $ptr
-  output ($->header.size > 50) ? 0 : ($->contents[0])@($->header.size & ~gdb_array_mark_flag)
+  output ($->header.size > 50) ? 0 : ($->contents[0])@($->header.size & ~ARRAY_MARK_FLAG)
 echo \n
 end
 document xvector
@@ -847,7 +836,7 @@ end
 define xboolvector
   xgetptr $
   print (struct Lisp_Bool_Vector *) $ptr
-  output ($->header.size > 256) ? 0 : ($->data[0])@((($->header.size & ~gdb_array_mark_flag) + 7)/ 8)
+  output ($->size > 256) ? 0 : ($->data[0])@(($->size + BOOL_VECTOR_BITS_PER_CHAR - 1)/ BOOL_VECTOR_BITS_PER_CHAR)
   echo \n
 end
 document xboolvector
@@ -990,7 +979,7 @@ define xpr
   end
   if $type == Lisp_Vectorlike
     set $size = ((struct Lisp_Vector *) $ptr)->header.size
-    if ($size & PVEC_FLAG)
+    if ($size & PSEUDOVECTOR_FLAG)
       set $vec = (enum pvec_type) ($size & PVEC_TYPE_MASK)
       if $vec == PVEC_NORMAL_VECTOR
        xvector
@@ -1036,7 +1025,7 @@ end
 
 define xprintstr
   set $data = (char *) $arg0->data
-  output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte)
+  output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~ARRAY_MARK_FLAG : $arg0->size_byte)
 end
 
 define xprintsym
@@ -1051,8 +1040,8 @@ document xprintsym
 end
 
 define xcoding
-  set $tmp = (struct Lisp_Hash_Table *) ((Vcoding_system_hash_table & $valmask) | gdb_data_seg_bits)
-  set $tmp = (struct Lisp_Vector *) (($tmp->key_and_value & $valmask) | gdb_data_seg_bits)
+  set $tmp = (struct Lisp_Hash_Table *) ((Vcoding_system_hash_table & VALMASK) | DATA_SEG_BITS)
+  set $tmp = (struct Lisp_Vector *) (($tmp->key_and_value & VALMASK) | DATA_SEG_BITS)
   set $name = $tmp->contents[$arg0 * 2]
   print $name
   pr
@@ -1064,8 +1053,8 @@ document xcoding
 end
 
 define xcharset
-  set $tmp = (struct Lisp_Hash_Table *) ((Vcharset_hash_table & $valmask) | gdb_data_seg_bits)
-  set $tmp = (struct Lisp_Vector *) (($tmp->key_and_value & $valmask) | gdb_data_seg_bits)
+  set $tmp = (struct Lisp_Hash_Table *) ((Vcharset_hash_table & VALMASK) | DATA_SEG_BITS)
+  set $tmp = (struct Lisp_Vector *) (($tmp->key_and_value & VALMASK) | DATA_SEG_BITS)
   p $tmp->contents[charset_table[$arg0].hash_index * 2]
   pr
 end
@@ -1126,7 +1115,7 @@ define xbacktrace
       if $type == Lisp_Vectorlike
        xgetptr (*$bt->function)
         set $size = ((struct Lisp_Vector *) $ptr)->header.size
-        output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag
+        output ($size & PSEUDOVECTOR_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~ARRAY_MARK_FLAG
       else
         printf "Lisp type %d", $type
       end
@@ -1144,7 +1133,7 @@ end
 define xprintbytestr
   set $data = (char *) $arg0->data
   printf "Bytecode: "
-  output/u ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte)
+  output/u ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~ARRAY_MARK_FLAG : $arg0->size_byte)
 end
 document xprintbytestr
   Print a string of byte code.
@@ -1188,19 +1177,6 @@ define hookpost-backtrace
   end
 end
 
-define xreload
-  set $tagmask = ((1 << gdb_gctypebits) - 1)
-  set $valmask = gdb_use_lsb ? ~($tagmask) : ((EMACS_INT) 1 << gdb_valbits) - 1
-end
-document xreload
-  When starting Emacs a second time in the same gdb session under
-  FreeBSD 2.2.5, gdb 4.13, $valmask have lost
-  their values.  (The same happens on current (2000) versions of GNU/Linux
-  with gdb 5.0.)
-  This function reloads them.
-end
-xreload
-
 # Flush display (X only)
 define ff
   set x_flush (0)
@@ -1211,15 +1187,6 @@ Works only when an inferior emacs is executing.
 end
 
 
-define hook-run
-  xreload
-end
-
-# Call xreload if a new Emacs executable is loaded.
-define hookpost-run
-  xreload
-end
-
 set print pretty on
 set print sevenbit-strings
 
index 3b85ef3..71fc105 100644 (file)
@@ -1,3 +1,40 @@
+2012-07-26  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Simplify export of symbols to GDB; fix related .gdbinit bugs.
+       * .gdbinit (xgetptr, xgetint, xgettype): Don't use "set $bugfix =
+       $bugfix.i", as this doesn't work (with GDB 7.4.1, anyway).
+       (xgetptr, xgetint, xgettype, xcoding, xcharset, xprintbytestr):
+       Adjust to changes in lisp.h and emacs.c, by using
+       CHECK_LISP_OBJECT_TYPE rather than gdb_use_struct, VALMASK instead
+       of $valmask, DATA_SEG_BITS instead of gdb_data_seg_bits,
+       INTTYPEBITS instead of gdb_gctypebits - 1, USE_LSB_TAG instead of
+       gdb_use_lsb, (1 << GCTYPEBITS) - 1 instead of $tagmask, VALBITS
+       instead of gdb_valbits.
+       (xvectype, xvector, xpr, xprintstr, xbacktrace): Similarly, use
+       PSEUDOVECTOR_FLAG instead of PVEC_FLAG, and ARRAY_MARK_FLAG
+       instead of gdb_array_mark_flag.
+       (xboolvector): Get size from $->size, not $->header.size.
+       Use BOOL_VECTOR_BITS_PER_CHAR rather than mystery constants.
+       (xreload, hook-run, hookpost-run): Remove.
+       * emacs.c: Include <verify.h>.
+       (gdb_use_lsb, gdb_use_struct, gdb_valbits, gdb_gctypebits)
+       (gdb_data_seg_bits, PVEC_FLAG, gdb_array_mark_flag, gdb_pvec_type):
+       Remove.
+       (gdb_CHECK_LISP_OBJECT_TYPE, gdb_DATA_SEG_BITS, gdb_GCTYPEBITS)
+       (gdb_USE_LSB_TAG): New enum constants.
+       (CHECK_LISP_OBJECT_TYPE, DATA_SEG_BITS, GCTYPEBITS, USE_LSB_TAG):
+       Also define these as enum constants, so they're visible to GDB.
+       (ARRAY_MARK_FLAG_VAL, PSEUDOVECTOR_FLAG_VAL, VALMASK_VAL): New macros.
+       (ARRAY_MARK_FLAG, PSEUDOVECTOR_FLAG, VALMASK): Also define these
+       as constants, so they're visible to GDB.
+       * lisp.h (VALBITS, INTTYPEBITS, FIXNUM_BITS, PSEUDOVECTOR_SIZE_BITS)
+       (PSEUDOVECTOR_SIZE_MASK, PVEC_TYPE_MASK, BOOL_VECTOR_BITS_PER_CHAR):
+       Now enum constants, not macros, so they're visible to GDB.
+       (CHECK_LISP_OBJECT_TYPE, DATA_SEG_BITS): Default to 0, as this is
+       more convenient now.  All uses changed.
+       (VALMASK) [USE_LSB_TAG]: Also define in this case.
+       * mem-limits.h (EXCEEDS_LISP_PTR): Adjust to DATA_SEG_BITS change.
+
 2012-07-26  Dmitry Antipov  <dmantipov@yandex.ru>
 
        Explicitly free restriction data that are not needed anymore.
index 2893b5f..c737a41 100644 (file)
@@ -29,6 +29,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <setjmp.h>
 #include <unistd.h>
 
+#include <verify.h>
+
 #include "lisp.h"
 
 #ifdef WINDOWSNT
@@ -96,31 +98,6 @@ extern void moncontrol (int mode);
 static const char emacs_version[] = VERSION;
 static const char emacs_copyright[] = "Copyright (C) 2012 Free Software Foundation, Inc.";
 
-/* Make these values available in GDB, which doesn't see macros.  */
-
-#if USE_LSB_TAG
-int gdb_use_lsb EXTERNALLY_VISIBLE = 1;
-#else
-int gdb_use_lsb EXTERNALLY_VISIBLE = 0;
-#endif
-#ifndef CHECK_LISP_OBJECT_TYPE
-int gdb_use_struct EXTERNALLY_VISIBLE = 0;
-#else
-int gdb_use_struct EXTERNALLY_VISIBLE = 1;
-#endif
-int gdb_valbits EXTERNALLY_VISIBLE = VALBITS;
-int gdb_gctypebits EXTERNALLY_VISIBLE = GCTYPEBITS;
-#if defined DATA_SEG_BITS && !USE_LSB_TAG
-uintptr_t gdb_data_seg_bits EXTERNALLY_VISIBLE = DATA_SEG_BITS;
-#else
-uintptr_t gdb_data_seg_bits EXTERNALLY_VISIBLE = 0;
-#endif
-ptrdiff_t PVEC_FLAG EXTERNALLY_VISIBLE = PSEUDOVECTOR_FLAG;
-ptrdiff_t gdb_array_mark_flag EXTERNALLY_VISIBLE = ARRAY_MARK_FLAG;
-/* GDB might say "No enum type named pvec_type" if we don't have at
-   least one symbol with that type, and then xbacktrace could fail.  */
-enum pvec_type const gdb_pvec_type EXTERNALLY_VISIBLE = 0;
-
 /* Empty lisp strings.  To avoid having to build any others.  */
 Lisp_Object empty_unibyte_string, empty_multibyte_string;
 
@@ -2513,3 +2490,50 @@ libraries; only those already known by Emacs will be loaded.  */);
   /* Make sure IS_DAEMON starts up as false.  */
   daemon_pipe[1] = 0;
 }
+
+/* Make these values available in GDB, which doesn't see macros.
+   This is last, so that the #undef lines don't mess up later code.  */
+
+enum
+  {
+    gdb_CHECK_LISP_OBJECT_TYPE = CHECK_LISP_OBJECT_TYPE,
+    gdb_DATA_SEG_BITS = DATA_SEG_BITS,
+    gdb_GCTYPEBITS = GCTYPEBITS,
+    gdb_USE_LSB_TAG = USE_LSB_TAG
+  };
+
+#undef CHECK_LISP_OBJECT_TYPE
+#undef DATA_SEG_BITS
+#undef GCTYPEBITS
+#undef USE_LSB_TAG
+
+enum
+  {
+    CHECK_LISP_OBJECT_TYPE = gdb_CHECK_LISP_OBJECT_TYPE,
+    DATA_SEG_BITS = gdb_DATA_SEG_BITS,
+    GCTYPEBITS = gdb_GCTYPEBITS,
+    USE_LSB_TAG = gdb_USE_LSB_TAG
+  };
+
+/* These are trickier since they might fall out of int range.  Each
+   symbol X has a corresponding X_VAL symbol, verified to have the
+   correct value.  */
+
+#define ARRAY_MARK_FLAG_VAL PTRDIFF_MIN
+#define PSEUDOVECTOR_FLAG_VAL (PTRDIFF_MAX - PTRDIFF_MAX / 2)
+#define VALMASK_VAL (USE_LSB_TAG ? -1 << GCTYPEBITS : VAL_MAX)
+
+verify (ARRAY_MARK_FLAG_VAL == ARRAY_MARK_FLAG);
+verify (PSEUDOVECTOR_FLAG_VAL == PSEUDOVECTOR_FLAG);
+verify (VALMASK_VAL == VALMASK);
+
+#undef ARRAY_MARK_FLAG
+#undef PSEUDOVECTOR_FLAG
+#undef VALMASK
+
+ptrdiff_t const EXTERNALLY_VISIBLE
+  ARRAY_MARK_FLAG = ARRAY_MARK_FLAG_VAL,
+  PSEUDOVECTOR_FLAG = PSEUDOVECTOR_FLAG_VAL;
+
+EMACS_INT const EXTERNALLY_VISIBLE
+  VALMASK = VALMASK_VAL;
index d930555..204657f 100644 (file)
@@ -155,8 +155,11 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
    variable VAR of type TYPE with the added requirement that it be
    TYPEBITS-aligned.  */
 
+/* Number of bits in a Lisp_Obect tag.  This can be used in #if.  */
 #define GCTYPEBITS 3
-#define VALBITS (BITS_PER_EMACS_INT - GCTYPEBITS)
+
+/* Number of bits in a Lisp_Object value, not counting the tag.  */
+enum { VALBITS = BITS_PER_EMACS_INT - GCTYPEBITS };
 
 /* The maximum value that can be stored in a EMACS_INT, assuming all
    bits other than the type bits contribute to a nonnegative signed value.
@@ -218,8 +221,8 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
 
 /* Lisp integers use 2 tags, to give them one extra bit, thus
    extending their range from, e.g., -2^28..2^28-1 to -2^29..2^29-1.  */
-#define INTTYPEBITS (GCTYPEBITS - 1)
-#define FIXNUM_BITS (VALBITS + 1)
+enum { INTTYPEBITS = GCTYPEBITS - 1 };
+enum { FIXNUM_BITS = VALBITS + 1 };
 #define INTMASK (EMACS_INT_MAX >> (INTTYPEBITS - 1))
 #define LISP_INT_TAG Lisp_Int0
 #define case_Lisp_Int case Lisp_Int0: case Lisp_Int1
@@ -324,6 +327,7 @@ typedef EMACS_INT Lisp_Object;
 #define XIL(i) (i)
 #define LISP_MAKE_RVALUE(o) (0+(o))
 #define LISP_INITIALLY_ZERO 0
+#define CHECK_LISP_OBJECT_TYPE 0
 #endif /* CHECK_LISP_OBJECT_TYPE */
 
 /* In the size word of a vector, this bit means the vector has been marked.  */
@@ -370,13 +374,22 @@ enum pvec_type
    only the number of Lisp_Object fields (that need to be traced by the GC).
    The distinction is used e.g. by Lisp_Process which places extra
    non-Lisp_Object fields at the end of the structure.  */
-#define PSEUDOVECTOR_SIZE_BITS 16
-#define PSEUDOVECTOR_SIZE_MASK ((1 << PSEUDOVECTOR_SIZE_BITS) - 1)
-#define PVEC_TYPE_MASK (0x0fff << PSEUDOVECTOR_SIZE_BITS)
+enum
+  {
+    PSEUDOVECTOR_SIZE_BITS = 16,
+    PSEUDOVECTOR_SIZE_MASK = (1 << PSEUDOVECTOR_SIZE_BITS) - 1,
+    PVEC_TYPE_MASK = 0x0fff << PSEUDOVECTOR_SIZE_BITS
+  };
 
 /* Number of bits to put in each character in the internal representation
    of bool vectors.  This should not vary across implementations.  */
-#define BOOL_VECTOR_BITS_PER_CHAR 8
+enum { BOOL_VECTOR_BITS_PER_CHAR = 8 };
+
+/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers
+   which were stored in a Lisp_Object */
+#ifndef DATA_SEG_BITS
+# define DATA_SEG_BITS 0
+#endif
 \f
 /* These macros extract various sorts of values from a Lisp_Object.
  For example, if tem is a Lisp_Object whose type is Lisp_Cons,
@@ -387,6 +400,7 @@ enum pvec_type
 
 #if USE_LSB_TAG
 
+#define VALMASK (-1 << GCTYPEBITS)
 #define TYPEMASK ((1 << GCTYPEBITS) - 1)
 #define XTYPE(a) ((enum Lisp_Type) (XLI (a) & TYPEMASK))
 #define XINT(a) (XLI (a) >> INTTYPEBITS)
@@ -421,7 +435,7 @@ enum pvec_type
   ((var) = XIL ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS)  \
                + ((intptr_t) (ptr) & VALMASK)))
 
-#ifdef DATA_SEG_BITS
+#if DATA_SEG_BITS
 /* DATA_SEG_BITS forces extra bits to be or'd in with any pointers
    which were stored in a Lisp_Object */
 #define XPNTR(a) ((uintptr_t) ((XLI (a) & VALMASK)) | DATA_SEG_BITS))
index dbe58dc..0376f40 100644 (file)
@@ -36,7 +36,7 @@ extern int etext;
 extern char *start_of_data (void) ATTRIBUTE_CONST;
 #if USE_LSB_TAG || UINTPTR_MAX <= VAL_MAX
 #define EXCEEDS_LISP_PTR(ptr) 0
-#elif defined DATA_SEG_BITS
+#elif DATA_SEG_BITS
 #define EXCEEDS_LISP_PTR(ptr) \
   (((uintptr_t) (ptr) & ~DATA_SEG_BITS) >> VALBITS)
 #else