diff options
author | Sascha Schumann <sas@php.net> | 2000-03-03 16:10:38 +0000 |
---|---|---|
committer | Sascha Schumann <sas@php.net> | 2000-03-03 16:10:38 +0000 |
commit | 3bfe29fddbdd2817889a25bbec89fd8c7caa0db0 (patch) | |
tree | 7817149d0d639705db119690d88a09babf570005 | |
parent | b053e6422fee27acae2fc5888890525bbc6a2298 (diff) | |
download | php-git-3bfe29fddbdd2817889a25bbec89fd8c7caa0db0.tar.gz |
Support HP-UX 10.x non-standard time-related reentrant functions
-rw-r--r-- | acinclude.m4 | 29 | ||||
-rw-r--r-- | configure.in | 1 | ||||
-rw-r--r-- | main/reentrancy.c | 35 |
3 files changed, 65 insertions, 0 deletions
diff --git a/acinclude.m4 b/acinclude.m4 index 97ec99c09a..0d0b898f4d 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -2,6 +2,35 @@ dnl $Id$ dnl dnl This file contains local autoconf functions. +AC_DEFUN(PHP_TIME_R_TYPE,[ +AC_CACHE_CHECK(for time_r type, ac_cv_time_r_type,[ +AC_TRY_RUN([ +#include <time.h> + +main() { +char buf[27]; +struct tm t; +time_t old = 0; +int r; + +gmtime_r(&old, &t); +r = (int) asctime_r(&t, buf, 26); +if (r == -1 || (r > 0 && r <= 26)) exit(0); +exit(1); +} +],[ + ac_cv_time_r_type=hpux +],[ + ac_cv_time_r_type=normal +],[ + ac_cv_time_r_type=normal +]) +]) +if test "$ac_cv_time_r_type" = "hpux"; then + AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-SUX 10.x]) +fi +]) + AC_DEFUN(PHP_SUBST,[ PHP_VAR_SUBST="$PHP_VAR_SUBST $1" AC_SUBST($1) diff --git a/configure.in b/configure.in index edae80e588..2e48cb960c 100644 --- a/configure.in +++ b/configure.in @@ -340,6 +340,7 @@ AC_FUNC_UTIME_NULL AC_FUNC_ALLOCA AC_BROKEN_SPRINTF PHP_DECLARED_TIMEZONE +PHP_TIME_R_TYPE dnl AIX keeps in_addr_t in /usr/include/netinet/in.h dnl AC_MSG_CHECKING(for in_addr_t) diff --git a/main/reentrancy.c b/main/reentrancy.c index f02522f720..c1d1e7400b 100644 --- a/main/reentrancy.c +++ b/main/reentrancy.c @@ -46,7 +46,42 @@ static MUTEX_T reentrant_locks[NUMBER_OF_LOCKS]; #endif +#if defined(PHP_HPUX_TIME_R) +PHPAPI struct tm *localtime_r(const time_t *const timep, struct tm *p_tm) +{ +#undef localtime_r + if (localtime_r(timep, p_tm) == 0) + return (p_tm); + return (NULL); +} + +PHPAPI char *ctime_r(const time_t *clock, char *buf) +{ +#undef ctime_r + if (ctime_r(clock, buf, 26) != -1) + return (buf); + return (NULL); +} + +PHPAPI char *asctime_r(const struct tm *tm, char *buf) +{ +#undef asctime_r + if (asctime_r(tm, buf, 26) != -1) + return (buf); + return (NULL); +} + +PHPAPI struct tm *gmtime_r(const time_t *const timep, struct tm *p_tm) +{ +#undef gmtime_r + if (gmtime_r(timep, p_tm) == 0) + return (p_tm); + return (NULL); +} + +#endif + #if !defined(HAVE_LOCALTIME_R) && defined(HAVE_LOCALTIME) PHPAPI struct tm *localtime_r(const time_t *const timep, struct tm *p_tm) |