diff options
| author | Sascha Schumann <sas@php.net> | 2002-09-06 10:27:26 +0000 |
|---|---|---|
| committer | Sascha Schumann <sas@php.net> | 2002-09-06 10:27:26 +0000 |
| commit | 702d7afc3cbc8599ca8113c223079d57dfec939a (patch) | |
| tree | 024cc6160d68b5fc415a2f0b2eecb88fa91f952e /acinclude.m4 | |
| parent | 8f14aafe97639984022364afc544565a052ba399 (diff) | |
| download | php-git-702d7afc3cbc8599ca8113c223079d57dfec939a.tar.gz | |
Reenable pwrite/pread support
The old checks supposed that pread/pwrite worked, if a declaration was
found in <unistd.h>. We now actually check whether they work successfully
before using them.
Diffstat (limited to 'acinclude.m4')
| -rw-r--r-- | acinclude.m4 | 106 |
1 files changed, 51 insertions, 55 deletions
diff --git a/acinclude.m4 b/acinclude.m4 index 7da512c2fd..3ebad7a5bb 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -374,80 +374,76 @@ X 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([ +AC_DEFUN(PHP_DOES_PWRITE_WORK,[ + 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 - ]) - ],[ - ac_cv_pread=no - ]) - ]) +$1 + main() { return !(pwrite(open("conftest_in", O_WRONLY|O_CREAT, 0600), "hi", 2, 0) == 2); } + ],[ + ac_cv_pwrite=yes + ],[ + ac_cv_pwrite=no + ],[ + ac_cv_pwrite=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([ +AC_DEFUN(PHP_DOES_PREAD_WORK,[ + echo test > conftest_in + 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 - ]) - ],[ - ac_cv_pwrite=no - ]) +$1 + main() { char buf[3]; return !(pread(open("conftest_in", O_RDONLY), buf, 2, 0) == 2); } + ],[ + ac_cv_pread=yes + ],[ + ac_cv_pread=no + ],[ + ac_cv_pread=no ]) + rm -f conftest_in +]) + +AC_DEFUN(PHP_PWRITE_TEST,[ + AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[ + PHP_DOES_PWRITE_WORK + if test "$ac_cv_pwrite" = "no"; then + PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);]) + if test "$ac_cv_pwrite" = "yes"; then + ac_cv_pwrite=64 + fi + fi ]) + 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_PREAD_TEST,[ + AC_CACHE_CHECK(whether pread works,ac_cv_pread,[ + PHP_DOES_PREAD_WORK + if test "$ac_cv_pread" = "no"; then + PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);]) + if test "$ac_cv_pread" = "yes"; then + ac_cv_pread=64 + fi + fi + ]) + + 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_TIME_R_DECL,[ AC_MSG_CHECKING([for missing declarations of reentrant functions]) AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[ |
