aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
authorPaul Eggert2016-09-15 15:25:33 -0700
committerPaul Eggert2016-09-15 15:55:30 -0700
commit0bbf00c7f3de9c75372100afc3039d7f5c8a7587 (patch)
tree79fccec02fc3a9ceb9e04c16ae2117f725910276 /src/data.c
parent8f4b6a20bfec96086845b2f7161e121b1e41b4ad (diff)
downloademacs-0bbf00c7f3de9c75372100afc3039d7f5c8a7587.tar.gz
emacs-0bbf00c7f3de9c75372100afc3039d7f5c8a7587.zip
Prefer now-standard int width macros
* src/data.c (ULL_WIDTH): * src/lisp.h (EMACS_INT_WIDTH, BITS_PER_BITS_WORD): * src/lread.c (read_integer): * src/term.c (produce_glyphless_glyph): * src/xterm.c (x_send_scroll_bar_event): Use *_WIDTH macros instead of CHAR_BIT * sizeof. * src/data.c (ULL_WIDTH): Rename from BITS_PER_ULL for consistency with the *_WIDTH standard macros. All uses changed. * src/gmalloc.c (INT_BIT): Remove. All uses replaced with INT_WIDTH. * src/lisp.h (EMACS_INT_WIDTH): Rename from BITS_PER_EMACS_INT for consistency with the *_WIDTH standard macros. All uses changed. (BITS_PER_CHAR): Remove; all uses replaced by CHAR_BIT. This must be the same as CHAR_WIDTH and avoids confusion with Elisp char-width, which counts columns not bits. (BITS_PER_SHORT): Remove; all uses replaced by SHRT_WIDTH. (BITS_PER_LONG): Remove; all uses replaced by LONG_WIDTH. * src/lread.c: Do not include limits.h since CHAR_BIT is no longer used directly.
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/data.c b/src/data.c
index 9a076741f78..d221db429d1 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2935,11 +2935,11 @@ In this case, the sign bit is duplicated. */)
2935 CHECK_NUMBER (value); 2935 CHECK_NUMBER (value);
2936 CHECK_NUMBER (count); 2936 CHECK_NUMBER (count);
2937 2937
2938 if (XINT (count) >= BITS_PER_EMACS_INT) 2938 if (XINT (count) >= EMACS_INT_WIDTH)
2939 XSETINT (val, 0); 2939 XSETINT (val, 0);
2940 else if (XINT (count) > 0) 2940 else if (XINT (count) > 0)
2941 XSETINT (val, XUINT (value) << XFASTINT (count)); 2941 XSETINT (val, XUINT (value) << XFASTINT (count));
2942 else if (XINT (count) <= -BITS_PER_EMACS_INT) 2942 else if (XINT (count) <= -EMACS_INT_WIDTH)
2943 XSETINT (val, XINT (value) < 0 ? -1 : 0); 2943 XSETINT (val, XINT (value) < 0 ? -1 : 0);
2944 else 2944 else
2945 XSETINT (val, XINT (value) >> -XINT (count)); 2945 XSETINT (val, XINT (value) >> -XINT (count));
@@ -2957,11 +2957,11 @@ In this case, zeros are shifted in on the left. */)
2957 CHECK_NUMBER (value); 2957 CHECK_NUMBER (value);
2958 CHECK_NUMBER (count); 2958 CHECK_NUMBER (count);
2959 2959
2960 if (XINT (count) >= BITS_PER_EMACS_INT) 2960 if (XINT (count) >= EMACS_INT_WIDTH)
2961 XSETINT (val, 0); 2961 XSETINT (val, 0);
2962 else if (XINT (count) > 0) 2962 else if (XINT (count) > 0)
2963 XSETINT (val, XUINT (value) << XFASTINT (count)); 2963 XSETINT (val, XUINT (value) << XFASTINT (count));
2964 else if (XINT (count) <= -BITS_PER_EMACS_INT) 2964 else if (XINT (count) <= -EMACS_INT_WIDTH)
2965 XSETINT (val, 0); 2965 XSETINT (val, 0);
2966 else 2966 else
2967 XSETINT (val, XUINT (value) >> -XINT (count)); 2967 XSETINT (val, XUINT (value) >> -XINT (count));
@@ -3031,24 +3031,24 @@ bool_vector_spare_mask (EMACS_INT nr_bits)
3031/* Info about unsigned long long, falling back on unsigned long 3031/* Info about unsigned long long, falling back on unsigned long
3032 if unsigned long long is not available. */ 3032 if unsigned long long is not available. */
3033 3033
3034#if HAVE_UNSIGNED_LONG_LONG_INT && defined ULLONG_MAX 3034#if HAVE_UNSIGNED_LONG_LONG_INT && defined ULLONG_WIDTH
3035enum { BITS_PER_ULL = CHAR_BIT * sizeof (unsigned long long) }; 3035enum { ULL_WIDTH = ULLONG_WIDTH };
3036# define ULL_MAX ULLONG_MAX 3036# define ULL_MAX ULLONG_MAX
3037#else 3037#else
3038enum { BITS_PER_ULL = CHAR_BIT * sizeof (unsigned long) }; 3038enum { ULL_WIDTH = ULONG_WIDTH };
3039# define ULL_MAX ULONG_MAX 3039# define ULL_MAX ULONG_MAX
3040# define count_one_bits_ll count_one_bits_l 3040# define count_one_bits_ll count_one_bits_l
3041# define count_trailing_zeros_ll count_trailing_zeros_l 3041# define count_trailing_zeros_ll count_trailing_zeros_l
3042#endif 3042#endif
3043 3043
3044/* Shift VAL right by the width of an unsigned long long. 3044/* Shift VAL right by the width of an unsigned long long.
3045 BITS_PER_ULL must be less than BITS_PER_BITS_WORD. */ 3045 ULL_WIDTH must be less than BITS_PER_BITS_WORD. */
3046 3046
3047static bits_word 3047static bits_word
3048shift_right_ull (bits_word w) 3048shift_right_ull (bits_word w)
3049{ 3049{
3050 /* Pacify bogus GCC warning about shift count exceeding type width. */ 3050 /* Pacify bogus GCC warning about shift count exceeding type width. */
3051 int shift = BITS_PER_ULL - BITS_PER_BITS_WORD < 0 ? BITS_PER_ULL : 0; 3051 int shift = ULL_WIDTH - BITS_PER_BITS_WORD < 0 ? ULL_WIDTH : 0;
3052 return w >> shift; 3052 return w >> shift;
3053} 3053}
3054 3054
@@ -3065,7 +3065,7 @@ count_one_bits_word (bits_word w)
3065 { 3065 {
3066 int i = 0, count = 0; 3066 int i = 0, count = 0;
3067 while (count += count_one_bits_ll (w), 3067 while (count += count_one_bits_ll (w),
3068 (i += BITS_PER_ULL) < BITS_PER_BITS_WORD) 3068 (i += ULL_WIDTH) < BITS_PER_BITS_WORD)
3069 w = shift_right_ull (w); 3069 w = shift_right_ull (w);
3070 return count; 3070 return count;
3071 } 3071 }
@@ -3210,18 +3210,18 @@ count_trailing_zero_bits (bits_word val)
3210 { 3210 {
3211 int count; 3211 int count;
3212 for (count = 0; 3212 for (count = 0;
3213 count < BITS_PER_BITS_WORD - BITS_PER_ULL; 3213 count < BITS_PER_BITS_WORD - ULL_WIDTH;
3214 count += BITS_PER_ULL) 3214 count += ULL_WIDTH)
3215 { 3215 {
3216 if (val & ULL_MAX) 3216 if (val & ULL_MAX)
3217 return count + count_trailing_zeros_ll (val); 3217 return count + count_trailing_zeros_ll (val);
3218 val = shift_right_ull (val); 3218 val = shift_right_ull (val);
3219 } 3219 }
3220 3220
3221 if (BITS_PER_BITS_WORD % BITS_PER_ULL != 0 3221 if (BITS_PER_BITS_WORD % ULL_WIDTH != 0
3222 && BITS_WORD_MAX == (bits_word) -1) 3222 && BITS_WORD_MAX == (bits_word) -1)
3223 val |= (bits_word) 1 << pre_value (ULONG_MAX < BITS_WORD_MAX, 3223 val |= (bits_word) 1 << pre_value (ULONG_MAX < BITS_WORD_MAX,
3224 BITS_PER_BITS_WORD % BITS_PER_ULL); 3224 BITS_PER_BITS_WORD % ULL_WIDTH);
3225 return count + count_trailing_zeros_ll (val); 3225 return count + count_trailing_zeros_ll (val);
3226 } 3226 }
3227} 3227}