diff options
| author | Paul Eggert | 2025-11-19 11:18:13 -0800 |
|---|---|---|
| committer | Paul Eggert | 2025-11-19 16:21:24 -0800 |
| commit | 20fd47e741342e160d774ae6afee7182bba0de65 (patch) | |
| tree | 4a7f2899a18071d202adcbb76c290bf2a18d0d27 /lib-src | |
| parent | a1f36dc3b852494d6d4c2a2a949153a2dac86f2d (diff) | |
| download | emacs-20fd47e741342e160d774ae6afee7182bba0de65.tar.gz emacs-20fd47e741342e160d774ae6afee7182bba0de65.zip | |
Fix mis-declarations of non-const functions
Problem for mpz_get_d_rounded reported by Helmut Eller in:
https://lists.gnu.org/r/emacs-devel/2025-11/msg00795.html
* lib-src/make-docfile.c (DEFUN_pure): New constant.
(write_globals, scan_c_stream): Support "attributes: pure".
* src/bignum.h (mpz_get_d_rounded):
* src/data.c (Fsymbolp, Fmodule_function_p, Fintegerp, Fnumberp):
* src/lisp.h (bignum_to_double, bignum_to_intmax)
(bignum_to_uintmax, bignum_bufsize):
Now pure, not const, since they depend on current state.
For example, Fsymbolp now inspects symbols_with_pos_enabled,
and the bignum functions inspect bignum contents in memory.
* src/data.c (Feq):
* src/xfaces.c (Fface_attribute_relative_p):
No longer const, since they might abort when debugging.
* src/pdumper.h (pdumper_object_p, pdumper_cold_object_p)
(pdumper_find_object_type, pdumper_object_p_precise):
These are not const functions. But there is no need to declare
them to be pure, either, as they’re inline so the compiler can
figure it out.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/make-docfile.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 6243f666955..d0ea463f299 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c | |||
| @@ -577,7 +577,13 @@ struct global | |||
| 577 | }; | 577 | }; |
| 578 | 578 | ||
| 579 | /* Bit values for FLAGS field from the above. Applied for DEFUNs only. */ | 579 | /* Bit values for FLAGS field from the above. Applied for DEFUNs only. */ |
| 580 | enum { DEFUN_noreturn = 1, DEFUN_const = 2, DEFUN_noinline = 4 }; | 580 | enum |
| 581 | { | ||
| 582 | DEFUN_noreturn = 1, | ||
| 583 | DEFUN_const = 2, | ||
| 584 | DEFUN_noinline = 4, | ||
| 585 | DEFUN_pure = 8, | ||
| 586 | }; | ||
| 581 | 587 | ||
| 582 | /* All the variable names we saw while scanning C sources in `-g' | 588 | /* All the variable names we saw while scanning C sources in `-g' |
| 583 | mode. */ | 589 | mode. */ |
| @@ -752,6 +758,8 @@ write_globals (void) | |||
| 752 | fputs (" ATTRIBUTE_COLD", stdout); | 758 | fputs (" ATTRIBUTE_COLD", stdout); |
| 753 | if (globals[i].flags & DEFUN_const) | 759 | if (globals[i].flags & DEFUN_const) |
| 754 | fputs (" ATTRIBUTE_CONST", stdout); | 760 | fputs (" ATTRIBUTE_CONST", stdout); |
| 761 | if (globals[i].flags & DEFUN_pure) | ||
| 762 | fputs (" ATTRIBUTE_PURE", stdout); | ||
| 755 | 763 | ||
| 756 | puts (";"); | 764 | puts (";"); |
| 757 | } | 765 | } |
| @@ -1062,7 +1070,7 @@ scan_c_stream (FILE *infile) | |||
| 1062 | attributes: attribute1 attribute2 ...) | 1070 | attributes: attribute1 attribute2 ...) |
| 1063 | (Lisp_Object arg...) | 1071 | (Lisp_Object arg...) |
| 1064 | 1072 | ||
| 1065 | Now only `const', `noinline' and `noreturn' attributes | 1073 | Now only 'const', 'noinline', 'noreturn', and 'pure' attributes |
| 1066 | are used. */ | 1074 | are used. */ |
| 1067 | 1075 | ||
| 1068 | /* Advance to the end of docstring. */ | 1076 | /* Advance to the end of docstring. */ |
| @@ -1110,6 +1118,8 @@ scan_c_stream (FILE *infile) | |||
| 1110 | g->flags |= DEFUN_noreturn; | 1118 | g->flags |= DEFUN_noreturn; |
| 1111 | if (strstr (input_buffer, "const")) | 1119 | if (strstr (input_buffer, "const")) |
| 1112 | g->flags |= DEFUN_const; | 1120 | g->flags |= DEFUN_const; |
| 1121 | if (strstr (input_buffer, "pure")) | ||
| 1122 | g->flags |= DEFUN_pure; | ||
| 1113 | 1123 | ||
| 1114 | /* Although the noinline attribute is no longer used, | 1124 | /* Although the noinline attribute is no longer used, |
| 1115 | leave its support in, in case it's needed later. */ | 1125 | leave its support in, in case it's needed later. */ |