[psi_struct.m4],
[errno.m4],
[glob.m4],
+ [locale.m4],
[stddef.m4],
[stdio.m4],
[stdint.m4],
[netdb.m4],
[syslog.m4],
[time.m4],
- [wchar.m4]], [
+ [wchar.m4],
+ [wctype.m4]], [
dnl pecl build
sinclude([m4/]incfile)
dnl php-src build
PSI_CHECK_SYS_TYPES
PSI_CHECK_ERRNO
PSI_CHECK_GLOB
+ PSI_CHECK_LOCALE
PSI_CHECK_STDIO
PSI_CHECK_STDLIB
PSI_CHECK_TIME
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])
+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
])
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}
}
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)
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, :, [
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])])
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)])
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, [()])
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)])
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)
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)
}
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(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 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)])
#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>
#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;
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) {