}
if (FIXNUMP (AREF (status, i)))
{
- i = XFIXNAT (AREF (status, 8));
- if (ccl.ic < i && i < ccl.size)
- ccl.ic = i;
+ EMACS_INT ic = XFIXNUM (AREF (status, i));
+ if (ccl.ic < ic && ic < ccl.size)
+ ccl.ic = ic;
}
buf_magnification = ccl.buf_magnification ? ccl.buf_magnification : 1;
ptrdiff_t argnum = 0;
/* Set ACCUM to VAL's value if it is a fixnum, otherwise to some
ignored value to avoid using an uninitialized variable later. */
- intmax_t accum = XFIXNUM (val);
+ intmax_t accum = XFIXNUM_RAW (val);
if (FIXNUMP (val))
while (true)
if (no < 0 || no > 0xff || ASIZE (registers) != 8)
return Qnil;
for (i = 0; i < 8; i++)
- CHECK_FIXNUM (AREF (registers, i));
+ CHECK_FIXNAT (AREF (registers, i));
inregs.x.ax = (unsigned long) XFIXNAT (AREF (registers, 0));
inregs.x.bx = (unsigned long) XFIXNAT (AREF (registers, 1));
for (i = 0; i < len; i++)
{
- CHECK_FIXNUM (AREF (vector, i));
+ CHECK_FIXNAT (AREF (vector, i));
buf[i] = (unsigned char) XFIXNAT (AREF (vector, i)) & 0xFF;
}
Lisp_Object tem = XCAR (old_undo);
if (CONSP (tem) && FIXNUMP (XCAR (tem))
&& FIXNUMP (XCDR (tem))
- && XFIXNAT (XCDR (tem)) == PT + old_inserted)
+ && XFIXNUM (XCDR (tem)) == PT + old_inserted)
XSETCDR (tem, make_fixnum (PT + inserted));
}
}
tem = Fcar_safe (Fcar (*annot));
nextpos = pos - 1;
if (FIXNUMP (tem))
- nextpos = XFIXNAT (tem);
+ nextpos = XFIXNUM (tem);
/* If there are no more annotations in this range,
output the rest of the range all at once. */
&& FIXNUMP (BVAR (b, save_length))
/* A short file is likely to change a large fraction;
spare the user annoying messages. */
- && XFIXNAT (BVAR (b, save_length)) > 5000
+ && XFIXNUM (BVAR (b, save_length)) > 5000
&& (growth_factor * (BUF_Z (b) - BUF_BEG (b))
< (growth_factor - 1) * XFIXNAT (BVAR (b, save_length)))
/* These messages are frequent and annoying for `*mail*'. */
#endif
ascent = image_spec_value (spec, QCascent, NULL);
- if (FIXNUMP (ascent))
+ if (RANGED_FIXNUMP (0, ascent, INT_MAX))
img->ascent = XFIXNAT (ascent);
else if (EQ (ascent, Qcenter))
img->ascent = CENTERED_IMAGE_ASCENT;
margin = image_spec_value (spec, QCmargin, NULL);
- if (FIXNUMP (margin))
+ if (RANGED_FIXNUMP (0, margin, INT_MAX))
img->vmargin = img->hmargin = XFIXNAT (margin);
else if (CONSP (margin))
{
#define lisp_h_XCDR(c) XCONS (c)->u.s.u.cdr
#define lisp_h_XCONS(a) \
(eassert (CONSP (a)), XUNTAG (a, Lisp_Cons, struct Lisp_Cons))
-#define lisp_h_XHASH(a) XUFIXNUM (a)
+#define lisp_h_XHASH(a) XUFIXNUM_RAW (a)
#if USE_LSB_TAG
# define lisp_h_make_fixnum(n) \
XIL ((EMACS_INT) (((EMACS_UINT) (n) << INTTYPEBITS) + Lisp_Int0))
-# define lisp_h_XFIXNAT(a) XFIXNUM (a)
-# define lisp_h_XFIXNUM(a) (XLI (a) >> INTTYPEBITS)
+# define lisp_h_XFIXNUM_RAW(a) (XLI (a) >> INTTYPEBITS)
# define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK))
#endif
# define XHASH(a) lisp_h_XHASH (a)
# if USE_LSB_TAG
# define make_fixnum(n) lisp_h_make_fixnum (n)
-# define XFIXNAT(a) lisp_h_XFIXNAT (a)
-# define XFIXNUM(a) lisp_h_XFIXNUM (a)
+# define XFIXNUM_RAW(a) lisp_h_XFIXNUM_RAW (a)
# define XTYPE(a) lisp_h_XTYPE (a)
# endif
#endif
}
INLINE EMACS_INT
-(XFIXNUM) (Lisp_Object a)
+(XFIXNUM_RAW) (Lisp_Object a)
{
- return lisp_h_XFIXNUM (a);
-}
-
-INLINE EMACS_INT
-(XFIXNAT) (Lisp_Object a)
-{
- EMACS_INT n = lisp_h_XFIXNAT (a);
- eassume (0 <= n);
- return n;
+ return lisp_h_XFIXNUM_RAW (a);
}
#else /* ! USE_LSB_TAG */
return XIL (n);
}
-/* Extract A's value as a signed integer. */
+/* Extract A's value as a signed integer. Unlike XFIXNUM, this works
+ on any Lisp object, although the resulting integer is useful only
+ for things like hashing when A is not a fixnum. */
INLINE EMACS_INT
-XFIXNUM (Lisp_Object a)
+XFIXNUM_RAW (Lisp_Object a)
{
EMACS_INT i = XLI (a);
if (! USE_LSB_TAG)
return i >> INTTYPEBITS;
}
-/* Like XFIXNUM (A), but may be faster. A must be nonnegative.
- If ! USE_LSB_TAG, this takes advantage of the fact that Lisp
- integers have zero-bits in their tags. */
-INLINE EMACS_INT
-XFIXNAT (Lisp_Object a)
+#endif /* ! USE_LSB_TAG */
+
+INLINE bool
+(FIXNUMP) (Lisp_Object x)
{
- EMACS_INT int0 = Lisp_Int0;
- EMACS_INT n = USE_LSB_TAG ? XFIXNUM (a) : XLI (a) - (int0 << VALBITS);
- eassume (0 <= n);
- return n;
+ return lisp_h_FIXNUMP (x);
}
-#endif /* ! USE_LSB_TAG */
+INLINE EMACS_INT
+XFIXNUM (Lisp_Object a)
+{
+ eassume (FIXNUMP (a));
+ return XFIXNUM_RAW (a);
+}
/* Extract A's value as an unsigned integer in the range 0..INTMASK. */
INLINE EMACS_UINT
-XUFIXNUM (Lisp_Object a)
+XUFIXNUM_RAW (Lisp_Object a)
{
EMACS_UINT i = XLI (a);
return USE_LSB_TAG ? i >> INTTYPEBITS : i & INTMASK;
}
+INLINE EMACS_UINT
+XUFIXNUM (Lisp_Object a)
+{
+ eassume (FIXNUMP (a));
+ return XUFIXNUM_RAW (a);
+}
-/* Return A's hash, which is in the range 0..INTMASK. Although XHASH (A) ==
- XUFIXNUM (A) currently, XUFIXNUM should be applied only to fixnums. */
-
+/* Return A's hash, which is in the range 0..INTMASK. */
INLINE EMACS_INT
(XHASH) (Lisp_Object a)
{
return a;
}
-INLINE bool
-(FIXNUMP) (Lisp_Object x)
-{
- return lisp_h_FIXNUMP (x);
-}
-
#define XSETINT(a, b) ((a) = make_fixnum (b))
#define XSETFASTINT(a, b) ((a) = make_fixed_natnum (b))
#define XSETCONS(a, b) ((a) = make_lisp_ptr (b, Lisp_Cons))
{
return FIXNUMP (x) && 0 <= XFIXNUM (x);
}
+
+/* Like XFIXNUM (A), but may be faster. A must be nonnegative. */
+INLINE EMACS_INT
+XFIXNAT (Lisp_Object a)
+{
+ eassume (FIXNATP (a));
+ EMACS_INT int0 = Lisp_Int0;
+ return USE_LSB_TAG ? XFIXNUM (a) : XLI (a) - (int0 << VALBITS);
+}
+
INLINE bool
NUMBERP (Lisp_Object x)
{
for (i = 0; i < len; i++)
if (FIXNUMP (p->contents[i]))
{
- int j = XFIXNAT (p->contents[i]) & 0xffff;
+ int j = XFIXNUM (p->contents[i]) & 0xffff;
ip6[i] = ntohs (j);
}
sa->sa_family = family;
else
CHECK_FIXNUM_COERCE_MARKER (limit);
- if (XFIXNAT (position) >= XFIXNAT (limit))
+ if (XFIXNAT (position) >= XFIXNUM (limit))
{
position = limit;
if (XFIXNAT (position) > ZV)
else
CHECK_FIXNUM_COERCE_MARKER (limit);
- if (XFIXNAT (position) <= XFIXNAT (limit))
+ if (XFIXNUM (position) <= XFIXNUM (limit))
{
position = limit;
- if (XFIXNAT (position) < BEGV)
+ if (XFIXNUM (position) < BEGV)
XSETFASTINT (position, BEGV);
}
else
{
Lisp_Object initial_value
- = Fget_char_property (make_fixnum (XFIXNAT (position) - 1),
+ = Fget_char_property (make_fixnum (XFIXNUM (position)
+ - (0 <= XFIXNUM (position))),
prop, object);
while (true)
next = next_interval (i);
while (next && intervals_equal (i, next)
- && (NILP (limit) || next->position < XFIXNAT (limit)))
+ && (NILP (limit) || next->position < XFIXNUM (limit)))
next = next_interval (next);
if (!next
|| (next->position
>= (FIXNUMP (limit)
- ? XFIXNAT (limit)
+ ? XFIXNUM (limit)
: (STRINGP (object)
? SCHARS (object)
: BUF_ZV (XBUFFER (object))))))
next = next_interval (i);
while (next
&& EQ (here_val, textget (next->plist, prop))
- && (NILP (limit) || next->position < XFIXNAT (limit)))
+ && (NILP (limit) || next->position < XFIXNUM (limit)))
next = next_interval (next);
if (!next
|| (next->position
>= (FIXNUMP (limit)
- ? XFIXNAT (limit)
+ ? XFIXNUM (limit)
: (STRINGP (object)
? SCHARS (object)
: BUF_ZV (XBUFFER (object))))))
previous = previous_interval (i);
while (previous && intervals_equal (previous, i)
&& (NILP (limit)
- || (previous->position + LENGTH (previous) > XFIXNAT (limit))))
+ || (previous->position + LENGTH (previous) > XFIXNUM (limit))))
previous = previous_interval (previous);
if (!previous
|| (previous->position + LENGTH (previous)
<= (FIXNUMP (limit)
- ? XFIXNAT (limit)
+ ? XFIXNUM (limit)
: (STRINGP (object) ? 0 : BUF_BEGV (XBUFFER (object))))))
return limit;
else
while (previous
&& EQ (here_val, textget (previous->plist, prop))
&& (NILP (limit)
- || (previous->position + LENGTH (previous) > XFIXNAT (limit))))
+ || (previous->position + LENGTH (previous) > XFIXNUM (limit))))
previous = previous_interval (previous);
if (!previous
|| (previous->position + LENGTH (previous)
<= (FIXNUMP (limit)
- ? XFIXNAT (limit)
+ ? XFIXNUM (limit)
: (STRINGP (object) ? 0 : BUF_BEGV (XBUFFER (object))))))
return limit;
else
/* If we want no properties for a whole string,
get rid of its intervals. */
if (NILP (properties) && STRINGP (object)
- && XFIXNAT (start) == 0
- && XFIXNAT (end) == SCHARS (object))
+ && EQ (start, make_fixnum (0))
+ && EQ (end, make_fixnum (SCHARS (object))))
{
if (!string_intervals (object))
return Qnil;
= buffer_local_value (Qunderline_minimum_offset,
s->w->contents);
if (FIXNUMP (val))
- minimum_offset = XFIXNAT (val);
+ minimum_offset = max (0, XFIXNUM (val));
else
minimum_offset = 1;
val = buffer_local_value (Qx_underline_at_descent_line,
= buffer_local_value (Qunderline_minimum_offset,
s->w->contents);
if (FIXNUMP (val))
- minimum_offset = XFIXNAT (val);
+ minimum_offset = max (0, XFIXNUM (val));
else
minimum_offset = 1;
val = buffer_local_value (Qx_underline_at_descent_line,