avoid busting bash's stack with a too big if body in configure
authorMichael Wallner <mike@php.net>
Thu, 14 Jan 2016 11:20:13 +0000 (12:20 +0100)
committerMichael Wallner <mike@php.net>
Thu, 14 Jan 2016 11:20:13 +0000 (12:20 +0100)
28 files changed:
config.m4
m4/errno.m4
m4/glob.m4
m4/netdb.m4
m4/psi.m4
m4/psi_const.m4
m4/psi_decl.m4
m4/psi_macro.m4
m4/psi_struct.m4
m4/psi_type.m4
m4/stddef.m4
m4/stdint.m4
m4/stdio.m4
m4/stdlib.m4
m4/sys_select.m4
m4/sys_socket.m4
m4/sys_stat.m4
m4/sys_time.m4
m4/sys_times.m4
m4/sys_types.m4
m4/sys_uio.m4
m4/sys_utsname.m4
m4/syslog.m4 [new file with mode: 0644]
m4/time.m4
m4/wchar.m4
psi.d/syslog.psi [new file with mode: 0644]
src/context.c
tests/netdb/gai001.phpt

index bfa56e5d4121ab48c21480cf3cb818da40821872..641b16ab934c32e8a912c23838cb887ba210a07f 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -1,43 +1,44 @@
 PHP_ARG_ENABLE(psi, whether to enable PHP System Interface support,
 [  --enable-psi            Enable PHP System Interface support])
 
+PHP_PSI_SRCDIR=PHP_EXT_SRCDIR(psi)
+PHP_PSI_BUILDDIR=PHP_EXT_BUILDDIR(psi)
+
+m4_foreach(incfile, [
+       [ax_check_sign.m4],
+       [psi.m4],
+       [psi_type.m4],
+       [psi_const.m4],
+       [psi_decl.m4],
+       [psi_macro.m4],
+       [psi_struct.m4],
+       [errno.m4],
+       [glob.m4],
+       [stddef.m4],
+       [stdio.m4],
+       [stdint.m4],
+       [stdlib.m4],
+       [sys_select.m4],
+       [sys_socket.m4],
+       [sys_stat.m4],
+       [sys_time.m4],
+       [sys_times.m4],
+       [sys_types.m4],
+       [sys_uio.m4],
+       [sys_utsname.m4],
+       [netdb.m4],
+       [syslog.m4],
+       [time.m4],
+       [wchar.m4]], [
+       dnl pecl build
+       sinclude([m4/]incfile)
+       dnl php-src build
+       sinclude([ext/psi/m4/]incfile)
+])
+
 if test "$PHP_PSI" != no; then
        PHP_CONFIGURE_PART(Configuring PSI)
 
-       PHP_PSI_SRCDIR=PHP_EXT_SRCDIR(psi)
-       PHP_PSI_BUILDDIR=PHP_EXT_BUILDDIR(psi)
-
-       m4_foreach(incfile, [
-               [ax_check_sign.m4],
-               [psi.m4],
-               [psi_type.m4],
-               [psi_const.m4],
-               [psi_decl.m4],
-               [psi_macro.m4],
-               [psi_struct.m4],
-               [errno.m4],
-               [glob.m4],
-               [stddef.m4],
-               [stdio.m4],
-               [stdint.m4],
-               [stdlib.m4],
-               [sys_select.m4],
-               [sys_socket.m4],
-               [sys_stat.m4],
-               [sys_time.m4],
-               [sys_times.m4],
-               [sys_types.m4],
-               [sys_uio.m4],
-               [sys_utsname.m4],
-               [netdb.m4],
-               [syslog.m4],
-               [time.m4],
-               [wchar.m4]], [
-               dnl pecl build
-               sinclude([m4/]incfile)
-               dnl php-src build
-               sinclude([ext/psi/m4/]incfile)
-       ])
        PSI_LEMON
        PSI_CHECK_LIBJIT
        PSI_CHECK_LIBFFI
@@ -45,6 +46,7 @@ if test "$PHP_PSI" != no; then
        AC_FUNC_FNMATCH
        AC_HEADER_DIRENT
 
+       PSI_CONFIG_INIT
        PSI_CHECK_STD_TYPES
        PSI_CHECK_STDINT
        PSI_CHECK_STDDEF
@@ -64,6 +66,7 @@ if test "$PHP_PSI" != no; then
        PSI_CHECK_NETDB
        PSI_CHECK_SYSLOG
        PSI_CHECK_WCHAR
+       PSI_CONFIG_DONE
 
        PHP_SUBST(PSI_SHARED_LIBADD)
 
@@ -77,7 +80,6 @@ if test "$PHP_PSI" != no; then
        AC_DEFINE_UNQUOTED([PSI_DECLS], [$PSI_DECLS], [Predefined functions])
        AC_DEFINE_UNQUOTED([PSI_VA_DECLS], [$PSI_VA_DECLS], [Predefined vararg functions])
 
-
        PHP_ADD_INCLUDE($PHP_PSI_SRCDIR/src)
        PHP_ADD_BUILD_DIR($PHP_PSI_BUILDDIR/src)
 
@@ -95,6 +97,5 @@ if test "$PHP_PSI" != no; then
        PHP_SUBST(PHP_PSI_BUILDDIR)
 
        PHP_ADD_MAKEFILE_FRAGMENT
-
        AC_MSG_RESULT()
 fi
