diff options
| author | Eli Zaretskii | 2015-12-02 16:06:01 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2015-12-02 16:06:01 +0200 |
| commit | 36dbe6fc3e141e5b4c87efec5026931b89f026a5 (patch) | |
| tree | 799aeb97c74682607b3dd6ad853b26e50e2b745b | |
| parent | 0af2c269b1d68d114e74aa1313b2ad7d1fe21726 (diff) | |
| download | emacs-36dbe6fc3e141e5b4c87efec5026931b89f026a5.tar.gz emacs-36dbe6fc3e141e5b4c87efec5026931b89f026a5.zip | |
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.
| -rw-r--r-- | modules/mod-test/test.el | 7 | ||||
| -rw-r--r-- | 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 eacc6671ead..ad4cc49c690 100644 --- a/modules/mod-test/test.el +++ b/modules/mod-test/test.el | |||
| @@ -43,10 +43,15 @@ | |||
| 43 | (should (= (nth 2 descr) 3))) | 43 | (should (= (nth 2 descr) 3))) |
| 44 | (should-error (mod-test-sum "1" 2) :type 'wrong-type-argument) | 44 | (should-error (mod-test-sum "1" 2) :type 'wrong-type-argument) |
| 45 | (should-error (mod-test-sum 1 "2") :type 'wrong-type-argument) | 45 | (should-error (mod-test-sum 1 "2") :type 'wrong-type-argument) |
| 46 | ;; The following tests are for 32-bit build --with-wide-int. | ||
| 46 | (should (= (mod-test-sum -1 most-positive-fixnum) | 47 | (should (= (mod-test-sum -1 most-positive-fixnum) |
| 47 | (1- most-positive-fixnum))) | 48 | (1- most-positive-fixnum))) |
| 48 | (should (= (mod-test-sum 1 most-negative-fixnum) | 49 | (should (= (mod-test-sum 1 most-negative-fixnum) |
| 49 | (1+ most-negative-fixnum)))) | 50 | (1+ most-negative-fixnum))) |
| 51 | (should (= (mod-test-sum 1 #x1fffffff) | ||
| 52 | (1+ #x1fffffff))) | ||
| 53 | (should (= (mod-test-sum -1 #x20000000) | ||
| 54 | #x1fffffff))) | ||
| 50 | 55 | ||
| 51 | (ert-deftest mod-test-sum-docstring () | 56 | (ert-deftest mod-test-sum-docstring () |
| 52 | (should (string= (documentation 'mod-test-sum) "Return A + B"))) | 57 | (should (string= (documentation 'mod-test-sum) "Return A + B"))) |
diff --git a/src/emacs-module.c b/src/emacs-module.c index 13f2a1dd98f..22fee7e4860 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -850,8 +850,8 @@ static Lisp_Object | |||
| 850 | value_to_lisp (emacs_value v) | 850 | value_to_lisp (emacs_value v) |
| 851 | { | 851 | { |
| 852 | #ifdef WIDE_EMACS_INT | 852 | #ifdef WIDE_EMACS_INT |
| 853 | ptrdiff_t tmp = (ptrdiff_t)v; | 853 | uintptr_t tmp = (uintptr_t)v; |
| 854 | int tag = tmp & ((1 << GCTYPEBITS) - 1); | 854 | unsigned tag = tmp & ((1 << GCTYPEBITS) - 1); |
| 855 | Lisp_Object o; | 855 | Lisp_Object o; |
| 856 | switch (tag) | 856 | switch (tag) |
| 857 | { | 857 | { |