preparing to handle singals
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
hyung-hwan 2024-09-27 21:06:12 +09:00
parent e337e9d48b
commit 4fe4ee649f
7 changed files with 1224 additions and 190 deletions

View File

@ -141,7 +141,7 @@ static void vm_checkbc (hcl_t* hcl, hcl_oob_t bcode)
} }
*/ */
static void gc_hcl (hcl_t* hcl) static void on_gc_hcl (hcl_t* hcl)
{ {
/*xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);*/ /*xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);*/
/*if (xtn->sym_errstr) xtn->sym_errstr = hcl_moveoop(hcl, xtn->sym_errstr);*/ /*if (xtn->sym_errstr) xtn->sym_errstr = hcl_moveoop(hcl, xtn->sym_errstr);*/
@ -859,7 +859,7 @@ int main (int argc, char* argv[])
} }
memset (&hclcb, 0, HCL_SIZEOF(hclcb)); memset (&hclcb, 0, HCL_SIZEOF(hclcb));
hclcb.gc = gc_hcl; hclcb.on_gc = on_gc_hcl;
hclcb.vm_startup = vm_startup; hclcb.vm_startup = vm_startup;
hclcb.vm_cleanup = vm_cleanup; hclcb.vm_cleanup = vm_cleanup;
/*hclcb.vm_checkbc = vm_checkbc;*/ /*hclcb.vm_checkbc = vm_checkbc;*/

View File

@ -1024,7 +1024,7 @@ static HCL_INLINE void gc_ms_mark_roots (hcl_t* hcl)
for (cb = hcl->cblist; cb; cb = cb->next) for (cb = hcl->cblist; cb; cb = cb->next)
{ {
if (cb->gc) cb->gc (hcl); if (cb->on_gc) cb->on_gc (hcl);
} }
#if defined(ENABLE_GCFIN) #if defined(ENABLE_GCFIN)

View File

@ -766,7 +766,7 @@ struct hcl_ntime_t
#define HCL_LBMASK(type,n) (~(~((type)0) << (n))) #define HCL_LBMASK(type,n) (~(~((type)0) << (n)))
#define HCL_LBMASK_SAFE(type,n) (((n) < HCL_BITSOF(type))? HCL_LBMASK(type,n): ~(type)0) #define HCL_LBMASK_SAFE(type,n) (((n) < HCL_BITSOF(type))? HCL_LBMASK(type,n): ~(type)0)
/* make a bit mask that can mask off hig n bits */ /* make a bit mask that can mask off high n bits */
#define HCL_HBMASK(type,n) (~(~((type)0) >> (n))) #define HCL_HBMASK(type,n) (~(~((type)0) >> (n)))
#define HCL_HBMASK_SAFE(type,n) (((n) < HCL_BITSOF(type))? HCL_HBMASK(type,n): ~(type)0) #define HCL_HBMASK_SAFE(type,n) (((n) < HCL_BITSOF(type))? HCL_HBMASK(type,n): ~(type)0)

View File

@ -231,7 +231,7 @@ void hcl_fini (hcl_t* hcl)
for (cb = hcl->cblist; cb; cb = cb->next) for (cb = hcl->cblist; cb; cb = cb->next)
{ {
if (cb->fini) cb->fini (hcl); if (cb->on_fini) cb->on_fini (hcl);
} }
if (hcl->log.len > 0) if (hcl->log.len > 0)
@ -583,7 +583,7 @@ int hcl_setoption (hcl_t* hcl, hcl_option_t id, const void* value)
for (cb = hcl->cblist; cb; cb = cb->next) for (cb = hcl->cblist; cb; cb = cb->next)
{ {
if (cb->opt_set) cb->opt_set (hcl, id, value); if (cb->on_option) cb->on_option (hcl, id, value);
} }
return 0; return 0;

View File

