flush
[m6w6/ext-psi] / config.m4
index d372f5d037b81268d376bb349513176b77f4b9ee..647b0a9eb82faa27b7a73a56d7436d9e8006b65f 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -90,9 +90,10 @@ if test "$PHP_PSI" != "no"; then
                        m4_expand([#include <]$1[>])
                )
        ])
-       
+
        psi_type_pair() { # (type, size)
-               local psi_type_lower=`tr A-Z a-z <<<$1`
+               local psi_type_name=`tr -cd A-Za-z <<<$1` 
+               local psi_type_lower=`tr A-Z a-z <<<$psi_type_name`
                case $psi_type_lower in
                int*|uint*)
                        local psi_type_upper=`tr a-z A-Z <<<$1`
@@ -103,11 +104,11 @@ if test "$PHP_PSI" != "no"; then
                        echo "PSI_T_STRUCT, \"$2\""
                        ;;
                *)
-                       echo "PSI_T_NAME, \"$1\""
+                       echo "PSI_T_NAME, \"$psi_type_name\""
                        ;;
                esac
        }
-       
+
        PSI_TYPES=""
        dnl PSI_TYPE(type name, basic type, includes)
        AC_DEFUN(PSI_TYPE, [
@@ -117,9 +118,8 @@ if test "$PHP_PSI" != "no"; then
                        PSI_TYPES="{`psi_type_pair $2 $ac_cv_sizeof_[]$1`, \""$1"\"}, $PSI_TYPES"
                fi
        ])
-       
 
-       PSI_CONSTS=""
+
        dnl PSI_COMPUTE_STR(variable, string or expression, includes)
        AC_DEFUN(PSI_COMPUTE_STR, [
                AC_TRY_RUN([
@@ -131,10 +131,12 @@ if test "$PHP_PSI" != "no"; then
                        eval $1=\\\"`cat conftest.out`\\\"
                ])
        ])
-       
+
+       PSI_CONSTS=""
        dnl PSI_CONST(const name, type, headers to include)
        AC_DEFUN(PSI_CONST, [
                AC_CACHE_CHECK(value of $1, psi_cv_const_$1, [
+                       psi_const_val=
                        case $2 in
                        str*|quoted_str*)
                                if test "$cross_compiling" = "yes"
@@ -154,10 +156,10 @@ if test "$PHP_PSI" != "no"; then
                then
                        case $2 in
                        str*|quoted_str*)
-                               PSI_CONSTS="{PSI_T_STRING, \"string\", \"$1\", $psi_cv_const_$1, PSI_T_QUOTED_STRING}, $PSI_CONSTS"
+                               PSI_CONSTS="{PSI_T_STRING, \"string\", \"psi\\\\$1\", $psi_cv_const_$1, PSI_T_QUOTED_STRING}, $PSI_CONSTS"
                                ;;
                        *)
-                               PSI_CONSTS="{PSI_T_INT, \"int\", \"$1\", \"$psi_cv_const_$1\", PSI_T_NUMBER}, $PSI_CONSTS"
+                               PSI_CONSTS="{PSI_T_INT, \"int\", \"psi\\\\$1\", \"$psi_cv_const_$1\", PSI_T_NUMBER}, $PSI_CONSTS"
                                ;;
                        esac
                fi
@@ -191,38 +193,50 @@ if test "$PHP_PSI" != "no"; then
                AC_DEFINE_UNQUOTED(
                        AS_TR_CPP(offsetof_$1_$2),
                        $AS_TR_SH([ac_cv_offsetof_$1_$2]),
-                       [The offset of `$1' in `$2', as computed by offsetof.]
+                       [The offset of `$2' in `$1', as computed by offsetof.]
                )
        ])
 
        dnl PSI_STRUCT(name, members, member type cases, includes)
        PSI_STRUCTS=
        AC_DEFUN(PSI_STRUCT, [
+               AC_CHECK_SIZEOF(struct $1, [], PSI_INCLUDES_DEFAULT($4))
+               psi_struct_size=$ac_cv_sizeof_struct_$1
                psi_struct_members=
                m4_foreach(member, [$2], [
                        AC_CHECK_MEMBER(struct $1.member, [
-                               case member in
-                               $3
-                               *) psi_member_type=int ;;
-                               esac
+                               psi_member_name=member
                                AC_CHECK_SIZEOF(struct_$1[_]member, [], PSI_INCLUDES_DEFAULT($4,
                                        [#define struct_$1_]member ((struct $1 *)0)->member
                                ))
+                               psi_member_size=$ac_cv_sizeof_struct_$1[]_[]member
                                PSI_CHECK_OFFSETOF(struct $1, member, PSI_INCLUDES_DEFAULT($4))
+                               psi_member_offset=$ac_cv_offsetof_struct_$1[]_[]member
+                               # type
+                               case member in
+                               $3
+                               *) psi_member_type=int ;;
+                               esac
                                # pointer level
                                psi_struct_member_pl=`echo $psi_member_type | tr -cd '*' | wc -c`
                                # array size
-                               psi_struct_member_as=`echo $psi_member_type | $AWK -F'\x5b\x5d\x5b\x5d' 'END {print 0} /\\x5b\x5b\x5b:digit:\x5d\x5d+\\x5d/ {print$[]2; exit}'`
+                               psi_struct_member_as=`echo $psi_member_type | $AWK -F'\x5b\x5d\x5b\x5d' 'END {if(!found)print 0} /\\x5b\x5b\x5b:digit:\x5d\x5d+\\x5d/ {found=1; print$[]2}'`
                                if test $psi_struct_member_as -gt 0
                                then
                                        psi_struct_member_pl=`expr $psi_struct_member_pl + 1`
                                fi
-                               psi_struct_members="{`psi_type_pair $psi_member_type $ac_cv_sizeof_struct_$1[]_[]member`, \"[]member[]\", $ac_cv_offsetof_struct_$1[]_[]member, $ac_cv_sizeof_struct_$1[]_[]member, $psi_struct_member_pl, $psi_struct_member_as}, $psi_struct_members"
+                               psi_struct_member="{`psi_type_pair $psi_member_type $psi_member_size`, \"$psi_member_name\", $psi_member_offset, $psi_member_size, $psi_struct_member_pl, $psi_struct_member_as}"
+                               if test "$psi_struct_members"
+                               then
+                                       psi_struct_members="$psi_struct_members, $psi_struct_member"
+                               else
+                                       psi_struct_members="$psi_struct_member"
+                               fi
                        ], [], PSI_INCLUDES_DEFAULT($4))
                ])
-               PSI_STRUCTS="{\"$1\", {$psi_struct_members}}, $PSI_STRUCTS"
+               PSI_STRUCTS="{\"$1\", $psi_struct_size, {$psi_struct_members}}, $PSI_STRUCTS"
        ])
