configure: add --enable-psi-maintainer-mode
authorMichael Wallner <mike@php.net>
Thu, 2 Feb 2017 15:00:02 +0000 (16:00 +0100)
committerMichael Wallner <mike@php.net>
Thu, 2 Feb 2017 15:00:02 +0000 (16:00 +0100)
32 files changed:
Makefile.frag
config.m4
m4/posix/errno.m4
m4/posix/fcntl.m4
m4/posix/glob.m4
m4/posix/locale.m4
m4/posix/ndbm.m4
m4/posix/netdb.m4
m4/posix/netinet_in.m4
m4/posix/netinet_tcp.m4
m4/posix/poll.m4
m4/posix/signal.m4
m4/posix/stdio.m4
m4/posix/stdlib.m4
m4/posix/sys_select.m4
m4/posix/sys_socket.m4
m4/posix/sys_stat.m4
m4/posix/sys_time.m4
m4/posix/sys_times.m4
m4/posix/sys_uio.m4
m4/posix/sys_utsname.m4
m4/posix/syslog.m4
m4/posix/time.m4
m4/posix/unistd.m4
m4/posix/wchar.m4
m4/posix/wctype.m4
m4/psi/psi.m4
m4/psi/psi_const.m4
m4/psi/psi_decl.m4
m4/psi/psi_macro.m4
m4/psi/psi_type.m4
psi.d/getopt.psi

index c31b9d971f092e2f711cb5bd35d65e26c4d8d9a2..289821170b492da9f0ecc60368fba5b124c4d5c1 100644 (file)
@@ -62,11 +62,11 @@ $(PHP_PSI_SRCDIR)/src/context.c: $(PHP_PSI_SRCDIR)/php_psi_consts.h $(PHP_PSI_SR
 
 # -- deps
 
-PHP_PSI_DEPEND = $(patsubst $(PHP_PSI_SRCDIR)/%,$(PHP_PSI_BUILDDIR)/%,$(PHP_PSI_SOURCES:.c=.dep))
+PHP_PSI_DEPEND = $(PHP_PSI_BUILDDIR)/php_psi.dep $(patsubst $(PHP_PSI_SRCDIR)/%,$(PHP_PSI_BUILDDIR)/%,$(PHP_PSI_SOURCES:.c=.dep))
 
 .PHONY: psi-clean-depend
 psi-clean-depend:
-       -rm -f $(PHP_PSI_DEPEND) $(PHP_PSI_BUILDDIR)/php_psi.dep
+       -rm -f $(PHP_PSI_DEPEND)
 
 psi-clean: psi-clean-depend
 
@@ -75,10 +75,10 @@ $(PHP_PSI_BUILDDIR)/%.dep: $(PHP_PSI_SRCDIR)/%.c
                $(CPPFLAGS) $(DEFS) $(INCLUDES) $< \
                        || touch $@
 
-DEPS = 
-ifneq  ($(DEPS),)
+ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
+ifneq ($(PSI_DEPS),)
 -include $(PHP_PSI_DEPEND)
--include $(PHP_PSI_BUILDDIR)/php_psi.dep
+endif
 endif
 
 
index fa209641b1acb375ce910bdaac7153cc13df8541..a873ab94dbb7ff97fb3a9b1b4bfb2660c9490ccc 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -1,5 +1,11 @@
 PHP_PSI_SRCDIR=PHP_EXT_SRCDIR(psi)
-PHP_PSI_BUILDDIR=PHP_EXT_BUILDDIR(psi)
+
+case "PHP_EXT_BUILDDIR(psi)" in
+""|.) PHP_PSI_BUILDDIR=$PHP_PSI_SRCDIR
+       ;;
+*)    PHP_PSI_BUILDDIR=PHP_EXT_BUILDDIR(psi)
+       ;;
+esac
 
 m4_foreach(incfile, [
        [ax/ax_check_sign.m4],
@@ -44,13 +50,18 @@ m4_foreach(incfile, [
 ])
 
 PHP_ARG_ENABLE(psi, whether to enable PHP System Interface support,
-[  --enable-psi            Enable PHP System Interface support])
+[  --enable-psi            Enable PSI (PHP System Interface) support])
 
 if test "$PHP_PSI" != no; then
-       PHP_CONFIGURE_PART(Configuring PSI)
-
        PHP_ARG_ENABLE(psi-posix, whether to pre-define POSIX decls,
-       [  --enable-psi-posix=...  PSI: pre-define POSIX decls], [ ], [ ])
+       [  --enable-psi-posix=...  PSI: pre-define POSIX decls], [all], [no])
+       
+       PHP_ARG_ENABLE(psi-maintainer-mode, whether to enable maintainer mode,
+       [  --enable-psi-maintainer-mode
+                          PSI: enable maintainer mode
+                           . parallel configure
+                           . source dependencies
+                           . extra decl wrappers], [no], [no])
 
        PHP_ARG_WITH(psi-libjit, where to find libjit,
        [  --with-psi-libjit=DIR   PSI: path to libjit], [ ], [ ])
