aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2020-01-01 04:15:27 +0000
committerPaul Eggert2019-12-31 20:18:22 -0800
commit12d004d6eee2d136825df92eca33eaa6b705030b (patch)
treebcb7c98c4e61fa819e04ab358ad4beaaf4cd361b /src
parent87772ffe317897b781b2ef8b3bcaa9b6c077311c (diff)
downloademacs-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')
-rw-r--r--src/data.c33
-rw-r--r--src/sysdep.c7
2 files changed, 10 insertions, 30 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
3317enum { ULL_WIDTH = ULLONG_WIDTH };
3318# define ULL_MAX ULLONG_MAX
3319#else
3320enum { 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
3329static bits_word 3316static bits_word
3330shift_right_ull (bits_word w) 3317shift_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;
diff --git a/src/sysdep.c b/src/sysdep.c
index cb2f7f2f23c..c6344d8cec7 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -135,11 +135,6 @@ int _cdecl _spawnlp (int, const char *, const char *, ...);
135# include <sys/socket.h> 135# include <sys/socket.h>
136#endif 136#endif
137 137
138/* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */
139#ifndef ULLONG_MAX
140#define ULLONG_MAX TYPE_MAXIMUM (unsigned long long int)
141#endif
142
143/* Declare here, including term.h is problematic on some systems. */ 138/* Declare here, including term.h is problematic on some systems. */
144extern void tputs (const char *, int, int (*)(int)); 139extern void tputs (const char *, int, int (*)(int));
145 140
@@ -3141,7 +3136,7 @@ make_lisp_timeval (struct timeval t)
3141 3136
3142#endif 3137#endif
3143 3138
3144#if defined GNU_LINUX && defined HAVE_LONG_LONG_INT 3139#ifdef GNU_LINUX
3145static struct timespec 3140static struct timespec
3146time_from_jiffies (unsigned long long tval, long hz) 3141time_from_jiffies (unsigned long long tval, long hz)
3147{ 3142{