# -- 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
$(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
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],
])
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], [ ], [ ])
#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
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)
PSI_CHECK_ERRNO() {
- PSI_CONFIG_POSIX(errno, errno.h)
PSI_EXTVAR(int errno)
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)
PSI_CHECK_GLOB() {
- PSI_CONFIG_POSIX(glob, glob.h)
PSI_STRUCT(glob_t, [
size_t gl_pathc,
PSI_CHECK_LOCALE() {
- PSI_CONFIG_POSIX(locale, locale.h xlocale.h)
-
PSI_STRUCT(struct lconv, [
char *currency_symbol,
char *decimal_point,
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,
PSI_CHECK_NETDB() {
- PSI_CONFIG_POSIX(netdb, netdb.h)
PSI_STRUCT(struct hostent, [
char *h_name,
PSI_CHECK_NETINET_IN() {
- PSI_CONFIG_POSIX(netinet/in, netinet/in.h)
PSI_TYPE(in_port_t, uint)
PSI_TYPE(in_addr_t, uint)
PSI_CHECK_NETINET_TCP() {
- PSI_CONFIG_POSIX(netinet/tcp, netinet/tcp.h)
-
PSI_CONST(TCP_NODELAY, int)
}
PSI_CHECK_POLL() {
- PSI_CONFIG_POSIX(poll, poll.h)
PSI_STRUCT(struct pollfd, [
int fd,
PSI_CHECK_SIGNAL() {
- PSI_CONFIG_POSIX(signal, signal.h)
PSI_PTHREAD
PSI_CHECK_STDIO() {
- PSI_CONFIG_POSIX(stdio, stdio.h)
-
PSI_STRUCT(FILE)
PSI_STRUCT(fpos_t)
PSI_CHECK_STDLIB() {
- AC_CHECK_HEADERS(stdlib.h)
-
PSI_STRUCT(div_t, [
int quot,
int rem
PSI_CHECK_SYS_SELECT() {
- PSI_CONFIG_POSIX(sys/select, sys/select.h)
-
PSI_STRUCT(fd_set, [])
PSI_CONST(FD_SETSIZE, int)
PSI_CHECK_SYS_SOCKET() {
- PSI_CONFIG_POSIX(sys/socket, sys/socket.h)
-
PSI_TYPE(socklen_t, int)
PSI_TYPE(sa_family_t, uint)
PSI_CHECK_SYS_STAT() {
- PSI_CONFIG_POSIX(sys/stat, sys/stat.h)
PSI_STRUCT(struct stat, [
dev_t st_dev,
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)
PSI_CHECK_SYS_TIMES() {
- PSI_CONFIG_POSIX(sys/times, sys/times.h)
PSI_STRUCT(struct tms, [
clock_t tms_utime,
PSI_CHECK_SYS_UIO() {
- PSI_CONFIG_POSIX(sys/uio, sys/uio.h)
PSI_STRUCT(struct iovec, [
void *iov_base,
PSI_CHECK_SYS_UTSNAME() {
- PSI_CONFIG_POSIX(sys/utsname, sys/utsname.h)
PSI_STRUCT(struct utsname, [
char sysname@<:@0@:>@,
PSI_CHECK_SYSLOG() {
- PSI_CONFIG_POSIX(syslog, syslog.h)
PSI_CONST(LOG_PID, int)
PSI_CONST(LOG_CONS, int)
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)
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)])
PSI_MACRO(int getdate_err)
PSI_EXTVAR(int daylight)
PSI_EXTVAR(long timezone)
- PSI_EXTVAR(char **tzname)
+ PSI_EXTVAR(char *tzname@<:@2@:>@)
}
PSI_CHECK_UNISTD() {
- PSI_CONFIG_POSIX(unistd, unistd.h)
-
PSI_CONST(F_LOCK, int)
PSI_CONST(F_TEST, int)
PSI_CONST(F_TLOCK, int)
PSI_CHECK_WCHAR() {
- PSI_CONFIG_POSIX(wchar, wchar.h)
PSI_TYPE(wint_t, int)
PSI_STRUCT(mbstate_t)
PSI_CHECK_WCTYPE() {
- PSI_CONFIG_POSIX(wctype, wctype.h)
PSI_TYPE(wctype_t, int)
PSI_TYPE(wctrans_t, int)
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:
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
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"
# 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
# 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
# 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
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"
])
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)"
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"
])
])
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+], [\&])])
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 {