PSI_MACROS
+size_t psi_fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
+{
+ size_t rv = fread(ptr, size, nmemb, stream);
+ return rv;
+}
+
+FILE *psi_fopen(const char *path, const char *mode)
+{
+ FILE *f = fopen(path, mode);
+ return f;
+}
+
static struct psi_func_redir {
const char *name;
void (*func)(void);
} psi_func_redirs[] = {
+ {"fopen", (void (*)(void)) psi_fopen},
+ {"fread", (void (*)(void)) psi_fread},
PSI_REDIRS
{0}
};
return 0;
}
}
-static inline int validate_set_value(PSI_Data *data, set_value *set, decl_arg *ref, decl_args *ref_list) {
- size_t i;
- decl_type *ref_type = real_decl_type(ref->type);
- decl_var *set_var = set->vars->vars[0];
-
+static inline int validate_set_value_handler(set_value *set) {
switch (set->func->type) {
case PSI_T_TO_BOOL:
set->func->handler = psi_to_bool;
case PSI_T_VOID:
set->func->handler = psi_to_void;
break;
- EMPTY_SWITCH_DEFAULT_CASE();
+ default:
+ return 0;
+ }
+ return 1;
+}
+static inline void decl_var_arg_v(decl_args *args, va_list argp) {
+ int argc;
+ decl_arg **argv;
+
+ memset(args, 0, sizeof(*args));
+
+ while ((argc = va_arg(argp, int))) {
+ argv = va_arg(argp, decl_arg **);
+ while (argc--) {
+ add_decl_arg(args, *argv++);
+ }
+ }
+}
+static inline int validate_set_value_ex(PSI_Data *data, set_value *set, decl_arg *ref, decl_args *ref_list) {
+ size_t i;
+ decl_type *ref_type;
+ decl_var *set_var = set->vars->vars[0];
+
+ if (!validate_set_value_handler(set)) {
+ data->error(PSI_WARNING, "Invalid cast '%s'", set->func->name);
+ return 0;
}
- for (i = 1; i < set->vars->count; ++i) {
- if (!locate_decl_var_arg(set->vars->vars[i], ref_list, ref)) {
+ for (i = 0; i < set->vars->count; ++i) {
+ if (!locate_decl_var_arg(set->vars->vars[i], ref_list, NULL)) {
+ data->error(PSI_WARNING, "Unknown variable '%s'", set->vars->vars[i]->name);
return 0;
}
}
- set_var->arg = ref;
+
+ if (!ref) {
+ ref = set_var->arg;
+ }
+ ref_type = real_decl_type(ref->type);
if (set->count) {
int is_to_array = (set->func->type == PSI_T_TO_ARRAY);
set->inner[i]->outer.set = set;
if (sub_ref) {
- if (!validate_set_value(data, set->inner[i], sub_ref, ref_type->strct->args)) {
+ if (!validate_set_value_ex(data, set->inner[i], sub_ref, ref_type->strct->args)) {
return 0;
}
}
data->error(E_WARNING, "Inner `set` statement casts on pointers must reference the same variable");
return 0;
}
- if (!validate_set_value(data, set->inner[0], sub_ref, ref_list)) {
+ if (!validate_set_value_ex(data, set->inner[0], sub_ref, ref_list)) {
return 0;
}
}
return 1;
}
+static inline int validate_set_value(PSI_Data *data, set_value *set, ...) {
+ va_list argp;
+ decl_args args = {0};
+ int check;
+
+ va_start(argp, set);
+ decl_var_arg_v(&args, argp);
+ va_end(argp);
+
+ check = validate_set_value_ex(data, set, NULL, &args);
+ if (args.args) {
+ free(args.args);
+ }
+ return check;
+}
static inline decl *locate_impl_decl(decls *decls, return_stmt *ret) {
if (decls) {
size_t i;
return 0;
}
- if (!validate_set_value(data, ret->set, ret->decl, impl->decl->args)) {
+ if (!validate_set_value(data, ret->set, 1, &ret->decl, impl->decl->args ? (int) impl->decl->args->count : 0, impl->decl->args ? impl->decl->args->args : NULL, 0)) {
return 0;
}
static inline int validate_impl_let_stmts(PSI_Data *data, impl *impl) {
size_t i, j;
/* we can have multiple let stmts */
+ /* check that we have a decl arg for every let stmt */
+ for (i = 0; i < impl->stmts->let.count; ++i) {
+ let_stmt *let = impl->stmts->let.list[i];
+
+ if (!locate_decl_var_arg(let->var, impl->decl->args, impl->decl->func)) {
+ data->error(PSI_WARNING, "Unknown variable '%s' in `let` statement"
+ " of implementation '%s'", let->var->name, impl->func->name);
+ return 0;
+ }
+ }
+
/* check that we have a let stmt for every decl arg */
if (impl->decl->args) for (i = 0; i < impl->decl->args->count; ++i) {
decl_arg *darg = impl->decl->args->args[i];
if (!strcmp(set_var->name, set_arg->var->name)) {
check = 1;
set_var->arg = set_arg;
- if (!validate_set_value(data, set->val, set_arg, impl->decl->args)) {
+ if (!validate_set_value(data, set->val, 1, &set_arg, 1, &impl->decl->func, impl->decl->args->count, impl->decl->args->args, 0)) {
return 0;
}
break;
void PSI_ContextCall(PSI_Context *C, impl_val *ret_val, decl *decl)
{
- errno = 0;
C->ops->call(C, ret_val, decl);
}
static inline void dump_level(int fd, unsigned level) {
dprintf(fd, "%.*s", level, "\t\t\t\t\t\t\t\t\t");
}
+static inline void dump_num_exp(int fd, num_exp *exp) {
+ while (exp) {
+ switch (exp->t) {
+ case PSI_T_NUMBER:
+ dprintf(fd, "%s", exp->u.numb);
+ break;
+ case PSI_T_NSNAME:
+ dprintf(fd, "%s", exp->u.cnst->name);
+ break;
+ case PSI_T_NAME:
+ dump_decl_var(fd, exp->u.dvar);
+ break;
+ EMPTY_SWITCH_DEFAULT_CASE();
+ }
+ if (exp->operand) {
+ char op;
+
+ switch (exp->operator) {
+ case PSI_T_PLUS: op = '+'; break;
+ case PSI_T_MINUS: op = '-'; break;
+ case PSI_T_ASTERISK:op = '*'; break;
+ case PSI_T_SLASH: op = '/'; break;
+ EMPTY_SWITCH_DEFAULT_CASE();
+ }
+ dprintf(fd, " %c ", op);
+ }
+ exp = exp->operand;
+ }
+}
static inline void dump_impl_set_value(int fd, set_value *set, unsigned level) {
size_t i;
}
dump_decl_var(fd, svar);
}
+ if (set->num) {
+ dprintf(fd, ", ");
+ dump_num_exp(fd, set->num);
+ }
if (set->inner) {
dprintf(fd, ",\n");
for (i = 0; i < set->count; ++i) {
dprintf(fd, ");\n");
}
}
-static inline void dump_num_exp(int fd, num_exp *exp) {
- switch (exp->t) {
- case PSI_T_NUMBER:
- dprintf(fd, "%s", exp->u.numb);
- break;
- case PSI_T_NAME:
- dump_decl_var(fd, exp->u.dvar);
- break;
- case PSI_T_NSNAME:
- dprintf(fd, "%s", exp->u.cnst->name);
- break;
- EMPTY_SWITCH_DEFAULT_CASE();
- }
-}
void PSI_ContextDump(PSI_Context *C, int fd)
{
size_t i, j, k, l;
#include "php_psi.h"
#include "parser.h"
+#include "context.h"
#if HAVE_LIBJIT
# include "libjit.h"
return ALIGNOF_VOID_P;
EMPTY_SWITCH_DEFAULT_CASE();
}
+ return 0;
}
size_t psi_t_size(token_t t)
return SIZEOF_VOID_P;
EMPTY_SWITCH_DEFAULT_CASE();
}
+ return 0;
}
size_t psi_t_align(token_t t, size_t s)
} else {
ret_val = deref_impl_val(ret_val, var);
if (ret_val && ret_val->ptr) {
- RETVAL_STRING(ret_val->ptr);
+ if (set->num) {
+ RETVAL_STRINGL(ret_val->ptr, psi_long_num_exp(set->num, NULL));
+ } else {
+ RETVAL_STRING(ret_val->ptr);
+ }
} else {
RETVAL_EMPTY_STRING();
}
zval ele;
if (set->outer.set) {
- /* struct *//*
+ / * struct *//*
for (i = 1; i < set->vars->count; ++i) {
impl_val *tmp = NULL, *cnt_val;
decl_var *cnt_var = set->vars->vars[i];
static inline ZEND_RESULT_CODE psi_parse_args(zend_execute_data *execute_data, impl *impl)
{
+ size_t i;
+ zval *zarg = ZEND_CALL_ARG(execute_data, 0);
impl_arg *iarg;
zend_error_handling zeh;
return rv;
}
+ /* set up defaults */
+ for (i = 0; i < impl->func->args->count; ++i) {
+ iarg = impl->func->args->args[i];
+
+ if (i < EX_NUM_ARGS()) {
+ iarg->_zv = ++zarg;
+ ZVAL_DEREF(iarg->_zv);
+ if (iarg->var->reference) {
+ zval_dtor(iarg->_zv);
+ ZVAL_NULL(iarg->_zv);
+ }
+ }
+
+ if (iarg->def) {
+ switch (iarg->type->type) {
+ case PSI_T_BOOL:
+ iarg->val.zend.bval = iarg->def->type == PSI_T_TRUE ? 1 : 0;
+ break;
+ case PSI_T_INT:
+ iarg->val.zend.lval = zend_atol(iarg->def->text, strlen(iarg->def->text));
+ break;
+ case PSI_T_FLOAT:
+ case PSI_T_DOUBLE:
+ iarg->val.dval = zend_strtod(iarg->def->text, NULL);
+ break;
+ case PSI_T_STRING:
+ /* FIXME */
+ iarg->val.zend.str = zend_string_init(&iarg->def->text[1], strlen(iarg->def->text) - 2, 0);
+ break;
+ }
+ }
+ }
+
ZEND_PARSE_PARAMETERS_START(psi_num_min_args(impl), impl->func->args->count)
nextarg:
iarg = impl->func->args->args[_i];
}
Z_PARAM_DOUBLE(iarg->val.dval);
} else if (PSI_T_STRING == iarg->type->type) {
- struct {char *val; size_t len;} str;
- if (iarg->def) {
- /* FIXME */
- str.len = strlen(iarg->def->text) - 2;
- str.val = &iarg->def->text[1];
- }
- Z_PARAM_STR_EX(iarg->val.zend.str, 1, 0);
- if (iarg->val.zend.str) {
- zend_string_addref(iarg->val.zend.str);
- } else if (iarg->def) {
- iarg->val.zend.str = zend_string_init(str.val, str.len, 0);
+ zend_string *str = iarg->val.zend.str;
+ Z_PARAM_STR_EX(iarg->val.zend.str, 1, iarg->var->reference);
+ if (str && str != iarg->val.zend.str) {
+ zend_string_release(str);
}
} else if (PSI_T_ARRAY == iarg->type->type) {
- /* handled as _zv in let or set */
- Z_PARAM_ARRAY_EX(iarg->_zv, 1, 0);
+ Z_PARAM_PROLOGUE(0);
} else if (PSI_T_OBJECT == iarg->type->type) {
- Z_PARAM_OBJECT_EX(iarg->_zv, 1, 0);
+ Z_PARAM_PROLOGUE(0);
} else {
error_code = ZPP_ERROR_FAILURE;
break;
}
- iarg->_zv = _arg;
- if (_i < _max_num_args) {
+ if (_i < _num_args) {
goto nextarg;
}
ZEND_PARSE_PARAMETERS_END_EX(
return mem;
}
-static inline void *psi_do_let(decl_arg *darg)
+static inline void *psi_do_let(let_stmt *let)
{
+ decl_arg *darg = let->var->arg;
impl_arg *iarg = darg->let->arg;
- impl_val *arg_val;
-
- darg->let->ptr = &darg->let->out;
- arg_val = darg->let->ptr;
+ impl_val *arg_val = darg->ptr;
if (!iarg) {
/* let foo = calloc(1, long);
*/
if (darg->let->val->func && darg->let->val->func->type == PSI_T_CALLOC) {
arg_val->ptr = psi_do_calloc(darg->let->val->func->alloc);
- darg->let->mem = arg_val->ptr;
+ darg->mem = arg_val->ptr;
} else if (darg->var->array_size) {
arg_val->ptr = ecalloc(darg->var->array_size, sizeof(*arg_val));
- darg->let->mem = arg_val->ptr;
+ darg->mem = arg_val->ptr;
} else {
memset(arg_val, 0, sizeof(*arg_val));
}
case PSI_T_STRVAL:
if (iarg->type->type == PSI_T_STRING) {
arg_val->ptr = estrdup(iarg->val.zend.str->val);
- darg->let->mem = arg_val->ptr;
+ darg->mem = arg_val->ptr;
zend_string_release(iarg->val.zend.str);
} else {
zend_string *zs = zval_get_string(iarg->_zv);
arg_val->ptr = estrdup(zs->val);
- darg->let->mem = arg_val->ptr;
+ darg->mem = arg_val->ptr;
zend_string_release(zs);
}
if (PSI_T_PATHVAL == darg->let->val->func->type) {
switch (type->type) {
case PSI_T_STRUCT:
arg_val->ptr = psi_array_to_struct(type->strct, HASH_OF(iarg->_zv));
- darg->let->mem = arg_val->ptr;
+ darg->mem = arg_val->ptr;
break;
}
}
}
if (darg->let->val && darg->let->val->is_reference) {
- return &darg->let->ptr;
+ return darg->let->ptr = &darg->ptr;
} else {
- return darg->let->ptr;
+ return darg->let->ptr = darg->ptr;
}
}
static inline void psi_do_set(zval *return_value, set_value *set)
{
- ZVAL_DEREF(return_value);
- zval_dtor(return_value);
+ set->func->handler(return_value, set, set->vars->vars[0]->arg->ptr);
+}
- set->func->handler(return_value, set, set->vars->vars[0]->arg->let->ptr);
+static inline void psi_do_return(zval *return_value, return_stmt *ret)
+{
+ ret->set->func->handler(return_value, ret->set, ret->set->vars->vars[0]->arg->ptr);
}
-static inline void psi_do_return(zval *return_value, return_stmt *ret, impl_val *ret_val)
+static inline void psi_do_return2(zval *return_value, return_stmt *ret, impl_val *ret_val)
{
ret->set->func->handler(return_value, ret->set, ret_val);
}
decl_var *dvar = f->vars->vars[j];
decl_arg *darg = dvar->arg;
- f->decl->call.args[j] = &darg->let->out;
+ f->decl->call.args[j] = &darg->val;
}
/* FIXME: check in validate_* that free functions return scalar */
if (impl->decl->args) for (i = 0; i < impl->decl->args->count; ++i) {
decl_arg *darg = impl->decl->args->args[i];
- if (darg->let && darg->let->mem) {
+ if (darg->mem) {
decl_type *type = real_decl_type(darg->type);
if (type->type == PSI_T_STRUCT) {
- void **ptr = (void **) ((char *) darg->let->mem + type->strct->size);
+ void **ptr = (void **) ((char *) darg->mem + type->strct->size);
while (*ptr) {
efree(*ptr++);
}
}
- efree(darg->let->mem);
- darg->let->mem = NULL;
+ efree(darg->mem);
+ darg->mem = NULL;
}
}
}
break;
case PSI_T_NAME:
- if (exp->u.dvar->arg->let) {
- ref = exp->u.dvar->arg->let->ptr;
+ if (1) {
+ ref = exp->u.dvar->arg->ptr;
} else {
ref = struct_member_ref(exp->u.dvar->arg, ref, &tmp);
}
#define PRIdval "lf"
#define PSI_CALC_OP(var) do { \
- const char *fmt = "calc: %" PRI##var ", %" PRI##var ": %" PRI##var "\n"; \
+ const char *fmt = "calc %" PRI##var ", %" PRI##var ": %" PRI##var "\n"; \
res->var = PSI_CALC(v1->var, v2->var); \
- /*fprintf(stderr, fmt, v1->var, v2->var, res->var);*/ \
+ if (!res->var) fprintf(stderr, fmt, v1->var, v2->var, res->var); \
} while (0)
#define PSI_CALC_OP2(vres, var1, var2) do { \
- const char *fmt = "calc: %" PRI##var1 ", %" PRI##var2 ": %" PRI##vres "\n"; \
+ const char *fmt = "calc %" PRI##var1 ", %" PRI##var2 ": %" PRI##vres "\n"; \
res->vres = PSI_CALC(v1->var1, v2->var2); \
- /*fprintf(stderr, fmt, v1->var1, v2->var2, res->vres);*/ \
+ if (!res->vres) fprintf(stderr, fmt, v1->var1, v2->var2, res->vres); \
} while(0)
#define PSI_CALC_FN(op) int psi_calc_##op(int t1, impl_val *v1, int t2, impl_val *v2, impl_val *res) \
{ \
void psi_call(zend_execute_data *execute_data, zval *return_value, impl *impl)
{
- impl_val ret_val;
size_t i;
+ return_stmt *ret = impl->stmts->ret.list[0];
+ decl_var *var = ret->set->vars->vars[0];
+
+ memset(var->arg->ptr, 0, sizeof(impl_val));
if (SUCCESS != psi_parse_args(execute_data, impl)) {
return;
}
- if (impl->decl->args) {
- for (i = 0; i < impl->decl->args->count; ++i) {
- decl_arg *darg = impl->decl->args->args[i];
+ for (i = 0; i < impl->stmts->let.count; ++i) {
+ let_stmt *let = impl->stmts->let.list[i];
- if (!(impl->decl->call.args[i] = psi_do_let(darg))) {
- goto cleanup;
- }
+ if (!psi_do_let(let)) {
+ psi_do_return(return_value, ret);
+ psi_do_clean(impl);
+ return;
}
}
- memset(&ret_val, 0, sizeof(ret_val));
- PSI_ContextCall(&PSI_G(context), &ret_val, impl->decl);
+ if (impl->decl->args) for (i = 0; i < impl->decl->args->count; ++i) {
+ impl->decl->call.args[i] = impl->decl->args->args[i]->let->ptr;
+ }
- psi_do_return(return_value, impl->stmts->ret.list[0], &ret_val);
+ PSI_ContextCall(&PSI_G(context), var->arg->ptr, impl->decl);
+ psi_do_return(return_value, ret);
for (i = 0; i < impl->stmts->set.count; ++i) {
set_stmt *set = impl->stmts->set.list[i];
psi_do_free(fre);
}
psi_do_clean(impl);
- return;
-
-cleanup:
- memset(&ret_val, 0, sizeof(ret_val));
- psi_do_return(return_value, impl->stmts->ret.list[0], &ret_val);
- psi_do_clean(impl);
}
static void psi_object_free(zend_object *o)
return SUCCESS;
}
+
PHP_MSHUTDOWN_FUNCTION(psi)
{
PSI_ContextDtor(&PSI_G(context));
return SUCCESS;
}
-/* Remove if there's nothing to do at request start */
-/* {{{ PHP_RINIT_FUNCTION
- */
+#if defined(COMPILE_DL_PSI) && defined(ZTS)
PHP_RINIT_FUNCTION(psi)
{
-#if defined(COMPILE_DL_PSI) && defined(ZTS)
ZEND_TSRMLS_CACHE_UPDATE();
-#endif
return SUCCESS;
}
-/* }}} */
-
-/* Remove if there's nothing to do at request end */
-/* {{{ PHP_RSHUTDOWN_FUNCTION
- */
-PHP_RSHUTDOWN_FUNCTION(psi)
-{
- return SUCCESS;
-}
-/* }}} */
+#endif
PHP_MINFO_FUNCTION(psi)
{
psi_functions,
PHP_MINIT(psi),
PHP_MSHUTDOWN(psi),
+#if defined(COMPILE_DL_PSI) && defined(ZTS)
PHP_RINIT(psi), /* Replace with NULL if there's nothing to do at request start */
- PHP_RSHUTDOWN(psi), /* Replace with NULL if there's nothing to do at request end */
+#else
+ NULL,
+#endif
+ NULL,
PHP_MINFO(psi),
PHP_PSI_VERSION,
STANDARD_MODULE_PROPERTIES
char text[1];
} PSI_Token;
+typedef union impl_val {
+ char cval;
+ int8_t i8;
+ uint8_t u8;
+ short sval;
+ int16_t i16;
+ uint16_t u16;
+ int ival;
+ int32_t i32;
+ uint32_t u32;
+ long lval;
+ int64_t i64;
+ uint64_t u64;
+ float fval;
+ double dval;
+ union {
+ zend_bool bval;
+ zend_long lval;
+ zend_string *str;
+ } zend;
+ void *ptr;
+ uint8_t _dbg[sizeof(void *)];
+} impl_val;
+
typedef struct decl_type {
char *name;
token_t type;
decl_var *var;
decl_struct_layout *layout;
struct let_stmt *let;
+ impl_val val;
+ void *ptr;
+ void *mem;
} decl_arg;
static inline decl_arg *init_decl_arg(decl_type *type, decl_var *var) {
arg->type = type;
arg->var = var;
var->arg = arg;
+ arg->ptr = &arg->val;
return arg;
}
free(ss);
}
-typedef union impl_val {
- char cval;
- int8_t i8;
- uint8_t u8;
- short sval;
- int16_t i16;
- uint16_t u16;
- int ival;
- int32_t i32;
- uint32_t u32;
- long lval;
- int64_t i64;
- uint64_t u64;
- float fval;
- double dval;
- union {
- zend_bool bval;
- zend_long lval;
- zend_string *str;
- } zend;
- void *ptr;
- uint8_t _dbg[sizeof(void *)];
-} impl_val;
-
-static inline impl_val *deref_impl_val(impl_val *ret_val, decl_var *var) {
- unsigned i;
-
- if (var->arg->var != var) for (i = 1; i < var->pointer_level; ++i) {
- ret_val = *(void **) ret_val;
- }
- return ret_val;
-}
-
-static inline impl_val *enref_impl_val(void *ptr, decl_var *var) {
- impl_val *val, *val_ptr;
- unsigned i;
-
- if (!var->pointer_level && real_decl_type(var->arg->type)->type != PSI_T_STRUCT) {
- return ptr;
- }
- val = val_ptr = calloc(var->pointer_level + 1, sizeof(void *));
- for (i = 1; i < var->pointer_level; ++i) {
- val_ptr->ptr = (void **) val_ptr + 1;
- val_ptr = val_ptr->ptr;
- }
- val_ptr->ptr = ptr;
- return val;
-}
-
typedef struct impl_type {
char *name;
token_t type;
decl_var *var;
let_value *val;
impl_arg *arg;
- impl_val out;
void *ptr;
- void *mem;
} let_stmt;
static inline let_stmt *init_let_stmt(decl_var *var, let_value *val) {
free(impls);
}
-static inline impl_val *struct_member_ref(decl_arg *set_arg, impl_val *struct_ptr, impl_val **to_free) {
- void *ptr = (char *) struct_ptr->ptr + set_arg->layout->pos;
- impl_val *val = enref_impl_val(ptr, set_arg->var);
-
- if (val != ptr) {
- *to_free = val;
- }
-
- return val;
-}
-
-#define PSI_ERROR 16
-#define PSI_WARNING 32
-typedef void (*psi_error_cb)(int type, const char *msg, ...);
-
typedef struct decl_file {
char *ln;
char *fn;
libs->dl[libs->count-1] = dlopened;
}
+static inline impl_val *deref_impl_val(impl_val *ret_val, decl_var *var) {
+ unsigned i;
+
+ if (var->arg->var != var) for (i = 1; i < var->pointer_level; ++i) {
+ ret_val = *(void **) ret_val;
+ }
+ return ret_val;
+}
+
+static inline impl_val *enref_impl_val(void *ptr, decl_var *var) {
+ impl_val *val, *val_ptr;
+ unsigned i;
+
+ if (!var->pointer_level && real_decl_type(var->arg->type)->type != PSI_T_STRUCT) {
+ return ptr;
+ }
+ val = val_ptr = calloc(var->pointer_level + 1, sizeof(void *));
+ for (i = 1; i < var->pointer_level; ++i) {
+ val_ptr->ptr = (void **) val_ptr + 1;
+ val_ptr = val_ptr->ptr;
+ }
+ val_ptr->ptr = ptr;
+ return val;
+}
+
+static inline impl_val *struct_member_ref(decl_arg *set_arg, impl_val *struct_ptr, impl_val **to_free) {
+ void *ptr = (char *) struct_ptr->ptr + set_arg->layout->pos;
+ impl_val *val = enref_impl_val(ptr, set_arg->var);
+
+ if (val != ptr) {
+ *to_free = val;
+ }
+
+ return val;
+}
+
+#define PSI_ERROR 16
+#define PSI_WARNING 32
+typedef void (*psi_error_cb)(int type, const char *msg, ...);
+
#define PSI_DATA(D) ((PSI_Data *) (D))
#define PSI_DATA_MEMBERS \
constants *consts; \