]> granicus.if.org Git - php/commitdiff
Support for IRIX-style asctime_r/ctime_r.
authorSascha Schumann <sas@php.net>
Sun, 20 May 2001 21:29:55 +0000 (21:29 +0000)
committerSascha Schumann <sas@php.net>
Sun, 20 May 2001 21:29:55 +0000 (21:29 +0000)
acinclude.m4
main/php_reentrancy.h
main/reentrancy.c

index d627235a2226edea75e701eb3fe7680c47cf017b..1c4b8cc8b692d954bdaf8f66fedcd8855d028a3f 100644 (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_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
 ])
 
index 691392f7c9529740094a3d915a42947adc7eba2a..8e9c674a1437248f105e2943255e4ad16018b2c7 100644 (file)
 #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
index a6a7cc563aae1e5b7fc5775d7619ace20225b94c..d4049ee77da6f95e59ede510c09058a40fc210b5 100644 (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