flush
authorMichael Wallner <mike@php.net>
Mon, 1 Feb 2016 16:59:21 +0000 (17:59 +0100)
committerMichael Wallner <mike@php.net>
Mon, 1 Feb 2016 16:59:21 +0000 (17:59 +0100)
.gitignore
m4/psi.m4
m4/psi_decl.m4
m4/psi_macro.m4
tests/pipe/pipe.psi

index ec1ac8ea95ba6c81d633d258d568334e841015ca..f0b0682d344fca8ae2c89abb3fafca9cf62eae0c 100644 (file)
@@ -64,3 +64,4 @@ php_psi_types.h
 php_psi_va_decls.h
 /tmp/
 *.loT
 php_psi_va_decls.h
 /tmp/
 *.loT
+php_psi_unions.h
index 63407beb24bb9fd0c61856c65668475fd0da3aed..cf7a0354e1ff0863fbc9eb43343b3b79f15bf036 100644 (file)
--- a/m4/psi.m4
+++ b/m4/psi.m4
@@ -75,9 +75,10 @@ static struct psi_predef_const {
 EOF
        cat >$PSI_REDIRS <<EOF
 /* generated by configure */
 EOF
        cat >$PSI_REDIRS <<EOF
 /* generated by configure */
+typedef void (*psi_func_ptr)();
 static struct psi_func_redir {
        const char *name;
 static struct psi_func_redir {
        const char *name;
-       void (*func)(void);
+       psi_func_ptr func;
 } psi_func_redirs@<:@@:>@ = {
 EOF
        cat >$PSI_MACROS </dev/null
 } psi_func_redirs@<:@@:>@ = {
 EOF
        cat >$PSI_MACROS </dev/null
index 92da2929816947da13d3fa7eb7c35a1380bb0794..d1acd32f1eb248da35392cfc5004fdc87f6601f9 100644 (file)
@@ -1,7 +1,7 @@
 # psi_add_redir(name, symbol)
 # Add a function redirection to $PSI_REDIRS.
 psi_add_redir() {
 # psi_add_redir(name, symbol)
 # Add a function redirection to $PSI_REDIRS.
 psi_add_redir() {
-       cat >>$PSI_REDIRS <<<"  {\"$1\", (void(*)(void))$2}, "
+       cat >>$PSI_REDIRS <<<"  {\"$1\", (psi_func_ptr) $2}, "
 }
 
 # psi_add_decl(decl, options)
 }
 
 # psi_add_decl(decl, options)
@@ -37,32 +37,15 @@ AC_DEFUN(PSI_FUNC_LIBC_MAIN, [
        ])
 ])
 
        ])
 ])
 
-dnl PSI_FUNC(fn, action-if-yes, action-if-no)
-dnl Check for a possible function redirection.
-AC_DEFUN(PSI_FUNC, [
-       AC_REQUIRE([PSI_FUNC_LIBC_MAIN])
-       psi_symbol=$1
-       AC_CACHE_CHECK(for $1, psi_cv_fn_$1, [
-               psi_symbol_redirect=
-               AC_TRY_LINK(PSI_INCLUDES, [
-                       void (*fn)(void) = (void (*)(void)) $psi_symbol;
-               ], [
-                       psi_symbol_redirect=`$NM -g conftest$ac_exeext | $AWK -F" *|@" '/^@<:@@<:@:space:@:>@@:>@+U '$psi_cv_libc_main'/ {next} /^@<:@@<:@:space:@:>@@:>@+U / {print$[]3; exit}'`
-               ])
-               psi_cv_fn_$1=$psi_symbol_redirect
-       ])
-       case "$psi_cv_fn_$1" in
-       "")
-               $3
-               ;;
-       "$psi_symbol"|"_$psi_symbol")
-               $2
-               ;;
-       *)
-               $2
-               PSI_REDIR($1)
-               ;;
-       esac
+dnl PSI_DECL_ARGS(decl args)
+dnl INTERNAL: build psi_decl_args
+AC_DEFUN(PSI_DECL_ARGS, [
+       psi_decl_args=
+       PSI_DECL_ARG($1)
+       m4_case([$2],
+               [(void)], [],
+               [()], [],
+               [m4_map_args_sep([PSI_DECL_ARG(m4_normalize(], [))], [], m4_bregexp([$2], [(\(.*\))], [\1]))])
 ])
 
 dnl PSI_DECL_ARG(decl arg)
 ])
 
 dnl PSI_DECL_ARG(decl arg)
