CHECK_NUMBER (value);
CHECK_NUMBER (count);
- if (XINT (count) >= BITS_PER_EMACS_INT)
+ if (XINT (count) >= EMACS_INT_WIDTH)
XSETINT (val, 0);
else if (XINT (count) > 0)
XSETINT (val, XUINT (value) << XFASTINT (count));
- else if (XINT (count) <= -BITS_PER_EMACS_INT)
+ else if (XINT (count) <= -EMACS_INT_WIDTH)
XSETINT (val, XINT (value) < 0 ? -1 : 0);
else
XSETINT (val, XINT (value) >> -XINT (count));
CHECK_NUMBER (value);
CHECK_NUMBER (count);
- if (XINT (count) >= BITS_PER_EMACS_INT)
+ if (XINT (count) >= EMACS_INT_WIDTH)
XSETINT (val, 0);
else if (XINT (count) > 0)
XSETINT (val, XUINT (value) << XFASTINT (count));
- else if (XINT (count) <= -BITS_PER_EMACS_INT)
+ else if (XINT (count) <= -EMACS_INT_WIDTH)
XSETINT (val, 0);
else
XSETINT (val, XUINT (value) >> -XINT (count));
/* Info about unsigned long long, falling back on unsigned long
if unsigned long long is not available. */
-#if HAVE_UNSIGNED_LONG_LONG_INT && defined ULLONG_MAX
-enum { BITS_PER_ULL = CHAR_BIT * sizeof (unsigned long long) };
+#if HAVE_UNSIGNED_LONG_LONG_INT && defined ULLONG_WIDTH
+enum { ULL_WIDTH = ULLONG_WIDTH };
# define ULL_MAX ULLONG_MAX
#else
-enum { BITS_PER_ULL = CHAR_BIT * sizeof (unsigned long) };
+enum { ULL_WIDTH = ULONG_WIDTH };
# define ULL_MAX ULONG_MAX
# define count_one_bits_ll count_one_bits_l
# define count_trailing_zeros_ll count_trailing_zeros_l
#endif
/* Shift VAL right by the width of an unsigned long long.
- BITS_PER_ULL must be less than BITS_PER_BITS_WORD. */
+ ULL_WIDTH must be less than BITS_PER_BITS_WORD. */
static bits_word
shift_right_ull (bits_word w)
{
/* Pacify bogus GCC warning about shift count exceeding type width. */
- int shift = BITS_PER_ULL - BITS_PER_BITS_WORD < 0 ? BITS_PER_ULL : 0;
+ int shift = ULL_WIDTH - BITS_PER_BITS_WORD < 0 ? ULL_WIDTH : 0;
return w >> shift;
}
{
int i = 0, count = 0;
while (count += count_one_bits_ll (w),
- (i += BITS_PER_ULL) < BITS_PER_BITS_WORD)
+ (i += ULL_WIDTH) < BITS_PER_BITS_WORD)
w = shift_right_ull (w);
return count;
}
{
int count;
for (count = 0;
- count < BITS_PER_BITS_WORD - BITS_PER_ULL;
- count += BITS_PER_ULL)
+ count < BITS_PER_BITS_WORD - ULL_WIDTH;
+ count += ULL_WIDTH)
{
if (val & ULL_MAX)
return count + count_trailing_zeros_ll (val);
val = shift_right_ull (val);
}
- if (BITS_PER_BITS_WORD % BITS_PER_ULL != 0
+ if (BITS_PER_BITS_WORD % ULL_WIDTH != 0
&& BITS_WORD_MAX == (bits_word) -1)
val |= (bits_word) 1 << pre_value (ULONG_MAX < BITS_WORD_MAX,
- BITS_PER_BITS_WORD % BITS_PER_ULL);
+ BITS_PER_BITS_WORD % ULL_WIDTH);
return count + count_trailing_zeros_ll (val);
}
}
receive a fragment of a block. Fragment sizes are powers of two,
and all fragments of a block are the same size. When all the
fragments in a block have been freed, the block itself is freed. */
-#define INT_BIT (CHAR_BIT * sizeof (int))
-#define BLOCKLOG (INT_BIT > 16 ? 12 : 9)
+#define BLOCKLOG (INT_WIDTH > 16 ? 12 : 9)
#define BLOCKSIZE (1 << BLOCKLOG)
#define BLOCKIFY(SIZE) (((SIZE) + BLOCKSIZE - 1) / BLOCKSIZE)
/* Determine the amount of memory spanned by the initial heap table
(not an absolute limit). */
-#define HEAP (INT_BIT > 16 ? 4194304 : 65536)
+#define HEAP (INT_WIDTH > 16 ? 4194304 : 65536)
/* Number of contiguous free blocks allowed to build up at the end of
memory before they will be returned to the system. */
if (STRINGP (elt))
{
if (SCHARS (elt)
- < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR)
+ < (width + CHAR_BIT - 1) / CHAR_BIT)
return 0;
}
else if (BOOL_VECTOR_P (elt))
else if (STRINGP (data))
{
if (SCHARS (data)
- < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR * height)
+ < (width + CHAR_BIT - 1) / CHAR_BIT * height)
return 0;
}
else if (BOOL_VECTOR_P (data))
{
int i;
char *p;
- int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR;
+ int nbytes = (img->width + CHAR_BIT - 1) / CHAR_BIT;
SAFE_NALLOCA (bits, nbytes, img->height);
p = bits;
int nbytes, i;
/* Windows mono bitmaps are reversed compared with X. */
invertedBits = bits;
- nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR;
+ nbytes = (img->width + CHAR_BIT - 1) / CHAR_BIT;
SAFE_NALLOCA (bits, nbytes, img->height);
for (i = 0; i < nbytes; i++)
bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]);
}
pos = *compute_motion (prevline, bytepos, 0, lmargin, 0, from,
/* Don't care for VPOS... */
- 1 << (BITS_PER_SHORT - 1),
+ 1 << (SHRT_WIDTH - 1),
/* ... nor HPOS. */
- 1 << (BITS_PER_SHORT - 1),
+ 1 << (SHRT_WIDTH - 1),
-1, hscroll, 0, w);
vpos -= pos.vpos;
first = 0;
}
pos = *compute_motion (prevline, bytepos, 0, lmargin, 0, from,
/* Don't care for VPOS... */
- 1 << (BITS_PER_SHORT - 1),
+ 1 << (SHRT_WIDTH - 1),
/* ... nor HPOS. */
- 1 << (BITS_PER_SHORT - 1),
+ 1 << (SHRT_WIDTH - 1),
-1, hscroll, 0, w);
did_motion = 1;
}
did_motion = 0;
}
return compute_motion (from, from_byte, vpos, pos.hpos, did_motion,
- ZV, vtarget, - (1 << (BITS_PER_SHORT - 1)),
+ ZV, vtarget, - (1 << (SHRT_WIDTH - 1)),
-1, hscroll, 0, w);
}
DEFINE_GDB_SYMBOL_END (GCTYPEBITS)
/* EMACS_INT - signed integer wide enough to hold an Emacs value
+ EMACS_INT_WIDTH - width in bits of EMACS_INT
EMACS_INT_MAX - maximum value of EMACS_INT; can be used in #if
pI - printf length modifier for EMACS_INT
EMACS_UINT - unsigned variant of EMACS_INT */
# elif INTPTR_MAX <= INT_MAX && !defined WIDE_EMACS_INT
typedef int EMACS_INT;
typedef unsigned int EMACS_UINT;
+enum { EMACS_INT_WIDTH = INT_WIDTH };
# define EMACS_INT_MAX INT_MAX
# define pI ""
# elif INTPTR_MAX <= LONG_MAX && !defined WIDE_EMACS_INT
typedef long int EMACS_INT;
typedef unsigned long EMACS_UINT;
+enum { EMACS_INT_WIDTH = LONG_WIDTH };
# define EMACS_INT_MAX LONG_MAX
# define pI "l"
# elif INTPTR_MAX <= LLONG_MAX
typedef long long int EMACS_INT;
typedef unsigned long long int EMACS_UINT;
+enum { EMACS_INT_WIDTH = LLONG_WIDTH };
# define EMACS_INT_MAX LLONG_MAX
# ifdef __MINGW32__
# define pI "I64"
/* An unsigned integer type representing a fixed-length bit sequence,
suitable for bool vector words, GC mark bits, etc. Normally it is size_t
- for speed, but it is unsigned char on weird platforms. */
+ for speed, but on weird platforms it is unsigned char and not all
+ its bits are used. */
#if BOOL_VECTOR_BITS_PER_CHAR == CHAR_BIT
typedef size_t bits_word;
# define BITS_WORD_MAX SIZE_MAX
-enum { BITS_PER_BITS_WORD = CHAR_BIT * sizeof (bits_word) };
+enum { BITS_PER_BITS_WORD = SIZE_WIDTH };
#else
typedef unsigned char bits_word;
# define BITS_WORD_MAX ((1u << BOOL_VECTOR_BITS_PER_CHAR) - 1)
#endif
verify (BITS_WORD_MAX >> (BITS_PER_BITS_WORD - 1) == 1);
-/* Number of bits in some machine integer types. */
-enum
- {
- BITS_PER_CHAR = CHAR_BIT,
- BITS_PER_SHORT = CHAR_BIT * sizeof (short),
- BITS_PER_LONG = CHAR_BIT * sizeof (long int),
- BITS_PER_EMACS_INT = CHAR_BIT * sizeof (EMACS_INT)
- };
-
/* printmax_t and uprintmax_t are types for printing large integers.
These are the widest integers that are supported for printing.
pMd etc. are conversions for printing them.
#define GCALIGNMENT 8
/* Number of bits in a Lisp_Object value, not counting the tag. */
- VALBITS = BITS_PER_EMACS_INT - GCTYPEBITS,
+ VALBITS = EMACS_INT_WIDTH - GCTYPEBITS,
/* Number of bits in a Lisp fixnum tag. */
INTTYPEBITS = GCTYPEBITS - 1,
INLINE EMACS_UINT
sxhash_combine (EMACS_UINT x, EMACS_UINT y)
{
- return (x << 4) + (x >> (BITS_PER_EMACS_INT - 4)) + y;
+ return (x << 4) + (x >> (EMACS_INT_WIDTH - 4)) + y;
}
/* Hash X, returning a value that fits into a fixnum. */
INLINE EMACS_UINT
SXHASH_REDUCE (EMACS_UINT x)
{
- return (x ^ x >> (BITS_PER_EMACS_INT - FIXNUM_BITS)) & INTMASK;
+ return (x ^ x >> (EMACS_INT_WIDTH - FIXNUM_BITS)) & INTMASK;
}
/* These structures are used for various misc types. */
#include <sys/stat.h>
#include <sys/file.h>
#include <errno.h>
-#include <limits.h> /* For CHAR_BIT. */
#include <math.h>
#include <stat-time.h>
#include "lisp.h"
{
/* Room for sign, leading 0, other digits, trailing null byte.
Also, room for invalid syntax diagnostic. */
- char buf[max (1 + 1 + sizeof (uintmax_t) * CHAR_BIT + 1,
+ char buf[max (1 + 1 + UINTMAX_WIDTH + 1,
sizeof "integer, radix " + INT_STRLEN_BOUND (EMACS_INT))];
int valid = -1; /* 1 if valid, 0 if not, -1 if incomplete. */
int i;
for (i = 0; i < (FIXNUM_BITS + RAND_BITS - 1) / RAND_BITS; i++)
val = (random () ^ (val << RAND_BITS)
- ^ (val >> (BITS_PER_EMACS_INT - RAND_BITS)));
- val ^= val >> (BITS_PER_EMACS_INT - FIXNUM_BITS);
+ ^ (val >> (EMACS_INT_WIDTH - RAND_BITS)));
+ val ^= val >> (EMACS_INT_WIDTH - FIXNUM_BITS);
return val & INTMASK;
}
produce_glyphless_glyph (struct it *it, Lisp_Object acronym)
{
int len, face_id = merge_glyphless_glyph_face (it);
- char buf[sizeof "\\x" + max (6, (sizeof it->c * CHAR_BIT + 3) / 4)];
+ char buf[sizeof "\\x" + max (6, (INT_WIDTH + 3) / 4)];
char const *str = " ";
if (it->glyphless_method == GLYPHLESS_DISPLAY_THIN_SPACE)
errno = EINVAL;
return -1;
}
- if (signo > sizeof (*set) * BITS_PER_CHAR)
+ if (signo > sizeof (*set) * CHAR_BIT)
emacs_abort ();
return (*set & (1U << signo)) != 0;
&& RANGED_INTEGERP (1, width, INT_MAX)
&& RANGED_INTEGERP (1, height, INT_MAX))
{
- int bytes_per_row = ((XINT (width) + BITS_PER_CHAR - 1)
- / BITS_PER_CHAR);
+ int bytes_per_row = (XINT (width) + CHAR_BIT - 1) / CHAR_BIT;
if (XINT (height) <= SBYTES (data) / bytes_per_row)
pixmap_p = true;
}
property and those are indeed in 32 bit quantities if format is
32. */
- if (BITS_PER_LONG > 32 && actual_format == 32)
+ if (LONG_WIDTH > 32 && actual_format == 32)
{
unsigned long i;
int *idata = (int *) tmp_data;
data = data1;
}
- if (BITS_PER_LONG > 32 && *actual_format_ret == 32)
+ if (LONG_WIDTH > 32 && *actual_format_ret == 32)
{
unsigned long i;
int *idata = (int *) (data + offset);
function expects them to be of size int (i.e. 32). So to be able to
use that function, put the data in the form it expects if format is 32. */
- if (BITS_PER_LONG > 32 && event->format == 32)
+ if (LONG_WIDTH > 32 && event->format == 32)
{
for (i = 0; i < 5; ++i) /* There are only 5 longs in a ClientMessage. */
idata[i] = event->data.l[i];
struct window *w = XWINDOW (window);
struct frame *f = XFRAME (w->frame);
intptr_t iw = (intptr_t) w;
- enum { BITS_PER_INTPTR = CHAR_BIT * sizeof iw };
- verify (BITS_PER_INTPTR <= 64);
- int sign_shift = BITS_PER_INTPTR - 32;
+ verify (INTPTR_WIDTH <= 64);
+ int sign_shift = INTPTR_WIDTH - 32;
block_input ();