configure improvements
authorMichael Wallner <mike@php.net>
Fri, 15 Jan 2016 16:00:44 +0000 (17:00 +0100)
committerMichael Wallner <mike@php.net>
Fri, 15 Jan 2016 16:00:44 +0000 (17:00 +0100)
config.m4
m4/psi.m4
m4/psi_type.m4
m4/stdio.m4
m4/stdlib.m4
m4/sys_select.m4
m4/sys_stat.m4
m4/time.m4
m4/wchar.m4
src/context.c
src/libffi.c

index 641b16ab934c32e8a912c23838cb887ba210a07f..fd41d32494e46810f8948df94519d3dc7a723454 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -14,6 +14,7 @@ m4_foreach(incfile, [
        [psi_struct.m4],
        [errno.m4],
        [glob.m4],
+       [locale.m4],
        [stddef.m4],
        [stdio.m4],
        [stdint.m4],
@@ -29,7 +30,8 @@ m4_foreach(incfile, [
        [netdb.m4],
        [syslog.m4],
        [time.m4],
-       [wchar.m4]], [
+       [wchar.m4],
+       [wctype.m4]], [
        dnl pecl build
        sinclude([m4/]incfile)
        dnl php-src build
@@ -53,6 +55,7 @@ if test "$PHP_PSI" != no; then
        PSI_CHECK_SYS_TYPES
        PSI_CHECK_ERRNO
        PSI_CHECK_GLOB
+       PSI_CHECK_LOCALE
        PSI_CHECK_STDIO
        PSI_CHECK_STDLIB
        PSI_CHECK_TIME
@@ -66,12 +69,14 @@ if test "$PHP_PSI" != no; then
        PSI_CHECK_NETDB
        PSI_CHECK_SYSLOG
        PSI_CHECK_WCHAR
+       PSI_CHECK_WCTYPE
        PSI_CONFIG_DONE
 
        PHP_SUBST(PSI_SHARED_LIBADD)
 
        AC_DEFINE_UNQUOTED(PHP_PSI_SHLIB_SUFFIX, ["$SHLIB_SUFFIX_NAME"], DL suffix)
 
+       AC_DEFINE_UNQUOTED([PSI_STDINC], [$PSI_STDINC], [Standard includes])
        AC_DEFINE_UNQUOTED([PSI_TYPES], [$PSI_TYPES], [Predefined types])
        AC_DEFINE_UNQUOTED([PSI_STRUCTS], [$PSI_STRUCTS], [Predefined structs])
        AC_DEFINE_UNQUOTED([PSI_CONSTS], [$PSI_CONSTS], [Predefined constants])
index 81aca2801419e12bcf29077d382ba7054f4ce871..4ea5590a4e4af6985818b80b07cba106a75e7f21 100644 (file)
--- a/m4/psi.m4
+++ b/m4/psi.m4
@@ -1,3 +1,4 @@
+PSI_STDINC=$PHP_PSI_SRCDIR/php_psi_stdinc.h
 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
@@ -56,6 +57,9 @@ EOF
 ])
 
 AC_DEFUN(PSI_CONFIG_DONE, [
+       cat >$PSI_STDINC <<EOF
+PSI_INCLUDES
+EOF
        for i in $PSI_TYPES $PSI_STRUCTS $PSI_CONSTS $PSI_REDIRS $PSI_DECLS $PSI_VA_DECLS; do
                cat >>$i <<EOF
        {0}
@@ -75,7 +79,61 @@ EOF
 }
 
 AC_DEFUN(PSI_INCLUDES, [AC_INCLUDES_DEFAULT()
-`psi_includes`])
+#ifdef HAVE_ERRNO_H
+# include <errno.h>
+#endif
+#ifdef HAVE_GLOB_H
+# include <glob.h>
+#endif
+#ifdef HAVE_LOCALE_H
+# include <locale.h>
+#endif
+#ifdef HAVE_XLOCALE_H
+# include <xlocale.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+# include <arpa/nameser.h>
+#endif
+#ifdef HAVE_NETDB_H
+# include <netdb.h>
+#endif
+#ifdef HAVE_RESOLV_H
+# include <resolv.h>
+#endif
+#ifdef HAVE_SYS_SELECT_H
+# include <sys/select.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#ifdef HAVE_SYS_TIMES_H
+# include <sys/times.h>
+#endif
+#ifdef HAVE_SYS_UIO_H
+# include <sys/uio.h>
+#endif
+#ifdef HAVE_SYS_UTSNAME_H
+# include <sys/utsname.h>
+#endif
+#ifdef HAVE_TIME_H
+# include <time.h>
+#endif
+#ifdef HAVE_SYSLOG_H
+# include <syslog.h>
+#endif
+#ifdef HAVE_WCHAR_H
+# include <wchar.h>
+#endif
+#ifdef HAVE_WCTYPE_H
+# include <wctype.h>
+#endif
+])
 
 AC_DEFUN(PSI_LEMON, [
        AC_ARG_VAR(LEMON, The lemon parser generator of the SQLite project)
index 70a9ab1bd1efc6187fc4dc45160543e12ec81904..6324c75e5da342e6d0f47b16795875701aefa6fa 100644 (file)
@@ -21,11 +21,11 @@ psi_type_pair() {
        esac
 }
 
-dnl PSI_TYPE(type name, basic type, includes)
+dnl PSI_TYPE(type name, basic type)
 AC_DEFUN(PSI_TYPE, [
        ifdef(AS_TR_CPP(AC_TYPE_$1), AS_TR_CPP(AC_TYPE_$1))
        PSI_CHECK_SIZEOF($1, PSI_INCLUDES)
-       psi_basic_type=$2
+       psi_basic_type=AS_TR_SH($2)
        case $psi_basic_type in
        int)
                AX_CHECK_SIGN($1, :, [
@@ -42,6 +42,44 @@ AC_DEFUN(PSI_TYPE, [
        fi
 ])
 
+AC_DEFUN(PSI_OPAQUE_TYPE, [
+       ifdef(AS_TR_CPP(AC_TYPE_$1), AS_TR_CPP(AC_TYPE_$1))
+       PSI_CHECK_SIZEOF($1, PSI_INCLUDES)
+       if test "$AS_TR_SH([ac_cv_sizeof_]$1)" -gt 0; then
+               psi_type_class=
+               AC_CACHE_CHECK(type class of $1, AS_TR_SH([psi_cv_type_class_]$1), [
+                       AC_TRY_COMPILE(PSI_INCLUDES, [char test@<:@($1)1@:>@;], [
+                               psi_type_class=scalar
+                       ], [
+                               AC_TRY_COMPILE(PSI_INCLUDES, [$1 test = 0;], [
+                                       AC_TRY_COMPILE(PSI_INCLUDES, [$1 test = (($1)0)+1;], [
+                                               psi_type_class="pointer of known type"
+                                       ], [
+                                               psi_type_class="pointer of opaque type"
+                                       ])
+                               ], [
+                                       psi_type_class=struct
+                               ])
+                       ])
+                       AS_TR_SH([psi_cv_type_class_]$1)="$psi_type_class"
+               ])
+               case "$AS_TR_SH([psi_cv_type_class_]$1)" in
+               scalar)
+                       PSI_TYPE($1, int)
+                       ;;
+               struct)
+                       PSI_STRUCT($1)
+                       ;;
+               pointer*)
+                       cat >>$PSI_TYPES <<<"   {PSI_T_POINTER, \"void\", \"$1\"}, "
+                       ;;
+               *)
+                       AC_MSG_WARN(could not detect type class of $1)
+                       ;;
+               esac
+       fi
+])
+
 dnl unsigned char* buf[16] -> unsigned char*
 dnl AC_DEFUN(PSI_VAR_TYPE, [m4_bregexp([$1], [\(\(struct \)?[^ ]+\)[ *]+[^ ]+$], [\1])])
 AC_DEFUN(PSI_VAR_TYPE, [m4_bregexp([$1], [^\(const \)?\(.*\) \([*]*\)[^ ]+$], [\2\3])])
index 2f079c117eefd78055f43e06c77c03f304c9f55d..9144cb1df0faaeb61afd8377027cf1e4d2c44ef8 100644 (file)
@@ -19,6 +19,10 @@ PSI_CHECK_STDIO() {
     PSI_CONST(L_ctermid, int)
     PSI_CONST(L_tmpnam, int)
 
+    PSI_MACRO(FILE *stderr)
+    PSI_MACRO(FILE *stdout)
+    PSI_MACRO(FILE *stdin)
+
     PSI_DECL(void clearerr, [(FILE *stream)])
     PSI_DECL(char *ctermid, [(char *s)])
     PSI_DECL(int fclose, [(FILE *stream)])
index 48dbfc969fed278f62c0571b0914a5f5250e2f37..c7654b67cf38f2b99c46a3319fdf5d2f91fa11dd 100644 (file)
@@ -13,7 +13,8 @@ PSI_CHECK_STDLIB() {
        PSI_CONST(EXIT_FAILURE, int)
        PSI_CONST(EXIT_SUCCESS, int)
        PSI_CONST(RAND_MAX, int)
-       PSI_CONST(MB_CUR_MAX, int)
+       
+       PSI_MACRO(int MB_CUR_MAX)
 
        PSI_DECL(void _Exit, [(int status)])
        PSI_DECL(void abort, [()])
index 7c8da1056bc2cce1875af834d8007e9ba0e7b2d1..8bd7e88956be4577a919b877d756cd2f3fa5a47f 100644 (file)
@@ -5,12 +5,12 @@ PSI_CHECK_SYS_SELECT() {
 
        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(void FD_CLEAR, [(int fd, fd_set *s)])
+       PSI_DECL(void FD_COPY, [(fd_set *s1, fd_set *s2)])
+       PSI_DECL(void FD_CLR, [(int fd, fd_set *s)])
+       PSI_DECL(void FD_SET, [(int fd, fd_set *s)])
+       PSI_DECL(int FD_ISSET, [(int fd, fd_set *s)])
+       PSI_DECL(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)])
index 36f08fcab1c81a34e1a61eb79c24c6a94d0ac91f..937eb3853025d42f7b92b4b2300fcab789b91873 100644 (file)
@@ -49,6 +49,7 @@ PSI_CHECK_SYS_STAT() {
        PSI_CONST(S_IXOTH, int)
        PSI_CONST(S_ISUID, int)
        PSI_CONST(S_ISGID, int)
+       PSI_CONST(S_ISVTX, int)
        PSI_CONST(UTIME_NOW, int)
        PSI_CONST(UTIME_OMIT, int)
 
index c6f71b7ad7910f08ece56ccadb6d209b07df5125..6fd6c1004679ce5f9c0f110fe97a00f105d13875 100644 (file)
@@ -56,4 +56,8 @@ 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, [()])
+
+       PSI_EXTVAR(int daylight)
+       PSI_EXTVAR(long timezone)
+       PSI_EXTVAR(char **tzname)
 }
index 83612b398804337bf4785585d756f2dcc7d1bf43..6c5430b8535af0d031c7f45092a6817733af80e9 100644 (file)
@@ -19,18 +19,6 @@ PSI_CHECK_WCHAR() {
        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)])
