Support for IRIX-style asctime_r/ctime_r.

This commit is contained in:
Sascha Schumann 2001-05-20 21:29:55 +00:00
parent 7dfce52fdc
commit ff5a9de31d
3 changed files with 49 additions and 7 deletions

View File

@ -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 <time.h>
#include <stdlib.h>
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_TRY_RUN([
#include <time.h>
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
])

View File

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

View File

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