summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2001-05-20 21:29:55 +0000
committerSascha Schumann <sas@php.net>2001-05-20 21:29:55 +0000
commitff5a9de31d886f6b052eedaad28f39a878ec55b4 (patch)
tree7204010e804527cc27aa9a56a17e15457ac21c4f
parent7dfce52fdc73147b783b50e2ef3ff9944b84f02c (diff)
downloadphp-git-ff5a9de31d886f6b052eedaad28f39a878ec55b4.tar.gz
Support for IRIX-style asctime_r/ctime_r.
-rw-r--r--acinclude.m429
-rw-r--r--main/php_reentrancy.h6
-rw-r--r--main/reentrancy.c21
3 files changed, 49 insertions, 7 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index d627235a22..1c4b8cc8b6 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 <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_cv_time_r_type=POSIX
+ 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
])
diff --git a/main/php_reentrancy.h b/main/php_reentrancy.h
index 691392f7c9..8e9c674a14 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 a6a7cc563a..d4049ee77d 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