modules: [5/n] introduce ecl_module_ffi

This commit is contained in:
Daniel Kochmański 2024-12-03 09:53:28 +01:00
parent dfd99e0e16
commit 2a5c8a4598
3 changed files with 32 additions and 13 deletions

View file

@ -13,6 +13,7 @@
#include <string.h>
#define ECL_INCLUDE_FFI_H
#include <ecl/ecl.h>
#include <ecl/ecl-inl.h>
#include <ecl/internal.h>
static const cl_object ecl_aet_to_ffi_table[ecl_aet_bc+1] = {
@ -1019,3 +1020,32 @@ si_free_ffi_closure(cl_object closure)
@(return closure_object);
} @)
#endif /* HAVE_LIBFFI */
/* -- Module definition ------------------------------------------------------ */
static cl_object
init_env_ffi(cl_env_ptr the_env)
{
#ifdef HAVE_LIBFFI
the_env->ffi_args_limit = 0;
the_env->ffi_types = 0;
the_env->ffi_values = 0;
the_env->ffi_values_ptrs = 0;
#endif
return ECL_NIL;
}
ecl_def_ct_base_string(str_ffi, "FFI", 3, static, const);
static struct ecl_module module_ffi = {
.name = str_ffi,
.create = ecl_module_no_op,
.enable = ecl_module_no_op,
.init_env = init_env_ffi,
.init_cpu = ecl_module_no_op_cpu,
.free_cpu = ecl_module_no_op_cpu,
.free_env = ecl_module_no_op_env,
.disable = ecl_module_no_op,
.destroy = ecl_module_no_op
};
cl_object ecl_module_ffi = (cl_object)&module_ffi;

View file

@ -42,17 +42,6 @@ const char *ecl_self;
static int ARGC;
static char **ARGV;
static void
init_env_ffi(cl_env_ptr env)
{
#ifdef HAVE_LIBFFI
env->ffi_args_limit = 0;
env->ffi_types = 0;
env->ffi_values = 0;
env->ffi_values_ptrs = 0;
#endif
}
static void
init_env_aux(cl_env_ptr env)
{
@ -79,7 +68,6 @@ ecl_init_first_env(cl_env_ptr the_env)
#endif
ecl_cs_init(the_env);
init_env_aux(the_env);
init_env_ffi(the_env);
init_stacks(the_env);
}
@ -88,7 +76,6 @@ ecl_init_env(cl_env_ptr env)
{
ecl_modules_init_env(env);
init_env_aux(env);
init_env_ffi(env);
init_stacks(env);
}
@ -283,6 +270,7 @@ cl_boot(int argc, char **argv)
ecl_add_module(ecl_module_gc);
ecl_add_module(ecl_module_unixint);
ecl_add_module(ecl_module_bignum);
ecl_add_module(ecl_module_ffi);
/*
* Initialize the per-thread data.

View file

@ -28,6 +28,7 @@ extern ECL_API cl_object ecl_module_dummy;
extern ECL_API cl_object ecl_module_gc;
extern ECL_API cl_object ecl_module_unixint;
extern ECL_API cl_object ecl_module_bignum;
extern ECL_API cl_object ecl_module_ffi;
extern void init_all_symbols(void);
extern void init_backq(void);