From: Michael Wallner Date: Thu, 14 Jan 2016 11:20:13 +0000 (+0100) Subject: avoid busting bash's stack with a too big if body in configure X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=b1720af16e5d7765e2effcd16e23f351c2f82e54;p=m6w6%2Fext-psi avoid busting bash's stack with a too big if body in configure --- diff --git a/config.m4 b/config.m4 index bfa56e5..641b16a 100644 --- 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 diff --git a/m4/errno.m4 b/m4/errno.m4 index 99311b7..be6f996 100644 --- a/m4/errno.m4 +++ b/m4/errno.m4 @@ -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) -]) +} diff --git a/m4/glob.m4 b/m4/glob.m4 index fbb036e..343b372 100644 --- a/m4/glob.m4 +++ b/m4/glob.m4 @@ -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) -]) +} diff --git a/m4/netdb.m4 b/m4/netdb.m4 index b14b54f..5049a53 100644 --- a/m4/netdb.m4 +++ b/m4/netdb.m4 @@ -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 +} diff --git a/m4/psi.m4 b/m4/psi.m4 index eecfa61..81aca28 100644 --- 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 + cat >$PSI_STRUCTS <@ = { +EOF + cat >$PSI_CONSTS <@ = { +EOF + cat >$PSI_REDIRS <@ = { +EOF + cat >$PSI_MACROS $PSI_DECLS <@ = { +EOF + cat >$PSI_VA_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 <>$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, [ diff --git a/m4/psi_decl.m4 b/m4/psi_decl.m4 index 69f8edb..c331bbe 100644 --- a/m4/psi_decl.m4 +++ b/m4/psi_decl.m4 @@ -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}, " ]) ]) ]) diff --git a/m4/psi_macro.m4 b/m4/psi_macro.m4 index 0ce6f84..0bae220 100644 --- a/m4/psi_macro.m4 +++ b/m4/psi_macro.m4 @@ -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) ]) diff --git a/m4/psi_struct.m4 b/m4/psi_struct.m4 index 430baf7..ce04f3d 100644 --- a/m4/psi_struct.m4 +++ b/m4/psi_struct.m4 @@ -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 ]) diff --git a/m4/psi_type.m4 b/m4/psi_type.m4 index 3b0a22e..70a9ab1 100644 --- a/m4/psi_type.m4 +++ b/m4/psi_type.m4 @@ -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+], [\&]), diff --git a/m4/stddef.m4 b/m4/stddef.m4 index 7c99d6c..b6ee82e 100644 --- a/m4/stddef.m4 +++ b/m4/stddef.m4 @@ -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) -]) +} diff --git a/m4/stdint.m4 b/m4/stdint.m4 index 65afe65..045279d 100644 --- a/m4/stdint.m4 +++ b/m4/stdint.m4 @@ -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) -]) +} diff --git a/m4/stdio.m4 b/m4/stdio.m4 index 7d601f5..2f079c1 100644 --- a/m4/stdio.m4 +++ b/m4/stdio.m4 @@ -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) -]) +} diff --git a/m4/stdlib.m4 b/m4/stdlib.m4 index e521d43..48dbfc9 100644 --- a/m4/stdlib.m4 +++ b/m4/stdlib.m4 @@ -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)]) -]) - +} diff --git a/m4/sys_select.m4 b/m4/sys_select.m4 index 7ae010e..7c8da10 100644 --- a/m4/sys_select.m4 +++ b/m4/sys_select.m4 @@ -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 +} diff --git a/m4/sys_socket.m4 b/m4/sys_socket.m4 index 3d403cd..4d28cdd 100644 --- a/m4/sys_socket.m4 +++ b/m4/sys_socket.m4 @@ -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 +} diff --git a/m4/sys_stat.m4 b/m4/sys_stat.m4 index b293232..36f08fc 100644 --- a/m4/sys_stat.m4 +++ b/m4/sys_stat.m4 @@ -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)]) -]) +} diff --git a/m4/sys_time.m4 b/m4/sys_time.m4 index 758ca79..1b845dd 100644 --- a/m4/sys_time.m4 +++ b/m4/sys_time.m4 @@ -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@:>@)]) -]) +} diff --git a/m4/sys_times.m4 b/m4/sys_times.m4 index cbaa6fe..9f9da56 100644 --- a/m4/sys_times.m4 +++ b/m4/sys_times.m4 @@ -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)]) -]) +} diff --git a/m4/sys_types.m4 b/m4/sys_types.m4 index 352d8b5..88315df 100644 --- a/m4/sys_types.m4 +++ b/m4/sys_types.m4 @@ -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) -]) +} diff --git a/m4/sys_uio.m4 b/m4/sys_uio.m4 index d57f901..e7cbce3 100644 --- a/m4/sys_uio.m4 +++ b/m4/sys_uio.m4 @@ -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)]) -]) +} diff --git a/m4/sys_utsname.m4 b/m4/sys_utsname.m4 index 475779f..dde0313 100644 --- a/m4/sys_utsname.m4 +++ b/m4/sys_utsname.m4 @@ -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 index 0000000..198f4f8 --- /dev/null +++ b/m4/syslog.m4 @@ -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)]) +} diff --git a/m4/time.m4 b/m4/time.m4 index a4cb58e..c6f71b7 100644 --- a/m4/time.m4 +++ b/m4/time.m4 @@ -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, [()]) -]) +} diff --git a/m4/wchar.m4 b/m4/wchar.m4 index ebffee9..83612b3 100644 --- a/m4/wchar.m4 +++ b/m4/wchar.m4 @@ -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 index 0000000..b3510b8 --- /dev/null +++ b/psi.d/syslog.psi @@ -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); +} diff --git a/src/context.c b/src/context.c index 4a4f472..fd315ee 100644 --- a/src/context.c +++ b/src/context.c @@ -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; diff --git a/tests/netdb/gai001.phpt b/tests/netdb/gai001.phpt index 42e83fc..7e6f953 100644 --- a/tests/netdb/gai001.phpt +++ b/tests/netdb/gai001.phpt @@ -3,12 +3,12 @@ getaddrinfo --INI-- psi.directory={PWD}:{PWD}/../../psi.d --SKIPIF-- - --FILE-- ===TEST=== - ===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===