]> granicus.if.org Git - php/commitdiff
Add support for systems where p{read|write} take a off64_t without
authorSascha Schumann <sas@php.net>
Sun, 20 May 2001 23:39:09 +0000 (23:39 +0000)
committerSascha Schumann <sas@php.net>
Sun, 20 May 2001 23:39:09 +0000 (23:39 +0000)
being properly prototyped.

acinclude.m4
ext/session/config.m4
main/php.h

index e084f29fe6ea5556acdcc6c29234baeef92b64bf..3d561c71d20385dc1c2633d76a2d6ed5e56e325e 100644 (file)
@@ -188,7 +188,77 @@ X
     (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1
     rm -fr conftest*
 ])
-       
+
+AC_DEFUN(PHP_MISSING_PREAD_DECL,[
+  AC_CACHE_CHECK(whether pread works without custom declaration,ac_cv_pread,[
+  AC_TRY_COMPILE([#include <unistd.h>],[size_t (*func)() = pread],[
+    ac_cv_pread=yes
+  ],[
+    echo test > conftest_in
+    AC_TRY_RUN([
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+      main() { char buf[3]; return !(pread(open("conftest_in", O_RDONLY), buf, 2, 0) == 2); }
+    ],[
+      ac_cv_pread=yes
+    ],[
+      echo test > conftest_in
+      AC_TRY_RUN([
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+        ssize_t pread(int, void *, size_t, off64_t);
+        main() { char buf[3]; return !(pread(open("conftest_in", O_RDONLY), buf, 2, 0) == 2); }
+      ],[
+        ac_cv_pread=64
+      ],[
+        ac_cv_pread=no
+      ])
+    ])
+  ])
+  ])
+  case $ac_cv_pread in
+  no) ac_cv_func_pread=no;;
+  64) AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default]);;
+  esac
+])
+
+AC_DEFUN(PHP_MISSING_PWRITE_DECL,[
+  AC_CACHE_CHECK(whether pwrite works without custom declaration,ac_cv_pwrite,[
+  AC_TRY_COMPILE([#include <unistd.h>],[size_t (*func)() = pwrite],[
+    ac_cv_pwrite=yes
+  ],[
+    AC_TRY_RUN([
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+      main() { return !(pwrite(open("conftest_out", O_WRONLY|O_CREAT, 0600), "Ok", 2, 0) == 2); }
+    ],[
+      ac_cv_pwrite=yes
+    ],[
+      AC_TRY_RUN([
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+        ssize_t pwrite(int, void *, size_t, off64_t);
+        main() { return !(pwrite(open("conftest_out", O_WRONLY|O_CREAT, 0600), "Ok", 2, 0) == 2); }
+      ],[
+        ac_cv_pwrite=64
+      ],[
+        ac_cv_pwrite=no
+      ])
+    ])
+  ])
+  ])
+  case $ac_cv_pwrite in
+  no) ac_cv_func_pwrite=no;;
+  64) AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default]);;
+  esac
+])
+
 AC_DEFUN(PHP_MISSING_TIME_R_DECL,[
   AC_MSG_CHECKING(for missing declarations of reentrant functions)
   AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[
index 29c52dce6eaf84213e5571861f3d8671ad4a3514..74c77414f78664be41faa80140d3c3109a5cb051 100644 (file)
@@ -32,6 +32,8 @@ fi
 
 if test "$PHP_SESSION" != "no"; then
   AC_CHECK_FUNCS(pread pwrite)
+  PHP_MISSING_PWRITE_DECL
+  PHP_MISSING_PREAD_DECL
   PHP_EXTENSION(session,$ext_shared)
   PHP_SUBST(SESSION_SHARED_LIBADD)
 fi
index f8877267463f0d7122e12da7e6bf242e09166d93..533d39ae1c41fd55384b3956085e2b41de597565 100644 (file)
@@ -238,6 +238,14 @@ extern char **environ;
 #define php_sleep sleep
 #endif
 
+#ifdef PHP_PWRITE_64
+ssize_t pwrite(int, void *, size_t, off64_t);
+#endif
+
+#ifdef PHP_PREAD_64
+ssize_t pread(int, void *, size_t, off64_t);
+#endif
+
 void phperror(char *error);
 PHPAPI int php_write(void *buf, uint size);
 PHPAPI int php_printf(const char *format, ...);