diff options
| author | Paul Eggert | 2018-03-21 16:08:27 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-03-21 16:08:53 -0700 |
| commit | cae9e0fa0358d6323b57a288b5661dc72d36356d (patch) | |
| tree | f4eec6361449e6c78624652cde29817c8f26d26e /test/src | |
| parent | 3b42c083b658649a300594a5499db73b0a49152f (diff) | |
| download | emacs-cae9e0fa0358d6323b57a288b5661dc72d36356d.tar.gz emacs-cae9e0fa0358d6323b57a288b5661dc72d36356d.zip | |
Port data-tests-popcnt to 32-bit Emacs
* test/src/data-tests.el (data-tests-popcnt):
Don’t assume Emacs integers can represent 32-bit quantities.
Change to a simple and straightforward approach, since runtime
performance is not important here.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/data-tests.el | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/test/src/data-tests.el b/test/src/data-tests.el index 3b88dbca9a2..33b00d6c9ad 100644 --- a/test/src/data-tests.el +++ b/test/src/data-tests.el | |||
| @@ -111,9 +111,9 @@ | |||
| 111 | "Calculate the Hamming weight of BYTE." | 111 | "Calculate the Hamming weight of BYTE." |
| 112 | (if (< byte 0) | 112 | (if (< byte 0) |
| 113 | (setq byte (lognot byte))) | 113 | (setq byte (lognot byte))) |
| 114 | (setq byte (- byte (logand (lsh byte -1) #x55555555))) | 114 | (if (zerop byte) |
| 115 | (setq byte (+ (logand byte #x33333333) (logand (lsh byte -2) #x33333333))) | 115 | 0 |
| 116 | (lsh (* (logand (+ byte (lsh byte -4)) #x0f0f0f0f) #x01010101) -24)) | 116 | (+ (logand byte 1) (data-tests-popcnt (lsh byte -1))))) |
| 117 | 117 | ||
| 118 | (ert-deftest data-tests-logcount () | 118 | (ert-deftest data-tests-logcount () |
| 119 | (should (cl-loop for n in (number-sequence -255 255) | 119 | (should (cl-loop for n in (number-sequence -255 255) |