introduced the new type hcl_bitmask_t
This commit is contained in:
parent
727f612b38
commit
deb53399a4
@ -2564,7 +2564,7 @@ static HCL_INLINE int emit_set (hcl_t* hcl)
|
||||
int hcl_compile (hcl_t* hcl, hcl_oop_t obj)
|
||||
{
|
||||
hcl_oow_t saved_bc_len, saved_lit_len;
|
||||
int log_default_type_mask;
|
||||
hcl_bitmask_t log_default_type_mask;
|
||||
|
||||
HCL_ASSERT (hcl, GET_TOP_CFRAME_INDEX(hcl) < 0);
|
||||
|
||||
|
@ -2243,7 +2243,8 @@ oops:
|
||||
|
||||
hcl_oop_t hcl_executefromip (hcl_t* hcl, hcl_oow_t initial_ip)
|
||||
{
|
||||
int n, log_default_type_mask;
|
||||
int n;
|
||||
hcl_bitmask_t log_default_type_mask;
|
||||
|
||||
HCL_ASSERT (hcl, hcl->code.bc.len < HCL_SMOOI_MAX); /* asserted by the compiler */
|
||||
if (initial_ip >= hcl->code.bc.len)
|
||||
|
20
lib/hcl-c.c
20
lib/hcl-c.c
@ -61,8 +61,8 @@ struct hcl_client_t
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned int trait;
|
||||
unsigned int logmask;
|
||||
hcl_bitmask_t trait;
|
||||
hcl_bitmask_t logmask;
|
||||
} cfg;
|
||||
|
||||
hcl_client_state_t state;
|
||||
@ -128,7 +128,7 @@ struct hcl_client_t
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
static void log_write_for_dummy (hcl_t* hcl, unsigned int mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
static void log_write_for_dummy (hcl_t* hcl, hcl_bitmask_t mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
{
|
||||
dummy_hcl_xtn_t* xtn = (dummy_hcl_xtn_t*)hcl_getxtn(hcl);
|
||||
hcl_client_t* client;
|
||||
@ -838,7 +838,7 @@ hcl_client_t* hcl_client_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_client_p
|
||||
client->prim = *prim;
|
||||
client->dummy_hcl = hcl;
|
||||
|
||||
client->cfg.logmask = ~0u;
|
||||
client->cfg.logmask = ~(hcl_bitmask_t)0;
|
||||
|
||||
/* the dummy hcl is used for this client to perform primitive operations
|
||||
* such as getting system time or logging. so the heap size doesn't
|
||||
@ -862,11 +862,11 @@ int hcl_client_setoption (hcl_client_t* client, hcl_client_option_t id, const vo
|
||||
switch (id)
|
||||
{
|
||||
case HCL_CLIENT_TRAIT:
|
||||
client->cfg.trait = *(const unsigned int*)value;
|
||||
client->cfg.trait = *(const hcl_bitmask_t*)value;
|
||||
return 0;
|
||||
|
||||
case HCL_CLIENT_LOG_MASK:
|
||||
client->cfg.logmask = *(const unsigned int*)value;
|
||||
client->cfg.logmask = *(const hcl_bitmask_t*)value;
|
||||
if (client->dummy_hcl)
|
||||
{
|
||||
/* setting this affects the dummy hcl immediately.
|
||||
@ -887,11 +887,11 @@ int hcl_client_getoption (hcl_client_t* client, hcl_client_option_t id, void* va
|
||||
switch (id)
|
||||
{
|
||||
case HCL_CLIENT_TRAIT:
|
||||
*(unsigned int*)value = client->cfg.trait;
|
||||
*(hcl_bitmask_t*)value = client->cfg.trait;
|
||||
return 0;
|
||||
|
||||
case HCL_CLIENT_LOG_MASK:
|
||||
*(unsigned int*)value = client->cfg.logmask;
|
||||
*(hcl_bitmask_t*)value = client->cfg.logmask;
|
||||
return 0;
|
||||
};
|
||||
|
||||
@ -973,7 +973,7 @@ void hcl_client_seterrufmt (hcl_client_t* client, hcl_errnum_t errnum, const hcl
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
void hcl_client_logbfmt (hcl_client_t* client, unsigned int mask, const hcl_bch_t* fmt, ...)
|
||||
void hcl_client_logbfmt (hcl_client_t* client, hcl_bitmask_t mask, const hcl_bch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
@ -981,7 +981,7 @@ void hcl_client_logbfmt (hcl_client_t* client, unsigned int mask, const hcl_bch_
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
void hcl_client_logufmt (hcl_client_t* client, unsigned int mask, const hcl_uch_t* fmt, ...)
|
||||
void hcl_client_logufmt (hcl_client_t* client, hcl_bitmask_t mask, const hcl_uch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
|
@ -77,7 +77,7 @@ typedef enum hcl_client_reply_type_t hcl_client_reply_type_t;
|
||||
|
||||
typedef void (*hcl_client_log_write_t) (
|
||||
hcl_client_t* client,
|
||||
unsigned int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_ooch_t* msg,
|
||||
hcl_oow_t len
|
||||
);
|
||||
@ -228,14 +228,14 @@ HCL_EXPORT void hcl_client_seterrufmt (
|
||||
|
||||
HCL_EXPORT void hcl_client_logbfmt (
|
||||
hcl_client_t* client,
|
||||
unsigned int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_bch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
HCL_EXPORT void hcl_client_logufmt (
|
||||
hcl_client_t* client,
|
||||
unsigned int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_uch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
@ -85,7 +85,7 @@ typedef enum hcl_json_inst_t hcl_json_inst_t;
|
||||
|
||||
typedef void (*hcl_json_log_write_t) (
|
||||
hcl_json_t* json,
|
||||
unsigned int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_ooch_t* msg,
|
||||
hcl_oow_t len
|
||||
);
|
||||
@ -199,14 +199,14 @@ HCL_EXPORT void hcl_json_seterrufmt (
|
||||
|
||||
HCL_EXPORT void hcl_json_logbfmt (
|
||||
hcl_json_t* json,
|
||||
unsigned int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_bch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
HCL_EXPORT void hcl_json_logufmt (
|
||||
hcl_json_t* json,
|
||||
unsigned int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_uch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
@ -644,7 +644,7 @@ enum hcl_bcode_t
|
||||
|
||||
typedef hcl_ooi_t (*hcl_outbfmt_t) (
|
||||
hcl_t* hcl,
|
||||
int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_bch_t* fmt,
|
||||
...
|
||||
);
|
||||
@ -1091,7 +1091,7 @@ hcl_pfbase_t* hcl_querymod (
|
||||
/* ========================================================================= */
|
||||
int hcl_outfmtobj (
|
||||
hcl_t* hcl,
|
||||
int mask,
|
||||
hcl_bitmask_t mask,
|
||||
hcl_oop_t obj,
|
||||
hcl_outbfmt_t outbfmt
|
||||
);
|
||||
|
28
lib/hcl-s.c
28
lib/hcl-s.c
@ -309,8 +309,8 @@ struct hcl_server_t
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned int trait;
|
||||
unsigned int logmask;
|
||||
hcl_bitmask_t trait;
|
||||
hcl_bitmask_t logmask;
|
||||
hcl_oow_t worker_stack_size;
|
||||
hcl_oow_t worker_max_count;
|
||||
hcl_ntime_t worker_idle_timeout;
|
||||
@ -699,7 +699,7 @@ static void free_heap (hcl_t* hcl, void* ptr)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void log_write (hcl_t* hcl, unsigned int mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
static void log_write (hcl_t* hcl, hcl_bitmask_t mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
{
|
||||
worker_hcl_xtn_t* xtn = (worker_hcl_xtn_t*)hcl_getxtn(hcl);
|
||||
hcl_server_t* server;
|
||||
@ -710,7 +710,7 @@ static void log_write (hcl_t* hcl, unsigned int mask, const hcl_ooch_t* msg, hcl
|
||||
pthread_mutex_unlock (&server->log_mutex);
|
||||
}
|
||||
|
||||
static void log_write_for_dummy (hcl_t* hcl, unsigned int mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
static void log_write_for_dummy (hcl_t* hcl, hcl_bitmask_t mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
{
|
||||
dummy_hcl_xtn_t* xtn = (dummy_hcl_xtn_t*)hcl_getxtn(hcl);
|
||||
hcl_server_t* server;
|
||||
@ -1038,7 +1038,7 @@ hcl_server_proto_t* hcl_server_proto_open (hcl_oow_t xtnsize, hcl_server_worker_
|
||||
hcl_vmprim_t vmprim;
|
||||
hcl_cb_t hclcb;
|
||||
worker_hcl_xtn_t* xtn;
|
||||
unsigned int trait;
|
||||
hcl_bitmask_t trait;
|
||||
|
||||
HCL_MEMSET (&vmprim, 0, HCL_SIZEOF(vmprim));
|
||||
if (worker->server->cfg.trait & HCL_SERVER_TRAIT_USE_LARGE_PAGES)
|
||||
@ -1898,7 +1898,7 @@ hcl_server_t* hcl_server_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_server_p
|
||||
hcl_tmr_t* tmr = HCL_NULL;
|
||||
dummy_hcl_xtn_t* xtn;
|
||||
int pfd[2], fcv;
|
||||
unsigned int trait;
|
||||
hcl_bitmask_t trait;
|
||||
|
||||
server = (hcl_server_t*)HCL_MMGR_ALLOC(mmgr, HCL_SIZEOF(*server) + xtnsize);
|
||||
if (!server)
|
||||
@ -1959,7 +1959,7 @@ hcl_server_t* hcl_server_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_server_p
|
||||
server->dummy_hcl = hcl;
|
||||
server->tmr = tmr;
|
||||
|
||||
server->cfg.logmask = ~0u;
|
||||
server->cfg.logmask = ~(hcl_bitmask_t)0;
|
||||
server->cfg.worker_stack_size = 512000UL;
|
||||
server->cfg.actor_heap_size = 512000UL;
|
||||
|
||||
@ -2283,7 +2283,7 @@ static void purge_all_workers (hcl_server_t* server, hcl_server_worker_state_t w
|
||||
}
|
||||
}
|
||||
|
||||
void hcl_server_logbfmt (hcl_server_t* server, unsigned int mask, const hcl_bch_t* fmt, ...)
|
||||
void hcl_server_logbfmt (hcl_server_t* server, hcl_bitmask_t mask, const hcl_bch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
@ -2291,7 +2291,7 @@ void hcl_server_logbfmt (hcl_server_t* server, unsigned int mask, const hcl_bch_
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
void hcl_server_logufmt (hcl_server_t* server, unsigned int mask, const hcl_uch_t* fmt, ...)
|
||||
void hcl_server_logufmt (hcl_server_t* server, hcl_bitmask_t mask, const hcl_uch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
@ -2648,14 +2648,14 @@ int hcl_server_setoption (hcl_server_t* server, hcl_server_option_t id, const vo
|
||||
switch (id)
|
||||
{
|
||||
case HCL_SERVER_TRAIT:
|
||||
server->cfg.trait = *(const unsigned int*)value;
|
||||
server->cfg.trait = *(const hcl_bitmask_t*)value;
|
||||
if (server->dummy_hcl)
|
||||
{
|
||||
/* setting this affects the dummy hcl immediately.
|
||||
* existing hcl instances inside worker threads won't get
|
||||
* affected. new hcl instances to be created later
|
||||
* is supposed to use the new value */
|
||||
unsigned int trait;
|
||||
hcl_bitmask_t trait;
|
||||
|
||||
hcl_getoption (server->dummy_hcl, HCL_TRAIT, &trait);
|
||||
#if defined(HCL_BUILD_DEBUG)
|
||||
@ -2667,7 +2667,7 @@ int hcl_server_setoption (hcl_server_t* server, hcl_server_option_t id, const vo
|
||||
return 0;
|
||||
|
||||
case HCL_SERVER_LOG_MASK:
|
||||
server->cfg.logmask = *(const unsigned int*)value;
|
||||
server->cfg.logmask = *(const hcl_bitmask_t*)value;
|
||||
if (server->dummy_hcl)
|
||||
{
|
||||
/* setting this affects the dummy hcl immediately.
|
||||
@ -2716,11 +2716,11 @@ int hcl_server_getoption (hcl_server_t* server, hcl_server_option_t id, void* va
|
||||
switch (id)
|
||||
{
|
||||
case HCL_SERVER_TRAIT:
|
||||
*(unsigned int*)value = server->cfg.trait;
|
||||
*(hcl_bitmask_t*)value = server->cfg.trait;
|
||||
return 0;
|
||||
|
||||
case HCL_SERVER_LOG_MASK:
|
||||
*(unsigned int*)value = server->cfg.logmask;
|
||||
*(hcl_bitmask_t*)value = server->cfg.logmask;
|
||||
return 0;
|
||||
|
||||
case HCL_SERVER_WORKER_MAX_COUNT:
|
||||
|
@ -64,7 +64,7 @@ typedef enum hcl_server_trait_t hcl_server_trait_t;
|
||||
typedef void (*hcl_server_log_write_t) (
|
||||
hcl_server_t* server,
|
||||
hcl_oow_t wid,
|
||||
unsigned int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_ooch_t* msg,
|
||||
hcl_oow_t len
|
||||
);
|
||||
@ -163,14 +163,14 @@ HCL_EXPORT void hcl_server_seterrufmt (
|
||||
|
||||
HCL_EXPORT void hcl_server_logbfmt (
|
||||
hcl_server_t* server,
|
||||
unsigned int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_bch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
HCL_EXPORT void hcl_server_logufmt (
|
||||
hcl_server_t* server,
|
||||
unsigned int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_uch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
10
lib/hcl.c
10
lib/hcl.c
@ -110,7 +110,7 @@ int hcl_init (hcl_t* hcl, hcl_mmgr_t* mmgr, hcl_oow_t heapsz, const hcl_vmprim_t
|
||||
if (!hcl->vmprim.alloc_heap) hcl->vmprim.alloc_heap = alloc_heap;
|
||||
if (!hcl->vmprim.free_heap) hcl->vmprim.free_heap = free_heap;
|
||||
|
||||
hcl->option.log_mask = ~0u;
|
||||
hcl->option.log_mask = ~(hcl_bitmask_t)0;
|
||||
hcl->option.log_maxcapa = HCL_DFL_LOG_MAXCAPA;
|
||||
hcl->option.dfl_symtab_size = HCL_DFL_SYMTAB_SIZE;
|
||||
hcl->option.dfl_sysdic_size = HCL_DFL_SYSDIC_SIZE;
|
||||
@ -323,14 +323,14 @@ int hcl_setoption (hcl_t* hcl, hcl_option_t id, const void* value)
|
||||
switch (id)
|
||||
{
|
||||
case HCL_TRAIT:
|
||||
hcl->option.trait = *(const unsigned int*)value;
|
||||
hcl->option.trait = *(const hcl_bitmask_t*)value;
|
||||
#if defined(HCL_BUILD_DEBUG)
|
||||
hcl->option.karatsuba_cutoff = ((hcl->option.trait & HCL_DEBUG_BIGINT)? HCL_KARATSUBA_CUTOFF_DEBUG: HCL_KARATSUBA_CUTOFF);
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
case HCL_LOG_MASK:
|
||||
hcl->option.log_mask = *(const unsigned int*)value;
|
||||
hcl->option.log_mask = *(const hcl_bitmask_t*)value;
|
||||
return 0;
|
||||
|
||||
case HCL_LOG_MAXCAPA:
|
||||
@ -385,11 +385,11 @@ int hcl_getoption (hcl_t* hcl, hcl_option_t id, void* value)
|
||||
switch (id)
|
||||
{
|
||||
case HCL_TRAIT:
|
||||
*(unsigned int*)value = hcl->option.trait;
|
||||
*(hcl_bitmask_t*)value = hcl->option.trait;
|
||||
return 0;
|
||||
|
||||
case HCL_LOG_MASK:
|
||||
*(unsigned int*)value = hcl->option.log_mask;
|
||||
*(hcl_bitmask_t*)value = hcl->option.log_mask;
|
||||
return 0;
|
||||
|
||||
case HCL_LOG_MAXCAPA:
|
||||
|
189
lib/hcl.h
189
lib/hcl.h
@ -37,7 +37,7 @@
|
||||
/* ========================================================================== */
|
||||
|
||||
typedef struct hcl_mod_t hcl_mod_t;
|
||||
|
||||
typedef unsigned int hcl_bitmask_t;
|
||||
/* ========================================================================== */
|
||||
|
||||
/**
|
||||
@ -183,16 +183,16 @@ typedef enum hcl_option_dflval_t hcl_option_dflval_t;
|
||||
enum hcl_trait_t
|
||||
{
|
||||
#if defined(HCL_BUILD_DEBUG)
|
||||
HCL_DEBUG_GC = (1 << 0),
|
||||
HCL_DEBUG_BIGINT = (1 << 1),
|
||||
HCL_DEBUG_GC = (1u << 0),
|
||||
HCL_DEBUG_BIGINT = (1u << 1),
|
||||
#endif
|
||||
|
||||
/* perform no garbage collection when the heap is full.
|
||||
* you still can use hcl_gc() explicitly. */
|
||||
HCL_NOGC = (1 << 8),
|
||||
HCL_NOGC = (1u << 8),
|
||||
|
||||
/* wait for running process when exiting from the main method */
|
||||
HCL_AWAIT_PROCS = (1 << 9)
|
||||
HCL_AWAIT_PROCS = (1u << 9)
|
||||
};
|
||||
typedef enum hcl_trait_t hcl_trait_t;
|
||||
|
||||
@ -708,6 +708,84 @@ struct hcl_heap_t
|
||||
hcl_uint8_t* ptr; /* next allocation pointer */
|
||||
};
|
||||
|
||||
/* =========================================================================
|
||||
* HCL VM LOGGING
|
||||
* ========================================================================= */
|
||||
|
||||
enum hcl_log_mask_t
|
||||
{
|
||||
HCL_LOG_DEBUG = (1u << 0),
|
||||
HCL_LOG_INFO = (1u << 1),
|
||||
HCL_LOG_WARN = (1u << 2),
|
||||
HCL_LOG_ERROR = (1u << 3),
|
||||
HCL_LOG_FATAL = (1u << 4),
|
||||
|
||||
HCL_LOG_UNTYPED = (1u << 6), /* only to be used by HCL_DEBUGx() and HCL_INFOx() */
|
||||
HCL_LOG_COMPILER = (1u << 7),
|
||||
HCL_LOG_VM = (1u << 8),
|
||||
HCL_LOG_MNEMONIC = (1u << 9), /* bytecode mnemonic */
|
||||
HCL_LOG_GC = (1u << 10),
|
||||
HCL_LOG_IC = (1u << 11), /* instruction cycle, fetch-decode-execute */
|
||||
HCL_LOG_PRIMITIVE = (1u << 12),
|
||||
|
||||
HCL_LOG_APP = (1u << 13), /* hcl applications, set by hcl logging primitive */
|
||||
HCL_LOG_APP_X1 = (1u << 14), /* more hcl applications, you can choose to use one of APP_X? randomly */
|
||||
HCL_LOG_APP_X2 = (1u << 15),
|
||||
HCL_LOG_APP_X3 = (1u << 16),
|
||||
|
||||
HCL_LOG_ALL_LEVELS = (HCL_LOG_DEBUG | HCL_LOG_INFO | HCL_LOG_WARN | HCL_LOG_ERROR | HCL_LOG_FATAL),
|
||||
HCL_LOG_ALL_TYPES = (HCL_LOG_UNTYPED | HCL_LOG_COMPILER | HCL_LOG_VM | HCL_LOG_MNEMONIC | HCL_LOG_GC | HCL_LOG_IC | HCL_LOG_PRIMITIVE | HCL_LOG_APP | HCL_LOG_APP_X1 | HCL_LOG_APP_X2 | HCL_LOG_APP_X3),
|
||||
|
||||
|
||||
HCL_LOG_STDOUT = (1u << 20), /* write log messages to stdout without timestamp. HCL_LOG_STDOUT wins over HCL_LOG_STDERR. */
|
||||
HCL_LOG_STDERR = (1u << 21), /* write log messages to stderr without timestamp. */
|
||||
|
||||
HCL_LOG_PREFER_JSON = (1u << 30) /* write a object in the json format. don't set this explicitly. use %J instead */
|
||||
};
|
||||
typedef enum hcl_log_mask_t hcl_log_mask_t;
|
||||
|
||||
/* all bits must be set to get enabled */
|
||||
#define HCL_LOG_ENABLED(hcl,mask) (((hcl)->option.log_mask & (mask)) == (mask))
|
||||
|
||||
#define HCL_LOG0(hcl,mask,fmt) do { if (HCL_LOG_ENABLED(hcl,mask)) hcl_logbfmt(hcl, mask, fmt); } while(0)
|
||||
#define HCL_LOG1(hcl,mask,fmt,a1) do { if (HCL_LOG_ENABLED(hcl,mask)) hcl_logbfmt(hcl, mask, fmt, a1); } while(0)
|
||||
#define HCL_LOG2(hcl,mask,fmt,a1,a2) do { if (HCL_LOG_ENABLED(hcl,mask)) hcl_logbfmt(hcl, mask, fmt, a1, a2); } while(0)
|
||||
#define HCL_LOG3(hcl,mask,fmt,a1,a2,a3) do { if (HCL_LOG_ENABLED(hcl,mask)) hcl_logbfmt(hcl, mask, fmt, a1, a2, a3); } while(0)
|
||||
#define HCL_LOG4(hcl,mask,fmt,a1,a2,a3,a4) do { if (HCL_LOG_ENABLED(hcl,mask)) hcl_logbfmt(hcl, mask, fmt, a1, a2, a3, a4); } while(0)
|
||||
#define HCL_LOG5(hcl,mask,fmt,a1,a2,a3,a4,a5) do { if (HCL_LOG_ENABLED(hcl,mask)) hcl_logbfmt(hcl, mask, fmt, a1, a2, a3, a4, a5); } while(0)
|
||||
#define HCL_LOG6(hcl,mask,fmt,a1,a2,a3,a4,a5,a6) do { if (HCL_LOG_ENABLED(hcl,mask)) hcl_logbfmt(hcl, mask, fmt, a1, a2, a3, a4, a5, a6); } while(0)
|
||||
|
||||
#if defined(HCL_BUILD_RELEASE)
|
||||
/* [NOTE]
|
||||
* get rid of debugging message totally regardless of
|
||||
* the log mask in the release build.
|
||||
*/
|
||||
# define HCL_DEBUG0(hcl,fmt)
|
||||
# define HCL_DEBUG1(hcl,fmt,a1)
|
||||
# define HCL_DEBUG2(hcl,fmt,a1,a2)
|
||||
# define HCL_DEBUG3(hcl,fmt,a1,a2,a3)
|
||||
# define HCL_DEBUG4(hcl,fmt,a1,a2,a3,a4)
|
||||
# define HCL_DEBUG5(hcl,fmt,a1,a2,a3,a4,a5)
|
||||
# define HCL_DEBUG6(hcl,fmt,a1,a2,a3,a4,a5,a6)
|
||||
#else
|
||||
# define HCL_DEBUG0(hcl,fmt) HCL_LOG0(hcl, HCL_LOG_DEBUG | HCL_LOG_UNTYPED, fmt)
|
||||
# define HCL_DEBUG1(hcl,fmt,a1) HCL_LOG1(hcl, HCL_LOG_DEBUG | HCL_LOG_UNTYPED, fmt, a1)
|
||||
# define HCL_DEBUG2(hcl,fmt,a1,a2) HCL_LOG2(hcl, HCL_LOG_DEBUG | HCL_LOG_UNTYPED, fmt, a1, a2)
|
||||
# define HCL_DEBUG3(hcl,fmt,a1,a2,a3) HCL_LOG3(hcl, HCL_LOG_DEBUG | HCL_LOG_UNTYPED, fmt, a1, a2, a3)
|
||||
# define HCL_DEBUG4(hcl,fmt,a1,a2,a3,a4) HCL_LOG4(hcl, HCL_LOG_DEBUG | HCL_LOG_UNTYPED, fmt, a1, a2, a3, a4)
|
||||
# define HCL_DEBUG5(hcl,fmt,a1,a2,a3,a4,a5) HCL_LOG5(hcl, HCL_LOG_DEBUG | HCL_LOG_UNTYPED, fmt, a1, a2, a3, a4, a5)
|
||||
# define HCL_DEBUG6(hcl,fmt,a1,a2,a3,a4,a5,a6) HCL_LOG6(hcl, HCL_LOG_DEBUG | HCL_LOG_UNTYPED, fmt, a1, a2, a3, a4, a5, a6)
|
||||
#endif
|
||||
|
||||
#define HCL_INFO0(hcl,fmt) HCL_LOG0(hcl, HCL_LOG_INFO | HCL_LOG_UNTYPED, fmt)
|
||||
#define HCL_INFO1(hcl,fmt,a1) HCL_LOG1(hcl, HCL_LOG_INFO | HCL_LOG_UNTYPED, fmt, a1)
|
||||
#define HCL_INFO2(hcl,fmt,a1,a2) HCL_LOG2(hcl, HCL_LOG_INFO | HCL_LOG_UNTYPED, fmt, a1, a2)
|
||||
#define HCL_INFO3(hcl,fmt,a1,a2,a3) HCL_LOG3(hcl, HCL_LOG_INFO | HCL_LOG_UNTYPED, fmt, a1, a2, a3)
|
||||
#define HCL_INFO4(hcl,fmt,a1,a2,a3,a4) HCL_LOG4(hcl, HCL_LOG_INFO | HCL_LOG_UNTYPED, fmt, a1, a2, a3, a4)
|
||||
#define HCL_INFO5(hcl,fmt,a1,a2,a3,a4,a5) HCL_LOG5(hcl, HCL_LOG_INFO | HCL_LOG_UNTYPED, fmt, a1, a2, a3, a4, a5)
|
||||
#define HCL_INFO6(hcl,fmt,a1,a2,a3,a4,a5,a6) HCL_LOG6(hcl, HCL_LOG_INFO | HCL_LOG_UNTYPED, fmt, a1, a2, a3, a4, a5, a6)
|
||||
|
||||
|
||||
/* =========================================================================
|
||||
* VIRTUAL MACHINE PRIMITIVES
|
||||
* ========================================================================= */
|
||||
@ -724,7 +802,7 @@ typedef void (*hcl_free_heap_t) (
|
||||
|
||||
typedef void (*hcl_log_write_t) (
|
||||
hcl_t* hcl,
|
||||
unsigned int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_ooch_t* msg,
|
||||
hcl_oow_t len
|
||||
);
|
||||
@ -1072,8 +1150,8 @@ struct hcl_t
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned int trait;
|
||||
unsigned int log_mask;
|
||||
hcl_bitmask_t trait;
|
||||
hcl_bitmask_t log_mask;
|
||||
hcl_oow_t log_maxcapa;
|
||||
hcl_oow_t dfl_symtab_size;
|
||||
hcl_oow_t dfl_sysdic_size;
|
||||
@ -1097,8 +1175,8 @@ struct hcl_t
|
||||
hcl_ooch_t* ptr;
|
||||
hcl_oow_t len;
|
||||
hcl_oow_t capa;
|
||||
unsigned int last_mask;
|
||||
unsigned int default_type_mask;
|
||||
hcl_bitmask_t last_mask;
|
||||
hcl_bitmask_t default_type_mask;
|
||||
} log;
|
||||
/* ========================= */
|
||||
|
||||
@ -1266,85 +1344,6 @@ struct hcl_t
|
||||
#define HCL_STACK_SETRETTOERRNUM(hcl,nargs) HCL_STACK_SETRET(hcl, nargs, HCL_ERROR_TO_OOP(hcl->errnum))
|
||||
#define HCL_STACK_SETRETTOERROR(hcl,nargs,ec) HCL_STACK_SETRET(hcl, nargs, HCL_ERROR_TO_OOP(ec))
|
||||
|
||||
|
||||
/* =========================================================================
|
||||
* HCL VM LOGGING
|
||||
* ========================================================================= */
|
||||
|
||||
enum hcl_log_mask_t
|
||||
{
|
||||
HCL_LOG_DEBUG = (1u << 0),
|
||||
HCL_LOG_INFO = (1u << 1),
|
||||
HCL_LOG_WARN = (1u << 2),
|
||||
HCL_LOG_ERROR = (1u << 3),
|
||||
HCL_LOG_FATAL = (1u << 4),
|
||||
|
||||
HCL_LOG_UNTYPED = (1u << 6), /* only to be used by HCL_DEBUGx() and HCL_INFOx() */
|
||||
HCL_LOG_COMPILER = (1u << 7),
|
||||
HCL_LOG_VM = (1u << 8),
|
||||
HCL_LOG_MNEMONIC = (1u << 9), /* bytecode mnemonic */
|
||||
HCL_LOG_GC = (1u << 10),
|
||||
HCL_LOG_IC = (1u << 11), /* instruction cycle, fetch-decode-execute */
|
||||
HCL_LOG_PRIMITIVE = (1u << 12),
|
||||
|
||||
HCL_LOG_APP = (1u << 13), /* hcl applications, set by hcl logging primitive */
|
||||
HCL_LOG_APP_X1 = (1u << 14), /* more hcl applications, you can choose to use one of APP_X? randomly */
|
||||
HCL_LOG_APP_X2 = (1u << 15),
|
||||
HCL_LOG_APP_X3 = (1u << 16),
|
||||
|
||||
HCL_LOG_ALL_LEVELS = (HCL_LOG_DEBUG | HCL_LOG_INFO | HCL_LOG_WARN | HCL_LOG_ERROR | HCL_LOG_FATAL),
|
||||
HCL_LOG_ALL_TYPES = (HCL_LOG_UNTYPED | HCL_LOG_COMPILER | HCL_LOG_VM | HCL_LOG_MNEMONIC | HCL_LOG_GC | HCL_LOG_IC | HCL_LOG_PRIMITIVE | HCL_LOG_APP | HCL_LOG_APP_X1 | HCL_LOG_APP_X2 | HCL_LOG_APP_X3),
|
||||
|
||||
|
||||
HCL_LOG_STDOUT = (1u << 20), /* write log messages to stdout without timestamp. HCL_LOG_STDOUT wins over HCL_LOG_STDERR. */
|
||||
HCL_LOG_STDERR = (1u << 21), /* write log messages to stderr without timestamp. */
|
||||
|
||||
HCL_LOG_PREFER_JSON = (1u << 30) /* write a object in the json format. don't set this explicitly. use %J instead */
|
||||
};
|
||||
typedef enum hcl_log_mask_t hcl_log_mask_t;
|
||||
|
||||
/* all bits must be set to get enabled */
|
||||
#define HCL_LOG_ENABLED(hcl,mask) (((hcl)->option.log_mask & (mask)) == (mask))
|
||||
|
||||
#define HCL_LOG0(hcl,mask,fmt) do { if (HCL_LOG_ENABLED(hcl,mask)) hcl_logbfmt(hcl, mask, fmt); } while(0)
|
||||
#define HCL_LOG1(hcl,mask,fmt,a1) do { if (HCL_LOG_ENABLED(hcl,mask)) hcl_logbfmt(hcl, mask, fmt, a1); } while(0)
|
||||
#define HCL_LOG2(hcl,mask,fmt,a1,a2) do { if (HCL_LOG_ENABLED(hcl,mask)) hcl_logbfmt(hcl, mask, fmt, a1, a2); } while(0)
|
||||
#define HCL_LOG3(hcl,mask,fmt,a1,a2,a3) do { if (HCL_LOG_ENABLED(hcl,mask)) hcl_logbfmt(hcl, mask, fmt, a1, a2, a3); } while(0)
|
||||
#define HCL_LOG4(hcl,mask,fmt,a1,a2,a3,a4) do { if (HCL_LOG_ENABLED(hcl,mask)) hcl_logbfmt(hcl, mask, fmt, a1, a2, a3, a4); } while(0)
|
||||
#define HCL_LOG5(hcl,mask,fmt,a1,a2,a3,a4,a5) do { if (HCL_LOG_ENABLED(hcl,mask)) hcl_logbfmt(hcl, mask, fmt, a1, a2, a3, a4, a5); } while(0)
|
||||
#define HCL_LOG6(hcl,mask,fmt,a1,a2,a3,a4,a5,a6) do { if (HCL_LOG_ENABLED(hcl,mask)) hcl_logbfmt(hcl, mask, fmt, a1, a2, a3, a4, a5, a6); } while(0)
|
||||
|
||||
#if defined(HCL_BUILD_RELEASE)
|
||||
/* [NOTE]
|
||||
* get rid of debugging message totally regardless of
|
||||
* the log mask in the release build.
|
||||
*/
|
||||
# define HCL_DEBUG0(hcl,fmt)
|
||||
# define HCL_DEBUG1(hcl,fmt,a1)
|
||||
# define HCL_DEBUG2(hcl,fmt,a1,a2)
|
||||
# define HCL_DEBUG3(hcl,fmt,a1,a2,a3)
|
||||
# define HCL_DEBUG4(hcl,fmt,a1,a2,a3,a4)
|
||||
# define HCL_DEBUG5(hcl,fmt,a1,a2,a3,a4,a5)
|
||||
# define HCL_DEBUG6(hcl,fmt,a1,a2,a3,a4,a5,a6)
|
||||
#else
|
||||
# define HCL_DEBUG0(hcl,fmt) HCL_LOG0(hcl, HCL_LOG_DEBUG | HCL_LOG_UNTYPED, fmt)
|
||||
# define HCL_DEBUG1(hcl,fmt,a1) HCL_LOG1(hcl, HCL_LOG_DEBUG | HCL_LOG_UNTYPED, fmt, a1)
|
||||
# define HCL_DEBUG2(hcl,fmt,a1,a2) HCL_LOG2(hcl, HCL_LOG_DEBUG | HCL_LOG_UNTYPED, fmt, a1, a2)
|
||||
# define HCL_DEBUG3(hcl,fmt,a1,a2,a3) HCL_LOG3(hcl, HCL_LOG_DEBUG | HCL_LOG_UNTYPED, fmt, a1, a2, a3)
|
||||
# define HCL_DEBUG4(hcl,fmt,a1,a2,a3,a4) HCL_LOG4(hcl, HCL_LOG_DEBUG | HCL_LOG_UNTYPED, fmt, a1, a2, a3, a4)
|
||||
# define HCL_DEBUG5(hcl,fmt,a1,a2,a3,a4,a5) HCL_LOG5(hcl, HCL_LOG_DEBUG | HCL_LOG_UNTYPED, fmt, a1, a2, a3, a4, a5)
|
||||
# define HCL_DEBUG6(hcl,fmt,a1,a2,a3,a4,a5,a6) HCL_LOG6(hcl, HCL_LOG_DEBUG | HCL_LOG_UNTYPED, fmt, a1, a2, a3, a4, a5, a6)
|
||||
#endif
|
||||
|
||||
#define HCL_INFO0(hcl,fmt) HCL_LOG0(hcl, HCL_LOG_INFO | HCL_LOG_UNTYPED, fmt)
|
||||
#define HCL_INFO1(hcl,fmt,a1) HCL_LOG1(hcl, HCL_LOG_INFO | HCL_LOG_UNTYPED, fmt, a1)
|
||||
#define HCL_INFO2(hcl,fmt,a1,a2) HCL_LOG2(hcl, HCL_LOG_INFO | HCL_LOG_UNTYPED, fmt, a1, a2)
|
||||
#define HCL_INFO3(hcl,fmt,a1,a2,a3) HCL_LOG3(hcl, HCL_LOG_INFO | HCL_LOG_UNTYPED, fmt, a1, a2, a3)
|
||||
#define HCL_INFO4(hcl,fmt,a1,a2,a3,a4) HCL_LOG4(hcl, HCL_LOG_INFO | HCL_LOG_UNTYPED, fmt, a1, a2, a3, a4)
|
||||
#define HCL_INFO5(hcl,fmt,a1,a2,a3,a4,a5) HCL_LOG5(hcl, HCL_LOG_INFO | HCL_LOG_UNTYPED, fmt, a1, a2, a3, a4, a5)
|
||||
#define HCL_INFO6(hcl,fmt,a1,a2,a3,a4,a5,a6) HCL_LOG6(hcl, HCL_LOG_INFO | HCL_LOG_UNTYPED, fmt, a1, a2, a3, a4, a5, a6)
|
||||
|
||||
|
||||
/* =========================================================================
|
||||
* HCL ASSERTION
|
||||
* ========================================================================= */
|
||||
@ -1694,14 +1693,14 @@ HCL_EXPORT int hcl_print (
|
||||
|
||||
HCL_EXPORT hcl_ooi_t hcl_proutbfmt (
|
||||
hcl_t* hcl,
|
||||
int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_bch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
HCL_EXPORT hcl_ooi_t hcl_proutufmt (
|
||||
hcl_t* hcl,
|
||||
int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_uch_t* fmt,
|
||||
...
|
||||
);
|
||||
@ -1843,28 +1842,28 @@ HCL_EXPORT hcl_pfbase_t* hcl_findpfbase (
|
||||
|
||||
HCL_EXPORT hcl_ooi_t hcl_logbfmt (
|
||||
hcl_t* hcl,
|
||||
int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_bch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
HCL_EXPORT hcl_ooi_t hcl_logbfmtv (
|
||||
hcl_t* hcl,
|
||||
int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_bch_t* fmt,
|
||||
va_list ap
|
||||
);
|
||||
|
||||
HCL_EXPORT hcl_ooi_t hcl_logufmt (
|
||||
hcl_t* hcl,
|
||||
int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_uch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
HCL_EXPORT hcl_ooi_t hcl_logufmtv (
|
||||
hcl_t* hcl,
|
||||
int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_uch_t* fmt,
|
||||
va_list ap
|
||||
);
|
||||
|
20
lib/json.c
20
lib/json.c
@ -92,8 +92,8 @@ struct hcl_json_t
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned int trait;
|
||||
unsigned int logmask;
|
||||
hcl_bitmask_t trait;
|
||||
hcl_bitmask_t logmask;
|
||||
} cfg;
|
||||
|
||||
hcl_json_state_node_t state_top;
|
||||
@ -106,7 +106,7 @@ struct hcl_json_t
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
static void log_write_for_dummy (hcl_t* hcl, unsigned int mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
static void log_write_for_dummy (hcl_t* hcl, hcl_bitmask_t mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
{
|
||||
dummy_hcl_xtn_t* xtn = (dummy_hcl_xtn_t*)hcl_getxtn(hcl);
|
||||
hcl_json_t* json;
|
||||
@ -899,7 +899,7 @@ hcl_json_t* hcl_json_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_json_prim_t*
|
||||
json->prim = *prim;
|
||||
json->dummy_hcl = hcl;
|
||||
|
||||
json->cfg.logmask = ~0u;
|
||||
json->cfg.logmask = ~(hcl_bitmask_t)0;
|
||||
|
||||
/* the dummy hcl is used for this json to perform primitive operations
|
||||
* such as getting system time or logging. so the heap size doesn't
|
||||
@ -928,11 +928,11 @@ int hcl_json_setoption (hcl_json_t* json, hcl_json_option_t id, const void* valu
|
||||
switch (id)
|
||||
{
|
||||
case HCL_JSON_TRAIT:
|
||||
json->cfg.trait = *(const unsigned int*)value;
|
||||
json->cfg.trait = *(const hcl_bitmask_t*)value;
|
||||
return 0;
|
||||
|
||||
case HCL_JSON_LOG_MASK:
|
||||
json->cfg.logmask = *(const unsigned int*)value;
|
||||
json->cfg.logmask = *(const hcl_bitmask_t*)value;
|
||||
if (json->dummy_hcl)
|
||||
{
|
||||
/* setting this affects the dummy hcl immediately.
|
||||
@ -953,11 +953,11 @@ int hcl_json_getoption (hcl_json_t* json, hcl_json_option_t id, void* value)
|
||||
switch (id)
|
||||
{
|
||||
case HCL_JSON_TRAIT:
|
||||
*(unsigned int*)value = json->cfg.trait;
|
||||
*(hcl_bitmask_t*)value = json->cfg.trait;
|
||||
return 0;
|
||||
|
||||
case HCL_JSON_LOG_MASK:
|
||||
*(unsigned int*)value = json->cfg.logmask;
|
||||
*(hcl_bitmask_t*)value = json->cfg.logmask;
|
||||
return 0;
|
||||
};
|
||||
|
||||
@ -1039,7 +1039,7 @@ void hcl_json_seterrufmt (hcl_json_t* json, hcl_errnum_t errnum, const hcl_uch_t
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
void hcl_json_logbfmt (hcl_json_t* json, unsigned int mask, const hcl_bch_t* fmt, ...)
|
||||
void hcl_json_logbfmt (hcl_json_t* json, hcl_bitmask_t mask, const hcl_bch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
@ -1047,7 +1047,7 @@ void hcl_json_logbfmt (hcl_json_t* json, unsigned int mask, const hcl_bch_t* fmt
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
void hcl_json_logufmt (hcl_json_t* json, unsigned int mask, const hcl_uch_t* fmt, ...)
|
||||
void hcl_json_logufmt (hcl_json_t* json, hcl_bitmask_t mask, const hcl_uch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
|
50
lib/logfmt.c
50
lib/logfmt.c
@ -129,14 +129,14 @@ static hcl_bch_t bch_nullstr[] = { '(','n','u','l','l', ')','\0' };
|
||||
|
||||
typedef int (*hcl_fmtout_putch_t) (
|
||||
hcl_t* hcl,
|
||||
int mask,
|
||||
hcl_bitmask_t mask,
|
||||
hcl_ooch_t c,
|
||||
hcl_oow_t len
|
||||
);
|
||||
|
||||
typedef int (*hcl_fmtout_putcs_t) (
|
||||
hcl_t* hcl,
|
||||
int mask,
|
||||
hcl_bitmask_t mask,
|
||||
const hcl_ooch_t* ptr,
|
||||
hcl_oow_t len
|
||||
);
|
||||
@ -145,7 +145,7 @@ typedef struct hcl_fmtout_t hcl_fmtout_t;
|
||||
struct hcl_fmtout_t
|
||||
{
|
||||
hcl_oow_t count; /* out */
|
||||
int mask; /* in */
|
||||
hcl_bitmask_t mask; /* in */
|
||||
hcl_fmtout_putch_t putch; /* in */
|
||||
hcl_fmtout_putcs_t putcs; /* in */
|
||||
};
|
||||
@ -182,7 +182,7 @@ static hcl_bch_t* sprintn_upper (hcl_bch_t* nbuf, hcl_uintmax_t num, int base, h
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
static int put_logch (hcl_t* hcl, int mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
static int put_logch (hcl_t* hcl, hcl_bitmask_t mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
{
|
||||
/* this is not equivalent to put_logcs(hcl,mask,&ch,1);
|
||||
* this function is to emit a single character multiple times */
|
||||
@ -276,7 +276,7 @@ redo:
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int put_logcs (hcl_t* hcl, int mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
static int put_logcs (hcl_t* hcl, hcl_bitmask_t mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
{
|
||||
hcl_oow_t rem;
|
||||
|
||||
@ -406,7 +406,7 @@ static int _logufmtv (hcl_t* hcl, const hcl_uch_t* fmt, hcl_fmtout_t* data, va_l
|
||||
return __logufmtv (hcl, fmt, data, ap, hcl_logbfmt);
|
||||
}
|
||||
|
||||
hcl_ooi_t hcl_logbfmtv (hcl_t* hcl, int mask, const hcl_bch_t* fmt, va_list ap)
|
||||
hcl_ooi_t hcl_logbfmtv (hcl_t* hcl, hcl_bitmask_t mask, const hcl_bch_t* fmt, va_list ap)
|
||||
{
|
||||
int x;
|
||||
hcl_fmtout_t fo;
|
||||
@ -436,7 +436,7 @@ hcl_ooi_t hcl_logbfmtv (hcl_t* hcl, int mask, const hcl_bch_t* fmt, va_list ap)
|
||||
return (x <= -1)? -1: fo.count;
|
||||
}
|
||||
|
||||
hcl_ooi_t hcl_logbfmt (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...)
|
||||
hcl_ooi_t hcl_logbfmt (hcl_t* hcl, hcl_bitmask_t mask, const hcl_bch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
hcl_ooi_t x;
|
||||
@ -448,7 +448,7 @@ hcl_ooi_t hcl_logbfmt (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...)
|
||||
return x;
|
||||
}
|
||||
|
||||
hcl_ooi_t hcl_logufmtv (hcl_t* hcl, int mask, const hcl_uch_t* fmt, va_list ap)
|
||||
hcl_ooi_t hcl_logufmtv (hcl_t* hcl, hcl_bitmask_t mask, const hcl_uch_t* fmt, va_list ap)
|
||||
{
|
||||
int x;
|
||||
hcl_fmtout_t fo;
|
||||
@ -474,7 +474,7 @@ hcl_ooi_t hcl_logufmtv (hcl_t* hcl, int mask, const hcl_uch_t* fmt, va_list ap)
|
||||
return (x <= -1)? -1: fo.count;
|
||||
}
|
||||
|
||||
hcl_ooi_t hcl_logufmt (hcl_t* hcl, int mask, const hcl_uch_t* fmt, ...)
|
||||
hcl_ooi_t hcl_logufmt (hcl_t* hcl, hcl_bitmask_t mask, const hcl_uch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
hcl_ooi_t x;
|
||||
@ -491,7 +491,7 @@ hcl_ooi_t hcl_logufmt (hcl_t* hcl, int mask, const hcl_uch_t* fmt, ...)
|
||||
* HELPER FOR PRINTING
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
static int put_prcs (hcl_t* hcl, int mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
static int put_prcs (hcl_t* hcl, hcl_bitmask_t mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
{
|
||||
hcl_ooch_t* optr;
|
||||
|
||||
@ -512,7 +512,7 @@ static int put_prcs (hcl_t* hcl, int mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int put_prch (hcl_t* hcl, int mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
static int put_prch (hcl_t* hcl, hcl_bitmask_t mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
{
|
||||
hcl_ooch_t str[256];
|
||||
hcl_oow_t seglen, i;
|
||||
@ -532,7 +532,7 @@ static int put_prch (hcl_t* hcl, int mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static hcl_ooi_t __prbfmtv (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...);
|
||||
static hcl_ooi_t __prbfmtv (hcl_t* hcl, hcl_bitmask_t mask, const hcl_bch_t* fmt, ...);
|
||||
|
||||
static int _prbfmtv (hcl_t* hcl, const hcl_bch_t* fmt, hcl_fmtout_t* data, va_list ap)
|
||||
{
|
||||
@ -544,7 +544,7 @@ static int _prufmtv (hcl_t* hcl, const hcl_uch_t* fmt, hcl_fmtout_t* data, va_li
|
||||
return __logufmtv (hcl, fmt, data, ap, __prbfmtv);
|
||||
}
|
||||
|
||||
static hcl_ooi_t __prbfmtv (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...)
|
||||
static hcl_ooi_t __prbfmtv (hcl_t* hcl, hcl_bitmask_t mask, const hcl_bch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
hcl_fmtout_t fo;
|
||||
@ -560,7 +560,7 @@ static hcl_ooi_t __prbfmtv (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...)
|
||||
return fo.count;
|
||||
}
|
||||
|
||||
hcl_ooi_t hcl_proutbfmt (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...)
|
||||
hcl_ooi_t hcl_proutbfmt (hcl_t* hcl, hcl_bitmask_t mask, const hcl_bch_t* fmt, ...)
|
||||
{
|
||||
int x;
|
||||
va_list ap;
|
||||
@ -577,7 +577,7 @@ hcl_ooi_t hcl_proutbfmt (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...)
|
||||
return (x <= -1)? -1: fo.count;
|
||||
}
|
||||
|
||||
hcl_ooi_t hcl_proutufmt (hcl_t* hcl, int mask, const hcl_uch_t* fmt, ...)
|
||||
hcl_ooi_t hcl_proutufmt (hcl_t* hcl, hcl_bitmask_t mask, const hcl_uch_t* fmt, ...)
|
||||
{
|
||||
int x;
|
||||
va_list ap;
|
||||
@ -598,7 +598,7 @@ hcl_ooi_t hcl_proutufmt (hcl_t* hcl, int mask, const hcl_uch_t* fmt, ...)
|
||||
* ERROR MESSAGE FORMATTING
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
static int put_errcs (hcl_t* hcl, int mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
static int put_errcs (hcl_t* hcl, hcl_bitmask_t mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
{
|
||||
hcl_oow_t max;
|
||||
|
||||
@ -614,7 +614,7 @@ static int put_errcs (hcl_t* hcl, int mask, const hcl_ooch_t* ptr, hcl_oow_t len
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int put_errch (hcl_t* hcl, int mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
static int put_errch (hcl_t* hcl, hcl_bitmask_t mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
{
|
||||
hcl_oow_t max;
|
||||
|
||||
@ -633,7 +633,7 @@ static int put_errch (hcl_t* hcl, int mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static hcl_ooi_t __errbfmtv (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...);
|
||||
static hcl_ooi_t __errbfmtv (hcl_t* hcl, hcl_bitmask_t mask, const hcl_bch_t* fmt, ...);
|
||||
|
||||
static int _errbfmtv (hcl_t* hcl, const hcl_bch_t* fmt, hcl_fmtout_t* data, va_list ap)
|
||||
{
|
||||
@ -645,7 +645,7 @@ static int _errufmtv (hcl_t* hcl, const hcl_uch_t* fmt, hcl_fmtout_t* data, va_l
|
||||
return __logufmtv (hcl, fmt, data, ap, __errbfmtv);
|
||||
}
|
||||
|
||||
static hcl_ooi_t __errbfmtv (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...)
|
||||
static hcl_ooi_t __errbfmtv (hcl_t* hcl, hcl_bitmask_t mask, const hcl_bch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
hcl_fmtout_t fo;
|
||||
@ -1327,7 +1327,7 @@ int hcl_logfmtst (hcl_t* hcl, hcl_ooi_t nargs)
|
||||
/* --------------------------------------------------------------------------
|
||||
* SUPPORT FOR THE BUILTIN SPRINTF PRIMITIVE FUNCTION
|
||||
* -------------------------------------------------------------------------- */
|
||||
static int put_sprcs (hcl_t* hcl, int mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
static int put_sprcs (hcl_t* hcl, hcl_bitmask_t mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
{
|
||||
if (len > hcl->sprintf.xbuf.capa - hcl->sprintf.xbuf.len)
|
||||
{
|
||||
@ -1349,7 +1349,7 @@ static int put_sprcs (hcl_t* hcl, int mask, const hcl_ooch_t* ptr, hcl_oow_t len
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int put_sprch (hcl_t* hcl, int mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
static int put_sprch (hcl_t* hcl, hcl_bitmask_t mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
{
|
||||
if (len > hcl->sprintf.xbuf.capa - hcl->sprintf.xbuf.len)
|
||||
{
|
||||
@ -1375,7 +1375,7 @@ static int put_sprch (hcl_t* hcl, int mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static hcl_ooi_t __sprbfmtv (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...);
|
||||
static hcl_ooi_t __sprbfmtv (hcl_t* hcl, hcl_bitmask_t mask, const hcl_bch_t* fmt, ...);
|
||||
|
||||
static int _sprbfmtv (hcl_t* hcl, const hcl_bch_t* fmt, hcl_fmtout_t* data, va_list ap)
|
||||
{
|
||||
@ -1388,7 +1388,7 @@ static int _sprufmtv (hcl_t* hcl, const hcl_uch_t* fmt, hcl_fmtout_t* data, va_l
|
||||
return __logufmtv (hcl, fmt, data, ap, __sprbfmtv);
|
||||
}*/
|
||||
|
||||
static hcl_ooi_t __sprbfmtv (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...)
|
||||
static hcl_ooi_t __sprbfmtv (hcl_t* hcl, hcl_bitmask_t mask, const hcl_bch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
hcl_fmtout_t fo;
|
||||
@ -1404,7 +1404,7 @@ static hcl_ooi_t __sprbfmtv (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...)
|
||||
return fo.count;
|
||||
}
|
||||
|
||||
hcl_ooi_t hcl_sproutbfmt (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...)
|
||||
hcl_ooi_t hcl_sproutbfmt (hcl_t* hcl, hcl_bitmask_t mask, const hcl_bch_t* fmt, ...)
|
||||
{
|
||||
int x;
|
||||
va_list ap;
|
||||
@ -1422,7 +1422,7 @@ hcl_ooi_t hcl_sproutbfmt (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...)
|
||||
}
|
||||
|
||||
/*
|
||||
hcl_ooi_t hcl_sproutufmt (hcl_t* hcl, int mask, const hcl_uch_t* fmt, ...)
|
||||
hcl_ooi_t hcl_sproutufmt (hcl_t* hcl, hcl_bitmask_t mask, const hcl_uch_t* fmt, ...)
|
||||
{
|
||||
int x;
|
||||
va_list ap;
|
||||
|
@ -60,7 +60,7 @@ typedef struct client_xtn_t client_xtn_t;
|
||||
struct client_xtn_t
|
||||
{
|
||||
int logfd;
|
||||
unsigned int logmask;
|
||||
hcl_bitmask_t logmask;
|
||||
int logfd_istty;
|
||||
|
||||
struct
|
||||
@ -197,7 +197,7 @@ static void flush_log (hcl_client_t* client, int fd)
|
||||
}
|
||||
}
|
||||
|
||||
static void log_write (hcl_client_t* client, unsigned int mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
static void log_write (hcl_client_t* client, hcl_bitmask_t mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
{
|
||||
hcl_bch_t buf[256];
|
||||
hcl_oow_t ucslen, bcslen;
|
||||
@ -364,7 +364,7 @@ static int handle_logopt (hcl_client_t* client, const hcl_bch_t* str)
|
||||
{
|
||||
hcl_bch_t* xstr = (hcl_bch_t*)str;
|
||||
hcl_bch_t* cm, * flt;
|
||||
unsigned int logmask;
|
||||
hcl_bitmask_t logmask;
|
||||
client_xtn_t* xtn;
|
||||
|
||||
xtn = (client_xtn_t*)hcl_client_getxtn(client);
|
||||
|
@ -13,7 +13,7 @@ typedef struct json_xtn_t json_xtn_t;
|
||||
struct json_xtn_t
|
||||
{
|
||||
int logfd;
|
||||
unsigned int logmask;
|
||||
hcl_bitmask_t logmask;
|
||||
int logfd_istty;
|
||||
|
||||
struct
|
||||
@ -148,7 +148,7 @@ static void flush_log (hcl_json_t* json, int fd)
|
||||
}
|
||||
}
|
||||
|
||||
static void log_write (hcl_json_t* json, unsigned int mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
static void log_write (hcl_json_t* json, hcl_bitmask_t mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
{
|
||||
hcl_bch_t buf[256];
|
||||
hcl_oow_t ucslen, bcslen;
|
||||
|
10
lib/main-s.c
10
lib/main-s.c
@ -57,7 +57,7 @@ typedef struct server_xtn_t server_xtn_t;
|
||||
struct server_xtn_t
|
||||
{
|
||||
int logfd;
|
||||
unsigned int logmask;
|
||||
hcl_bitmask_t logmask;
|
||||
int logfd_istty;
|
||||
|
||||
struct
|
||||
@ -191,7 +191,7 @@ static void flush_log (hcl_server_t* server, int fd)
|
||||
}
|
||||
}
|
||||
|
||||
static void log_write (hcl_server_t* server, hcl_oow_t wid, unsigned int mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
static void log_write (hcl_server_t* server, hcl_oow_t wid, hcl_bitmask_t mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
{
|
||||
hcl_bch_t buf[256];
|
||||
hcl_oow_t ucslen, bcslen;
|
||||
@ -365,7 +365,7 @@ static int handle_logopt (hcl_server_t* server, const hcl_bch_t* str)
|
||||
{
|
||||
hcl_bch_t* xstr = (hcl_bch_t*)str;
|
||||
hcl_bch_t* cm, * flt;
|
||||
unsigned int logmask;
|
||||
hcl_bitmask_t logmask;
|
||||
server_xtn_t* xtn;
|
||||
|
||||
xtn = (server_xtn_t*)hcl_server_getxtn(server);
|
||||
@ -452,7 +452,7 @@ static int handle_dbgopt (hcl_server_t* server, const char* str)
|
||||
{
|
||||
const hcl_bch_t* cm, * flt;
|
||||
hcl_oow_t len;
|
||||
unsigned int trait;
|
||||
hcl_bitmask_t trait;
|
||||
|
||||
hcl_server_getoption (server, HCL_SERVER_TRAIT, &trait);
|
||||
|
||||
@ -535,7 +535,7 @@ int main (int argc, char* argv[])
|
||||
hcl_oow_t actor_heap_size = MIN_ACTOR_HEAP_SIZE;
|
||||
hcl_ntime_t actor_max_runtime = { 0, 0 };
|
||||
int large_pages = 0;
|
||||
unsigned int trait;
|
||||
hcl_bitmask_t trait;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
|
10
lib/main.c
10
lib/main.c
@ -148,7 +148,7 @@ struct xtn_t
|
||||
int vm_running;
|
||||
|
||||
int logfd;
|
||||
unsigned int logmask;
|
||||
hcl_bitmask_t logmask;
|
||||
int logfd_istty;
|
||||
|
||||
struct
|
||||
@ -624,7 +624,7 @@ static void flush_log (hcl_t* hcl, int fd)
|
||||
}
|
||||
}
|
||||
|
||||
static void log_write (hcl_t* hcl, unsigned int mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
static void log_write (hcl_t* hcl, hcl_bitmask_t mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
{
|
||||
hcl_bch_t buf[256];
|
||||
hcl_oow_t ucslen, bcslen, msgidx;
|
||||
@ -1334,7 +1334,7 @@ static int handle_logopt (hcl_t* hcl, const hcl_bch_t* str)
|
||||
xtn_t* xtn = (xtn_t*)hcl_getxtn (hcl);
|
||||
hcl_bch_t* xstr = (hcl_bch_t*)str;
|
||||
hcl_bch_t* cm, * flt;
|
||||
unsigned int logmask;
|
||||
hcl_bitmask_t logmask;
|
||||
|
||||
cm = hcl_find_bchar_in_bcstr (xstr, ',');
|
||||
if (cm)
|
||||
@ -1424,7 +1424,7 @@ static int handle_dbgopt (hcl_t* hcl, const hcl_bch_t* str)
|
||||
xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);
|
||||
const hcl_bch_t* cm, * flt;
|
||||
hcl_oow_t len;
|
||||
unsigned int trait, dbgopt = 0;
|
||||
hcl_bitmask_t trait, dbgopt = 0;
|
||||
|
||||
cm = str - 1;
|
||||
do
|
||||
@ -1784,7 +1784,7 @@ int main (int argc, char* argv[])
|
||||
}
|
||||
|
||||
{
|
||||
unsigned int trait = 0;
|
||||
hcl_bitmask_t trait = 0;
|
||||
|
||||
/*trait |= HCL_NOGC;*/
|
||||
trait |= HCL_AWAIT_PROCS;
|
||||
|
@ -57,7 +57,7 @@ hcl_oop_t hcl_makeprim (hcl_t* hcl, hcl_pfimpl_t primimpl, hcl_oow_t minargs, hc
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static void log_char_object (hcl_t* hcl, int mask, hcl_oop_char_t msg)
|
||||
static void log_char_object (hcl_t* hcl, hcl_bitmask_t mask, hcl_oop_char_t msg)
|
||||
{
|
||||
hcl_ooi_t n;
|
||||
hcl_oow_t rem;
|
||||
@ -99,7 +99,7 @@ static hcl_pfrc_t pf_log (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
{
|
||||
/* TODO: accept log level */
|
||||
hcl_oop_t msg;
|
||||
int mask;
|
||||
hcl_bitmask_t mask;
|
||||
hcl_ooi_t k;
|
||||
|
||||
/*level = HCL_STACK_GET(hcl, hcl->sp - nargs + 1);
|
||||
|
@ -113,7 +113,7 @@ static struct
|
||||
{ 12, { '#','<','S','E','M','A','P','H','O','R','E','>' } }
|
||||
};
|
||||
|
||||
static HCL_INLINE int print_single_char (hcl_t* hcl, int mask, hcl_ooch_t ch, hcl_outbfmt_t outbfmt)
|
||||
static HCL_INLINE int print_single_char (hcl_t* hcl, hcl_bitmask_t mask, hcl_ooch_t ch, hcl_outbfmt_t outbfmt)
|
||||
{
|
||||
hcl_oochu_t chu = (hcl_oochu_t)ch;
|
||||
if (chu == '\\' || chu == '\"')
|
||||
@ -194,7 +194,7 @@ static HCL_INLINE int print_single_char (hcl_t* hcl, int mask, hcl_ooch_t ch, hc
|
||||
return 0;
|
||||
}
|
||||
|
||||
static HCL_INLINE int outfmt_obj (hcl_t* hcl, int mask, hcl_oop_t obj, hcl_outbfmt_t outbfmt)
|
||||
static HCL_INLINE int outfmt_obj (hcl_t* hcl, hcl_bitmask_t mask, hcl_oop_t obj, hcl_outbfmt_t outbfmt)
|
||||
{
|
||||
hcl_oop_t cur;
|
||||
print_stack_t ps;
|
||||
@ -716,7 +716,7 @@ done:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hcl_outfmtobj (hcl_t* hcl, int mask, hcl_oop_t obj, hcl_outbfmt_t outbfmt)
|
||||
int hcl_outfmtobj (hcl_t* hcl, hcl_bitmask_t mask, hcl_oop_t obj, hcl_outbfmt_t outbfmt)
|
||||
{
|
||||
int n;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user