aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2025-11-20 11:59:47 -0800
committerPaul Eggert2025-11-20 12:04:01 -0800
commitc230dfdc26f0ffffd0718120d5e49478ae7cbb72 (patch)
tree66b374259f8b2143805605f06cbffba9cf93fa59
parent918b9f04f422efb7b614a9f71b004523a39d7674 (diff)
downloademacs-c230dfdc26f0ffffd0718120d5e49478ae7cbb72.tar.gz
emacs-c230dfdc26f0ffffd0718120d5e49478ae7cbb72.zip
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.
-rw-r--r--src/bignum.h2
-rw-r--r--src/fns.c3
-rw-r--r--src/gnutls.c3
-rw-r--r--src/lisp.h10
4 files changed, 8 insertions, 10 deletions
diff --git a/src/bignum.h b/src/bignum.h
index 132fa31f0f5..9be3a41fd35 100644
--- a/src/bignum.h
+++ b/src/bignum.h
@@ -56,7 +56,7 @@ extern void emacs_mpz_mul_2exp (mpz_t, mpz_t const, EMACS_INT)
56 ARG_NONNULL ((1, 2)); 56 ARG_NONNULL ((1, 2));
57extern void emacs_mpz_pow_ui (mpz_t, mpz_t const, unsigned long) 57extern void emacs_mpz_pow_ui (mpz_t, mpz_t const, unsigned long)
58 ARG_NONNULL ((1, 2)); 58 ARG_NONNULL ((1, 2));
59extern double mpz_get_d_rounded (mpz_t const) ATTRIBUTE_PURE; 59extern double mpz_get_d_rounded (mpz_t const);
60extern Lisp_Object get_random_bignum (struct Lisp_Bignum const *); 60extern Lisp_Object get_random_bignum (struct Lisp_Bignum const *);
61 61
62INLINE_HEADER_BEGIN 62INLINE_HEADER_BEGIN
diff --git a/src/fns.c b/src/fns.c
index 7d3c941a936..157022a5c44 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -242,8 +242,7 @@ counted. */)
242 242
243DEFUN ("proper-list-p", Fproper_list_p, Sproper_list_p, 1, 1, 0, 243DEFUN ("proper-list-p", Fproper_list_p, Sproper_list_p, 1, 1, 0,
244 doc: /* Return OBJECT's length if it is a proper list, nil otherwise. 244 doc: /* Return OBJECT's length if it is a proper list, nil otherwise.
245A proper list is neither circular nor dotted (i.e., its last cdr is nil). */ 245A proper list is neither circular nor dotted (i.e., its last cdr is nil). */)
246 attributes: pure)
247 (Lisp_Object object) 246 (Lisp_Object object)
248{ 247{
249 ptrdiff_t len = 0; 248 ptrdiff_t len = 0;
diff --git a/src/gnutls.c b/src/gnutls.c
index 247cc7ff3fe..31827280b48 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -1002,8 +1002,7 @@ See also `gnutls-boot'. */)
1002DEFUN ("gnutls-errorp", Fgnutls_errorp, Sgnutls_errorp, 1, 1, 0, 1002DEFUN ("gnutls-errorp", Fgnutls_errorp, Sgnutls_errorp, 1, 1, 0,
1003 doc: /* Return t if ERROR indicates a GnuTLS problem. 1003 doc: /* Return t if ERROR indicates a GnuTLS problem.
1004ERROR is an integer or a symbol with an integer `gnutls-code' property. 1004ERROR is an integer or a symbol with an integer `gnutls-code' property.
1005usage: (gnutls-errorp ERROR) */ 1005usage: (gnutls-errorp ERROR) */)
1006 attributes: pure)
1007 (Lisp_Object err) 1006 (Lisp_Object err)
1008{ 1007{
1009 if (EQ (err, Qt) 1008 if (EQ (err, Qt)
diff --git a/src/lisp.h b/src/lisp.h
index fe8e2aaea72..0d457345d85 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -619,13 +619,13 @@ INLINE void set_sub_char_table_contents (Lisp_Object, ptrdiff_t,
619/* Defined in bignum.c. */ 619/* Defined in bignum.c. */
620extern int check_int_nonnegative (Lisp_Object); 620extern int check_int_nonnegative (Lisp_Object);
621extern intmax_t check_integer_range (Lisp_Object, intmax_t, intmax_t); 621extern intmax_t check_integer_range (Lisp_Object, intmax_t, intmax_t);
622extern double bignum_to_double (Lisp_Object) ATTRIBUTE_PURE; 622extern double bignum_to_double (Lisp_Object);
623extern Lisp_Object make_bigint (intmax_t); 623extern Lisp_Object make_bigint (intmax_t);
624extern Lisp_Object make_biguint (uintmax_t); 624extern Lisp_Object make_biguint (uintmax_t);
625extern uintmax_t check_uinteger_max (Lisp_Object, uintmax_t); 625extern uintmax_t check_uinteger_max (Lisp_Object, uintmax_t);
626 626
627/* Defined in chartab.c. */ 627/* Defined in chartab.c. */
628extern Lisp_Object char_table_ref (Lisp_Object, int) ATTRIBUTE_PURE; 628extern Lisp_Object char_table_ref (Lisp_Object, int);
629extern void char_table_set (Lisp_Object, int, Lisp_Object); 629extern void char_table_set (Lisp_Object, int, Lisp_Object);
630 630
631/* Defined in data.c. */ 631/* Defined in data.c. */
@@ -4105,9 +4105,9 @@ set_sub_char_table_contents (Lisp_Object table, ptrdiff_t idx, Lisp_Object val)
4105 4105
4106/* Defined in bignum.c. This part of bignum.c's API does not require 4106/* Defined in bignum.c. This part of bignum.c's API does not require
4107 the caller to access bignum internals; see bignum.h for that. */ 4107 the caller to access bignum internals; see bignum.h for that. */
4108extern intmax_t bignum_to_intmax (Lisp_Object) ATTRIBUTE_PURE; 4108extern intmax_t bignum_to_intmax (Lisp_Object);
4109extern uintmax_t bignum_to_uintmax (Lisp_Object) ATTRIBUTE_PURE; 4109extern uintmax_t bignum_to_uintmax (Lisp_Object);
4110extern ptrdiff_t bignum_bufsize (Lisp_Object, int) ATTRIBUTE_PURE; 4110extern ptrdiff_t bignum_bufsize (Lisp_Object, int);
4111extern ptrdiff_t bignum_to_c_string (char *, ptrdiff_t, Lisp_Object, int); 4111extern ptrdiff_t bignum_to_c_string (char *, ptrdiff_t, Lisp_Object, int);
4112extern Lisp_Object bignum_to_string (Lisp_Object, int); 4112extern Lisp_Object bignum_to_string (Lisp_Object, int);
4113extern Lisp_Object make_bignum_str (char const *, int); 4113extern Lisp_Object make_bignum_str (char const *, int);