diff options
| author | Paul Eggert | 2015-01-07 23:02:01 -0800 |
|---|---|---|
| committer | Paul Eggert | 2015-01-07 23:02:27 -0800 |
| commit | f6a27d26dccdcc121bebc96fbf41f656fbf13138 (patch) | |
| tree | 344d746bc2738cbf6a19bc378236b3a6810febc2 /src | |
| parent | 9f654763f2223ce9f3317b44a3d1a8ac2c8bb832 (diff) | |
| download | emacs-f6a27d26dccdcc121bebc96fbf41f656fbf13138.tar.gz emacs-f6a27d26dccdcc121bebc96fbf41f656fbf13138.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/lisp.h | 5 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index eae16c27b75..817483be1fb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,12 @@ | |||
| 1 | 2015-01-08 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2015-01-08 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Port Qnil==0 XUNTAG to clang | ||
| 4 | clang has undefined behavior if the program subtracts an integer | ||
| 5 | from (char *) 0. Problem reported by YAMAMOTO Mitsuharu in: | ||
| 6 | http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00132.html | ||
| 7 | * lisp.h (lisp_h_XUNTAG) [USE_LSB_TAG]: | ||
| 8 | (XUNTAG) [!USE_LSB_TAG]: Port to clang 3.5.0. | ||
| 9 | |||
| 3 | Port GFileMonitor * hack to Qnil==0 platforms | 10 | Port GFileMonitor * hack to Qnil==0 platforms |
| 4 | Reported by Glenn Morris in: http://bugs.gnu.org/15880#112 | 11 | Reported by Glenn Morris in: http://bugs.gnu.org/15880#112 |
| 5 | * gfilenotify.c (monitor_to_lisp, lisp_to_monitor): New functions. | 12 | * gfilenotify.c (monitor_to_lisp, lisp_to_monitor): New functions. |
diff --git a/src/lisp.h b/src/lisp.h index 1f18b5e0775..b9263f88c11 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -368,7 +368,7 @@ error !; | |||
| 368 | # define lisp_h_XFASTINT(a) XINT (a) | 368 | # define lisp_h_XFASTINT(a) XINT (a) |
| 369 | # define lisp_h_XINT(a) (XLI (a) >> INTTYPEBITS) | 369 | # define lisp_h_XINT(a) (XLI (a) >> INTTYPEBITS) |
| 370 | # define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK)) | 370 | # define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK)) |
| 371 | # define lisp_h_XUNTAG(a, type) XUNTAGBASE (a, type, 0) | 371 | # define lisp_h_XUNTAG(a, type) ((void *) (intptr_t) (XLI (a) - (type))) |
| 372 | # define lisp_h_XUNTAGBASE(a, type, base) \ | 372 | # define lisp_h_XUNTAGBASE(a, type, base) \ |
| 373 | ((void *) ((char *) (base) - (type) + (intptr_t) XLI (a))) | 373 | ((void *) ((char *) (base) - (type) + (intptr_t) XLI (a))) |
| 374 | #endif | 374 | #endif |
| @@ -905,7 +905,8 @@ XUNTAGBASE (Lisp_Object a, int type, void *base) | |||
| 905 | INLINE void * | 905 | INLINE void * |
| 906 | XUNTAG (Lisp_Object a, int type) | 906 | XUNTAG (Lisp_Object a, int type) |
| 907 | { | 907 | { |
| 908 | return XUNTAGBASE (a, type, 0); | 908 | intptr_t i = USE_LSB_TAG ? XLI (a) - type : XLI (a) & VALMASK; |
| 909 | return (void *) i; | ||
| 909 | } | 910 | } |
| 910 | 911 | ||
| 911 | #endif /* ! USE_LSB_TAG */ | 912 | #endif /* ! USE_LSB_TAG */ |