@@ -69,14 +80,11 @@ if test "$PHP_PSI" != no; then
                #endif
        ], [
                AC_MSG_RESULT([needs define])
-               AC_DEFINE([_GNU_SOURCE], [], [ ])
+               AC_DEFINE([_GNU_SOURCE], [1], [ ])
        ], [
                AC_MSG_RESULT([already defined])
        ])
 
-       psi_save_LIBS=$LIBS
-       LIBS=
-
        PSI_LEMON
        PSI_CHECK_LIBJIT
        PSI_CHECK_LIBFFI
@@ -86,39 +94,47 @@ if test "$PHP_PSI" != no; then
        AC_FUNC_MMAP
 
        PSI_CONFIG_INIT
+
+       dnl basics, one-by-one
        PSI_CHECK_STD_TYPES
        PSI_CHECK_STDINT
        PSI_CHECK_SYS_TYPES
        PSI_CHECK_STDDEF
-       PSI_CHECK_ERRNO
-       PSI_CHECK_FCNTL
-       PSI_CHECK_GLOB
-       PSI_CHECK_LOCALE
-       PSI_CHECK_STDIO
-       PSI_CHECK_STDLIB
-       PSI_CHECK_UNISTD
-       PSI_CHECK_TIME
-       PSI_CHECK_SYS_SELECT
-       PSI_CHECK_SYS_SOCKET
-       PSI_CHECK_SYS_TIME
-       PSI_CHECK_SYS_TIMES
-       PSI_CHECK_SYS_STAT
-       PSI_CHECK_SYS_UIO
-       PSI_CHECK_SYS_UTSNAME
-       PSI_CHECK_NDBM
-       PSI_CHECK_NETDB
-       PSI_CHECK_NETINET_IN
-       PSI_CHECK_NETINET_TCP
-       PSI_CHECK_POLL
-       PSI_CHECK_SIGNAL
-       PSI_CHECK_SYSLOG
-       PSI_CHECK_WCHAR
-       PSI_CHECK_WCTYPE
+       
+       dnl parallel
+       AC_MSG_CHECKING([for POSIX modules: $PHP_PSI_POSIX])
+       
+       PSI_CONFIG_POSIX(errno, errno.h)
+       PSI_CONFIG_POSIX(fcntl, fcntl.h)
+       PSI_CONFIG_POSIX(glob, glob.h)
+       PSI_CONFIG_POSIX(locale, locale.h xlocale.h)
+       PSI_CONFIG_POSIX(stdio, stdio.h)
+       PSI_CONFIG_POSIX(stdlib, stdlib.h)
+       PSI_CONFIG_POSIX(unistd, unistd.h)
+       PSI_CONFIG_POSIX(time, time.h)
+       PSI_CONFIG_POSIX(sys/select, sys/select.h)
+       PSI_CONFIG_POSIX(sys/socket, sys/socket.h)
+       PSI_CONFIG_POSIX(sys/time, sys/time.h)
+       PSI_CONFIG_POSIX(sys/times, sys/times.h)
+       PSI_CONFIG_POSIX(sys/stat, sys/stat.h)
+       PSI_CONFIG_POSIX(sys/uio, sys/uio.h)
+       PSI_CONFIG_POSIX(sys/utsname, sys/utsname.h)
+       PSI_CONFIG_POSIX(ndbm, dnl
+               ndbm.h dnl posix
+               relic.h dnl qdbm
+               gdbm-ndbm.h dnl gdbm
+       )
+       PSI_CONFIG_POSIX(netdb, netdb.h)
+       PSI_CONFIG_POSIX(netinet/in, netinet/in.h)
+       PSI_CONFIG_POSIX(netinet/tcp, netinet/tcp.h)
+       PSI_CONFIG_POSIX(poll, poll.h)
+       PSI_CONFIG_POSIX(signal, signal.h)
+       PSI_CONFIG_POSIX(syslog, syslog.h)
+       PSI_CONFIG_POSIX(wchar, wchar.h)
+       PSI_CONFIG_POSIX(wctype, wctype.h)
+       
        PSI_CONFIG_DONE
 
