#endif /* ENABLE_CHECKING && USE_STACK_LISP_OBJECTS */
-/* Memory allocation for GMP. */
-
-void
-range_error (void)
-{
- xsignal0 (Qrange_error);
-}
-
/* Initialization. */
void
/* The documentation says integer-width should be nonnegative, so
a single comparison suffices even though 'bits' is unsigned. */
if (integer_width < bits)
- range_error ();
+ overflow_error ();
struct Lisp_Bignum *b = ALLOCATE_PSEUDOVECTOR (struct Lisp_Bignum, value,
PVEC_BIGNUM);
emacs_mpz_mul (mpz_t rop, mpz_t const op1, mpz_t const op2)
{
if (NLIMBS_LIMIT - emacs_mpz_size (op1) < emacs_mpz_size (op2))
- range_error ();
+ overflow_error ();
mpz_mul (rop, op1, op2);
}
mp_bitcnt_t op2limbs = op2 / GMP_NUMB_BITS;
if (lim - emacs_mpz_size (op1) < op2limbs)
- range_error ();
+ overflow_error ();
mpz_mul_2exp (rop, op1, op2);
}
int nbase = emacs_mpz_size (base), n;
if (INT_MULTIPLY_WRAPV (nbase, exp, &n) || lim < n)
- range_error ();
+ overflow_error ();
mpz_pow_ui (rop, base, exp);
}
&& mpz_fits_ulong_p (XBIGNUM (y)->value))
exp = mpz_get_ui (XBIGNUM (y)->value);
else
- range_error ();
+ overflow_error ();
emacs_mpz_pow_ui (mpz[0], *bignum_integer (&mpz[0], x), exp);
return make_integer_mpz ();
xsignal (Qerror, Fcons (build_string (s), arg));
}
+/* Use this for arithmetic overflow, e.g., when an integer result is
+ too large even for a bignum. */
+void
+overflow_error (void)
+{
+ xsignal0 (Qoverflow_error);
+}
+
/* Return true if LIST is a non-nil atom or
a list containing one of CONDITIONS. */
extern ptrdiff_t inhibit_garbage_collection (void);
extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object);
extern void free_cons (struct Lisp_Cons *);
-extern _Noreturn void range_error (void);
extern void init_alloc_once (void);
extern void init_alloc (void);
extern void syms_of_alloc (void);
extern _Noreturn void xsignal3 (Lisp_Object, Lisp_Object, Lisp_Object,
Lisp_Object);
extern _Noreturn void signal_error (const char *, Lisp_Object);
+extern _Noreturn void overflow_error (void);
extern bool FUNCTIONP (Lisp_Object);
extern Lisp_Object funcall_subr (struct Lisp_Subr *subr, ptrdiff_t numargs, Lisp_Object *arg_vector);
extern Lisp_Object eval_sub (Lisp_Object form);