1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-01 23:30:28 +02:00
Commit graph

4 commits

Author SHA1 Message Date
Andy Wingo
c79d5bd0f7 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.
2025-06-26 15:56:16 +02:00
Andy Wingo
6389acf192 New internal functions to alloc subr closures
* libguile/gsubr.c (scm_allocate_subr_code):
(scm_make_subr_from_code): New functions.
(create_subr): Refactor in terms of new functions.
(scm_c_make_gsubr):
(scm_c_define_gsubr):
(scm_c_make_gsubr_with_generic):
(scm_c_define_gsubr_with_generic): Adapt.
2025-06-11 15:39:58 +02:00
Andy Wingo
710fa4c6f0 Add machinery to pass thread and/or closure when invoking subr
* libguile/gsubr.c: Arrange to store flags alongside array of subrs.
One flag indicates the thread should also be passed as the first
argument; another says that the closure should be passed.  Should remove
the need for arg shuffling in get_callee_vcode eventually.
(record_subr_name): Make the names be a vector; will integrate better
with precise tracing.
(create_subr): Add flags arg.  Adapt callers.
(scm_apply_subr): Allow for passing thread or closure.
* libguile/gsubr-internal.h: Add new interfaces to see whether to pass
closure or thread.  Pass thread to scm_apply_subr.
* libguile/jit.c (compile_subr_call): Allow for passing thread or
closure.
* libguile/vm-engine.c (subr_call): Pass thread.
2025-06-11 13:05:15 +02:00
Andy Wingo
c03071b380 Move subr internals off to internal header file
* libguile/gsubr-internal.h: New file.
* libguile/Makefile.am: Add to build.
* libguile/gsubr.h: Remove internal-only definitions.
* libguile/foreign.c:
* libguile/goops.c:
* libguile/gsubr.c:
* libguile/jit.c:
* libguile/programs.c:
* libguile/vm.c: Include new header.
2025-06-11 12:40:45 +02:00