1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-02 15:40:38 +02:00

Change to be less sloppy as regards functions without prototypes

* libguile/gsubr.h (scm_t_subr_0, scm_t_subr_1, etc): New precise
typedefs.
(SCM_AS_SUBR): Use C11's _Generic to cast subrs to the generic subr
type, while also producing a warning/error if the function isn't
compatible.
(SCM_DEFINE_GSUBR, SCM_PRIMITIVE_GENERIC, SCM_DEFINE_PUBLIC)
(SCM_DEFINE_STATIC, SCM_PROC, SCM_REGISTER_PROC, SCM_GPROC): Use
SCM_AS_SUBR.
* libguile/gsubr-internal.h (scm_t_subr_with_thread_0)
(scm_t_subr_with_thread_1, etc): New precise typedefs.
(SCM_AS_SUBR_WITH_THREAD): Like SCM_AS_SUBR.
* libguile/gsubr.c (scm_apply_subr): Cast callee to the right type
before calling.
* libguile/hash.c (floor): Remove weird unused declaration.
* libguile/init.c (scm_boot_guile): Fix type of main_func in definition.
* libguile/jit.c: Fix type of enter_mcode.
* libguile/smob.c (apply_0, apply_1, apply_2, apply_3): Cast callee to
right type.
(scm_smob_trampoline): Use SCM_AS_SUBR.
* libguile/smob.h (SCM_SMOB_APPLY): Use SCM_AS_SUBR.
* libguile/backtrace.c:
* libguile/control.c:
* libguile/dynl.c:
* libguile/eval.c:
* libguile/exceptions.c:
* libguile/expand.c:
* libguile/finalizers.c:
* libguile/fluids.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/gc.c:
* libguile/load.c:
* libguile/loader.c:
* libguile/macros.c:
* libguile/memoize.c:
* libguile/pairs.c:
* libguile/poll.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/rdelim.c:
* libguile/rw.c:
* libguile/vm.c: Adapt scm_c_make_gsubr / scm_c_define_gsubr callers to
use SCM_AS_SUBR.
This commit is contained in:
Andy Wingo 2025-06-26 15:56:16 +02:00
parent a7d7ff5019
commit c79d5bd0f7
30 changed files with 180 additions and 130 deletions

View file

@ -33,6 +33,33 @@
#define SCM_PRIMITIVE_P(x) (scm_is_primitive (x))
#define SCM_PRIMITIVE_GENERIC_P(x) (scm_is_primitive_generic (x))
typedef SCM (*scm_t_subr_with_thread_0) (scm_thread*);
typedef SCM (*scm_t_subr_with_thread_1) (scm_thread*, SCM);
typedef SCM (*scm_t_subr_with_thread_2) (scm_thread*, SCM, SCM);
typedef SCM (*scm_t_subr_with_thread_3) (scm_thread*, SCM, SCM, SCM);
typedef SCM (*scm_t_subr_with_thread_4) (scm_thread*, SCM, SCM, SCM, SCM);
typedef SCM (*scm_t_subr_with_thread_5) (scm_thread*, SCM, SCM, SCM, SCM, SCM);
typedef SCM (*scm_t_subr_with_thread_6) (scm_thread*, SCM, SCM, SCM, SCM, SCM, SCM);
typedef SCM (*scm_t_subr_with_thread_7) (scm_thread*, SCM, SCM, SCM, SCM, SCM, SCM, SCM);
typedef SCM (*scm_t_subr_with_thread_8) (scm_thread*, SCM, SCM, SCM, SCM, SCM, SCM, SCM, SCM);
typedef SCM (*scm_t_subr_with_thread_9) (scm_thread*, SCM, SCM, SCM, SCM, SCM, SCM, SCM, SCM, SCM);
typedef SCM (*scm_t_subr_with_thread_10) (scm_thread*, SCM, SCM, SCM, SCM, SCM, SCM, SCM, SCM, SCM, SCM);
#define SCM_AS_SUBR_WITH_THREAD(fn) \
_Generic (fn, \
scm_t_subr_with_thread_0 : (scm_t_subr) fn, \
scm_t_subr_with_thread_1 : (scm_t_subr) fn, \
scm_t_subr_with_thread_2 : (scm_t_subr) fn, \
scm_t_subr_with_thread_3 : (scm_t_subr) fn, \
scm_t_subr_with_thread_4 : (scm_t_subr) fn, \
scm_t_subr_with_thread_5 : (scm_t_subr) fn, \
scm_t_subr_with_thread_6 : (scm_t_subr) fn, \
scm_t_subr_with_thread_7 : (scm_t_subr) fn, \
scm_t_subr_with_thread_8 : (scm_t_subr) fn, \
scm_t_subr_with_thread_9 : (scm_t_subr) fn, \
scm_t_subr_with_thread_10 : (scm_t_subr) fn, \
default: fn)
struct scm_program;