aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
authorPaul Eggert2012-02-20 15:09:58 -0800
committerPaul Eggert2012-02-20 15:09:58 -0800
commit310f5bd4294ec3624b425e2c27da6fc730d0e928 (patch)
treeb1989e75f50a4c50c9b5fe34b698c93c2abec7ff /src/lisp.h
parent132b9726f60888f990e6174ce430769eb9dda986 (diff)
downloademacs-310f5bd4294ec3624b425e2c27da6fc730d0e928.tar.gz
emacs-310f5bd4294ec3624b425e2c27da6fc730d0e928.zip
Fix crash due to non-contiguous EMACS_INT (Bug#10780).
* lisp.h (VALBITS): Move definition up, so that USE_LSB_TAG can use it. (USE_LSB_TAG): Do not define if UINTPTR_MAX >> VALBITS == 0. It's useless in that case, and it can cause problems on hosts that allocate halves of EMACS_INT values separately. Reported by Dan HorĂ¡k. Diagnosed by Andreas Schwab in <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10780#30>. * mem-limits.h (EXCEEDS_LISP_PTR): Define to 0 on hosts where UINTPTR_MAX >> VALBITS == 0. This is required by the above change; it avoids undefined behavior on hosts where shifting right by more than the word width has undefined behavior.
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/lisp.h b/src/lisp.h
index 366d24a737d..8bfd7071e5f 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -168,6 +168,10 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
168#define GCTYPEBITS 3 168#define GCTYPEBITS 3
169#endif 169#endif
170 170
171#ifndef VALBITS
172#define VALBITS (BITS_PER_EMACS_INT - GCTYPEBITS)
173#endif
174
171#ifndef NO_DECL_ALIGN 175#ifndef NO_DECL_ALIGN
172# ifndef DECL_ALIGN 176# ifndef DECL_ALIGN
173# if HAVE_ATTRIBUTE_ALIGNED 177# if HAVE_ATTRIBUTE_ALIGNED
@@ -191,7 +195,15 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
191 || defined DARWIN_OS || defined __sun) 195 || defined DARWIN_OS || defined __sun)
192/* We also need to be able to specify mult-of-8 alignment on static vars. */ 196/* We also need to be able to specify mult-of-8 alignment on static vars. */
193# if defined DECL_ALIGN 197# if defined DECL_ALIGN
194# define USE_LSB_TAG 198/* mark_maybe_object assumes that EMACS_INT values are contiguous,
199 but this is not true on some hosts where EMACS_INT is wider than a pointer,
200 as they may allocate the halves of an EMACS_INT separately.
201 On these hosts USE_LSB_TAG is not needed because the top bits of an
202 EMACS_INT are unused, so define USE_LSB_TAG only on hosts where it
203 might be useful. */
204# if UINTPTR_MAX >> VALBITS != 0
205# define USE_LSB_TAG
206# endif
195# endif 207# endif
196#endif 208#endif
197 209
@@ -309,11 +321,6 @@ enum Lisp_Fwd_Type
309 Lisp_Fwd_Kboard_Obj, /* Fwd to a Lisp_Object field of kboards. */ 321 Lisp_Fwd_Kboard_Obj, /* Fwd to a Lisp_Object field of kboards. */
310 }; 322 };
311 323
312/* These values are overridden by the m- file on some machines. */
313#ifndef VALBITS
314#define VALBITS (BITS_PER_EMACS_INT - GCTYPEBITS)
315#endif
316
317#ifdef USE_LISP_UNION_TYPE 324#ifdef USE_LISP_UNION_TYPE
318 325
319#ifndef WORDS_BIGENDIAN 326#ifndef WORDS_BIGENDIAN