diff options
| author | Paul Eggert | 2016-09-15 15:25:33 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-09-15 15:55:30 -0700 |
| commit | 0bbf00c7f3de9c75372100afc3039d7f5c8a7587 (patch) | |
| tree | 79fccec02fc3a9ceb9e04c16ae2117f725910276 /src | |
| parent | 8f4b6a20bfec96086845b2f7161e121b1e41b4ad (diff) | |
| download | emacs-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')
| -rw-r--r-- | src/data.c | 28 | ||||
| -rw-r--r-- | src/gmalloc.c | 5 | ||||
| -rw-r--r-- | src/image.c | 8 | ||||
| -rw-r--r-- | src/indent.c | 10 | ||||
| -rw-r--r-- | src/lisp.h | 24 | ||||
| -rw-r--r-- | src/lread.c | 3 | ||||
| -rw-r--r-- | src/sysdep.c | 4 | ||||
| -rw-r--r-- | src/term.c | 2 | ||||
| -rw-r--r-- | src/w32proc.c | 2 | ||||
| -rw-r--r-- | src/xfaces.c | 3 | ||||
| -rw-r--r-- | src/xfns.c | 2 | ||||
| -rw-r--r-- | src/xselect.c | 4 | ||||
| -rw-r--r-- | src/xterm.c | 5 |
13 files changed, 46 insertions, 54 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 |
| 3035 | enum { BITS_PER_ULL = CHAR_BIT * sizeof (unsigned long long) }; | 3035 | enum { ULL_WIDTH = ULLONG_WIDTH }; |
| 3036 | # define ULL_MAX ULLONG_MAX | 3036 | # define ULL_MAX ULLONG_MAX |
| 3037 | #else | 3037 | #else |
| 3038 | enum { BITS_PER_ULL = CHAR_BIT * sizeof (unsigned long) }; | 3038 | enum { 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 | ||
| 3047 | static bits_word | 3047 | static bits_word |
| 3048 | shift_right_ull (bits_word w) | 3048 | shift_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 | } |
diff --git a/src/gmalloc.c b/src/gmalloc.c index 483d05c5c61..33d424fe9af 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c | |||
| @@ -118,14 +118,13 @@ extern int posix_memalign (void **, size_t, size_t); | |||
| 118 | receive a fragment of a block. Fragment sizes are powers of two, | 118 | receive a fragment of a block. Fragment sizes are powers of two, |
| 119 | and all fragments of a block are the same size. When all the | 119 | and all fragments of a block are the same size. When all the |
| 120 | fragments in a block have been freed, the block itself is freed. */ | 120 | fragments in a block have been freed, the block itself is freed. */ |
| 121 | #define INT_BIT (CHAR_BIT * sizeof (int)) | 121 | #define BLOCKLOG (INT_WIDTH > 16 ? 12 : 9) |
| 122 | #define BLOCKLOG (INT_BIT > 16 ? 12 : 9) | ||
| 123 | #define BLOCKSIZE (1 << BLOCKLOG) | 122 | #define BLOCKSIZE (1 << BLOCKLOG) |
| 124 | #define BLOCKIFY(SIZE) (((SIZE) + BLOCKSIZE - 1) / BLOCKSIZE) | 123 | #define BLOCKIFY(SIZE) (((SIZE) + BLOCKSIZE - 1) / BLOCKSIZE) |
| 125 | 124 | ||
| 126 | /* Determine the amount of memory spanned by the initial heap table | 125 | /* Determine the amount of memory spanned by the initial heap table |
| 127 | (not an absolute limit). */ | 126 | (not an absolute limit). */ |
| 128 | #define HEAP (INT_BIT > 16 ? 4194304 : 65536) | 127 | #define HEAP (INT_WIDTH > 16 ? 4194304 : 65536) |
| 129 | 128 | ||
| 130 | /* Number of contiguous free blocks allowed to build up at the end of | 129 | /* Number of contiguous free blocks allowed to build up at the end of |
| 131 | memory before they will be returned to the system. */ | 130 | memory before they will be returned to the system. */ |
diff --git a/src/image.c b/src/image.c index f15c2788967..53ec3873632 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -2525,7 +2525,7 @@ xbm_image_p (Lisp_Object object) | |||
| 2525 | if (STRINGP (elt)) | 2525 | if (STRINGP (elt)) |
| 2526 | { | 2526 | { |
| 2527 | if (SCHARS (elt) | 2527 | if (SCHARS (elt) |
| 2528 | < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR) | 2528 | < (width + CHAR_BIT - 1) / CHAR_BIT) |
| 2529 | return 0; | 2529 | return 0; |
| 2530 | } | 2530 | } |
| 2531 | else if (BOOL_VECTOR_P (elt)) | 2531 | else if (BOOL_VECTOR_P (elt)) |
| @@ -2540,7 +2540,7 @@ xbm_image_p (Lisp_Object object) | |||
| 2540 | else if (STRINGP (data)) | 2540 | else if (STRINGP (data)) |
| 2541 | { | 2541 | { |
| 2542 | if (SCHARS (data) | 2542 | if (SCHARS (data) |
| 2543 | < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR * height) | 2543 | < (width + CHAR_BIT - 1) / CHAR_BIT * height) |
| 2544 | return 0; | 2544 | return 0; |
| 2545 | } | 2545 | } |
| 2546 | else if (BOOL_VECTOR_P (data)) | 2546 | else if (BOOL_VECTOR_P (data)) |
| @@ -3089,7 +3089,7 @@ xbm_load (struct frame *f, struct image *img) | |||
| 3089 | { | 3089 | { |
| 3090 | int i; | 3090 | int i; |
| 3091 | char *p; | 3091 | char *p; |
| 3092 | int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR; | 3092 | int nbytes = (img->width + CHAR_BIT - 1) / CHAR_BIT; |
| 3093 | 3093 | ||
| 3094 | SAFE_NALLOCA (bits, nbytes, img->height); | 3094 | SAFE_NALLOCA (bits, nbytes, img->height); |
| 3095 | p = bits; | 3095 | p = bits; |
| @@ -3113,7 +3113,7 @@ xbm_load (struct frame *f, struct image *img) | |||
| 3113 | int nbytes, i; | 3113 | int nbytes, i; |
| 3114 | /* Windows mono bitmaps are reversed compared with X. */ | 3114 | /* Windows mono bitmaps are reversed compared with X. */ |
| 3115 | invertedBits = bits; | 3115 | invertedBits = bits; |
| 3116 | nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR; | 3116 | nbytes = (img->width + CHAR_BIT - 1) / CHAR_BIT; |
| 3117 | SAFE_NALLOCA (bits, nbytes, img->height); | 3117 | SAFE_NALLOCA (bits, nbytes, img->height); |
| 3118 | for (i = 0; i < nbytes; i++) | 3118 | for (i = 0; i < nbytes; i++) |
| 3119 | bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]); | 3119 | bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]); |
diff --git a/src/indent.c b/src/indent.c index cc5bf37f1df..b68b60297fd 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -1876,9 +1876,9 @@ vmotion (register ptrdiff_t from, register ptrdiff_t from_byte, | |||
| 1876 | } | 1876 | } |
| 1877 | pos = *compute_motion (prevline, bytepos, 0, lmargin, 0, from, | 1877 | pos = *compute_motion (prevline, bytepos, 0, lmargin, 0, from, |
| 1878 | /* Don't care for VPOS... */ | 1878 | /* Don't care for VPOS... */ |
| 1879 | 1 << (BITS_PER_SHORT - 1), | 1879 | 1 << (SHRT_WIDTH - 1), |
| 1880 | /* ... nor HPOS. */ | 1880 | /* ... nor HPOS. */ |
| 1881 | 1 << (BITS_PER_SHORT - 1), | 1881 | 1 << (SHRT_WIDTH - 1), |
| 1882 | -1, hscroll, 0, w); | 1882 | -1, hscroll, 0, w); |
| 1883 | vpos -= pos.vpos; | 1883 | vpos -= pos.vpos; |
| 1884 | first = 0; | 1884 | first = 0; |
| @@ -1926,9 +1926,9 @@ vmotion (register ptrdiff_t from, register ptrdiff_t from_byte, | |||
| 1926 | } | 1926 | } |
| 1927 | pos = *compute_motion (prevline, bytepos, 0, lmargin, 0, from, | 1927 | pos = *compute_motion (prevline, bytepos, 0, lmargin, 0, from, |
| 1928 | /* Don't care for VPOS... */ | 1928 | /* Don't care for VPOS... */ |
| 1929 | 1 << (BITS_PER_SHORT - 1), | 1929 | 1 << (SHRT_WIDTH - 1), |
| 1930 | /* ... nor HPOS. */ | 1930 | /* ... nor HPOS. */ |
| 1931 | 1 << (BITS_PER_SHORT - 1), | 1931 | 1 << (SHRT_WIDTH - 1), |
| 1932 | -1, hscroll, 0, w); | 1932 | -1, hscroll, 0, w); |
| 1933 | did_motion = 1; | 1933 | did_motion = 1; |
| 1934 | } | 1934 | } |
| @@ -1939,7 +1939,7 @@ vmotion (register ptrdiff_t from, register ptrdiff_t from_byte, | |||
| 1939 | did_motion = 0; | 1939 | did_motion = 0; |
| 1940 | } | 1940 | } |
| 1941 | return compute_motion (from, from_byte, vpos, pos.hpos, did_motion, | 1941 | return compute_motion (from, from_byte, vpos, pos.hpos, did_motion, |
| 1942 | ZV, vtarget, - (1 << (BITS_PER_SHORT - 1)), | 1942 | ZV, vtarget, - (1 << (SHRT_WIDTH - 1)), |
| 1943 | -1, hscroll, 0, w); | 1943 | -1, hscroll, 0, w); |
| 1944 | } | 1944 | } |
| 1945 | 1945 | ||
diff --git a/src/lisp.h b/src/lisp.h index d3331861fe3..f653d855dad 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -68,6 +68,7 @@ DEFINE_GDB_SYMBOL_BEGIN (int, GCTYPEBITS) | |||
| 68 | DEFINE_GDB_SYMBOL_END (GCTYPEBITS) | 68 | DEFINE_GDB_SYMBOL_END (GCTYPEBITS) |
| 69 | 69 | ||
| 70 | /* EMACS_INT - signed integer wide enough to hold an Emacs value | 70 | /* EMACS_INT - signed integer wide enough to hold an Emacs value |
| 71 | EMACS_INT_WIDTH - width in bits of EMACS_INT | ||
| 71 | EMACS_INT_MAX - maximum value of EMACS_INT; can be used in #if | 72 | EMACS_INT_MAX - maximum value of EMACS_INT; can be used in #if |
| 72 | pI - printf length modifier for EMACS_INT | 73 | pI - printf length modifier for EMACS_INT |
| 73 | EMACS_UINT - unsigned variant of EMACS_INT */ | 74 | EMACS_UINT - unsigned variant of EMACS_INT */ |
| @@ -77,16 +78,19 @@ DEFINE_GDB_SYMBOL_END (GCTYPEBITS) | |||
| 77 | # elif INTPTR_MAX <= INT_MAX && !defined WIDE_EMACS_INT | 78 | # elif INTPTR_MAX <= INT_MAX && !defined WIDE_EMACS_INT |
| 78 | typedef int EMACS_INT; | 79 | typedef int EMACS_INT; |
| 79 | typedef unsigned int EMACS_UINT; | 80 | typedef unsigned int EMACS_UINT; |
| 81 | enum { EMACS_INT_WIDTH = INT_WIDTH }; | ||
| 80 | # define EMACS_INT_MAX INT_MAX | 82 | # define EMACS_INT_MAX INT_MAX |
| 81 | # define pI "" | 83 | # define pI "" |
| 82 | # elif INTPTR_MAX <= LONG_MAX && !defined WIDE_EMACS_INT | 84 | # elif INTPTR_MAX <= LONG_MAX && !defined WIDE_EMACS_INT |
| 83 | typedef long int EMACS_INT; | 85 | typedef long int EMACS_INT; |
| 84 | typedef unsigned long EMACS_UINT; | 86 | typedef unsigned long EMACS_UINT; |
| 87 | enum { EMACS_INT_WIDTH = LONG_WIDTH }; | ||
| 85 | # define EMACS_INT_MAX LONG_MAX | 88 | # define EMACS_INT_MAX LONG_MAX |
| 86 | # define pI "l" | 89 | # define pI "l" |
| 87 | # elif INTPTR_MAX <= LLONG_MAX | 90 | # elif INTPTR_MAX <= LLONG_MAX |
| 88 | typedef long long int EMACS_INT; | 91 | typedef long long int EMACS_INT; |
| 89 | typedef unsigned long long int EMACS_UINT; | 92 | typedef unsigned long long int EMACS_UINT; |
| 93 | enum { EMACS_INT_WIDTH = LLONG_WIDTH }; | ||
| 90 | # define EMACS_INT_MAX LLONG_MAX | 94 | # define EMACS_INT_MAX LLONG_MAX |
| 91 | # ifdef __MINGW32__ | 95 | # ifdef __MINGW32__ |
| 92 | # define pI "I64" | 96 | # define pI "I64" |
| @@ -107,11 +111,12 @@ enum { BOOL_VECTOR_BITS_PER_CHAR = | |||
| 107 | 111 | ||
| 108 | /* An unsigned integer type representing a fixed-length bit sequence, | 112 | /* An unsigned integer type representing a fixed-length bit sequence, |
| 109 | suitable for bool vector words, GC mark bits, etc. Normally it is size_t | 113 | suitable for bool vector words, GC mark bits, etc. Normally it is size_t |
| 110 | for speed, but it is unsigned char on weird platforms. */ | 114 | for speed, but on weird platforms it is unsigned char and not all |
| 115 | its bits are used. */ | ||
| 111 | #if BOOL_VECTOR_BITS_PER_CHAR == CHAR_BIT | 116 | #if BOOL_VECTOR_BITS_PER_CHAR == CHAR_BIT |
| 112 | typedef size_t bits_word; | 117 | typedef size_t bits_word; |
| 113 | # define BITS_WORD_MAX SIZE_MAX | 118 | # define BITS_WORD_MAX SIZE_MAX |
| 114 | enum { BITS_PER_BITS_WORD = CHAR_BIT * sizeof (bits_word) }; | 119 | enum { BITS_PER_BITS_WORD = SIZE_WIDTH }; |
| 115 | #else | 120 | #else |
| 116 | typedef unsigned char bits_word; | 121 | typedef unsigned char bits_word; |
| 117 | # define BITS_WORD_MAX ((1u << BOOL_VECTOR_BITS_PER_CHAR) - 1) | 122 | # define BITS_WORD_MAX ((1u << BOOL_VECTOR_BITS_PER_CHAR) - 1) |
| @@ -119,15 +124,6 @@ enum { BITS_PER_BITS_WORD = BOOL_VECTOR_BITS_PER_CHAR }; | |||
| 119 | #endif | 124 | #endif |
| 120 | verify (BITS_WORD_MAX >> (BITS_PER_BITS_WORD - 1) == 1); | 125 | verify (BITS_WORD_MAX >> (BITS_PER_BITS_WORD - 1) == 1); |
| 121 | 126 | ||
| 122 | /* Number of bits in some machine integer types. */ | ||
| 123 | enum | ||
| 124 | { | ||
| 125 | BITS_PER_CHAR = CHAR_BIT, | ||
| 126 | BITS_PER_SHORT = CHAR_BIT * sizeof (short), | ||
| 127 | BITS_PER_LONG = CHAR_BIT * sizeof (long int), | ||
| 128 | BITS_PER_EMACS_INT = CHAR_BIT * sizeof (EMACS_INT) | ||
| 129 | }; | ||
| 130 | |||
| 131 | /* printmax_t and uprintmax_t are types for printing large integers. | 127 | /* printmax_t and uprintmax_t are types for printing large integers. |
| 132 | These are the widest integers that are supported for printing. | 128 | These are the widest integers that are supported for printing. |
| 133 | pMd etc. are conversions for printing them. | 129 | pMd etc. are conversions for printing them. |
| @@ -232,7 +228,7 @@ enum Lisp_Bits | |||
| 232 | #define GCALIGNMENT 8 | 228 | #define GCALIGNMENT 8 |
| 233 | 229 | ||
| 234 | /* Number of bits in a Lisp_Object value, not counting the tag. */ | 230 | /* Number of bits in a Lisp_Object value, not counting the tag. */ |
| 235 | VALBITS = BITS_PER_EMACS_INT - GCTYPEBITS, | 231 | VALBITS = EMACS_INT_WIDTH - GCTYPEBITS, |
| 236 | 232 | ||
| 237 | /* Number of bits in a Lisp fixnum tag. */ | 233 | /* Number of bits in a Lisp fixnum tag. */ |
| 238 | INTTYPEBITS = GCTYPEBITS - 1, | 234 | INTTYPEBITS = GCTYPEBITS - 1, |
| @@ -2027,7 +2023,7 @@ static double const DEFAULT_REHASH_SIZE = 1.5; | |||
| 2027 | INLINE EMACS_UINT | 2023 | INLINE EMACS_UINT |
| 2028 | sxhash_combine (EMACS_UINT x, EMACS_UINT y) | 2024 | sxhash_combine (EMACS_UINT x, EMACS_UINT y) |
| 2029 | { | 2025 | { |
| 2030 | return (x << 4) + (x >> (BITS_PER_EMACS_INT - 4)) + y; | 2026 | return (x << 4) + (x >> (EMACS_INT_WIDTH - 4)) + y; |
| 2031 | } | 2027 | } |
| 2032 | 2028 | ||
| 2033 | /* Hash X, returning a value that fits into a fixnum. */ | 2029 | /* Hash X, returning a value that fits into a fixnum. */ |
| @@ -2035,7 +2031,7 @@ sxhash_combine (EMACS_UINT x, EMACS_UINT y) | |||
| 2035 | INLINE EMACS_UINT | 2031 | INLINE EMACS_UINT |
| 2036 | SXHASH_REDUCE (EMACS_UINT x) | 2032 | SXHASH_REDUCE (EMACS_UINT x) |
| 2037 | { | 2033 | { |
| 2038 | return (x ^ x >> (BITS_PER_EMACS_INT - FIXNUM_BITS)) & INTMASK; | 2034 | return (x ^ x >> (EMACS_INT_WIDTH - FIXNUM_BITS)) & INTMASK; |
| 2039 | } | 2035 | } |
| 2040 | 2036 | ||
| 2041 | /* These structures are used for various misc types. */ | 2037 | /* These structures are used for various misc types. */ |
diff --git a/src/lread.c b/src/lread.c index ecd482793a9..dc7c00bbfae 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -27,7 +27,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 27 | #include <sys/stat.h> | 27 | #include <sys/stat.h> |
| 28 | #include <sys/file.h> | 28 | #include <sys/file.h> |
| 29 | #include <errno.h> | 29 | #include <errno.h> |
| 30 | #include <limits.h> /* For CHAR_BIT. */ | ||
| 31 | #include <math.h> | 30 | #include <math.h> |
| 32 | #include <stat-time.h> | 31 | #include <stat-time.h> |
| 33 | #include "lisp.h" | 32 | #include "lisp.h" |
| @@ -2471,7 +2470,7 @@ read_integer (Lisp_Object readcharfun, EMACS_INT radix) | |||
| 2471 | { | 2470 | { |
| 2472 | /* Room for sign, leading 0, other digits, trailing null byte. | 2471 | /* Room for sign, leading 0, other digits, trailing null byte. |
| 2473 | Also, room for invalid syntax diagnostic. */ | 2472 | Also, room for invalid syntax diagnostic. */ |
| 2474 | char buf[max (1 + 1 + sizeof (uintmax_t) * CHAR_BIT + 1, | 2473 | char buf[max (1 + 1 + UINTMAX_WIDTH + 1, |
| 2475 | sizeof "integer, radix " + INT_STRLEN_BOUND (EMACS_INT))]; | 2474 | sizeof "integer, radix " + INT_STRLEN_BOUND (EMACS_INT))]; |
| 2476 | 2475 | ||
| 2477 | int valid = -1; /* 1 if valid, 0 if not, -1 if incomplete. */ | 2476 | int valid = -1; /* 1 if valid, 0 if not, -1 if incomplete. */ |
diff --git a/src/sysdep.c b/src/sysdep.c index 70cb961e21f..190d6fbe920 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -2223,8 +2223,8 @@ get_random (void) | |||
| 2223 | int i; | 2223 | int i; |
| 2224 | for (i = 0; i < (FIXNUM_BITS + RAND_BITS - 1) / RAND_BITS; i++) | 2224 | for (i = 0; i < (FIXNUM_BITS + RAND_BITS - 1) / RAND_BITS; i++) |
| 2225 | val = (random () ^ (val << RAND_BITS) | 2225 | val = (random () ^ (val << RAND_BITS) |
| 2226 | ^ (val >> (BITS_PER_EMACS_INT - RAND_BITS))); | 2226 | ^ (val >> (EMACS_INT_WIDTH - RAND_BITS))); |
| 2227 | val ^= val >> (BITS_PER_EMACS_INT - FIXNUM_BITS); | 2227 | val ^= val >> (EMACS_INT_WIDTH - FIXNUM_BITS); |
| 2228 | return val & INTMASK; | 2228 | return val & INTMASK; |
| 2229 | } | 2229 | } |
| 2230 | 2230 | ||
diff --git a/src/term.c b/src/term.c index 426674f4470..c22d07ac579 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -1821,7 +1821,7 @@ static void | |||
| 1821 | produce_glyphless_glyph (struct it *it, Lisp_Object acronym) | 1821 | produce_glyphless_glyph (struct it *it, Lisp_Object acronym) |
| 1822 | { | 1822 | { |
| 1823 | int len, face_id = merge_glyphless_glyph_face (it); | 1823 | int len, face_id = merge_glyphless_glyph_face (it); |
| 1824 | char buf[sizeof "\\x" + max (6, (sizeof it->c * CHAR_BIT + 3) / 4)]; | 1824 | char buf[sizeof "\\x" + max (6, (INT_WIDTH + 3) / 4)]; |
| 1825 | char const *str = " "; | 1825 | char const *str = " "; |
| 1826 | 1826 | ||
| 1827 | if (it->glyphless_method == GLYPHLESS_DISPLAY_THIN_SPACE) | 1827 | if (it->glyphless_method == GLYPHLESS_DISPLAY_THIN_SPACE) |
diff --git a/src/w32proc.c b/src/w32proc.c index 217d005a363..90cef3231c8 100644 --- a/src/w32proc.c +++ b/src/w32proc.c | |||
| @@ -224,7 +224,7 @@ sigismember (const sigset_t *set, int signo) | |||
| 224 | errno = EINVAL; | 224 | errno = EINVAL; |
| 225 | return -1; | 225 | return -1; |
| 226 | } | 226 | } |
| 227 | if (signo > sizeof (*set) * BITS_PER_CHAR) | 227 | if (signo > sizeof (*set) * CHAR_BIT) |
| 228 | emacs_abort (); | 228 | emacs_abort (); |
| 229 | 229 | ||
| 230 | return (*set & (1U << signo)) != 0; | 230 | return (*set & (1U << signo)) != 0; |
diff --git a/src/xfaces.c b/src/xfaces.c index 0a1315d6f0d..056f90cb7ac 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -737,8 +737,7 @@ the pixmap. Bits are stored row by row, each row occupies | |||
| 737 | && RANGED_INTEGERP (1, width, INT_MAX) | 737 | && RANGED_INTEGERP (1, width, INT_MAX) |
| 738 | && RANGED_INTEGERP (1, height, INT_MAX)) | 738 | && RANGED_INTEGERP (1, height, INT_MAX)) |
| 739 | { | 739 | { |
| 740 | int bytes_per_row = ((XINT (width) + BITS_PER_CHAR - 1) | 740 | int bytes_per_row = (XINT (width) + CHAR_BIT - 1) / CHAR_BIT; |
| 741 | / BITS_PER_CHAR); | ||
| 742 | if (XINT (height) <= SBYTES (data) / bytes_per_row) | 741 | if (XINT (height) <= SBYTES (data) / bytes_per_row) |
| 743 | pixmap_p = true; | 742 | pixmap_p = true; |
| 744 | } | 743 | } |
diff --git a/src/xfns.c b/src/xfns.c index 2dfb8dfccab..dd39e782fac 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -5219,7 +5219,7 @@ x_window_property_intern (struct frame *f, | |||
| 5219 | property and those are indeed in 32 bit quantities if format is | 5219 | property and those are indeed in 32 bit quantities if format is |
| 5220 | 32. */ | 5220 | 32. */ |
| 5221 | 5221 | ||
| 5222 | if (BITS_PER_LONG > 32 && actual_format == 32) | 5222 | if (LONG_WIDTH > 32 && actual_format == 32) |
| 5223 | { | 5223 | { |
| 5224 | unsigned long i; | 5224 | unsigned long i; |
| 5225 | int *idata = (int *) tmp_data; | 5225 | int *idata = (int *) tmp_data; |
diff --git a/src/xselect.c b/src/xselect.c index 156888a540b..93b81b9fca1 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -1318,7 +1318,7 @@ x_get_window_property (Display *display, Window window, Atom property, | |||
| 1318 | data = data1; | 1318 | data = data1; |
| 1319 | } | 1319 | } |
| 1320 | 1320 | ||
| 1321 | if (BITS_PER_LONG > 32 && *actual_format_ret == 32) | 1321 | if (LONG_WIDTH > 32 && *actual_format_ret == 32) |
| 1322 | { | 1322 | { |
| 1323 | unsigned long i; | 1323 | unsigned long i; |
| 1324 | int *idata = (int *) (data + offset); | 1324 | int *idata = (int *) (data + offset); |
| @@ -2473,7 +2473,7 @@ x_handle_dnd_message (struct frame *f, const XClientMessageEvent *event, | |||
| 2473 | function expects them to be of size int (i.e. 32). So to be able to | 2473 | function expects them to be of size int (i.e. 32). So to be able to |
| 2474 | use that function, put the data in the form it expects if format is 32. */ | 2474 | use that function, put the data in the form it expects if format is 32. */ |
| 2475 | 2475 | ||
| 2476 | if (BITS_PER_LONG > 32 && event->format == 32) | 2476 | if (LONG_WIDTH > 32 && event->format == 32) |
| 2477 | { | 2477 | { |
| 2478 | for (i = 0; i < 5; ++i) /* There are only 5 longs in a ClientMessage. */ | 2478 | for (i = 0; i < 5; ++i) /* There are only 5 longs in a ClientMessage. */ |
| 2479 | idata[i] = event->data.l[i]; | 2479 | idata[i] = event->data.l[i]; |
diff --git a/src/xterm.c b/src/xterm.c index cd1d712f39a..4c14e62058f 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -5245,9 +5245,8 @@ x_send_scroll_bar_event (Lisp_Object window, enum scroll_bar_part part, | |||
| 5245 | struct window *w = XWINDOW (window); | 5245 | struct window *w = XWINDOW (window); |
| 5246 | struct frame *f = XFRAME (w->frame); | 5246 | struct frame *f = XFRAME (w->frame); |
| 5247 | intptr_t iw = (intptr_t) w; | 5247 | intptr_t iw = (intptr_t) w; |
| 5248 | enum { BITS_PER_INTPTR = CHAR_BIT * sizeof iw }; | 5248 | verify (INTPTR_WIDTH <= 64); |
| 5249 | verify (BITS_PER_INTPTR <= 64); | 5249 | int sign_shift = INTPTR_WIDTH - 32; |
| 5250 | int sign_shift = BITS_PER_INTPTR - 32; | ||
| 5251 | 5250 | ||
| 5252 | block_input (); | 5251 | block_input (); |
| 5253 | 5252 | ||