added dl_startup and dl_cleanup to vmprim
This commit is contained in:
parent
d932d5f29b
commit
7699d332b8
@ -1283,12 +1283,12 @@ oops:
|
||||
tmplen[0] = ndigits_yl + ndigits_yh + 1;
|
||||
tmplen[1] = ndigits_xh + ndigits_yh;
|
||||
if (tmplen[1] < tmplen[0]) tmplen[1] = tmplen[0];
|
||||
tmp[1] = (hcl_liw_t*)moo_callocmem(moo, MOO_SIZEOF(moo_liw_t) * tmplen[1]);
|
||||
tmp[1] = (moo_liw_t*)moo_callocmem(moo, MOO_SIZEOF(moo_liw_t) * tmplen[1]);
|
||||
if (!tmp[1]) goto oops;
|
||||
|
||||
/* make a temporary for (a0 + a1) and (a0 * b0) */
|
||||
tmplen[0] = ndigits_xl + ndigits_yl;
|
||||
tmp[0] = (hcl_liw_t*)moo_callocmem(moo, MOO_SIZEOF(moo_liw_t) * tmplen[0]);
|
||||
tmp[0] = (moo_liw_t*)moo_callocmem(moo, MOO_SIZEOF(moo_liw_t) * tmplen[0]);
|
||||
if (!tmp[0]) goto oops;
|
||||
|
||||
/* tmp[0] = a0 + a1 */
|
||||
|
@ -543,7 +543,7 @@ static moo_ooi_t input_handler (moo_t* moo, moo_iocmd_t cmd, moo_ioarg_t* arg)
|
||||
static void* alloc_heap (moo_t* moo, moo_oow_t size)
|
||||
{
|
||||
#if defined(HAVE_MMAP) && defined(HAVE_MUNMAP) && defined(MAP_ANONYMOUS)
|
||||
/* It's called via moo_makeheap() when HCL creates a GC heap.
|
||||
/* It's called via moo_makeheap() when MOO creates a GC heap.
|
||||
* The heap is large in size. I can use a different memory allocation
|
||||
* function instead of an ordinary malloc.
|
||||
* upon failure, it doesn't require to set error information as moo_makeheap()
|
||||
@ -1242,6 +1242,20 @@ static const char* mach_dlerror (void)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void dl_startup (moo_t* moo)
|
||||
{
|
||||
#if defined(USE_LTDL)
|
||||
lt_dlinit ();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void dl_cleanup (moo_t* moo)
|
||||
{
|
||||
#if defined(USE_LTDL)
|
||||
lt_dlexit ();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void* dl_open (moo_t* moo, const moo_ooch_t* name, int flags)
|
||||
{
|
||||
#if defined(USE_LTDL) || defined(USE_DLFCN) || defined(USE_MACH_O_DYLD) || defined(USE_WIN_DLL)
|
||||
@ -3023,6 +3037,8 @@ int main (int argc, char* argv[])
|
||||
vmprim.log_write = log_write;
|
||||
vmprim.syserrstrb = syserrstrb;
|
||||
vmprim.assertfail = assert_fail;
|
||||
vmprim.dl_startup = dl_startup;
|
||||
vmprim.dl_cleanup = dl_cleanup;
|
||||
vmprim.dl_open = dl_open;
|
||||
vmprim.dl_close = dl_close;
|
||||
vmprim.dl_getsym = dl_getsym;
|
||||
@ -3035,17 +3051,10 @@ int main (int argc, char* argv[])
|
||||
vmprim.vm_muxwait = vm_muxwait;
|
||||
vmprim.vm_sleep = vm_sleep;
|
||||
|
||||
#if defined(USE_LTDL)
|
||||
lt_dlinit ();
|
||||
#endif
|
||||
|
||||
moo = moo_open (&sys_mmgr, MOO_SIZEOF(xtn_t), memsize, &vmprim, MOO_NULL);
|
||||
if (!moo)
|
||||
{
|
||||
fprintf (stderr, "ERROR: cannot open moo\n");
|
||||
#if defined(USE_LTDL)
|
||||
lt_dlexit ();
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -3085,9 +3094,6 @@ int main (int argc, char* argv[])
|
||||
if (handle_logopt (moo, logopt) <= -1)
|
||||
{
|
||||
moo_close (moo);
|
||||
#if defined(USE_LTDL)
|
||||
lt_dlexit ();
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -3103,9 +3109,6 @@ int main (int argc, char* argv[])
|
||||
if (handle_dbgopt (moo, dbgopt) <= -1)
|
||||
{
|
||||
moo_close (moo);
|
||||
#if defined(USE_LTDL)
|
||||
lt_dlexit ();
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -3115,9 +3118,6 @@ int main (int argc, char* argv[])
|
||||
{
|
||||
moo_logbfmt (moo, MOO_LOG_STDERR, "ERROR: cannot ignite moo - [%d] %js\n", moo_geterrnum(moo), moo_geterrstr(moo));
|
||||
moo_close (moo);
|
||||
#if defined(USE_LTDL)
|
||||
lt_dlexit ();
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -3168,9 +3168,6 @@ int main (int argc, char* argv[])
|
||||
}
|
||||
|
||||
moo_close (moo);
|
||||
#if defined(USE_LTDL)
|
||||
lt_dlexit ();
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -3199,10 +3196,5 @@ int main (int argc, char* argv[])
|
||||
*moo_dumpdic(moo, moo->sysdic, "System dictionary");*/
|
||||
|
||||
moo_close (moo);
|
||||
|
||||
#if defined(USE_LTDL)
|
||||
lt_dlexit ();
|
||||
#endif
|
||||
|
||||
return xret;
|
||||
}
|
||||
|
@ -149,6 +149,7 @@ int moo_init (moo_t* moo, moo_mmgr_t* mmgr, moo_oow_t heapsz, const moo_vmprim_t
|
||||
moo->newheap = moo_makeheap (moo, heapsz);
|
||||
if (!moo->newheap) goto oops;
|
||||
|
||||
if (moo->vmprim.dl_startup) moo->vmprim.dl_startup (moo);
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
@ -284,6 +285,8 @@ void moo_fini (moo_t* moo)
|
||||
moo->inttostr.t.ptr = MOO_NULL;
|
||||
moo->inttostr.t.capa = 0;
|
||||
}
|
||||
|
||||
if (moo->vmprim.dl_cleanup) moo->vmprim.dl_cleanup (moo);
|
||||
}
|
||||
|
||||
int moo_setoption (moo_t* moo, moo_option_t id, const void* value)
|
||||
|
@ -1098,6 +1098,14 @@ enum moo_vmprim_dlopen_flag_t
|
||||
};
|
||||
typedef enum moo_vmprim_dlopen_flag_t moo_vmprim_dlopen_flag_t;
|
||||
|
||||
typedef void (*moo_vmprim_dlstartup_t) (
|
||||
moo_t* moo
|
||||
);
|
||||
|
||||
typedef void (*moo_vmprim_dlcleanup_t) (
|
||||
moo_t* moo
|
||||
);
|
||||
|
||||
typedef void* (*moo_vmprim_dlopen_t) (
|
||||
moo_t* moo,
|
||||
const moo_ooch_t* name,
|
||||
@ -1164,14 +1172,16 @@ typedef void (*moo_vmprim_sleep_t) (
|
||||
|
||||
struct moo_vmprim_t
|
||||
{
|
||||
moo_alloc_heap_t alloc_heap;
|
||||
moo_free_heap_t free_heap;
|
||||
moo_alloc_heap_t alloc_heap;
|
||||
moo_free_heap_t free_heap;
|
||||
|
||||
moo_log_write_t log_write;
|
||||
moo_syserrstrb_t syserrstrb;
|
||||
moo_syserrstru_t syserrstru;
|
||||
moo_assertfail_t assertfail;
|
||||
|
||||
moo_vmprim_dlstartup_t dl_startup;
|
||||
moo_vmprim_dlcleanup_t dl_cleanup;
|
||||
moo_vmprim_dlopen_t dl_open;
|
||||
moo_vmprim_dlclose_t dl_close;
|
||||
moo_vmprimt_dlgetsym_t dl_getsym;
|
||||
|
Loading…
Reference in New Issue
Block a user