From ae3745d5f343e34de86a9783f7e80c4c90daf89d Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 9 Apr 2018 15:54:54 +0000 Subject: [PATCH] added HCL_MOD_INCTX to hcl added HCL_SERVER_MODULE_INCTX to hcl server --- Makefile.in | 9 +++++---- configure | 14 +++++++++++++- lib/Makefile.in | 1 + lib/hcl-s.c | 10 ++++++++++ lib/hcl-s.h | 3 ++- lib/hcl.c | 12 +++++++++++- lib/hcl.h | 9 ++++++--- mod/Makefile.in | 1 + 8 files changed, 49 insertions(+), 10 deletions(-) diff --git a/Makefile.in b/Makefile.in index 365416a..ea0c943 100644 --- a/Makefile.in +++ b/Makefile.in @@ -353,6 +353,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -583,7 +584,7 @@ distdir: $(DISTFILES) ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir @@ -609,7 +610,7 @@ dist-shar: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 - shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir @@ -627,7 +628,7 @@ dist dist-all: distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ - eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ @@ -637,7 +638,7 @@ distcheck: dist *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ - eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac diff --git a/configure b/configure index 3f54fd0..188fdcb 100755 --- a/configure +++ b/configure @@ -781,6 +781,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -874,6 +875,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1126,6 +1128,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1263,7 +1274,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1416,6 +1427,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] diff --git a/lib/Makefile.in b/lib/Makefile.in index a387ebf..8b21fde 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -424,6 +424,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/lib/hcl-s.c b/lib/hcl-s.c index 9b0b348..2a981dd 100644 --- a/lib/hcl-s.c +++ b/lib/hcl-s.c @@ -316,6 +316,7 @@ struct hcl_server_t hcl_oow_t actor_heap_size; hcl_ntime_t actor_max_runtime; hcl_ooch_t script_include_path[HCL_PATH_MAX + 1]; + void* module_inctx; } cfg; struct @@ -1067,6 +1068,7 @@ hcl_server_proto_t* hcl_server_proto_open (hcl_oow_t xtnsize, hcl_server_worker_ xtn = (worker_hcl_xtn_t*)hcl_getxtn(proto->hcl); xtn->proto = proto; + hcl_setoption (proto->hcl, HCL_MOD_INCTX, &proto->worker->server->cfg.module_inctx); hcl_setoption (proto->hcl, HCL_LOG_MASK, &proto->worker->server->cfg.logmask); hcl_setcmgr (proto->hcl, proto->worker->server->cmgr); @@ -2644,6 +2646,10 @@ int hcl_server_setoption (hcl_server_t* server, hcl_server_option_t id, const vo case HCL_SERVER_SCRIPT_INCLUDE_PATH: hcl_copy_oocstr (server->cfg.script_include_path, HCL_COUNTOF(server->cfg.script_include_path), (const hcl_ooch_t*)value); return 0; + + case HCL_SERVER_MODULE_INCTX: + server->cfg.module_inctx = *(void**)value; + return 0; } hcl_server_seterrnum (server, HCL_EINVAL); @@ -2685,6 +2691,10 @@ int hcl_server_getoption (hcl_server_t* server, hcl_server_option_t id, void* va case HCL_SERVER_SCRIPT_INCLUDE_PATH: *(hcl_ooch_t**)value = server->cfg.script_include_path; return 0; + + case HCL_SERVER_MODULE_INCTX: + *(void**)value = server->cfg.module_inctx; + return 0; }; hcl_server_seterrnum (server, HCL_EINVAL); diff --git a/lib/hcl-s.h b/lib/hcl-s.h index 99f6522..654de3c 100644 --- a/lib/hcl-s.h +++ b/lib/hcl-s.h @@ -42,7 +42,8 @@ enum hcl_server_option_t HCL_SERVER_WORKER_IDLE_TIMEOUT, HCL_SERVER_ACTOR_HEAP_SIZE, HCL_SERVER_ACTOR_MAX_RUNTIME, - HCL_SERVER_SCRIPT_INCLUDE_PATH + HCL_SERVER_SCRIPT_INCLUDE_PATH, + HCL_SERVER_MODULE_INCTX }; typedef enum hcl_server_option_t hcl_server_option_t; diff --git a/lib/hcl.c b/lib/hcl.c index 1e50ed3..418c729 100644 --- a/lib/hcl.c +++ b/lib/hcl.c @@ -374,6 +374,10 @@ int hcl_setoption (hcl_t* hcl, hcl_option_t id, const void* value) hcl->option.dfl_procstk_size = *(hcl_oow_t*)value; return 0; } + + case HCL_MOD_INCTX: + hcl->option.mod_inctx = *(void**)value; + return 0; } einval: @@ -408,6 +412,10 @@ int hcl_getoption (hcl_t* hcl, hcl_option_t id, void* value) case HCL_PROCSTK_SIZE: *(hcl_oow_t*)value = hcl->option.dfl_procstk_size; return 0; + + case HCL_MOD_INCTX: + *(void**)value = hcl->option.mod_inctx; + return 0; }; hcl_seterrnum (hcl, HCL_EINVAL); @@ -563,6 +571,7 @@ hcl_mod_data_t* hcl_openmod (hcl_t* hcl, const hcl_ooch_t* name, hcl_oow_t namel /* found the module in the staic module table */ HCL_MEMSET (&md, 0, HCL_SIZEOF(md)); + md.mod.inctx = hcl->option.mod_inctx; hcl_copy_oochars ((hcl_ooch_t*)md.mod.name, name, namelen); /* Note md.handle is HCL_NULL for a static module */ @@ -605,6 +614,7 @@ hcl_mod_data_t* hcl_openmod (hcl_t* hcl, const hcl_ooch_t* name, hcl_oow_t namel /* attempt to find a dynamic external module */ HCL_MEMSET (&md, 0, HCL_SIZEOF(md)); + md.mod.inctx = hcl->option.mod_inctx; hcl_copy_oochars((hcl_ooch_t*)md.mod.name, name, namelen); if (hcl->vmprim.dl_open && hcl->vmprim.dl_getsym && hcl->vmprim.dl_close) { @@ -695,7 +705,7 @@ hcl_pfbase_t* hcl_querymod (hcl_t* hcl, const hcl_ooch_t* pfid, hcl_oow_t pfidle hcl_oow_t mod_name_len; hcl_pfbase_t* pfbase; - sep = hcl_rfind_oochar (pfid, pfidlen, '.'); + sep = hcl_rfind_oochar(pfid, pfidlen, '.'); if (!sep) { /* i'm writing a conservative code here. the compiler should diff --git a/lib/hcl.h b/lib/hcl.h index c593f34..37a3837 100644 --- a/lib/hcl.h +++ b/lib/hcl.h @@ -163,7 +163,8 @@ enum hcl_option_t HCL_LOG_MAXCAPA, HCL_SYMTAB_SIZE, /* default system table size */ HCL_SYSDIC_SIZE, /* default system dictionary size */ - HCL_PROCSTK_SIZE /* default process stack size */ + HCL_PROCSTK_SIZE, /* default process stack size */ + HCL_MOD_INCTX }; typedef enum hcl_option_t hcl_option_t; @@ -1015,9 +1016,10 @@ typedef void (*hcl_mod_gc_t) ( struct hcl_mod_t { /* input */ - /*const*/ hcl_ooch_t name[HCL_MOD_NAME_LEN_MAX + 1]; + hcl_ooch_t name[HCL_MOD_NAME_LEN_MAX + 1]; + void* inctx; - /* user-defined data */ + /* user-defined data - the module intializer shoudl fill in the following fields. */ hcl_mod_query_t query; hcl_mod_unload_t unload; hcl_mod_gc_t gc; @@ -1076,6 +1078,7 @@ struct hcl_t hcl_oow_t dfl_symtab_size; hcl_oow_t dfl_sysdic_size; hcl_oow_t dfl_procstk_size; + void* mod_inctx; #if defined(HCL_BUILD_DEBUG) /* set automatically when trait is set */ diff --git a/mod/Makefile.in b/mod/Makefile.in index 1970289..40b1ca0 100644 --- a/mod/Makefile.in +++ b/mod/Makefile.in @@ -376,6 +376,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@