From: Michael Wallner Date: Fri, 15 Jan 2016 16:00:44 +0000 (+0100) Subject: configure improvements X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=81b71a515e2024cee739deb6e207eb3b0e7c5d64;p=m6w6%2Fext-psi configure improvements --- diff --git a/config.m4 b/config.m4 index 641b16a..fd41d32 100644 --- 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]) diff --git a/m4/psi.m4 b/m4/psi.m4 index 81aca28..4ea5590 100644 --- 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 <>$i < +#endif +#ifdef HAVE_GLOB_H +# include +#endif +#ifdef HAVE_LOCALE_H +# include +#endif +#ifdef HAVE_XLOCALE_H +# include +#endif +#ifdef HAVE_NETINET_IN_H +# include +#endif +#ifdef HAVE_ARPA_NAMESER_H +# include +#endif +#ifdef HAVE_NETDB_H +# include +#endif +#ifdef HAVE_RESOLV_H +# include +#endif +#ifdef HAVE_SYS_SELECT_H +# include +#endif +#ifdef HAVE_SYS_SOCKET_H +# include +#endif +#ifdef HAVE_SYS_TIME_H +# include +#endif +#ifdef HAVE_SYS_TIMES_H +# include +#endif +#ifdef HAVE_SYS_UIO_H +# include +#endif +#ifdef HAVE_SYS_UTSNAME_H +# include +#endif +#ifdef HAVE_TIME_H +# include +#endif +#ifdef HAVE_SYSLOG_H +# include +#endif +#ifdef HAVE_WCHAR_H +# include +#endif +#ifdef HAVE_WCTYPE_H +# include +#endif +]) AC_DEFUN(PSI_LEMON, [ AC_ARG_VAR(LEMON, The lemon parser generator of the SQLite project) diff --git a/m4/psi_type.m4 b/m4/psi_type.m4 index 70a9ab1..6324c75 100644 --- a/m4/psi_type.m4 +++ b/m4/psi_type.m4 @@ -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])]) diff --git a/m4/stdio.m4 b/m4/stdio.m4 index 2f079c1..9144cb1 100644 --- a/m4/stdio.m4 +++ b/m4/stdio.m4 @@ -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)]) diff --git a/m4/stdlib.m4 b/m4/stdlib.m4 index 48dbfc9..c7654b6 100644 --- a/m4/stdlib.m4 +++ b/m4/stdlib.m4 @@ -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, [()]) diff --git a/m4/sys_select.m4 b/m4/sys_select.m4 index 7c8da10..8bd7e88 100644 --- a/m4/sys_select.m4 +++ b/m4/sys_select.m4 @@ -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)]) diff --git a/m4/sys_stat.m4 b/m4/sys_stat.m4 index 36f08fc..937eb38 100644 --- a/m4/sys_stat.m4 +++ b/m4/sys_stat.m4 @@ -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) diff --git a/m4/time.m4 b/m4/time.m4 index c6f71b7..6fd6c10 100644 --- a/m4/time.m4 +++ b/m4/time.m4 @@ -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) } diff --git a/m4/wchar.m4 b/m4/wchar.m4 index 83612b3..6c5430b 100644 --- a/m4/wchar.m4 +++ b/m4/wchar.m4 @@ -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)]) diff --git a/src/context.c b/src/context.c index fd315ee..d2293fe 100644 --- a/src/context.c +++ b/src/context.c @@ -4,85 +4,7 @@ #include "php.h" -#include -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef STDC_HEADERS -# include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined STDC_HEADERS && defined HAVE_MEMORY_H -# include -# endif -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_INTTYPES_H -# include -#endif -#ifdef HAVE_STDINT_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif - -#ifdef HAVE_ERRNO_H -# include -#endif -#ifdef HAVE_GLOB_H -# include -#endif -#ifdef HAVE_NETINET_IN_H -# include -#endif -#ifdef HAVE_ARPA_NAMESER_H -# include -#endif -#ifdef HAVE_NETDB_H -# include -#endif -#ifdef HAVE_RESOLV_H -# include -#endif -#ifdef HAVE_SYS_SELECT_H -# include -#endif -#ifdef HAVE_SYS_SOCKET_H -# include -#endif -#ifdef HAVE_SYS_TIME_H -# include -#endif -#ifdef HAVE_SYS_TIMES_H -# include -#endif -#ifdef HAVE_SYS_UIO_H -# include -#endif -#ifdef HAVE_SYS_UTSNAME_H -# include -#endif -#ifdef HAVE_TIME_H -# include -#endif -#ifdef HAVE_SYSLOG_H -# include -#endif -#ifdef HAVE_WCHAR_H -# include -#endif +#include "php_psi_stdinc.h" #ifdef HAVE_DIRENT_H # include @@ -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; diff --git a/src/libffi.c b/src/libffi.c index 8d41b7a..776e98c 100644 --- a/src/libffi.c +++ b/src/libffi.c @@ -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) {