diff --git a/acinclude.m4 b/acinclude.m4 index d627235a222..1c4b8cc8b69 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -323,7 +323,6 @@ AC_DEFUN(PHP_TIME_R_TYPE,[ AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[ AC_TRY_RUN([ #include -#include main() { char buf[27]; @@ -333,19 +332,37 @@ int r, s; s = gmtime_r(&old, &t); r = (int) asctime_r(&t, buf, 26); -if (r == s && s == 0) exit(0); -exit(1); +if (r == s && s == 0) return (0); +return (1); } ],[ ac_cv_time_r_type=hpux ],[ - ac_cv_time_r_type=POSIX + AC_TRY_RUN([ +#include +main() { + struct tm t, *s; + time_t old = 0; + char buf[27], *p; + + s = gmtime_r(&old, &t); + p = asctime_r(&t, buf, 26); + if (p == buf && s == t) return (0); + return (1); +} + ],[ + ac_cv_time_r_type=irix + ],[ + ac_cv_time_r_type=POSIX + ]) ],[ ac_cv_time_r_type=POSIX ]) ]) -if test "$ac_cv_time_r_type" = "hpux"; then - AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) + case $ac_cv_time_r_type in + hpux) AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;; + irix) AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;; + esac fi ]) diff --git a/main/php_reentrancy.h b/main/php_reentrancy.h index 691392f7c95..8e9c674a143 100644 --- a/main/php_reentrancy.h +++ b/main/php_reentrancy.h @@ -36,8 +36,12 @@ #define HAVE_ASCTIME 1 #define HAVE_CTIME 1 +#if defined(PHP_IRIX_TIME_R) +#undef HAVE_ASCTIME_R +#undef HAVE_CTIME_R +#endif -#ifdef PHP_HPUX_TIME_R +#if defined(PHP_HPUX_TIME_R) #undef HAVE_LOCALTIME_R #undef HAVE_ASCTIME_R #undef HAVE_CTIME_R diff --git a/main/reentrancy.c b/main/reentrancy.c index a6a7cc563aa..d4049ee77da 100644 --- a/main/reentrancy.c +++ b/main/reentrancy.c @@ -56,6 +56,27 @@ static MUTEX_T reentrant_locks[NUMBER_OF_LOCKS]; #endif +#if defined(PHP_IRIX_TIME_R) + +#define HAVE_CTIME_R 1 +#define HAVE_ASCTIME_R 1 + +PHPAPI char *php_ctime_r(const time_t *clock, char *buf) +{ + if (ctime_r(clock, buf, 26) == buf) + return (buf); + return (NULL); +} + +PHPAPI char *php_asctime_r(const struct tm *tm, char *buf) +{ + if (asctime_r(tm, buf, 26) == buf) + return (buf); + return (NULL); +} + +#endif + #if defined(PHP_HPUX_TIME_R) #define HAVE_LOCALTIME_R 1