@@ -79,25 +62,33 @@ AC_DEFUN(PSI_DECL_ARG, [
 ])
 
 dnl PSI_DECL(type func, args, flags)
 ])
 
 dnl PSI_DECL(type func, args, flags)
-dnl Check for a function or macro declaration.
+dnl Check for a function or macro declaration and a possible asm redirection.
 dnl Adds a pre-defined (vararg) decl to $PSI_VA_DECLS/$PSI_DECLS.
 dnl Calls PSI_MACRO if PSI_FUNC fails. 
 AC_DEFUN(PSI_DECL, [
 dnl Adds a pre-defined (vararg) decl to $PSI_VA_DECLS/$PSI_DECLS.
 dnl Calls PSI_MACRO if PSI_FUNC fails. 
 AC_DEFUN(PSI_DECL, [
-       psi_decl_args=
-       PSI_DECL_ARG($1)
-       m4_case([$2],
-               [(void)], [],
-               [()], [],
-               [m4_map_args_sep([PSI_DECL_ARG(m4_normalize(], [))], [], m4_bregexp([$2], [(\(.*\))], [\1]))])
-       PSI_FUNC(PSI_VAR_NAME($1), [
-               psi_add_decl "$psi_decl_args" $3
-       ], [
-               PSI_MACRO($1, $2, [
-                       ifelse([$3], vararg, [
-                               AC_MSG_ERROR(varargs macro support is not implemented)
-                       ],[
-                               psi_add_decl "$psi_decl_args"
-                       ])
+       AC_REQUIRE([PSI_FUNC_LIBC_MAIN])
+       PSI_DECL_ARGS($1, $2)
+       
+       psi_symbol="PSI_VAR_NAME($1)"
+       AC_CACHE_CHECK(for PSI_VAR_NAME($1), [psi_cv_fn_]PSI_VAR_NAME($1), [
+               psi_symbol_redirect=
+               AC_TRY_LINK(PSI_INCLUDES, [
+                       void (*fn)(void) = (void (*)(void)) $psi_symbol;
+               ], [
+                       psi_symbol_redirect=`$NM -g conftest$ac_exeext | $AWK -F" *|@" '/^@<:@@<:@:space:@:>@@:>@+U '$psi_cv_libc_main'/ {next} /^@<:@@<:@:space:@:>@@:>@+U / {print$[]3; exit}'`
                ])
                ])
+               [psi_cv_fn_]PSI_VAR_NAME($1)=$psi_symbol_redirect
        ])
        ])
+       case "$[psi_cv_fn_]PSI_VAR_NAME($1)" in
+       "$psi_symbol"|"_$psi_symbol")
+               psi_add_decl "$psi_decl_args" $3
+               ;;
+       *)
+               ifelse([$3], vararg, [
+                       AC_MSG_ERROR(varargs macro support is not implemented)
+               ],[
+                       PSI_MACRO($1, $2, [psi_add_decl "$psi_decl_args"])
+               ])
+               ;;
+       esac
 ])
 ])
index 337a7e55a39c6a6bfa34bcc20dfc9205ccf21cb9..e89e74b05967504ac733a4ade49d4bed7000cbfe 100644 (file)
@@ -33,8 +33,8 @@ AC_DEFUN(PSI_MACRO, [
                ], [
                        macro_body="return $macro_name$macro_call;"
                ])
                ], [
                        macro_body="return $macro_name$macro_call;"
                ])
-               psi_add_macro "$macro_type psi_macro_$macro_name$macro_decl { $macro_body }"
-               PSI_REDIR($macro_name, psi_macro_$macro_name)
+               psi_add_macro "$macro_type _psi_redir_$macro_name$macro_decl { $macro_body }"
+               PSI_REDIR($macro_name, _psi_redir_$macro_name)
        ], [], PSI_INCLUDES)
 ])
 
        ], [], PSI_INCLUDES)
 ])
 
index 6fc9e89aee5b2f64760aa7b9e1781f1d07026129..24c572381125c9108179c84c99f1c521c222e33c 100644 (file)
@@ -1,5 +1,5 @@
 
 
-//extern int pipe(int fildes[2]);
+// extern int pipe(int fildes[2]);
 
 function \pipe(array &$fds = null) : int {
        return to_int(pipe);
 
 function \pipe(array &$fds = null) : int {
        return to_int(pipe);