@ -1173,6 +1173,20 @@ typedef int (*hcl_vmprim_sleep_t) (
const hcl_ntime_t* duration const hcl_ntime_t* duration
); );
typedef hcl_ooi_t (*hcl_vmprim_getsigfd_t) (
hcl_t* hcl
);
typedef int (*hcl_vmprim_getsig_t) (
hcl_t* hcl,
hcl_uint8_t* sig
);
typedef int (*hcl_vmprim_setsig_t) (
hcl_t* hcl,
hcl_uint8_t sig
);
struct hcl_vmprim_t struct hcl_vmprim_t
{ {
/* The alloc_heap callback function is called very earlier /* The alloc_heap callback function is called very earlier
@ -1204,6 +1218,10 @@ struct hcl_vmprim_t
hcl_vmprim_muxmod_t vm_muxmod; hcl_vmprim_muxmod_t vm_muxmod;
hcl_vmprim_muxwait_t vm_muxwait; hcl_vmprim_muxwait_t vm_muxwait;
hcl_vmprim_sleep_t vm_sleep; /* required */ hcl_vmprim_sleep_t vm_sleep; /* required */
hcl_vmprim_getsigfd_t vm_getsigfd;
hcl_vmprim_getsig_t vm_getsig;
hcl_vmprim_setsig_t vm_setsig;
}; };
typedef struct hcl_vmprim_t hcl_vmprim_t; typedef struct hcl_vmprim_t hcl_vmprim_t;
@ -1404,9 +1422,10 @@ typedef int (*hcl_io_impl_t) (
* ========================================================================= */ * ========================================================================= */
typedef void (*hcl_cb_opt_set_t) (hcl_t* hcl, hcl_option_t id, const void* val); typedef void (*hcl_cb_on_fini_t) (hcl_t* hcl);
typedef void (*hcl_cb_fini_t) (hcl_t* hcl); typedef void (*hcl_cb_on_halting_t) (hcl_t* hcl);
typedef void (*hcl_cb_gc_t) (hcl_t* hcl); typedef void (*hcl_cb_on_option_t) (hcl_t* hcl, hcl_option_t id, const void* val);
typedef void (*hcl_cb_on_gc_t) (hcl_t* hcl);
typedef int (*hcl_cb_vm_startup_t) (hcl_t* hcl); typedef int (*hcl_cb_vm_startup_t) (hcl_t* hcl);
typedef void (*hcl_cb_vm_cleanup_t) (hcl_t* hcl); typedef void (*hcl_cb_vm_cleanup_t) (hcl_t* hcl);
typedef void (*hcl_cb_vm_checkbc_t) (hcl_t* hcl, hcl_oob_t bcode); typedef void (*hcl_cb_vm_checkbc_t) (hcl_t* hcl, hcl_oob_t bcode);
@ -1414,9 +1433,10 @@ typedef void (*hcl_cb_vm_checkbc_t) (hcl_t* hcl, hcl_oob_t bcode);
typedef struct hcl_cb_t hcl_cb_t; typedef struct hcl_cb_t hcl_cb_t;
struct hcl_cb_t struct hcl_cb_t
{ {
hcl_cb_opt_set_t opt_set; hcl_cb_on_fini_t on_fini; /* called from hcl_fini() */
hcl_cb_gc_t gc; hcl_cb_on_halting_t halting;
hcl_cb_fini_t fini; hcl_cb_on_option_t on_option; /* called from hcl_setoption() */
hcl_cb_on_gc_t on_gc; /* called from hcl_gc() */
hcl_cb_vm_startup_t vm_startup; hcl_cb_vm_startup_t vm_startup;
hcl_cb_vm_cleanup_t vm_cleanup; hcl_cb_vm_cleanup_t vm_cleanup;

View File

@ -4008,8 +4008,8 @@ static int init_compiler (hcl_t* hcl)
HCL_ASSERT (hcl, hcl->c == HCL_NULL); HCL_ASSERT (hcl, hcl->c == HCL_NULL);
HCL_MEMSET (&cb, 0, HCL_SIZEOF(cb)); HCL_MEMSET (&cb, 0, HCL_SIZEOF(cb));
cb.gc = gc_compiler_cb; cb.on_gc = gc_compiler_cb;
cb.fini = fini_compiler_cb; cb.on_fini = fini_compiler_cb;
cbp = hcl_regcb(hcl, &cb); cbp = hcl_regcb(hcl, &cb);
if (HCL_UNLIKELY(!cbp)) return -1; if (HCL_UNLIKELY(!cbp)) return -1;

1328
lib/std.c

File diff suppressed because it is too large Load Diff