-       psi_eval_LIBS=$LIBS
-       LIBS=$psi_save_LIBS
-       PHP_EVAL_LIBLINE($psi_eval_LIBS, PSI_SHARED_LIBADD)
        PHP_SUBST(PSI_SHARED_LIBADD)
 
        AC_DEFINE_UNQUOTED(PHP_PSI_SHLIB_SUFFIX, ["$SHLIB_SUFFIX_NAME"], DL suffix)
index 4d28b8bc903dac69d7a7d243787dae91cc8f536b..540918dbb3c63d7cb495bc12316a3d2458daa6ac 100644 (file)
@@ -1,5 +1,4 @@
 PSI_CHECK_ERRNO() {
-    PSI_CONFIG_POSIX(errno, errno.h)
 
     PSI_EXTVAR(int errno)
 
index 9e992cce318363ebc8dde4803438883ebd5c7e7d..0d35efa948f7a2d4e34722192494cdcfdaaeb355 100644 (file)
@@ -1,6 +1,4 @@
 PSI_CHECK_FCNTL() {
-       PSI_CONFIG_POSIX(fcntl, fcntl.h)
-
        PSI_CONST(F_DUPFD, int)
        PSI_CONST(F_DUPFD_CLOEXEC, int)
        PSI_CONST(F_GETFD, int)
index f727d5ee3f27e373656a8f0f3ff13308d8a651fc..942428e96111f46fca53ce887f7414f179bd97f8 100644 (file)
@@ -1,5 +1,4 @@
 PSI_CHECK_GLOB() {
-    PSI_CONFIG_POSIX(glob, glob.h)
     
     PSI_STRUCT(glob_t, [
         size_t gl_pathc,
index 3459101090053dd6e5c37e3a12eb7b1fa7bc84fb..64cd66f700d03a865032de896922184db9e40819 100644 (file)
@@ -1,6 +1,4 @@
 PSI_CHECK_LOCALE() {
-       PSI_CONFIG_POSIX(locale, locale.h xlocale.h)
-
        PSI_STRUCT(struct lconv, [
                char    *currency_symbol,
                char    *decimal_point,
index ee7159118d5ffaaad52bd51b0f1433bdf6b01f67..9cbd6484333a0edf8262c04f175d287c72dd609f 100644 (file)
@@ -1,9 +1,4 @@
 PSI_CHECK_NDBM() {
-       PSI_CONFIG_POSIX(ndbm, dnl
-               ndbm.h dnl posix
-               relic.h dnl qdbm
-               gdbm-ndbm.h dnl gdbm
-       )
 
        PSI_STRUCT(datum, [
                void *dptr,
index 8d5b49a72082042761f9a6fe03d40431ad8aa060..7f421260159f83ec44d701ee77739128a02e4ba5 100644 (file)
@@ -1,5 +1,4 @@
 PSI_CHECK_NETDB() {
-       PSI_CONFIG_POSIX(netdb, netdb.h)
 
        PSI_STRUCT(struct hostent, [
                char *h_name,
index 88f054b57120fd50bbe201d9cc0bf1a64458dc0a..7b26e8c11e4bfa696ec84be187d220d7ccb29c60 100644 (file)
@@ -1,5 +1,4 @@
 PSI_CHECK_NETINET_IN() {
-       PSI_CONFIG_POSIX(netinet/in, netinet/in.h)
 
        PSI_TYPE(in_port_t, uint)
        PSI_TYPE(in_addr_t, uint)
index 4e10420884559c69c3b6b6dcd1b921148d4330ef..5731002cf751ba1c3eb4264e0f26a7e0020ca141 100644 (file)
@@ -1,5 +1,3 @@
 PSI_CHECK_NETINET_TCP() {
-       PSI_CONFIG_POSIX(netinet/tcp, netinet/tcp.h)
-
        PSI_CONST(TCP_NODELAY, int)
 }
index bbbb221374ef8330a33855aaddbed7212d7cf51f..b53e11be8c4fc4991770f7834154c9a2e2e1888c 100644 (file)
@@ -1,5 +1,4 @@
 PSI_CHECK_POLL() {
-       PSI_CONFIG_POSIX(poll, poll.h)
 
        PSI_STRUCT(struct pollfd, [
                int fd,
index ac266ac3db1dfa50439f06a91922d71e1485abf9..4d954b6e89bbe0888e7beaf9b4769a68768d5b4b 100644 (file)
@@ -1,5 +1,4 @@
 PSI_CHECK_SIGNAL() {
-       PSI_CONFIG_POSIX(signal, signal.h)
        
        PSI_PTHREAD
        
index a2b40b56477a4ad74519350f28b3fc1b808b4be5..b1307ccf5da9aa9f78228c23455313d6d60e5a58 100644 (file)
@@ -1,6 +1,4 @@
 PSI_CHECK_STDIO() {
-    PSI_CONFIG_POSIX(stdio, stdio.h)
-
     PSI_STRUCT(FILE)
     PSI_STRUCT(fpos_t)
 
index a2a85be7e9b27b36c94564a2178a08ef4f371dd7..08408836b75c00a9b0be8e1ad73fa62ea3183906 100644 (file)
@@ -1,6 +1,4 @@
 PSI_CHECK_STDLIB() {
-       AC_CHECK_HEADERS(stdlib.h)
-
        PSI_STRUCT(div_t, [
                int quot,
                int rem
index 0390299802338d022e6d0db7d27f92ad8d1eb0c8..3b82f96424bcb38325395b99856a3c7eb3076703 100644 (file)
@@ -1,6 +1,4 @@
 PSI_CHECK_SYS_SELECT() {
-       PSI_CONFIG_POSIX(sys/select, sys/select.h)
-
        PSI_STRUCT(fd_set, [])
 
        PSI_CONST(FD_SETSIZE, int)
index 6d1eaf3fd44a5e7841b758a345441129597e38bf..bcadf3387260de1b17fceb23d2efc3163514cfab 100644 (file)
@@ -1,6 +1,4 @@
 PSI_CHECK_SYS_SOCKET() {
-       PSI_CONFIG_POSIX(sys/socket, sys/socket.h)
-
        PSI_TYPE(socklen_t, int)
        PSI_TYPE(sa_family_t, uint)
 
index fb4494512ce165dc5f6a867215b127e7a3ae8c09..f89a2320267fbf65cad4852dedc754f8357debc4 100644 (file)
@@ -1,5 +1,4 @@
 PSI_CHECK_SYS_STAT() {
-       PSI_CONFIG_POSIX(sys/stat, sys/stat.h)
 
        PSI_STRUCT(struct stat, [
                dev_t st_dev,
index 7dfecfd6c01761d3c4d800f65b1e1c74e647348a..c498c1239aef3fa907ed7fe7574bfd61cffbd94e 100644 (file)
@@ -1,6 +1,4 @@
 PSI_CHECK_SYS_TIME() {
-       PSI_CONFIG_POSIX(sys/time, sys/time.h)
-
        PSI_CONST(ITIMER_REAL, int)
        PSI_CONST(ITIMER_VIRTUAL, int)
        PSI_CONST(ITIMER_PROF, int)
index 33010700b70aedd831417edae0ee035de4f9839f..0ae593cd17093969e1a91a203d5054a314ff36c8 100644 (file)
@@ -1,5 +1,4 @@
 PSI_CHECK_SYS_TIMES() {
-       PSI_CONFIG_POSIX(sys/times, sys/times.h)
 
        PSI_STRUCT(struct tms, [
                clock_t tms_utime,
index 7cd4c3c5490e51099a7e4c06b148bfebcf0749a8..d82d9a7732a801c45916d89735e71d0e16a1faa6 100644 (file)
@@ -1,5 +1,4 @@
 PSI_CHECK_SYS_UIO() {
-       PSI_CONFIG_POSIX(sys/uio, sys/uio.h)
 
        PSI_STRUCT(struct iovec, [
                void *iov_base,
index 36f49d33db5ea7b6d92299deef9ada9884c9a707..a268f8101eb714f83eed9983a02e51d3e2522d6f 100644 (file)
@@ -1,5 +1,4 @@
 PSI_CHECK_SYS_UTSNAME() {
-       PSI_CONFIG_POSIX(sys/utsname, sys/utsname.h)
 
        PSI_STRUCT(struct utsname, [
                char sysname@<:@0@:>@,
index 3547f752acd6df1ccdf5d3bc9ca65ef06447de74..2c3764cd570812737e4afa3eff11edb86f7d772a 100644 (file)
@@ -1,5 +1,4 @@
 PSI_CHECK_SYSLOG() {
-       PSI_CONFIG_POSIX(syslog, syslog.h)
 
        PSI_CONST(LOG_PID, int)
        PSI_CONST(LOG_CONS, int)
index 63906e5fb3254bea39ffc6ccf4f8e256f7b82ba4..ea39f95f32d32fc009e48c6424090ca77280088c 100644 (file)
@@ -1,6 +1,4 @@
 PSI_CHECK_TIME() {
-       PSI_CONFIG_POSIX(time, time.h)
-
        PSI_CONST(CLOCKS_PER_SEC, int)
        PSI_CONST(CLOCK_MONOTONIC, int)
        PSI_CONST(CLOCK_PROCESS_CPUTIME_ID, int)
@@ -35,7 +33,7 @@ PSI_CHECK_TIME() {
        PSI_DECL(int clock_getres, [(clockid_t clk_id, struct timespec *res)], [], [-lrt])
        PSI_DECL(int clock_gettime, [(clockid_t clk_id, struct timespec *tp)], [], [-lrt])
        PSI_DECL(int clock_nanosleep, [(clockid_t clk_id, int flags, struct timespec *rqtp, struct timespec *rmtp)], [], [-lrt])
-       PSI_DECL(int clock_settime, [(clockid_t clk_id, struct timespec *tp)], [], [-lrt])
+       PSI_DECL(int clock_settime, [(clockid_t clk_id, const struct timespec *tp)], [], [-lrt])
        PSI_DECL(char *ctime, [(time_t *t)])
        PSI_DECL(char *ctime_r, [(time_t *t, char *buf)])
        PSI_DECL(double difftime, [(time_t time1, time_t time0)])
@@ -60,5 +58,5 @@ PSI_CHECK_TIME() {
        PSI_MACRO(int getdate_err)
        PSI_EXTVAR(int daylight)
        PSI_EXTVAR(long timezone)
-       PSI_EXTVAR(char **tzname)
+       PSI_EXTVAR(char *tzname@<:@2@:>@)
 }
index 0da8665645a7ace468a3be62982f85378ae1a855..94be1ad36781e42d1b4ad60bfbba9b85ebdf1f39 100644 (file)
@@ -1,6 +1,4 @@
 PSI_CHECK_UNISTD() {
-       PSI_CONFIG_POSIX(unistd, unistd.h)
-
        PSI_CONST(F_LOCK, int)
        PSI_CONST(F_TEST, int)
        PSI_CONST(F_TLOCK, int)
index f1a7026b55415101e9b06976624c235c57d0efcb..f5932eff29e46d4b3e5903bb095779e78a29d01c 100644 (file)
@@ -1,5 +1,4 @@
 PSI_CHECK_WCHAR() {
-       PSI_CONFIG_POSIX(wchar, wchar.h)
 
        PSI_TYPE(wint_t, int)
        PSI_STRUCT(mbstate_t)
index 319dada892186f72e04b58cd990f7f024054bfe3..530c165f8f3af03981f097211c30456a5d3b092b 100644 (file)
@@ -1,5 +1,4 @@
 PSI_CHECK_WCTYPE() {
-       PSI_CONFIG_POSIX(wctype, wctype.h)
 
        PSI_TYPE(wctype_t, int)
        PSI_TYPE(wctrans_t, int)
index c8eec1850d9f546efeef16b550e39bbf1be9c38a..b979719862a2db08fff771411158c4c7def3fe7d 100644 (file)
@@ -16,6 +16,27 @@ dnl Creates stubs of the headers with pre-defined types etc.
 dnl These headers are included by src/context.c.
 dnl This macro must be called prior any checks for a type, struct, decl etc.
 AC_DEFUN(PSI_CONFIG_INIT, [
+       psi_save_LIBS=$LIBS
+       LIBS=
+
+       if test "$PHP_PSI_MAINTAINER_MODE" = "yes"; then
+               PSI_FAST_CONFIG=true
+               PSI_DEPS=true
+               PSI_EXTRA_REDIRS=true
+               
+               PHP_SUBST(PSI_DEPS)
+               
+               PSI_CONFIG_TMP=$(mktemp -d)
+       else
+               PSI_FAST_CONFIG=false
+               PSI_DEPS=false
+               if test "$PHP_DEBUG" = "1"; then
+                       PSI_EXTRA_REDIRS=true
+               else
+                       PSI_EXTRA_REDIRS=false
+               fi
+       fi
+       
        cat >$PHP_PSI_BUILDDIR/php_psi.dep <<EOF
 \$(PHP_PSI_SRCDIR)/php_psi.h:
 php_psi.h:
@@ -114,6 +135,19 @@ EOF
 dnl PSI_CONFIG_DONE()
 dnl Finish the headers with the pre-defined types etc.
 AC_DEFUN(PSI_CONFIG_DONE, [
+       
+       wait
+       
+       if $PSI_FAST_CONFIG; then
+               for conf_env in $PSI_CONFIG_TMP/*/conf.env; do
+                       source $conf_env
+               done
+       fi
+       
+       psi_eval_LIBS=$LIBS
+       LIBS=$psi_save_LIBS
+       PHP_EVAL_LIBLINE($psi_eval_LIBS, PSI_SHARED_LIBADD)
+       
        cat >$PSI_STDINC <<EOF
 /* generated by configure */
 #ifndef PSI_STDINC_H
@@ -181,13 +215,44 @@ AC_DEFUN(PSI_SH_TEST_POSIX_ENABLED, [
 dnl PSI_CONFIG_POSIX(section, headers)
 AC_DEFUN(PSI_CONFIG_POSIX, [
        PSI_CONFIG_POSIX_ENABLED($1, [
-               PHP_CONFIGURE_PART(Configuring PSI POSIX: $1)
-               ifelse([$2],,:,[AC_CHECK_HEADERS($2)])
-       ], [
-               return 0
+               if $PSI_FAST_CONFIG; then
+                       PSI_CONFIG_POSIX_PARALLEL($1, $2)
+               else
+                       ifelse([$2],,:,[AC_CHECK_HEADERS($2)])
+                       AS_TR_CPP([PSI_CHECK_$1])
+               fi 
        ])
 ])
 
+AC_DEFUN([PSI_CONFIG_POSIX_PARALLEL], [
+       (
+               dnl setup
+               mkdir $PSI_CONFIG_TMP/AS_TR_SH([$1])
+               ln -s $(pwd)/confdefs.h $PSI_CONFIG_TMP/AS_TR_SH([$1])/confdefs.h
+               
+               dnl restore stdio
+               exec 66>&AS_MESSAGE_FD
+               exec AS_MESSAGE_FD>$PSI_CONFIG_TMP/AS_TR_SH([$1])/stdout.log
+               exec 2>$PSI_CONFIG_TMP/AS_TR_SH([$1])/stderr.log
+               
+               dnl check for headers?
+               ifelse([$2],,:,[AC_CHECK_HEADERS($2)])
+               
+               dnl chaway
+               cd $PSI_CONFIG_TMP/AS_TR_SH([$1])
+               
+               dnl run checks
+               AS_TR_CPP([PSI_CHECK_$1])
+               
+               dnl save libs
+               cat >$PSI_CONFIG_TMP/AS_TR_SH([$1])/conf.env <<EOF
+LIBS="$LIBS \$LIBS"
+EOF
+               dnl done
+               printf "%s " "$1" >&66
+       ) &
+])
+
 AC_DEFUN(PSI_PTHREAD_ONCE, [
        AX_PTHREAD([
                LIBS="$PTHREAD_LIBS $LIBS"
index 6c3cf6b28be665eaf28828e22461700a590d8fc0..f0345adfbff8af68c44dfa85968d42121a46a0ed 100644 (file)
@@ -1,7 +1,7 @@
 # psi_add_str_const(name, value)
 # Add a pre-defined string constant to $PSI_CONSTS
 psi_add_str_const() {
-       grep -q "\"psi\\\\\\\\$1\"" $PSI_CONSTS \
+       grep -Fq "\"psi\\\\$1\"" $PSI_CONSTS \
                || cat >>$PSI_CONSTS <<EOF
        {PSI_T_STRING, "string", "psi\\\\$1", $2, PSI_T_QUOTED_STRING},
 EOF
@@ -10,7 +10,7 @@ EOF
 # psi_add_int_const(name, value)
 # Add a pre-defined int constant to $PSI_CONSTS
 psi_add_int_const() {
-       grep -q "\"psi\\\\\\\\$1\"" $PSI_CONSTS \
+       grep -Fq "\"psi\\\\$1\"" $PSI_CONSTS \
                || cat >>$PSI_CONSTS <<EOF
        {PSI_T_INT, "int", "psi\\\\$1", "$2", PSI_T_NUMBER}, 
 EOF
index 745fe0c2241a3c6127e9bfd33b9c03b2a59c7be1..3cf8cc286ceb8e8180ed4a6a3d1af1f983b9c8bc 100644 (file)
@@ -10,7 +10,7 @@ EOF
 # Add a pre-defined decl to $PSI_VA_DECLS/$PSI_DECLS.
 psi_add_decl() {
        case "$2" in
- *functor*)
      *functor*)
                cat >>$PSI_FN_DECLS <<EOF
        $1, {0},
 EOF
@@ -125,8 +125,8 @@ AC_DEFUN(PSI_DECL, [
 
        case "$psi_symbol_redirect" in
        "$psi_symbol"|"_$psi_symbol")
-               case "$PHP_DEBUG-$3" in
-               "1-")
+               case "$PSI_EXTRA_REDIRS-$3" in
+               "true-")
                        PSI_MACRO($1, $2, [
                                psi_add_decl "$psi_decl_args"
                        ])
index d26a888774a5a7a2c094ecfeb58a92521620a6d4..35af8a4251e2f19d4a1e464c6264d9dd906cbc3e 100644 (file)
@@ -11,6 +11,14 @@ AC_DEFUN(PSI_MACRO, [
        AC_CHECK_DECL(PSI_VAR_NAME($1)$2, [
                macro_type="PSI_VAR_TYPE($1)"
                macro_name="PSI_VAR_NAME($1)"
+               PSI_TYPE_INDIRECTION([$1],, macro_pointer_level, macro_array_size)
+               if test "$macro_array_size" -gt 0; then
+                       macro_array="@<:@$macro_array_size@:>@"
+                       macro_return="$macro_type*"
+               else
+                       macro_array=""
+                       macro_return="$macro_type"
+               fi
                m4_case([$2],
                        [(void)], [
                                macro_decl="(void)"
@@ -39,24 +47,25 @@ AC_DEFUN(PSI_MACRO, [
                        macro_body="return $macro_name$macro_call;"
                ])
                $3
-               psi_add_macro "$macro_type _psi_${macro_action}_$macro_name$macro_decl { $macro_body }"
+               psi_add_macro "$macro_return _psi_${macro_action}_$macro_name$macro_decl { $macro_body }"
                PSI_REDIR($macro_name, _psi_${macro_action}_$macro_name)
-       ], [], PSI_INCLUDES)
+       ], [], [PSI_INCLUDES])
 ])
 
 dnl PSI_EXTVAR(type var)
 AC_DEFUN(PSI_EXTVAR, [
-       dnl just a getter
        PSI_MACRO($1, [], [
+               dnl just a getter
                PSI_DECL_ARGS($1)
                psi_add_decl "$psi_decl_args"
-               dnl explicit getter & setter
+               dnl explicit getter
                PSI_REDIR([${macro_name}_get], [_psi_get_$macro_name])
-               PSI_DECL_ARGS($1_get)
+               PSI_DECL_ARGS([PSI_VAR_TYPE_RETURN($1) PSI_VAR_NAME($1)_get])
                psi_add_decl "$psi_decl_args"
-               psi_add_macro "void _psi_set_${macro_name}($macro_type value) { memcpy(&$macro_name, &value, sizeof(value)); }"
+               dnl setter
+               psi_add_macro "void _psi_set_${macro_name}($macro_type value$macro_array) { memcpy(&$macro_name, &value, sizeof($macro_type$macro_array)); }"
                PSI_REDIR([${macro_name}_set], [_psi_set_${macro_name}])
-               PSI_DECL_ARGS([void PSI_VAR_NAME($1)_set], [(PSI_VAR_TYPE($1) _v)])
+               PSI_DECL_ARGS([void PSI_VAR_NAME($1)_set], [($1)])
                psi_add_decl "$psi_decl_args"
        ])
 ])
index b5fe39f20978daaf7958e0a33f1c80760dd3af9b..a55e6affcb2741b5dd5955d6ea37c218cb7eb146 100644 (file)
@@ -149,6 +149,10 @@ dnl PSI_VAR_TYPE(decl arg)
 dnl Extracts the type of a decl arg, e.g. dnl unsigned char* buf[16] -> unsigned char*.
 AC_DEFUN(PSI_VAR_TYPE, [m4_bregexp([$1], [^\(const \)?\(.*\) \([*]*\)[^ ]+$], [\2\3])])
 
+dnl PSI_VAR_TYPE_RETURN(decl arg)
+dnl Extracts the type of a decl arg usable for return types, e.g. dnl unsigned char* buf[16] -> unsigned char**.
+AC_DEFUN(PSI_VAR_TYPE_RETURN, [PSI_VAR_TYPE(m4_bpatsubst([$1], [\([^ ]+\) *@<:@[0-9]+@:>@], [* \1]))])
+
 dnl PSI_VAR_NAME(decl arg)
 dnl Extracts the var name of a decl arg, e.g. unsigned char* buf[16] -> buf.
 AC_DEFUN(PSI_VAR_NAME, [m4_bregexp(m4_bregexp([$1], [\([^ ]+\)$], [\1]), [\w+], [\&])])
index fcf1db7c348523bd6a21f02eeb67bdcd8c4ce1fd..ac7fd738c098d2c11bd208a89b4d9108caae985b 100644 (file)
@@ -1,12 +1,12 @@
 function psi\opterr(int $value) : void {
-       let _v = intval($value);
+       let opterr = intval($value);
        return void(opterr_set);
 }
 function psi\optind\get() : int {
        return to_int(optind_get);
 }
 function psi\optind\set(int $v) : void {
-       let _v = intval($v);
+       let optind = intval($v);
        return void(optind_set);
 }
 function psi\optopt() : int {