almost finised mpi migration
This commit is contained in:
@ -45,6 +45,7 @@
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# include <ltdl.h>
|
||||
# define USE_LTDL
|
||||
#endif
|
||||
|
||||
#ifndef QSE_HAVE_CONFIG_H
|
||||
@ -134,8 +135,7 @@ int StdAwk::open ()
|
||||
this->gbl_environ <= -1 ||
|
||||
this->gbl_procinfo <= -1)
|
||||
{
|
||||
Awk::close ();
|
||||
return -1;
|
||||
goto oops;
|
||||
}
|
||||
|
||||
if (addFunction (QSE_T("rand"), 0, 0, (FunctionHandler)&StdAwk::rand, 0) <= -1 ||
|
||||
@ -145,10 +145,17 @@ int StdAwk::open ()
|
||||
addFunction (QSE_T("setioattr"), 3, 3, (FunctionHandler)&StdAwk::setioattr, QSE_AWK_RIO) <= -1 ||
|
||||
addFunction (QSE_T("getioattr"), 2, 2, (FunctionHandler)&StdAwk::getioattr, QSE_AWK_RIO) <= -1)
|
||||
{
|
||||
Awk::close ();
|
||||
return -1;
|
||||
goto oops;
|
||||
}
|
||||
|
||||
#if defined(USE_LTDL)
|
||||
/* lt_dlinit() can be called more than once and
|
||||
* lt_dlexit() shuts down libltdl if it's called as many times as
|
||||
* corresponding lt_dlinit(). so it's safe to call lt_dlinit()
|
||||
* and lt_dlexit() at the library level. */
|
||||
if (lt_dlinit() != 0) goto oops;
|
||||
#endif
|
||||
|
||||
qse_ntime_t now;
|
||||
|
||||
this->seed = (qse_gettime(&now) <= -1)? 0u: (long_t)now;
|
||||
@ -160,6 +167,10 @@ int StdAwk::open ()
|
||||
|
||||
this->cmgrtab_inited = false;
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
Awk::close ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
void StdAwk::close ()
|
||||
@ -171,8 +182,13 @@ void StdAwk::close ()
|
||||
this->cmgrtab_inited = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
clearConsoleOutputs ();
|
||||
Awk::close ();
|
||||
|
||||
#if defined(USE_LTDL)
|
||||
lt_dlexit ();
|
||||
#endif
|
||||
}
|
||||
|
||||
StdAwk::Run* StdAwk::parse (Source& in, Source& out)
|
||||
|
@ -827,14 +827,14 @@ void qse_awk_rtx_close (qse_awk_rtx_t* rtx)
|
||||
qse_awk_rtx_ecb_t* ecb;
|
||||
struct module_fini_ctx_t mfc;
|
||||
|
||||
for (ecb = rtx->ecb; ecb; ecb = ecb->next)
|
||||
if (ecb->close) ecb->close (rtx);
|
||||
|
||||
mfc.limit = 0;
|
||||
mfc.count = 0;
|
||||
mfc.rtx = rtx;
|
||||
qse_rbt_walk (rtx->awk->modtab, fini_module, &mfc);
|
||||
|
||||
for (ecb = rtx->ecb; ecb; ecb = ecb->next)
|
||||
if (ecb->close) ecb->close (rtx);
|
||||
|
||||
/* NOTE:
|
||||
* the close callbacks are called before data in rtx
|
||||
* is destroyed. if the destruction count on any data
|
||||
|
@ -49,6 +49,7 @@
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# include <ltdl.h>
|
||||
# define USE_LTDL
|
||||
#endif
|
||||
|
||||
#ifndef QSE_HAVE_CONFIG_H
|
||||
@ -421,6 +422,9 @@ qse_awk_t* qse_awk_openstd (qse_size_t xtnsize)
|
||||
static void fini_xtn (qse_awk_t* awk)
|
||||
{
|
||||
/* nothing to do */
|
||||
#if defined(USE_LTDL)
|
||||
lt_dlexit ();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void clear_xtn (qse_awk_t* awk)
|
||||
@ -447,6 +451,7 @@ qse_awk_t* qse_awk_openstdwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize)
|
||||
prm.math.log10 = custom_awk_log10;
|
||||
prm.math.exp = custom_awk_exp;
|
||||
prm.math.sqrt = custom_awk_sqrt;
|
||||
|
||||
prm.modopen = custom_awk_modopen;
|
||||
prm.modclose = custom_awk_modclose;
|
||||
prm.modsym = custom_awk_modsym;
|
||||
@ -460,17 +465,25 @@ qse_awk_t* qse_awk_openstdwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize)
|
||||
|
||||
/* add intrinsic global variables and functions */
|
||||
if (add_globals(awk) <= -1 ||
|
||||
add_functions (awk) <= -1)
|
||||
{
|
||||
qse_awk_close (awk);
|
||||
return QSE_NULL;
|
||||
}
|
||||
add_functions (awk) <= -1) goto oops;
|
||||
|
||||
#if defined(USE_LTDL)
|
||||
/* lt_dlinit() can be called more than once and
|
||||
* lt_dlexit() shuts down libltdl if it's called as many times as
|
||||
* corresponding lt_dlinit(). so it's safe to call lt_dlinit()
|
||||
* and lt_dlexit() at the library level. */
|
||||
if (lt_dlinit () != 0) goto oops;
|
||||
#endif
|
||||
|
||||
xtn->ecb.close = fini_xtn;
|
||||
xtn->ecb.clear = clear_xtn;
|
||||
qse_awk_pushecb (awk, &xtn->ecb);
|
||||
|
||||
return awk;
|
||||
|
||||
oops:
|
||||
if (awk) qse_awk_close (awk);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
void* qse_awk_getxtnstd (qse_awk_t* awk)
|
||||
|
Reference in New Issue
Block a user