-       
+
        AC_TYPE_INT8_T
        AC_CHECK_ALIGNOF(int8_t)
        AC_TYPE_UINT8_T
@@ -247,7 +261,7 @@ if test "$PHP_PSI" != "no"; then
        PSI_TYPE(float)
        PSI_TYPE(double)
        PSI_TYPE(void *)
-       
+
        dnl stdint.h
        PSI_TYPE(int_least8_t, int)
        PSI_TYPE(int_least16_t, int)
@@ -269,7 +283,7 @@ if test "$PHP_PSI" != "no"; then
        PSI_TYPE(uintptr_t, uint)
        PSI_TYPE(intmax_t, int)
        PSI_TYPE(uintmax_t, uint)
-       
+
        PSI_CONST(INT8_MIN, int)
        PSI_CONST(INT8_MAX, int)
        PSI_CONST(UINT8_MAX, int)
@@ -308,7 +322,7 @@ if test "$PHP_PSI" != "no"; then
        PSI_CONST(INT_FAST64_MIN, int)
        PSI_CONST(INT_FAST64_MAX, int)
        PSI_CONST(UINT_FAST64_MAX, int)
-       
+
        PSI_CONST(INTPTR_MIN, int)
        PSI_CONST(INTPTR_MAX, int)
        PSI_CONST(UINTPTR_MAX, int)
@@ -351,25 +365,73 @@ if test "$PHP_PSI" != "no"; then
        PSI_CONST(MB_CUR_MAX, int)
        dnl sys/stat.h
        PSI_STRUCT(stat, [
-               [st_dev], 
-               [st_ino], 
-               [st_mode], 
-               [st_nlink], 
-               [st_uid], 
-               [st_gid], 
-               [st_rdev], 
-               [st_size], 
-               [st_atim], 
-               [st_mtim], 
-               [st_ctim], 
-               [st_blksize], 
-               [st_blocks]], [
+               [st_dev],
+               [st_ino],
+               [st_mode],
+               [st_nlink],
+               [st_uid],
+               [st_gid],
+               [st_rdev],
+               [st_size],
+               [st_atim], [st_atimespec],
+               [st_mtim], [st_mtimespec],
+               [st_ctim], [st_ctimespec],
+               [st_birthtimespec],
+               [st_blksize],
+               [st_blocks],
+               [st_flags],
+               [st_gen]], [
                st_?tim) psi_member_type="struct timespec" ;;
+               st_*timespec) psi_member_type="struct timespec" ;;
        ], sys/stat.h)