@@ -41,8 +29,6 @@ PSI_CHECK_WCHAR() {
        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)])
@@ -83,7 +69,6 @@ PSI_CHECK_WCHAR() {
        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)])
index fd315eefcbc413558bdc10a6e91ff1ec296a040a..d2293fe7bf4f360de6bd5bf19e4551e489e2559c 100644 (file)
@@ -4,85 +4,7 @@
 
 #include "php.h"
 
-#include <stdio.h>
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-#  include <stdlib.h>
-# endif
-#endif
-#ifdef HAVE_STRING_H
-# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
-#  include <memory.h>
-# endif
-# include <string.h>
-#endif
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#ifdef HAVE_ERRNO_H
-# include <errno.h>
-#endif
-#ifdef HAVE_GLOB_H
-# include <glob.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_NAMESER_H
-# include <arpa/nameser.h>
-#endif
-#ifdef HAVE_NETDB_H
-# include <netdb.h>
-#endif
-#ifdef HAVE_RESOLV_H
-# include <resolv.h>
-#endif
-#ifdef HAVE_SYS_SELECT_H
-# include <sys/select.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#ifdef HAVE_SYS_TIMES_H
-# include <sys/times.h>
-#endif
-#ifdef HAVE_SYS_UIO_H
-# include <sys/uio.h>
-#endif
-#ifdef HAVE_SYS_UTSNAME_H
-# include <sys/utsname.h>
-#endif
-#ifdef HAVE_TIME_H
-# include <time.h>
-#endif
-#ifdef HAVE_SYSLOG_H
-# include <syslog.h>
-#endif
-#ifdef HAVE_WCHAR_H
-# include <wchar.h>
-#endif
+#include "php_psi_stdinc.h"
 
 #ifdef HAVE_DIRENT_H
 # include <dirent.h>
