-#define psi_predef_count(of) ((sizeof(psi_predef ##of## s)/sizeof(psi_predef ##of))-1)
-typedef struct psi_predef_type {
- token_t type_tag;
- const char *type_name;
- const char *alias;
-} psi_predef_type;
-static const psi_predef_type psi_predef_types[] = {
- PHP_PSI_TYPES{0}
-};
-#define psi_predef_type_count() psi_predef_count(_type)
-
-typedef struct psi_predef_const {
- token_t type_tag;
- const char *type_name;
- const char *name;
- const char *val_text;
- token_t val_type_tag;
-} psi_predef_const;
-static const psi_predef_const psi_predef_consts[] = {
- PHP_PSI_CONSTS{0}
-};
-#define psi_predef_const_count() psi_predef_count(_const)
-
-typedef struct psi_predef_struct_member {
- token_t type_tag;
- const char *type_name;
- const char *name;
- size_t off;
- size_t len;
- size_t pointer_level;
- size_t array_size;
-} psi_predef_struct_member;
-#define PSI_PREDEF_STRUCT_MEMBERS 32
-typedef struct psi_predef_struct {
- const char *name;
- size_t size;
- psi_predef_struct_member members[PSI_PREDEF_STRUCT_MEMBERS];
-} psi_predef_struct;
-static const psi_predef_struct psi_predef_structs[] = {
- PHP_PSI_STRUCTS{0}
-};
-#define psi_predef_struct_count() psi_predef_count(_struct)
-
-PHP_PSI_MACROS
-
-typedef struct psi_predef_func {
- const char *name;
- void (*func)(void);
-} psi_predef_func;
-static psi_predef_func psi_predef_funcs[] = {
- PHP_PSI_FUNCS{0}
-};
-#define psi_predef_func_count() psi_predef_count(_func)
-
-static int validate_lib(PSI_Data *data, void **dlopened) {
- char lib[MAXPATHLEN];
- const char *ptr = data->psi.file.ln;
- size_t len;
-
- if (!ptr) {
- /* FIXME: assume stdlib */
- return 1;
- } else if (!strchr(ptr, '/')) {
- len = snprintf(lib, MAXPATHLEN, "lib%s.%s", ptr, PHP_PSI_SHLIB_SUFFIX);
- if (MAXPATHLEN == len) {
- data->error(PSI_WARNING, "Library name too long: '%s'", ptr);
- }
- lib[len] = 0;
- ptr = lib;
- }
- if (!(*dlopened = dlopen(ptr, RTLD_LAZY|RTLD_LOCAL))) {
- data->error(PSI_WARNING, "Could not open library '%s': %s.",
- data->psi.file.ln, dlerror());
- return 0;
- }
- return 1;
-}