+       PSI_CONST(S_IFMT, int, sys/stat.h)
+       PSI_CONST(S_IFBLK, int, sys/stat.h)
+       PSI_CONST(S_IFCHR, int, sys/stat.h)
+       PSI_CONST(S_IFIFO, int, sys/stat.h)
+       PSI_CONST(S_IFREG, int, sys/stat.h)
+       PSI_CONST(S_IFDIR, int, sys/stat.h)
+       PSI_CONST(S_IFLNK, int, sys/stat.h)
+       PSI_CONST(S_IFSOCK, int, sys/stat.h)
+       PSI_CONST(S_IRWXU, int, sys/stat.h)
+       PSI_CONST(S_IRUSR, int, sys/stat.h)
+       PSI_CONST(S_IWUSR, int, sys/stat.h)
+       PSI_CONST(S_IXUSR, int, sys/stat.h)
+       PSI_CONST(S_IRWXG, int, sys/stat.h)
+       PSI_CONST(S_IRGRP, int, sys/stat.h)
+       PSI_CONST(S_IWGRP, int, sys/stat.h)
+       PSI_CONST(S_IXGRP, int, sys/stat.h)
+       PSI_CONST(S_IRWXO, int, sys/stat.h)
+       PSI_CONST(S_IROTH, int, sys/stat.h)
+       PSI_CONST(S_IWOTH, int, sys/stat.h)
+       PSI_CONST(S_IXOTH, int, sys/stat.h)
+       PSI_CONST(S_ISUID, int, sys/stat.h)
+       PSI_CONST(S_ISGID, int, sys/stat.h)
+       PSI_CONST(UTIME_NOW, int, sys/stat.h)
+       PSI_CONST(UTIME_OMIT, int, sys/stat.h)
        dnl sys/time.h
+       PSI_STRUCT(timeval, [
+               [tv_sec],
+               [tv_usec]], [
+       ], sys/time.h)
+       PSI_STRUCT(itimerval, [
+               [it_interval],
+               [it_value]], [
+               it_*) psi_member_type="struct timeval" ;;
+       ], sys/time.h)
+       PSI_STRUCT(timezone, [
+               [tz_minuteswest],
+               [tz_dsttime]], [
+       ], sys/time.h)
        PSI_CONST(ITIMER_REAL, int, sys/time.h)
        PSI_CONST(ITIMER_VIRTUAL, int, sys/time.h)
        PSI_CONST(ITIMER_PROF, int, sys/time.h)
+       dnl sys/times.h
+       PSI_STRUCT(tms, [
+               [tms_utime],
+               [tms_stime],
+               [tms_cutime],
+               [tms_cstime]], [
+       ], sys/times.h)
        dnl sys/types.h
        PSI_TYPE(blkcnt_t, int)
        PSI_TYPE(blksize_t, int)
@@ -391,7 +453,38 @@ if test "$PHP_PSI" != "no"; then
        PSI_TYPE(time_t, int)
        PSI_TYPE(timer_t, int)
        PSI_TYPE(uid_t)
-       
+       dnl sys/utsname.h
+       PSI_STRUCT(utsname, [
+               [sysname],
+               [nodename],
+               [release],
+               [version],
+               [machine],
+               [domainname]], [
+               *) psi_member_type="char@<:@$psi_member_size@:>@" ;;
+       ], sys/utsname.h)
+       dnl time.h
+       PSI_STRUCT(tm, [
+               [tm_sec],
+               [tm_min],
+               [tm_hour],
+               [tm_mday],
+               [tm_mon],
+               [tm_year],
+               [tm_wday],
+               [tm_yday],
+               [tm_isdst]], [
+       ], time.h)
+       PSI_STRUCT(timespec, [
+               [tv_sec],
+               [tv_nsec]], [
+       ], time.h)
+       PSI_CONST(CLOCKS_PER_SEC, int, time.h)
+       PSI_CONST(CLOCK_MONOTONIC, int, time.h)
+       PSI_CONST(CLOCK_PROCESS_CPUTIME_ID, int, time.h)
+       PSI_CONST(CLOCK_REALTIME, int, time.h)
+       PSI_CONST(CLOCK_THREAD_CPUTIME_ID, int, time.h)
+       PSI_CONST(TIMER_ABSTIME, int, time.h)
        dnl wchar.h
        AC_CHECK_TYPE(wint_t, [
                AX_CHECK_SIGN(wint_t, psi_wint_t=int, psi_wint_t=uint)
@@ -403,7 +496,7 @@ if test "$PHP_PSI" != "no"; then
                AC_INCLUDES_DEFAULT()
                #include <wchar.h>
        ])
-       
+
 
        AC_DEFINE_UNQUOTED(PHP_PSI_TYPES, $PSI_TYPES, Predefined types)
        AC_DEFINE_UNQUOTED(PHP_PSI_CONSTS, $PSI_CONSTS, Predefined constants)
@@ -416,7 +509,7 @@ if test "$PHP_PSI" != "no"; then
        PHP_ADD_BUILD_DIR($PHP_PSI_BUILDDIR/src)
 
        PHP_PSI_HEADERS=`(cd $PHP_PSI_SRCDIR/src && echo *.h)`
-       PHP_PSI_SOURCES="src/parser_proc.c src/parser.c src/validator.c src/module.c src/context.c"
+       PHP_PSI_SOURCES="src/parser_proc.c src/parser.c src/module.c src/context.c"
        PHP_PSI_SOURCES="$PHP_PSI_SOURCES src/libjit.c src/libffi.c"
 
        PHP_NEW_EXTENSION(psi, $PHP_PSI_SOURCES, $ext_shared)