Support HP-UX 10.x non-standard time-related reentrant functions

This commit is contained in:
Sascha Schumann 2000-03-03 16:10:38 +00:00
parent b053e6422f
commit 3bfe29fddb
3 changed files with 65 additions and 0 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)