@@ -137,86 +59,6 @@ static struct psi_std_type {
 #include "php_psi_va_decls.h"
 #include "php_psi_structs.h"
 
-/*
-static struct psi_predef_type {
-       token_t type_tag;
-       const char *type_name;
-       const char *alias;
-} psi_predef_types[] = {
-       PSI_TYPES
-       {0}
-};
-
-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[] = {
-       PSI_CONSTS
-       {0}
-};
-
-PSI_MACROS
-
-struct utsname *uname2() {
-       struct utsname *u = calloc(1, sizeof(*u));
-       uname(u);
-       return u;
-}
-
-int psi_glob(const char *pattern, int flags,
-               int (*errfunc) (const char *epath, int eerrno),
-               glob_t *pglob) {
-       size_t offs = flags & GLOB_DOOFFS ? pglob->gl_offs : 0;
-       int rv = glob(pattern, flags, errfunc, pglob);
-       if (pglob->gl_pathv) {
-               while (offs--) {
-                       pglob->gl_pathv[offs] = NULL;
-               }
-       }
-       return rv;
-}
-
-static struct psi_func_redir {
-       const char *name;
-       void (*func)(void);
-} psi_func_redirs[] = {
-       {"glob", (void (*)(void)) psi_glob},
-       {"uname2", (void (*)(void)) uname2},
-       PSI_REDIRS
-       {0}
-};
-
-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[] = {
-       PSI_DECLS
-       {0}
-};
-static struct psi_predef_decl psi_predef_vararg_decls[] = {
-       PSI_VA_DECLS
-       {0}
-};
-
-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[] = {
-       PSI_STRUCTS
-       {0}
-};
-*/
 static int validate_lib(PSI_Data *data, void **dlopened) {
        char lib[MAXPATHLEN];
        const char *ptr = data->psi.file.ln;
index 8d41b7a192fa24287bffa03c522821d87bfea015..776e98c143d0fb309c20aa3b096aa60a6a3d49a6 100644 (file)
@@ -91,6 +91,8 @@ static inline ffi_type *psi_ffi_token_type(token_t t) {
                return &ffi_type_float;
        case PSI_T_DOUBLE:
                return &ffi_type_double;
+       case PSI_T_POINTER:
+               return &ffi_type_pointer;
        }
 }
 static inline ffi_type *psi_ffi_impl_type(token_t impl_type) {