emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master f6a27d2: Port Qnil==0 XUNTAG to clang


From: Paul Eggert
Subject: [Emacs-diffs] master f6a27d2: Port Qnil==0 XUNTAG to clang
Date: Thu, 08 Jan 2015 07:02:31 +0000

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

    Port Qnil==0 XUNTAG to clang
    
    clang has undefined behavior if the program subtracts an integer
    from (char *) 0.  Problem reported by YAMAMOTO Mitsuharu in:
    http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00132.html
    * lisp.h (lisp_h_XUNTAG) [USE_LSB_TAG]:
    (XUNTAG) [!USE_LSB_TAG]: Port to clang 3.5.0.
---
 src/ChangeLog |    7 +++++++
 src/lisp.h    |    5 +++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index eae16c2..817483b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,12 @@
 2015-01-08  Paul Eggert  <address@hidden>
 
+       Port Qnil==0 XUNTAG to clang
+       clang has undefined behavior if the program subtracts an integer
+       from (char *) 0.  Problem reported by YAMAMOTO Mitsuharu in:
+       http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00132.html
+       * lisp.h (lisp_h_XUNTAG) [USE_LSB_TAG]:
+       (XUNTAG) [!USE_LSB_TAG]: Port to clang 3.5.0.
+
        Port GFileMonitor * hack to Qnil==0 platforms
        Reported by Glenn Morris in: http://bugs.gnu.org/15880#112
        * gfilenotify.c (monitor_to_lisp, lisp_to_monitor): New functions.
diff --git a/src/lisp.h b/src/lisp.h
index 1f18b5e..b9263f8 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -368,7 +368,7 @@ error !;
 # define lisp_h_XFASTINT(a) XINT (a)
 # define lisp_h_XINT(a) (XLI (a) >> INTTYPEBITS)
 # define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK))
-# define lisp_h_XUNTAG(a, type) XUNTAGBASE (a, type, 0)
+# define lisp_h_XUNTAG(a, type) ((void *) (intptr_t) (XLI (a) - (type)))
 # define lisp_h_XUNTAGBASE(a, type, base) \
     ((void *) ((char *) (base) - (type) + (intptr_t) XLI (a)))
 #endif
@@ -905,7 +905,8 @@ XUNTAGBASE (Lisp_Object a, int type, void *base)
 INLINE void *
 XUNTAG (Lisp_Object a, int type)
 {
-  return XUNTAGBASE (a, type, 0);
+  intptr_t i = USE_LSB_TAG ? XLI (a) - type : XLI (a) & VALMASK;
+  return (void *) i;
 }
 
 #endif /* ! USE_LSB_TAG */



reply via email to

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