1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-29 08:31:35 -08:00

A few more functions are not pure

Assuming ATTRIBUTE_PURE means that the function must return,
a few more functions that should not be declared with ATTRIBUTE_PURE.
The GCC manual (and even the C23 standard, with [[reproducible]])
is not clear about this, and it’s better to be safe.
* src/bignum.h (mpz_get_d_rounded):
* src/lisp.h (bignum_to_double):
No longer pure, as it does not return if memory is exhausted.
* src/fns.c (Fproper_list_p): No longer pure, as it does not
return if the user quits.
* src/gnutls.c (Fgnutls_errorp): No longer pure, as it does not
return if it runs into an eassert failure in XSYMBOL_WITH_POS via EQ.
* src/lisp.h (bignum_to_intmax, bignum_to_uintmax, bignum_bufsize):
No longer pure, as it does not return if it runs into an
eassert failure in XBIGNUM via xbignum_val.
This commit is contained in:
Paul Eggert 2025-11-20 11:59:47 -08:00
parent 918b9f04f4
commit c230dfdc26
4 changed files with 8 additions and 10 deletions

View file

@ -56,7 +56,7 @@ extern void emacs_mpz_mul_2exp (mpz_t, mpz_t const, EMACS_INT)
ARG_NONNULL ((1, 2));
extern void emacs_mpz_pow_ui (mpz_t, mpz_t const, unsigned long)
ARG_NONNULL ((1, 2));
extern double mpz_get_d_rounded (mpz_t const) ATTRIBUTE_PURE;
extern double mpz_get_d_rounded (mpz_t const);
extern Lisp_Object get_random_bignum (struct Lisp_Bignum const *);
INLINE_HEADER_BEGIN

View file

@ -242,8 +242,7 @@ counted. */)
DEFUN ("proper-list-p", Fproper_list_p, Sproper_list_p, 1, 1, 0,
doc: /* Return OBJECT's length if it is a proper list, nil otherwise.
A proper list is neither circular nor dotted (i.e., its last cdr is nil). */
attributes: pure)
A proper list is neither circular nor dotted (i.e., its last cdr is nil). */)
(Lisp_Object object)
{
ptrdiff_t len = 0;

View file

@ -1002,8 +1002,7 @@ See also `gnutls-boot'. */)
DEFUN ("gnutls-errorp", Fgnutls_errorp, Sgnutls_errorp, 1, 1, 0,
doc: /* Return t if ERROR indicates a GnuTLS problem.
ERROR is an integer or a symbol with an integer `gnutls-code' property.
usage: (gnutls-errorp ERROR) */
attributes: pure)
usage: (gnutls-errorp ERROR) */)
(Lisp_Object err)
{
if (EQ (err, Qt)

View file

@ -619,13 +619,13 @@ INLINE void set_sub_char_table_contents (Lisp_Object, ptrdiff_t,
/* Defined in bignum.c. */
extern int check_int_nonnegative (Lisp_Object);
extern intmax_t check_integer_range (Lisp_Object, intmax_t, intmax_t);
extern double bignum_to_double (Lisp_Object) ATTRIBUTE_PURE;
extern double bignum_to_double (Lisp_Object);
extern Lisp_Object make_bigint (intmax_t);
extern Lisp_Object make_biguint (uintmax_t);
extern uintmax_t check_uinteger_max (Lisp_Object, uintmax_t);
/* Defined in chartab.c. */
extern Lisp_Object char_table_ref (Lisp_Object, int) ATTRIBUTE_PURE;
extern Lisp_Object char_table_ref (Lisp_Object, int);
extern void char_table_set (Lisp_Object, int, Lisp_Object);
/* Defined in data.c. */
@ -4105,9 +4105,9 @@ set_sub_char_table_contents (Lisp_Object table, ptrdiff_t idx, Lisp_Object val)
/* Defined in bignum.c. This part of bignum.c's API does not require
the caller to access bignum internals; see bignum.h for that. */
extern intmax_t bignum_to_intmax (Lisp_Object) ATTRIBUTE_PURE;
extern uintmax_t bignum_to_uintmax (Lisp_Object) ATTRIBUTE_PURE;
extern ptrdiff_t bignum_bufsize (Lisp_Object, int) ATTRIBUTE_PURE;
extern intmax_t bignum_to_intmax (Lisp_Object);
extern uintmax_t bignum_to_uintmax (Lisp_Object);
extern ptrdiff_t bignum_bufsize (Lisp_Object, int);
extern ptrdiff_t bignum_to_c_string (char *, ptrdiff_t, Lisp_Object, int);
extern Lisp_Object bignum_to_string (Lisp_Object, int);
extern Lisp_Object make_bignum_str (char const *, int);