index 99311b753199dc53a4ed24f059d070b261e6d319..be6f99613d413888a5f859cefb0789b070a74b61 100644 (file)
@@ -1,8 +1,8 @@
-AC_DEFUN(PSI_CHECK_ERRNO, [
+PSI_CHECK_ERRNO() {
     AC_CHECK_HEADERS(errno.h)
-    
+
     PSI_EXTVAR(int errno)
-    
+
     PSI_CONST(E2BIG, int)
     PSI_CONST(EACCES, int)
     PSI_CONST(EADDRINUSE, int)
@@ -84,4 +84,4 @@ AC_DEFUN(PSI_CHECK_ERRNO, [
     PSI_CONST(ETXTBSY, int)
     PSI_CONST(EWOULDBLOCK, int)
     PSI_CONST(EXDEV, int)
-])
+}
index fbb036e7376db3b0b889a50555ebad98d87370fb..343b3729b280018d5d2e37d4fbd5b2f2ab32eaa5 100644 (file)
@@ -1,4 +1,4 @@
-AC_DEFUN(PSI_CHECK_GLOB, [
+PSI_CHECK_GLOB() {
     AC_CHECK_HEADERS(glob.h)
     PSI_STRUCT(glob_t, [
         size_t gl_pathc,
@@ -26,4 +26,4 @@ AC_DEFUN(PSI_CHECK_GLOB, [
     PSI_CONST(GLOB_ABORTED, int)
     PSI_CONST(GLOB_NOMATCH, int)
     PSI_CONST(GLOB_NOSPACE, int)
-])
+}
index b14b54fe7832ee489a46c04b0a9b151043e7c90e..5049a53cc9d81f5f73cf8f875a0e03f8ac47f082 100644 (file)
@@ -1,6 +1,6 @@
-AC_DEFUN(PSI_CHECK_NETDB, [
+PSI_CHECK_NETDB() {
        AC_CHECK_HEADERS(netdb.h)
-       
+
        PSI_STRUCT(struct hostent, [
                char *h_name,
                char **h_aliases,
@@ -8,29 +8,29 @@ AC_DEFUN(PSI_CHECK_NETDB, [
                int h_length,
                char **h_addr_list]
        )
-       
+
        PSI_STRUCT(struct netent, [
                char *n_name,
                char **n_aliases,
                int n_addrtype,
                uint32_t n_net]
        )
-       
+
        PSI_STRUCT(struct protoent, [
                char *p_name,
                char **p_aliases,
                int p_proto]
        )
-       
+
        PSI_STRUCT(struct servent, [
                char *s_name,
                char **s_aliases,
                int s_port,
                char *s_proto]
        )
-       
+
        PSI_CONST(IPPORT_RESERVED, int)
-       
+
        PSI_STRUCT(struct addrinfo, [
                int ai_flags,
                int ai_family,
@@ -41,7 +41,7 @@ AC_DEFUN(PSI_CHECK_NETDB, [
                char *ai_canonname,
                struct addrinfo *ai_next]
        )
-       
+
        PSI_CONST(AI_PASSIVE, int)
        PSI_CONST(AI_CANONNAME, int)
        PSI_CONST(AI_NUMERICHOST, int)
@@ -49,17 +49,17 @@ AC_DEFUN(PSI_CHECK_NETDB, [
        PSI_CONST(AI_V4MAPPED, int)
        PSI_CONST(AI_ALL, int)
        PSI_CONST(AI_ADDRCONFIG, int)
-       
+
        PSI_CONST(NI_NOFQDN, int)
        PSI_CONST(NI_NUMERICHOST, int)
        PSI_CONST(NI_NAMEREQD, int)
        PSI_CONST(NI_NUMERICSERV, int)
        PSI_CONST(NI_NUMERICSCOPE, int)
        PSI_CONST(NI_DGRAM, int)
-       
+
        PSI_CONST(NI_MAXHOST, int)
        PSI_CONST(NI_MAXSERV, int)
-       
+
        PSI_CONST(EAI_AGAIN, int)
        PSI_CONST(EAI_BADFLAGS, int)
        PSI_CONST(EAI_FAIL, int)
@@ -70,7 +70,7 @@ AC_DEFUN(PSI_CHECK_NETDB, [
        PSI_CONST(EAI_SOCKTYPE, int)
        PSI_CONST(EAI_SYSTEM, int)
        PSI_CONST(EAI_OVERFLOW, int)
-       
+
        PSI_DECL(void endhostent, [(void)])
        PSI_DECL(void endnetent, [(void)])
        PSI_DECL(void endprotoent, [(void)])
@@ -93,5 +93,4 @@ AC_DEFUN(PSI_CHECK_NETDB, [
        PSI_DECL(void setnetent, [(int stayopen)])
        PSI_DECL(void setprotoent, [(int stayopen)])
        PSI_DECL(void setservent, [(int stayopen)])
-
-])
\ No newline at end of file
+}
index eecfa6192a3a57ff1efdae2d7bf61e605781c513..81aca2801419e12bcf29077d382ba7054f4ce871 100644 (file)
--- a/m4/psi.m4
+++ b/m4/psi.m4
@@ -1,10 +1,68 @@
-PSI_TYPES=
-PSI_STRUCTS=
-PSI_CONSTS=
-PSI_REDIRS=
-PSI_MACROS=
-PSI_DECLS=
-PSI_VA_DECLS=
+PSI_TYPES=$PHP_PSI_SRCDIR/php_psi_types.h
+PSI_STRUCTS=$PHP_PSI_SRCDIR/php_psi_structs.h
+PSI_CONSTS=$PHP_PSI_SRCDIR/php_psi_consts.h
+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
+
+AC_DEFUN(PSI_CONFIG_INIT, [
+       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
+static struct psi_predef_struct {
+       token_t type_tag;
+       const char *type_name;
+       const char *var_name;
+       size_t offset;
+       size_t size;
+       size_t pointer_level;
+       size_t array_size;
+} psi_predef_structs@<:@@:>@ = {
+EOF
+       cat >$PSI_CONSTS <<EOF
+static struct psi_predef_const {
+       token_t type_tag;
+       const char *type_name;
+       const char *var_name;
+       const char *val_text;
+       token_t val_type_tag;
+} psi_predef_consts@<:@@:>@ = {
+EOF
+       cat >$PSI_REDIRS <<EOF
+static struct psi_func_redir {
+       const char *name;
+       void (*func)(void);
+} psi_func_redirs@<:@@:>@ = {
+EOF
+       cat >$PSI_MACROS </dev/null
+       cat >$PSI_DECLS <<EOF
+static struct psi_predef_decl {
+       token_t type_tag;
+       const char *type_name;
+       const char *var_name;
+       size_t pointer_level;
+       size_t array_size;
+} psi_predef_decls@<:@@:>@ = {
+EOF
+       cat >$PSI_VA_DECLS <<EOF
+static struct psi_predef_decl psi_predef_vararg_decls@<:@@:>@ = {
+EOF
+])
+
+AC_DEFUN(PSI_CONFIG_DONE, [
+       for i in $PSI_TYPES $PSI_STRUCTS $PSI_CONSTS $PSI_REDIRS $PSI_DECLS $PSI_VA_DECLS; do
+               cat >>$i <<EOF
+       {0}
+};
+EOF
+       done
+])
 
 psi_includes() {
        local have_
index cea747e518928233f8a3f9f2ea12967560fe0175..79373d36a1da6d5eb82206bd4acd05c9d5293d5d 100644 (file)
@@ -1,10 +1,10 @@
 # add_str_const(name, value)
 add_str_const() {
-       PSI_CONSTS="{PSI_T_STRING, \"string\", \"psi\\\\$1\", $2, PSI_T_QUOTED_STRING}, $PSI_CONSTS"
+       cat >>$PSI_CONSTS <<<"  {PSI_T_STRING, \"string\", \"psi\\\\$1\", $2, PSI_T_QUOTED_STRING}, "
 }
 # add_int_const(name, value)
 add_int_const() {
-       PSI_CONSTS="{PSI_T_INT, \"int\", \"psi\\\\$1\", \"$2\", PSI_T_NUMBER}, $PSI_CONSTS"
+       cat >>$PSI_CONSTS <<<"  {PSI_T_INT, \"int\", \"psi\\\\$1\", \"$2\", PSI_T_NUMBER}, "
 }
 dnl PSI_CONST(const name, type)
 AC_DEFUN(PSI_CONST, [
index 69f8edb4e7b2c92905b142a132e391c9ebfb3361..c331bbecc658fa4aa8a6f3e7655323cc6e15962d 100644 (file)
@@ -1,5 +1,5 @@
 AC_DEFUN(PSI_REDIR, [psi_symbol=ifelse([$2],[],[$1],[$2])
-       PSI_REDIRS="{\"$1\", (void(*)(void))$psi_symbol}, $PSI_REDIRS"])
+       cat >>$PSI_REDIRS <<<"  {\"$1\", (void(*)(void))$psi_symbol}, "])
 
 AC_DEFUN(PSI_FUNC_LIBC_MAIN, [
        AC_REQUIRE([AC_PROG_NM])
@@ -61,14 +61,14 @@ AC_DEFUN(PSI_DECL, [
                [m4_map_args_sep([PSI_DECL_ARG(m4_normalize(], [))], [], m4_bregexp([$2], [(\(.*\))], [\1]))])
        PSI_FUNC(PSI_VAR_NAME($1), [
                ifelse([$3], vararg, [
-                       PSI_VA_DECLS="$psi_decl_args, {0}, $PSI_VA_DECLS"
+                       cat >>$PSI_VA_DECLS <<<"        $psi_decl_args, {0}, "
                ], [
-                       PSI_DECLS="$psi_decl_args, {0}, $PSI_DECLS"
+                       cat >>$PSI_DECLS <<<"   $psi_decl_args, {0}, "
                ])
        ], [
                PSI_MACRO($1, $2, [
                        ifelse([$3], vararg, AC_MSG_ERROR(varargs macro support is not implemented),[])
-                       PSI_DECLS="$psi_decl_args, {0}, $PSI_DECLS"
+                       cat >>$PSI_DECLS <<<"   $psi_decl_args, {0}, "
                ])
        ])
 ])
index 0ce6f84ac15b5dce19b0af3abf12398bce2bc613..0bae220459423111f84c2679b704c67e651cf3c4 100644 (file)
@@ -28,7 +28,7 @@ AC_DEFUN(PSI_MACRO, [
                        macro_body="return $macro_name$macro_call;"
                ])
                psi_macro="$macro_type psi_macro_$macro_name$macro_decl { $macro_body }"
-               PSI_MACROS="$PSI_MACROS $psi_macro"
+               cat >>$PSI_MACROS <<<"$psi_macro"
                PSI_REDIR($macro_name, psi_macro_$macro_name)
        ], [], PSI_INCLUDES)
 ])
index 430baf7e035eab0628372016185b81f6859ef980..ce04f3d393657d91666e8f6a498bfaccdde6b8ac 100644 (file)
@@ -17,8 +17,8 @@ AC_DEFUN(PSI_STRUCT, [
        psi_struct_name=m4_bregexp([$1], [^\(struct \)?\(\w+\)], [\2])
        psi_struct_members="{PSI_T_STRUCT, \"struct\", \"$psi_struct_name\", 0, $AS_TR_SH([ac_cv_sizeof_]$1), 0, 0}"
        ifelse([$2],,,[m4_map_args_sep([PSI_STRUCT_MEMBER($1, m4_normalize(], [))], [], $2)])
-       PSI_STRUCTS="$psi_struct_members, {0}, $PSI_STRUCTS"
+       cat >>$PSI_STRUCTS <<<" $psi_struct_members, {0}, "
        if test "$1" = "$psi_struct_name"; then
-               PSI_TYPES="{PSI_T_STRUCT, \"$1\", \"$1\"}, $PSI_TYPES"
+               cat >>$PSI_TYPES <<<"   {PSI_T_STRUCT, \"$1\", \"$1\"}, "
        fi
 ])
index 3b0a22efc0bff960e3645332983e5d68c42649a0..70a9ab1bd1efc6187fc4dc45160543e12ec81904 100644 (file)
@@ -7,7 +7,7 @@ psi_type_pair() {
                local psi_type_upper=`tr a-z A-Z <<<$psi_type_name`
                local psi_type_bits=`expr $2 \* 8`
                echo "PSI_T_${psi_type_upper}${psi_type_bits}, \"${psi_type_lower}${psi_type_bits}_t\""
-               eval AS_TR_SH([psi_standard_type_]$1)="${psi_type_lower}${psi_type_bits}_t"
+               #eval AS_TR_SH([psi_standard_type_]$1)="${psi_type_lower}${psi_type_bits}_t"
                ;;
        struct*)
                echo "PSI_T_STRUCT, \"$2\""
@@ -30,7 +30,7 @@ AC_DEFUN(PSI_TYPE, [
        int)
                AX_CHECK_SIGN($1, :, [
                        psi_basic_type=uint
-               ], $psi_header)
+               ], PSI_INCLUDES)
                ;;
        sint)
                psi_basic_type=int
@@ -38,7 +38,7 @@ AC_DEFUN(PSI_TYPE, [
        esac
        if test "$2" && test "$AS_TR_SH([ac_cv_sizeof_]$1)" -gt 0; then
                AS_TR_SH(psi_basic_type_$1)=$psi_basic_type
-               PSI_TYPES="{`psi_type_pair $psi_basic_type $AS_TR_SH([ac_cv_sizeof_]$1)`, \"$1\"}, $PSI_TYPES"
+               cat >>$PSI_TYPES <<<"   {`psi_type_pair $psi_basic_type $AS_TR_SH([ac_cv_sizeof_]$1)`, \"$1\"}, "
        fi
 ])
 
@@ -58,32 +58,32 @@ AC_DEFUN(PSI_TYPE_BITS, [`expr 8 \* $AS_TR_SH([ac_cv_sizeof_]$1)`])
 
 dnl PSI_TYPE_INDIRECTION(type, size, pointer_level_var, array_size_var)
 AC_DEFUN(PSI_TYPE_INDIRECTION, [
-       AC_MSG_CHECKING(indirection of $1)
-       m4_define([pointer_level], m4_len(m4_bpatsubst([PSI_VAR_TYPE($1)], [[^*]])))
-       m4_define([array_size], [m4_bregexp([PSI_VAR_TYPE($1)], [@<:@\([0-9]+\)@:>@], [\1])])
-       
-       ifelse(array_size.$2,0., [
+       dnl AC_MSG_CHECKING(indirection of $1)
+       m4_define([psi_pointer_level], m4_len(m4_bpatsubst([PSI_VAR_TYPE($1)], [[^*]])))
+       m4_define([psi_array_size], [m4_bregexp([PSI_VAR_TYPE($1)], [@<:@\([0-9]+\)@:>@], [\1])])
+
+       ifelse(psi_array_size.$2,0., [
                AC_MSG_ERROR([cannot compute dynamic array size of a non-struct member])
        ], [
-               ifelse(pointer_level,0,[
-                       m4_define([type_size],[$]AS_TR_SH([ac_cv_sizeof_]m4_bregexp(PSI_VAR_TYPE([$1]), [^\( \|\w\)+], [\&])))
+               ifelse(psi_pointer_level,0,[
+                       m4_define([psi_type_size],[$]AS_TR_SH([ac_cv_sizeof_]m4_bregexp(PSI_VAR_TYPE([$1]), [^\( \|\w\)+], [\&])))
                ],[
-                       m4_define([type_size],$ac_cv_sizeof_void_p)
+                       m4_define([psi_type_size],$ac_cv_sizeof_void_p)
                ])
        ])
-       
-       m4_case(array_size,,[
-               $3=pointer_level
+
+       m4_case(psi_array_size,,[
+               $3=psi_pointer_level
                $4=0]
        ,0,[
-               $3=m4_incr(pointer_level)
-               $4="`expr $2 / type_size`"
+               $3=m4_incr(psi_pointer_level)
+               $4="`expr $2 / psi_type_size`"
        ], [
-               $3=m4_incr(pointer_level)
-               $4=array_size
+               $3=m4_incr(psi_pointer_level)
+               $4=psi_array_size
        ])
-       
-       AC_MSG_RESULT([[$]$3, [$]$4])
+
+       dnl AC_MSG_RESULT([[$]$3, [$]$4])
 ])
 
 AC_DEFUN(PSI_TYPE_PAIR, [m4_case(m4_bregexp([$1], [^\w+], [\&]),
index 7c99d6c65af55be895772fd1d73f501350e309d7..b6ee82e16f6bec644fbf2d10be863fee4b2a2f70 100644 (file)
@@ -1,4 +1,4 @@
-AC_DEFUN(PSI_CHECK_STDDEF, [
+PSI_CHECK_STDDEF() {
     AC_CHECK_HEADERS(stddef.h)
     PSI_TYPE(ptrdiff_t, int)
     PSI_CONST(PTRDIFF_MIN, int)
@@ -8,4 +8,4 @@ AC_DEFUN(PSI_CHECK_STDDEF, [
     PSI_TYPE(wchar_t, int)
     PSI_CONST(WCHAR_MIN, int)
     PSI_CONST(WCHAR_MAX, int)
-])
+}
index 65afe65bd152a8700f79a86ae65d4359b4b2f0d3..045279db5054551484f95f4f969f3258b58ebd49 100644 (file)
@@ -1,4 +1,4 @@
-AC_DEFUN(PSI_CHECK_STDINT, [
+PSI_CHECK_STDINT() {
        AC_CHECK_HEADERS(stdint.h)
 
        PSI_TYPE(int_least8_t, int)
@@ -67,4 +67,4 @@ AC_DEFUN(PSI_CHECK_STDINT, [
        PSI_CONST(INTMAX_MIN, int)
        PSI_CONST(INTMAX_MAX, int)
        PSI_CONST(UINTMAX_MAX, int)
-])
+}
index 7d601f581723031cc3a28f3a731a587373562cf9..2f079c117eefd78055f43e06c77c03f304c9f55d 100644 (file)
@@ -1,4 +1,4 @@
-AC_DEFUN(PSI_CHECK_STDIO, [
+PSI_CHECK_STDIO() {
     AC_CHECK_HEADER(stdio.h)
 
     PSI_STRUCT(FILE)
@@ -80,4 +80,4 @@ AC_DEFUN(PSI_CHECK_STDIO, [
        PSI_DECL(int snprintf, [(char *str, size_t size, char *format)], vararg)
        PSI_DECL(int sprintf, [(char *str, char *format)], vararg)
        PSI_DECL(int sscanf, [(char *str, char *format)], vararg)
-])
+}
index e521d43731db13407326ea96cd2a13e0ea970004..48dbfc969fed278f62c0571b0914a5f5250e2f37 100644 (file)
@@ -1,6 +1,6 @@
-AC_DEFUN(PSI_CHECK_STDLIB, [
+PSI_CHECK_STDLIB() {
        AC_CHECK_HEADERS(stdlib.h)
-       
+
        PSI_STRUCT(div_t, [
                int quot,
                int rem
@@ -65,5 +65,4 @@ AC_DEFUN(PSI_CHECK_STDLIB, [
        PSI_DECL(int unsetenv, [(char *var)])
        PSI_DECL(size_t wcstombs, [(char *dest, wchar_t *src, size_t n)])
        PSI_DECL(int wctomb, [(char *s, wchar_t wc)])
-])
-
+}
index 7ae010e379a5491bb272919c4055442a4a17b0a6..7c8da1056bc2cce1875af834d8007e9ba0e7b2d1 100644 (file)
@@ -1,17 +1,17 @@
-AC_DEFUN(PSI_CHECK_SYS_SELECT, [
+PSI_CHECK_SYS_SELECT() {
        AC_CHECK_HEADERS(sys/select.h)
-       
+
        PSI_STRUCT(fd_set, [])
-       
+
        PSI_CONST(FD_SETSIZE, int)
-       
+
        PSI_MACRO(void FD_CLEAR, [(int fd, fd_set *s)])
        PSI_MACRO(void FD_COPY, [(fd_set *s1, fd_set *s2)])
        PSI_MACRO(void FD_CLR, [(int fd, fd_set *s)])
        PSI_MACRO(void FD_SET, [(int fd, fd_set *s)])
        PSI_MACRO(int FD_ISSET, [(int fd, fd_set *s)])
        PSI_MACRO(void FD_ZERO, [(fd_set *s)])
-       
+
        PSI_DECL(int select, [(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout)])
        dnl PSI_DECL(int pselect, [(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout, sigset_t *sigmask)])
-])
\ No newline at end of file
+}
index 3d403cde095b5cf98b1493a7be786ca08f1480c4..4d28cdde84a83fc2d372baf5ee6973e77f0a0a24 100644 (file)
@@ -1,9 +1,9 @@
-AC_DEFUN(PSI_CHECK_SYS_SOCKET, [
+PSI_CHECK_SYS_SOCKET() {
        AC_CHECK_HEADERS(sys/socket.h)
-       
+
        PSI_TYPE(socklen_t, int)
        PSI_TYPE(sa_family_t, uint)
-       
+
        PSI_STRUCT(struct sockaddr, [
                sa_family_t sa_family,
                char sa_data@<:@0@:>@]
@@ -29,7 +29,7 @@ AC_DEFUN(PSI_CHECK_SYS_SOCKET, [
                int l_onoff,
                int l_linger]
        )
-       
+
        PSI_CONST(AF_INET, int)
        PSI_CONST(AF_INET6, int)
     PSI_CONST(AF_UNIX, int)
@@ -67,11 +67,11 @@ AC_DEFUN(PSI_CHECK_SYS_SOCKET, [
     PSI_CONST(SO_SNDLOWAT, int)
     PSI_CONST(SO_SNDTIMEO, int)
     PSI_CONST(SO_TYPE, int)
-    
+
     PSI_MACRO(unsigned char *CMSG_DATA, [(struct cmsghdr *m)])
        PSI_MACRO(struct cmsghdr *CMSG_NXTHDR, [(struct msghdr *m, struct cmsghdr *c)])
        PSI_MACRO(struct cmsghdr *CMSG_FIRSTHDR, [(struct msghdr *m)])
-       
+
        PSI_DECL(int accept, [(int socket, struct sockaddr *address, socklen_t *address_len)])
        PSI_DECL(int bind, [(int socket, struct sockaddr *address, socklen_t address_len)])
        PSI_DECL(int connect, [(int socket, struct sockaddr *address, socklen_t address_len)])
@@ -90,5 +90,4 @@ AC_DEFUN(PSI_CHECK_SYS_SOCKET, [
        PSI_DECL(int sockatmark, [(int socket)])
        PSI_DECL(int socket, [(int domain, int type, int protocol)])
        PSI_DECL(int socketpair, [(int domain, int type, int protocol, int socket_vector@<:@2@:>@)])
-       
-])
\ No newline at end of file
+}
index b29323244ae391f470e4c9b4fa6ac5671d939006..36f08fcab1c81a34e1a61eb79c24c6a94d0ac91f 100644 (file)
@@ -1,4 +1,4 @@
-AC_DEFUN(PSI_CHECK_SYS_STAT, [
+PSI_CHECK_SYS_STAT() {
        AC_CHECK_HEADERS([sys/stat.h])
 
        PSI_STRUCT(struct stat, [
@@ -81,4 +81,4 @@ AC_DEFUN(PSI_CHECK_SYS_STAT, [
        PSI_DECL(int stat, [(char *path, struct stat *buf)])
        PSI_DECL(mode_t umask, [(mode_t mode)])
        PSI_DECL(int utimensat, [(int fd, char *path, struct timespec times@<:@2@:>@, int flag)])
-])
+}
index 758ca79b0b68eec8db0c6203a791d4be67595924..1b845dd5b8e7f35aef9b290ba6533a35c6316e0d 100644 (file)
@@ -1,4 +1,4 @@
-AC_DEFUN(PSI_CHECK_SYS_TIME, [
+PSI_CHECK_SYS_TIME() {
        AC_CHECK_HEADERS(sys/time.h)
 
        PSI_CONST(ITIMER_REAL, int)
@@ -23,4 +23,4 @@ AC_DEFUN(PSI_CHECK_SYS_TIME, [
        PSI_DECL(int gettimeofday, [(struct timeval *tp, struct timezone *tz)])
        PSI_DECL(int utimes, [(char *path, struct timeval times@<:@2@:>@)])
        PSI_DECL(int utimensat, [(int fd, char *path, struct timespec times@<:@2@:>@)])
-])
+}
index cbaa6feb13427676773ef389a9cafe22471cff0f..9f9da565d6cc8e190bbcc3118083bdf0791bad32 100644 (file)
@@ -1,12 +1,12 @@
-AC_DEFUN(PSI_CHECK_SYS_TIMES, [
+PSI_CHECK_SYS_TIMES() {
        AC_CHECK_HEADERS(sys/times.h)
-       
+
        PSI_STRUCT(struct tms, [
                clock_t tms_utime,
                clock_t tms_stime,
                clock_t tms_cutime,
                clock_t tms_cstime]
        )
-       
+
        PSI_DECL(clock_t times, [(struct tms *buf)])
-])
+}
index 352d8b5adb2c87e35114e7f6c63386829a7900da..88315dfcc5605dad031111ad76d31105599be6ec 100644 (file)
@@ -1,4 +1,4 @@
-AC_DEFUN(PSI_CHECK_SYS_TYPES, [
+PSI_CHECK_SYS_TYPES() {
        AC_CHECK_HEADERS(sys/types.h)
 
        PSI_TYPE(blkcnt_t, int)
@@ -21,4 +21,4 @@ AC_DEFUN(PSI_CHECK_SYS_TYPES, [
        PSI_TYPE(time_t, int)
        PSI_TYPE(timer_t, int)
        PSI_TYPE(uid_t, int)
-])
+}
index d57f901034839733ce178e4cdc21cb7940fadf1b..e7cbce357fd86242bc2e7769c872fa2afcbd6db9 100644 (file)
@@ -1,11 +1,11 @@
-AC_DEFUN(PSI_CHECK_SYS_UIO, [
+PSI_CHECK_SYS_UIO() {
        AC_CHECK_HEADERS(sys/uio.h)
-       
+
        PSI_STRUCT(struct iovec, [
                void *iov_base,
                size_t iov_len]
        )
-       
+
        PSI_DECL(ssize_t readv, [(int fd, struct iovec *iov, int iovcnt)])
        PSI_DECL(ssize_t writev, [(int fd, struct iovec *iov, int iovcnt)])
-])
+}
index 475779f66d2eac014ea60a7d2f59281add0ccb21..dde03137fd5d6bca13603efed749c9c7797300ad 100644 (file)
@@ -1,6 +1,6 @@
-AC_DEFUN(PSI_CHECK_SYS_UTSNAME, [
+PSI_CHECK_SYS_UTSNAME() {
        AC_CHECK_HEADERS(sys/utsname.h)
-       
+
        PSI_STRUCT(struct utsname, [
                char sysname@<:@0@:>@,
                char nodename@<:@0@:>@,
@@ -9,6 +9,6 @@ AC_DEFUN(PSI_CHECK_SYS_UTSNAME, [
                char machine@<:@0@:>@,
                char domainname@<:@0@:>@
        ])
-       
+
        PSI_DECL(int uname, [(struct utsname *name)])
-])
\ No newline at end of file
+}
diff --git a/m4/syslog.m4 b/m4/syslog.m4
new file mode 100644 (file)
index 0000000..198f4f8
--- /dev/null
@@ -0,0 +1,42 @@
+PSI_CHECK_SYSLOG() {
+       AC_CHECK_HEADERS(syslog.h)
+
+       PSI_CONST(LOG_PID, int)
+       PSI_CONST(LOG_CONS, int)
+       PSI_CONST(LOG_NDELAY, int)
+       PSI_CONST(LOG_ODELAY, int)
+       PSI_CONST(LOG_NOWAIT, int)
+       PSI_CONST(LOG_KERN, int)
+       PSI_CONST(LOG_USER, int)
+       PSI_CONST(LOG_MAIL, int)
+       PSI_CONST(LOG_NEWS, int)
+       PSI_CONST(LOG_UUCP, int)
+       PSI_CONST(LOG_DAEMON, int)
+       PSI_CONST(LOG_AUTH, int)
+       PSI_CONST(LOG_CRON, int)
+       PSI_CONST(LOG_LPR, int)
+       PSI_CONST(LOG_LOCAL0, int)
+       PSI_CONST(LOG_LOCAL1, int)
+       PSI_CONST(LOG_LOCAL2, int)
+       PSI_CONST(LOG_LOCAL3, int)
+       PSI_CONST(LOG_LOCAL4, int)
+       PSI_CONST(LOG_LOCAL5, int)
+       PSI_CONST(LOG_LOCAL6, int)
+       PSI_CONST(LOG_LOCAL7, int)
+       PSI_CONST(LOG_EMERG, int)
+       PSI_CONST(LOG_ALERT, int)
+       PSI_CONST(LOG_CRIT, int)
+       PSI_CONST(LOG_ERR, int)
+       PSI_CONST(LOG_WARNING, int)
+       PSI_CONST(LOG_NOTICE, int)
+       PSI_CONST(LOG_INFO, int)
+       PSI_CONST(LOG_DEBUG, int)
+
+       PSI_MACRO(int LOG_MASK, [(int pri)])
+       PSI_MACRO(int LOG_UPTO, [(int pri)])
+
+       PSI_DECL(void closelog, [(void)])
+       PSI_DECL(void openlog, [(char *ident, int option, int facility)])
+       PSI_DECL(void syslog, [(int priority, char *format)], vararg)
+       PSI_DECL(int setlogmask, [(int mask)])
+}
index a4cb58e7501b1f866024e602703f678fad65ecc5..c6f71b7ad7910f08ece56ccadb6d209b07df5125 100644 (file)
@@ -1,4 +1,4 @@
-AC_DEFUN(PSI_CHECK_TIME, [
+PSI_CHECK_TIME() {
        AC_CHECK_HEADERS(time.h)
 
        PSI_CONST(CLOCKS_PER_SEC, int)
@@ -56,4 +56,4 @@ AC_DEFUN(PSI_CHECK_TIME, [
        PSI_DECL(int timer_gettime, [(timer_t t, struct itimerspec *ts)])
        PSI_DECL(int timer_settime, [(timer_t t, int flags, struct itimerspec *value, struct itimerspec *ovalue)])
        PSI_DECL(void tzset, [()])
-])
+}
index ebffee9b5e3c5468fb54fc8ce4e1a21f815c3d98..83612b398804337bf4785585d756f2dcc7d1bf43 100644 (file)
@@ -1,13 +1,95 @@
-AC_DEFUN(PSI_CHECK_WCHAR, [
+PSI_CHECK_WCHAR() {
        AC_CHECK_HEADERS(wchar.h)
 
        PSI_TYPE(wint_t, int)
+       PSI_TYPE(wctype_t, int)
+       PSI_STRUCT(mbstate_t)
 
        PSI_CONST(WINT_MIN, int)
        PSI_CONST(WINT_MAX, int)
        PSI_CONST(WEOF, int)
 
-       PSI_DECL(int wprintf, [(wchar_t *format)], vararg)
-       PSI_DECL(int fwprintf, [(FILE *stream, wchar_t *format)], vararg)
-       PSI_DECL(int swprintf, [(wchar_t *wcs, size_t maxlen, wchar_t *format)], vararg)
-])
+       PSI_DECL(wint_t btowc, [(int c)])
+       PSI_DECL(wint_t fgetwc, [(FILE *stream)])
+       PSI_DECL(wchar_t *fgetws, [(wchar_t *ws, int n, FILE *stream)])
+       PSI_DECL(wint_t fputwc, [(wchar_t c, FILE *stream)])
+       PSI_DECL(int fputws, [(const wchar_t *ws, FILE *stream)])
+       PSI_DECL(int fwide, [(FILE *stream, int mode)])
+       PSI_DECL(int fwprintf, [(FILE *stream, const wchar_t *format)], vararg)
+       PSI_DECL(int fwscanf, [(FILE *stream, const wchar_t *format)], vararg)
+       PSI_DECL(wint_t getwc, [(FILE *stream)])
+       PSI_DECL(wint_t getwchar, [(void)])
+       PSI_DECL(int iswalnum, [(wint_t wc)])
+       PSI_DECL(int iswalpha, [(wint_t wc)])
+       PSI_DECL(int iswcntrl, [(wint_t wc)])
+       PSI_DECL(int iswctype, [(wint_t wc, wctype_t class)])
+       PSI_DECL(int iswdigit, [(wint_t wc)])
+       PSI_DECL(int iswgraph, [(wint_t wc)])
+       PSI_DECL(int iswlower, [(wint_t wc)])
+       PSI_DECL(int iswprint, [(wint_t wc)])
+       PSI_DECL(int iswpunct, [(wint_t wc)])
+       PSI_DECL(int iswspace, [(wint_t wc)])
+       PSI_DECL(int iswupper, [(wint_t wc)])
+       PSI_DECL(int iswxdigit, [(wint_t wc)])
+       PSI_DECL(size_t mbrlen, [(const char *s, size_t n, mbstate_t *ps)])
+       PSI_DECL(size_t mbrtowc, [(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)])
+       PSI_DECL(int mbsinit, [(const mbstate_t *ps)])
+       PSI_DECL(size_t mbsnrtowcs, [(wchar_t *dst, const char **src, size_t nms, size_t len, mbstate_t *ps)])
+       PSI_DECL(size_t mbsrtowcs, [(wchar_t *dst, const char **src, size_t len, mbstate_t *ps)])
+       PSI_DECL(FILE *open_wmemstream, [(wchar_t **ptr, size_t *size)])
+       PSI_DECL(wint_t putwc, [(wchar_t wc, FILE *stream)])
+       PSI_DECL(wint_t putwchar, [(wchar_t wc)])
+       PSI_DECL(int swprintf, [(wchar_t *wcs, size_t maxlen, const wchar_t *format)], vararg)
+       PSI_DECL(int swscanf, [(const wchar_t *ws, const wchar_t *format)], vararg)
+       PSI_DECL(wint_t towlower, [(wint_t wc)])
+       PSI_DECL(wint_t towupper, [(wint_t wc)])
+       PSI_DECL(wint_t ungetwc, [(wint_t wc, FILE *stream)])
+       PSI_DECL(wchar_t *wcpcpy, [(wchar_t *dest, const wchar_t *src)])
+       PSI_DECL(wchar_t *wcpncpy, [(wchar_t *dest, const wchar_t *src, size_t n)])
+       PSI_DECL(size_t wcrtomb, [(char *s, wchar_t wc, mbstate_t *ps)])
+       PSI_DECL(int wcscasecmp, [(const wchar_t *s1, const wchar_t *s2)])
+       PSI_DECL(int wcscasecmp_l, [(const wchar_t *s1, const wchar_t *s2, locale_t loc)])
+       PSI_DECL(wchar_t *wcscat, [(wchar_t *dest, const wchar_t *src)])
+       PSI_DECL(wchar_t *wcschr, [(const wchar_t *wcs, wchar_t wc)])
+       PSI_DECL(int wcscmp, [(const wchar_t *s1, const wchar_t *s2)])
+       PSI_DECL(int wcscoll, [(const wchar_t *s1, const wchar_t *s2)])
+       PSI_DECL(int wcscoll_l, [(const wchar_t *s1, const wchar_t *s2, locale_t loc)])
+       PSI_DECL(wchar_t *wcscpy, [(wchar_t *dest, const wchar_t *src)])
+       PSI_DECL(size_t wcscspn, [(const wchar_t *wcs, const wchar_t *reject)])
+       PSI_DECL(wchar_t *wcsdup, [(const wchar_t *s)])
+       PSI_DECL(size_t wcsftime, [(wchar_t *wcs, size_t maxsize, const wchar_t *format, const struct tm *timeptr)])
+       PSI_DECL(size_t wcslen, [(const wchar_t *s)])
+       PSI_DECL(int wcsncasecmp, [(const wchar_t *s1, const wchar_t *s2, size_t n)])
+       PSI_DECL(int wcsncasecmp_l, [(const wchar_t *s1, const wchar_t *s2, size_t n, locale_t loc)])
+       PSI_DECL(wchar_t *wcsncat, [(wchar_t *dest, const wchar_t *src, size_t n)])
+       PSI_DECL(int wcsncmp, [(const wchar_t *s1, const wchar_t *s2, size_t n)])
+       PSI_DECL(wchar_t *wcsncpy, [(wchar_t *dest, const wchar_t *src, size_t n)])
+       PSI_DECL(size_t wcsnlen, [(const wchar_t *s, size_t maxlen)])
+       PSI_DECL(size_t wcsnrtombs, [(char *dest, const wchar_t **src, size_t nwc, size_t len, mbstate_t *ps)])
+       PSI_DECL(wchar_t *wcspbrk, [(const wchar_t *wcs, const wchar_t *accept)])
+       PSI_DECL(wchar_t *wcsrchr, [(const wchar_t *wcs, wchar_t wc)])
+       PSI_DECL(size_t wcsrtombs, [(char *dest, const wchar_t **src, size_t n, mbstate_t *ps)])
+       PSI_DECL(size_t wcsspn, [(const wchar_t *wcs, const wchar_t *accept)])
+       PSI_DECL(wchar_t *wcsstr, [(const wchar_t *haystack, const wchar_t *needle)])
+       PSI_DECL(double wcstod, [(const wchar_t *nptr, wchar_t **endptr)])
+       PSI_DECL(float wcstof, [(const wchar_t *nptr, wchar_t **endptr)])
+       PSI_DECL(wchar_t *wcstok, [(wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)])
+       PSI_DECL(long wcstol, [(const wchar_t *nptr, wchar_t **endptr, int base)])
+       dnl PSI_DECL(long double wcstold, [(const wchar_t *nptr, wchar_t **endptr)])
+       dnl PSI_DECL(long long wcstoll, [(const wchar_t *nptr, wchar_t **endptr, int base)])
+       PSI_DECL(unsigned long wcstoul, [(const wchar_t *nptr, wchar_t **endptr, int base)])
+       dnl PSI_DECL(unsigned long long wcstoull, [(const wchar_t *nptr, wchar_t **endptr, int base)])
+       PSI_DECL(int wcswidth, [(const wchar_t *s, size_t n)])
+       PSI_DECL(size_t wcsxfrm, [(wchar_t *ws1, const wchar_t *ws2, size_t n)])
+       PSI_DECL(size_t wcsxfrm_l, [(wchar_t *ws1, const wchar_t *ws2, size_t n, locale_t loc)])
+       PSI_DECL(int wctob, [(wint_t c)])
+       PSI_DECL(wctype_t wctype, [(const char *name)])
+       PSI_DECL(int wcwidth, [(wchar_t c)])
+       PSI_DECL(wchar_t *wmemchr, [(const wchar_t *s, wchar_t c, size_t n)])
+       PSI_DECL(int wmemcmp, [(const wchar_t *s1, const wchar_t *s2, size_t n)])
+       PSI_DECL(wchar_t *wmemcpy, [(wchar_t *dest, const wchar_t *src, size_t n)])
+       PSI_DECL(wchar_t *wmemmove, [(wchar_t *dest, const wchar_t *src, size_t n)])
+       PSI_DECL(wchar_t *wmemset, [(wchar_t *wcs, wchar_t wc, size_t n)])
+       PSI_DECL(int wprintf, [(const wchar_t *format)], vararg)
+       PSI_DECL(int wscanf, [(const wchar_t *format)], vararg)
+}
diff --git a/psi.d/syslog.psi b/psi.d/syslog.psi
new file mode 100644 (file)
index 0000000..b3510b8
--- /dev/null
@@ -0,0 +1,28 @@
+function psi\openlog(string $ident, int $option, int $facility) : void {
+       let ident = strval($ident);
+       let option = intval($option);
+       let facility = intval($facility);
+       return void(openlog);
+}
+
+function psi\closelog() : void {
+       return void(closelog);
+}
+
+function psi\setlogmask(int $mask) : int {
+       let mask = intval($mask);
+       return to_int(setlogmask);
+}
+
+function psi\syslog(int $priority, string $format, mixed ...$args) : void {
+       let priority = intval($priority);
+       let format = strval($format);
+       return void(syslog);
+}
+
+// redirected macro
+extern int LOG_MASK(int pri);
+function psi\LOG_MASK(int $pri) : int {
+       let pri = intval($pri);
+       return to_int(LOG_MASK);
+}
index 4a4f4720bf058ee74e5916508b42f02bbff2107e..fd315eefcbc413558bdc10a6e91ff1ec296a040a 100644 (file)
@@ -129,6 +129,15 @@ static struct psi_std_type {
        {0}
 };
 
+#include "php_psi_types.h"
+#include "php_psi_consts.h"
+#include "php_psi_macros.h"
+#include "php_psi_redirs.h"
+#include "php_psi_decls.h"
+#include "php_psi_va_decls.h"
+#include "php_psi_structs.h"
+
+/*
 static struct psi_predef_type {
        token_t type_tag;
        const char *type_name;
@@ -207,7 +216,7 @@ static struct psi_predef_struct {
        PSI_STRUCTS
        {0}
 };
-
+*/
 static int validate_lib(PSI_Data *data, void **dlopened) {
        char lib[MAXPATHLEN];
        const char *ptr = data->psi.file.ln;
index 42e83fc3288da06ba880ca9d68d083df0f6ecaff..7e6f953e4ebc809c6e6c32d5fb87e69abfe9ec38 100644 (file)
@@ -3,12 +3,12 @@ getaddrinfo
 --INI--
 psi.directory={PWD}:{PWD}/../../psi.d
 --SKIPIF--
-<?php 
+<?php
 extension_loaded("psi") or die("skip -- need ext/psi");
 ?>
 --FILE--
 ===TEST===
-<?php 
+<?php
 
 $rc = psi\getaddrinfo("m6w6.name", NULL, NULL, $ai);
 
@@ -19,20 +19,14 @@ if ($rc) {
 
 $flags = psi\NI_NUMERICHOST|psi\NI_NUMERICSERV;
 do {
-       var_dump(psi\getnameinfo($ai["ai_addr"], $host, $serv, $flags), $host, $serv);
+       $rc = psi\getnameinfo($ai["ai_addr"], $host, $serv, $flags);
+       if ($rc !== 0) var_dump($rc);
+       if ($host !== "78.46.223.30") var_dump($host);
+       if ($serv !== "0") var_dump($serv);
 } while (($ai = $ai["ai_next"]));
 
 ?>
 ===DONE===
 --EXPECT--
 ===TEST===
-int(0)
-string(12) "78.46.223.30"
-string(1) "0"
-int(0)
-string(12) "78.46.223.30"
-string(1) "0"
-int(0)
-string(12) "78.46.223.30"
-string(1) "0"
-===DONE===
\ No newline at end of file
+===DONE===