functor types
[m6w6/ext-psi] / m4 / psi.m4
index 63407beb24bb9fd0c61856c65668475fd0da3aed..8d8797c86116f2d489edd78d3b72f158caf8bdc2 100644 (file)
--- a/m4/psi.m4
+++ b/m4/psi.m4
@@ -9,14 +9,20 @@ PSI_REDIRS=$PHP_PSI_SRCDIR/php_psi_redirs.h
 PSI_MACROS=$PHP_PSI_SRCDIR/php_psi_macros.h
 PSI_DECLS=$PHP_PSI_SRCDIR/php_psi_decls.h
 PSI_VA_DECLS=$PHP_PSI_SRCDIR/php_psi_va_decls.h
+PSI_FN_DECLS=$PHP_PSI_SRCDIR/php_psi_fn_decls.h
 
 dnl PSI_CONFIG_INIT()
 dnl Creates stubs of the headers with pre-defined types etc.
 dnl These headers are included by src/context.c.
 dnl This macro must be called prior any checks for a type, struct, decl etc.
 AC_DEFUN(PSI_CONFIG_INIT, [
-       cat >$PSI_STDTYPES <<EOF
+       for i in $PSI_STDTYPES $PSI_TYPES $PSI_STRUCTS $PSI_UNIONS $PSI_CONSTS $PSI_REDIRS $PSI_MACROS $PSI_DECLS $PSI_VA_DECLS $PSI_FN_DECLS; do
+               cat >$i <<EOF
 /* generated by configure */
+#include "php_psi_stdinc.h"
+EOF
+       done
+       cat >>$PSI_STDTYPES <<EOF
 static struct psi_std_type {
        token_t type_tag;
        const char *type_name;
@@ -31,16 +37,14 @@ static struct psi_std_type {
        {PSI_T_UINT32, "uint32_t", NULL},
        {PSI_T_UINT64, "uint64_t", NULL},
 EOF
-       cat >$PSI_TYPES <<EOF
-/* generated by configure */
+       cat >>$PSI_TYPES <<EOF
 static struct psi_predef_type {
        token_t type_tag;
        const char *type_name;
        const char *alias;
 } psi_predef_types@<:@@:>@ = {
 EOF
-       cat >$PSI_STRUCTS <<EOF
-/* generated by configure */
+       cat >>$PSI_STRUCTS <<EOF
 static struct psi_predef_struct {
        token_t type_tag;
        const char *type_name;
@@ -51,8 +55,7 @@ static struct psi_predef_struct {
        size_t array_size;
 } psi_predef_structs@<:@@:>@ = {
 EOF
-       cat >$PSI_UNIONS <<EOF
-/* generated by configure */
+       cat >>$PSI_UNIONS <<EOF
 static struct psi_predef_union {
        token_t type_tag;
        const char *type_name;
@@ -63,8 +66,7 @@ static struct psi_predef_union {
        size_t array_size;
 } psi_predef_unions@<:@@:>@ = {
 EOF
-       cat >$PSI_CONSTS <<EOF
-/* generated by configure */
+       cat >>$PSI_CONSTS <<EOF
 static struct psi_predef_const {
        token_t type_tag;
        const char *type_name;
@@ -73,16 +75,16 @@ static struct psi_predef_const {
        token_t val_type_tag;
 } psi_predef_consts@<:@@:>@ = {
 EOF
-       cat >$PSI_REDIRS <<EOF
-/* generated by configure */
+       cat >>$PSI_REDIRS <<EOF
+typedef void (*psi_func_ptr)();
 static struct psi_func_redir {
        const char *name;
-       void (*func)(void);
+       psi_func_ptr func;
 } psi_func_redirs@<:@@:>@ = {
 EOF
-       cat >$PSI_MACROS </dev/null
-       cat >$PSI_DECLS <<EOF
-/* generated by configure */
+       cat >>$PSI_MACROS <<EOF
+EOF
+       cat >>$PSI_DECLS <<EOF
 static struct psi_predef_decl {
        token_t type_tag;
        const char *type_name;
@@ -91,9 +93,11 @@ static struct psi_predef_decl {
        size_t array_size;
 } psi_predef_decls@<:@@:>@ = {
 EOF
-       cat >$PSI_VA_DECLS <<EOF
-/* generated by configure */
+       cat >>$PSI_VA_DECLS <<EOF
 static struct psi_predef_decl psi_predef_vararg_decls@<:@@:>@ = {
+EOF
+       cat >>$PSI_FN_DECLS <<EOF
+static struct psi_predef_decl psi_predef_functor_decls@<:@@:>@ = {
 EOF
 ])
 
@@ -102,9 +106,18 @@ dnl Finish the headers with the pre-defined types etc.
 AC_DEFUN(PSI_CONFIG_DONE, [
        cat >$PSI_STDINC <<EOF
 /* generated by configure */
+#ifndef _PSI_STDINC
+#define _PSI_STDINC
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE
+#endif
 PSI_INCLUDES
+#endif
 EOF
-       for i in $PSI_STDTYPES $PSI_TYPES $PSI_STRUCTS $PSI_UNIONS $PSI_CONSTS $PSI_REDIRS $PSI_DECLS $PSI_VA_DECLS; do
+       for i in $PSI_STDTYPES $PSI_TYPES $PSI_STRUCTS $PSI_UNIONS $PSI_CONSTS $PSI_REDIRS $PSI_DECLS $PSI_VA_DECLS $PSI_FN_DECLS; do
                cat >>$i <<EOF
        {0}
 };
@@ -151,7 +164,7 @@ dnl PSI_CONFIG_POSIX(section, headers)
 AC_DEFUN(PSI_CONFIG_POSIX, [
        PSI_CONFIG_POSIX_ENABLED($1, [
                PHP_CONFIGURE_PART(Configuring PSI POSIX: $1)
-               ifelse([$2],,,AC_CHECK_HEADERS($2))
+               ifelse([$2],,:,[AC_CHECK_HEADERS($2)])
        ], [
                return 0
        ])