mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
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.
This commit is contained in:
parent
a1f36dc3b8
commit
20fd47e741
6 changed files with 27 additions and 19 deletions
|
|
@ -577,7 +577,13 @@ struct global
|
|||
};
|
||||
|
||||
/* Bit values for FLAGS field from the above. Applied for DEFUNs only. */
|
||||
enum { DEFUN_noreturn = 1, DEFUN_const = 2, DEFUN_noinline = 4 };
|
||||
enum
|
||||
{
|
||||
DEFUN_noreturn = 1,
|
||||
DEFUN_const = 2,
|
||||
DEFUN_noinline = 4,
|
||||
DEFUN_pure = 8,
|
||||
};
|
||||
|
||||
/* All the variable names we saw while scanning C sources in `-g'
|
||||
mode. */
|
||||
|
|
@ -752,6 +758,8 @@ write_globals (void)
|
|||
fputs (" ATTRIBUTE_COLD", stdout);
|
||||
if (globals[i].flags & DEFUN_const)
|
||||
fputs (" ATTRIBUTE_CONST", stdout);
|
||||
if (globals[i].flags & DEFUN_pure)
|
||||
fputs (" ATTRIBUTE_PURE", stdout);
|
||||
|
||||
puts (";");
|
||||
}
|
||||
|
|
@ -1062,7 +1070,7 @@ scan_c_stream (FILE *infile)
|
|||
attributes: attribute1 attribute2 ...)
|
||||
(Lisp_Object arg...)
|
||||
|
||||
Now only `const', `noinline' and `noreturn' attributes
|
||||
Now only 'const', 'noinline', 'noreturn', and 'pure' attributes
|
||||
are used. */
|
||||
|
||||
/* Advance to the end of docstring. */
|
||||
|
|
@ -1110,6 +1118,8 @@ scan_c_stream (FILE *infile)
|
|||
g->flags |= DEFUN_noreturn;
|
||||
if (strstr (input_buffer, "const"))
|
||||
g->flags |= DEFUN_const;
|
||||
if (strstr (input_buffer, "pure"))
|
||||
g->flags |= DEFUN_pure;
|
||||
|
||||
/* Although the noinline attribute is no longer used,
|
||||
leave its support in, in case it's needed later. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue