diff options
| author | Paul Eggert | 2020-01-01 04:15:27 +0000 |
|---|---|---|
| committer | Paul Eggert | 2019-12-31 20:18:22 -0800 |
| commit | 12d004d6eee2d136825df92eca33eaa6b705030b (patch) | |
| tree | bcb7c98c4e61fa819e04ab358ad4beaaf4cd361b /src/data.c | |
| parent | 87772ffe317897b781b2ef8b3bcaa9b6c077311c (diff) | |
| download | emacs-12d004d6eee2d136825df92eca33eaa6b705030b.tar.gz emacs-12d004d6eee2d136825df92eca33eaa6b705030b.zip | |
Assume C99-style ‘long long’
Now that Gnulib assumes ‘long long’, it is a good time to clean
out old cruft porting to pre-C99 compilers that lack it.
* src/data.c (ULL_WIDTH, ULL_MAX): Remove.
All uses replaced by ULLONG_WIDTH, ULLONG_MAX.
(bits_word_to_host_endian): Assume ‘unsigned long long’.
By the way, the old code had a performance typo: it used
HAVE_UNSIGNED_LONG_LONG where it should have used
HAVE_UNSIGNED_LONG_LONG_INT.
* src/sysdep.c (ULLONG_MAX): Remove, as lib/limits.h does this now.
(time_from_jiffies) [GNU_LINUX]: Assume ‘long long’.
Diffstat (limited to 'src/data.c')
| -rw-r--r-- | src/data.c | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/src/data.c b/src/data.c index b1530688468..56e363f16b6 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -3310,27 +3310,14 @@ bool_vector_spare_mask (EMACS_INT nr_bits) | |||
| 3310 | return (((bits_word) 1) << (nr_bits % BITS_PER_BITS_WORD)) - 1; | 3310 | return (((bits_word) 1) << (nr_bits % BITS_PER_BITS_WORD)) - 1; |
| 3311 | } | 3311 | } |
| 3312 | 3312 | ||
| 3313 | /* Info about unsigned long long, falling back on unsigned long | ||
| 3314 | if unsigned long long is not available. */ | ||
| 3315 | |||
| 3316 | #if HAVE_UNSIGNED_LONG_LONG_INT && defined ULLONG_WIDTH | ||
| 3317 | enum { ULL_WIDTH = ULLONG_WIDTH }; | ||
| 3318 | # define ULL_MAX ULLONG_MAX | ||
| 3319 | #else | ||
| 3320 | enum { ULL_WIDTH = ULONG_WIDTH }; | ||
| 3321 | # define ULL_MAX ULONG_MAX | ||
| 3322 | # define count_one_bits_ll count_one_bits_l | ||
| 3323 | # define count_trailing_zeros_ll count_trailing_zeros_l | ||
| 3324 | #endif | ||
| 3325 | |||
| 3326 | /* Shift VAL right by the width of an unsigned long long. | 3313 | /* Shift VAL right by the width of an unsigned long long. |
| 3327 | ULL_WIDTH must be less than BITS_PER_BITS_WORD. */ | 3314 | ULLONG_WIDTH must be less than BITS_PER_BITS_WORD. */ |
| 3328 | 3315 | ||
| 3329 | static bits_word | 3316 | static bits_word |
| 3330 | shift_right_ull (bits_word w) | 3317 | shift_right_ull (bits_word w) |
| 3331 | { | 3318 | { |
| 3332 | /* Pacify bogus GCC warning about shift count exceeding type width. */ | 3319 | /* Pacify bogus GCC warning about shift count exceeding type width. */ |
| 3333 | int shift = ULL_WIDTH - BITS_PER_BITS_WORD < 0 ? ULL_WIDTH : 0; | 3320 | int shift = ULLONG_WIDTH - BITS_PER_BITS_WORD < 0 ? ULLONG_WIDTH : 0; |
| 3334 | return w >> shift; | 3321 | return w >> shift; |
| 3335 | } | 3322 | } |
| 3336 | 3323 | ||
| @@ -3347,7 +3334,7 @@ count_one_bits_word (bits_word w) | |||
| 3347 | { | 3334 | { |
| 3348 | int i = 0, count = 0; | 3335 | int i = 0, count = 0; |
| 3349 | while (count += count_one_bits_ll (w), | 3336 | while (count += count_one_bits_ll (w), |
| 3350 | (i += ULL_WIDTH) < BITS_PER_BITS_WORD) | 3337 | (i += ULLONG_WIDTH) < BITS_PER_BITS_WORD) |
| 3351 | w = shift_right_ull (w); | 3338 | w = shift_right_ull (w); |
| 3352 | return count; | 3339 | return count; |
| 3353 | } | 3340 | } |
| @@ -3478,7 +3465,7 @@ count_trailing_zero_bits (bits_word val) | |||
| 3478 | return count_trailing_zeros (val); | 3465 | return count_trailing_zeros (val); |
| 3479 | if (BITS_WORD_MAX == ULONG_MAX) | 3466 | if (BITS_WORD_MAX == ULONG_MAX) |
| 3480 | return count_trailing_zeros_l (val); | 3467 | return count_trailing_zeros_l (val); |
| 3481 | if (BITS_WORD_MAX == ULL_MAX) | 3468 | if (BITS_WORD_MAX == ULLONG_MAX) |
| 3482 | return count_trailing_zeros_ll (val); | 3469 | return count_trailing_zeros_ll (val); |
| 3483 | 3470 | ||
| 3484 | /* The rest of this code is for the unlikely platform where bits_word differs | 3471 | /* The rest of this code is for the unlikely platform where bits_word differs |
| @@ -3492,18 +3479,18 @@ count_trailing_zero_bits (bits_word val) | |||
| 3492 | { | 3479 | { |
| 3493 | int count; | 3480 | int count; |
| 3494 | for (count = 0; | 3481 | for (count = 0; |
| 3495 | count < BITS_PER_BITS_WORD - ULL_WIDTH; | 3482 | count < BITS_PER_BITS_WORD - ULLONG_WIDTH; |
| 3496 | count += ULL_WIDTH) | 3483 | count += ULLONG_WIDTH) |
| 3497 | { | 3484 | { |
| 3498 | if (val & ULL_MAX) | 3485 | if (val & ULLONG_MAX) |
| 3499 | return count + count_trailing_zeros_ll (val); | 3486 | return count + count_trailing_zeros_ll (val); |
| 3500 | val = shift_right_ull (val); | 3487 | val = shift_right_ull (val); |
| 3501 | } | 3488 | } |
| 3502 | 3489 | ||
| 3503 | if (BITS_PER_BITS_WORD % ULL_WIDTH != 0 | 3490 | if (BITS_PER_BITS_WORD % ULLONG_WIDTH != 0 |
| 3504 | && BITS_WORD_MAX == (bits_word) -1) | 3491 | && BITS_WORD_MAX == (bits_word) -1) |
| 3505 | val |= (bits_word) 1 << pre_value (ULONG_MAX < BITS_WORD_MAX, | 3492 | val |= (bits_word) 1 << pre_value (ULONG_MAX < BITS_WORD_MAX, |
| 3506 | BITS_PER_BITS_WORD % ULL_WIDTH); | 3493 | BITS_PER_BITS_WORD % ULLONG_WIDTH); |
| 3507 | return count + count_trailing_zeros_ll (val); | 3494 | return count + count_trailing_zeros_ll (val); |
| 3508 | } | 3495 | } |
| 3509 | } | 3496 | } |
| @@ -3516,10 +3503,8 @@ bits_word_to_host_endian (bits_word val) | |||
| 3516 | #else | 3503 | #else |
| 3517 | if (BITS_WORD_MAX >> 31 == 1) | 3504 | if (BITS_WORD_MAX >> 31 == 1) |
| 3518 | return bswap_32 (val); | 3505 | return bswap_32 (val); |
| 3519 | # if HAVE_UNSIGNED_LONG_LONG | ||
| 3520 | if (BITS_WORD_MAX >> 31 >> 31 >> 1 == 1) | 3506 | if (BITS_WORD_MAX >> 31 >> 31 >> 1 == 1) |
| 3521 | return bswap_64 (val); | 3507 | return bswap_64 (val); |
| 3522 | # endif | ||
| 3523 | { | 3508 | { |
| 3524 | int i; | 3509 | int i; |
| 3525 | bits_word r = 0; | 3510 | bits_word r = 0; |