cvs: php4 / acinclude.m4 configure.in reentrancy.c

[email protected] ("Sascha Schumann")
Newsgroups php.version4
Message-ID <cvssas959166418@cvsserver>
sas		Wed May 24 13:06:58 2000 EDT

  Modified files:
    /php4	acinclude.m4 configure.in reentrancy.c 
  Log:
  Support old-style readdir_r()
  
  
Index: php4/acinclude.m4
diff -u php4/acinclude.m4:1.88 php4/acinclude.m4:1.89
--- php4/acinclude.m4:1.88	Wed May 24 01:13:13 2000
+++ php4/acinclude.m4	Wed May 24 13:06:57 2000
@@ -1,12 +1,15 @@
-dnl $Id: acinclude.m4,v 1.88 2000/05/23 23:13:13 sas Exp $
+dnl $Id: acinclude.m4,v 1.89 2000/05/24 11:06:57 sas Exp $
 dnl
 dnl This file contains local autoconf functions.
 
 sinclude(dynlib.m4)
 
-AC_DEFUN(PHP_POSIX_READDIR_R,[
+AC_DEFUN(PHP_READDIR_R_TYPE,[
+  AC_CHECK_FUNCS(readdir_r)
+  if test "$ac_cv_func_readdir_r" = "yes"; then
   AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[
     AC_TRY_RUN([
+#define _REENTRANT
 #include <sys/types.h>
 #include <dirent.h>
 
@@ -24,13 +27,26 @@
     ],[
       ac_cv_what_readdir_r=POSIX
     ],[
-      ac_cv_what_readdir_r=none
+      AC_TRY_CPP([
+#define _REENTRANT
+#include <sys/types.h>
+#include <dirent.h>
+int readdir_r(DIR *, struct dirent *);
+        ],[
+          ac_cv_what_readdir_r=old-style
+        ],[
+          ac_cv_what_readdir_r=none
+      ])
     ],[
       ac_cv_what_readdir_r=none
    ])
   ])
-  if test "$ac_cv_what_readdir_r" = "POSIX"; then
-    AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r])
+    case "$ac_cv_what_readdir_r" in
+    POSIX)
+      AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);;
+    old-style)
+      AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);;
+    esac
   fi
 ])
 
Index: php4/configure.in
diff -u php4/configure.in:1.134 php4/configure.in:1.135
--- php4/configure.in:1.134	Tue May 23 17:13:15 2000
+++ php4/configure.in	Wed May 24 13:06:57 2000
@@ -1,4 +1,4 @@
-dnl ## $Id: configure.in,v 1.134 2000/05/23 15:13:15 sas Exp $ -*- sh -*-
+dnl ## $Id: configure.in,v 1.135 2000/05/24 11:06:57 sas Exp $ -*- sh -*-
 dnl ## Process this file with autoconf to produce a configure script.
 
 divert(1)
@@ -379,7 +379,7 @@
 AC_BROKEN_SPRINTF
 PHP_DECLARED_TIMEZONE
 PHP_TIME_R_TYPE
-PHP_POSIX_READDIR_R
+PHP_READDIR_R_TYPE
 
 dnl AIX keeps in_addr_t in /usr/include/netinet/in.h
 dnl AC_MSG_CHECKING(for in_addr_t)
Index: php4/reentrancy.c
diff -u php4/reentrancy.c:1.17 php4/reentrancy.c:1.18
--- php4/reentrancy.c:1.17	Wed May 24 12:44:57 2000
+++ php4/reentrancy.c	Wed May 24 13:06:57 2000
@@ -99,6 +99,20 @@
 PHPAPI int php_readdir_r(DIR *dirp, struct dirent *entry, 
 		struct dirent **result)
 {
+#if defined(HAVE_OLD_READDIR_R)
+	int ret;
+	
+	errno = 0;
+
+	ret = readdir_r(dirp, entry);
+	
+	if (ret == 0)
+		*result = entry;
+	else
+		*result = NULL;
+
+	return ret;
+#else
 	struct dirent *ptr;
 	int ret = 0;
 
@@ -120,6 +134,7 @@
 	local_unlock(READDIR_R);
 
 	return ret;
+#endif
 }
 
 #endif
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.