Commit 4e80e1d2 authored by Rob Latham's avatar Rob Latham Committed by Kenneth Raffenetti
Browse files

check for avialablity of pwrite



We can test at configure-time if pread/pwrite is available.
XOPEN_SOURCE set low enough will not provide this feature, for example
(as is the case with --enable-strict).
Signed-off-by: Kenneth Raffenetti's avatarKen Raffenetti <raffenet@mcs.anl.gov>
parent a8137ff9
...@@ -105,6 +105,35 @@ int ADIOI_Type_create_hindexed_x(int count, ...@@ -105,6 +105,35 @@ int ADIOI_Type_create_hindexed_x(int count,
return ret; return ret;
} }
/* some systems do not have pread/pwrite, or requrie XOPEN_SOURCE set higher
* than we would like. see #1973 */
#if (HAVE_DECL_PWRITE == 0)
#include <sys/types.h>
#include <unistd.h>
ssize_t pread(int fd, void *buf, size_t count, off_t offset);
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
ssize_t pread(int fd, void *buf, size_t count, off_t offset) {
off_t lseek_ret;
lseek_ret = lseek(fd, offset, SEEK_SET);
if (lseek_ret == -1)
return lseek_ret;
return (read(fd, buf, count));
}
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) {
off_t lseek_ret;
lseek_ret = lseek(fd, offset, SEEK_SET);
if (lseek_ret == -1)
return lseek_ret;
return (write(fd, buf, count));
}
#endif
/* /*
* vim: ts=8 sts=4 sw=4 noexpandtab * vim: ts=8 sts=4 sw=4 noexpandtab
*/ */
...@@ -1044,3 +1044,10 @@ void *ADIOI_IO_Thread_Func(void *vptr_args); ...@@ -1044,3 +1044,10 @@ void *ADIOI_IO_Thread_Func(void *vptr_args);
#endif #endif
#if (HAVE_DECL_PWRITE == 0)
#include <sys/types.h>
#include <unistd.h>
ssize_t pread(int fd, void *buf, size_t count, off_t offset);
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
#endif
...@@ -1414,6 +1414,14 @@ if test "$ac_cv_header_unistd_h" = "yes" ; then ...@@ -1414,6 +1414,14 @@ if test "$ac_cv_header_unistd_h" = "yes" ; then
fi fi
fi fi
# pread and pwrite are useful to ROMIO: if implemented well, they help us avoid
# an extra system call. But --enable-strict or CFLAGS="--std=c99" does not
# expose this feature. If we define XOPEN_SOURCE in ROMIO, we cause headaches
# for some versions of lustre, quota.h, and caddr_t. see if we need to provide
# our own pread/pwrite
AC_CHECK_DECLS([pwrite])
#################################################################### ####################################################################
# We're about to mess with CC etc. No more feature tests past here, # We're about to mess with CC etc. No more feature tests past here,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment