emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-25 36dbe6f: More emacs-module.c fixes for wide ints


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-25 36dbe6f: More emacs-module.c fixes for wide ints
Date: Wed, 02 Dec 2015 14:07:03 +0000

branch: emacs-25
commit 36dbe6fc3e141e5b4c87efec5026931b89f026a5
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    More emacs-module.c fixes for wide ints
    
    * src/emacs-module.c (value_to_lisp) [WIDE_EMACS_INT]: Use
    unsigned data types to manipulate pointers, to avoid sign
    extension coming after us with a vengeance.
    
    * modules/mod-test/test.el (mod-test-sum-test): Add tests for
    Emacs with wide ints that verify integer values near the critical
    value that requires us to switch to a cons cell.
---
 modules/mod-test/test.el |    7 ++++++-
 src/emacs-module.c       |    4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/modules/mod-test/test.el b/modules/mod-test/test.el
index eacc667..ad4cc49 100644
--- a/modules/mod-test/test.el
+++ b/modules/mod-test/test.el
@@ -43,10 +43,15 @@
     (should (= (nth 2 descr) 3)))
   (should-error (mod-test-sum "1" 2) :type 'wrong-type-argument)
   (should-error (mod-test-sum 1 "2") :type 'wrong-type-argument)
+  ;; The following tests are for 32-bit build --with-wide-int.
   (should (= (mod-test-sum -1 most-positive-fixnum)
              (1- most-positive-fixnum)))
   (should (= (mod-test-sum 1 most-negative-fixnum)
-             (1+ most-negative-fixnum))))
+             (1+ most-negative-fixnum)))
+  (should (= (mod-test-sum 1 #x1fffffff)
+             (1+  #x1fffffff)))
+  (should (= (mod-test-sum -1 #x20000000)
+             #x1fffffff)))
 
 (ert-deftest mod-test-sum-docstring ()
   (should (string= (documentation 'mod-test-sum) "Return A + B")))
diff --git a/src/emacs-module.c b/src/emacs-module.c
index 13f2a1d..22fee7e 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -850,8 +850,8 @@ static Lisp_Object
 value_to_lisp (emacs_value v)
 {
 #ifdef WIDE_EMACS_INT
-  ptrdiff_t tmp = (ptrdiff_t)v;
-  int tag = tmp & ((1 << GCTYPEBITS) - 1);
+  uintptr_t tmp = (uintptr_t)v;
+  unsigned tag = tmp & ((1 << GCTYPEBITS) - 1);
   Lisp_Object o;
   switch (tag)
     {



reply via email to

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