From 53fd425a6a0843a5de0a8c544901fbf01246ed31 Mon Sep 17 00:00:00 2001 From: Howard Pritchard Date: Mon, 2 Mar 2015 15:33:49 -0800 Subject: [PATCH] romio: patches from Rob Latham for issue #255 Patches supplied by Rob Latham which fix issue #255. See http://git.mpich.org/mpich.git/commit/4e80e1d2b9 http://git.mpich.org/mpich.git/commit/5a10283bf7fd Signed-off-by: Howard Pritchard --- .../romio/adio/ad_lustre/ad_lustre_rwcontig.c | 5 ---- ompi/mca/io/romio/romio/adio/ad_xfs/ad_xfs.h | 5 ---- ompi/mca/io/romio/romio/adio/common/ad_read.c | 5 ---- .../mca/io/romio/romio/adio/common/ad_write.c | 5 ---- ompi/mca/io/romio/romio/adio/common/utils.c | 30 ++++++++++++++++++- ompi/mca/io/romio/romio/adio/include/adioi.h | 7 +++++ ompi/mca/io/romio/romio/configure.ac | 8 +++++ 7 files changed, 44 insertions(+), 21 deletions(-) diff --git a/ompi/mca/io/romio/romio/adio/ad_lustre/ad_lustre_rwcontig.c b/ompi/mca/io/romio/romio/adio/ad_lustre/ad_lustre_rwcontig.c index 5f1c2321ed..cb187a39e9 100644 --- a/ompi/mca/io/romio/romio/adio/ad_lustre/ad_lustre_rwcontig.c +++ b/ompi/mca/io/romio/romio/adio/ad_lustre/ad_lustre_rwcontig.c @@ -8,11 +8,6 @@ * Copyright (C) 2008 Sun Microsystems, Lustre group */ -#ifdef _STDC_C99 -#define _XOPEN_SOURCE 600 -#else -#define _XOPEN_SOURCE 500 -#endif #include #include diff --git a/ompi/mca/io/romio/romio/adio/ad_xfs/ad_xfs.h b/ompi/mca/io/romio/romio/adio/ad_xfs/ad_xfs.h index 1a4d4ccc1b..d14858d4aa 100644 --- a/ompi/mca/io/romio/romio/adio/ad_xfs/ad_xfs.h +++ b/ompi/mca/io/romio/romio/adio/ad_xfs/ad_xfs.h @@ -8,11 +8,6 @@ #ifndef AD_XFS_INCLUDE #define AD_XFS_INCLUDE -#ifdef _STDC_C99 -#define _XOPEN_SOURCE 600 -#else -#define _XOPEN_SOURCE 500 -#endif #include #include #include diff --git a/ompi/mca/io/romio/romio/adio/common/ad_read.c b/ompi/mca/io/romio/romio/adio/common/ad_read.c index 544ccf41f3..19f2908614 100644 --- a/ompi/mca/io/romio/romio/adio/common/ad_read.c +++ b/ompi/mca/io/romio/romio/adio/common/ad_read.c @@ -6,11 +6,6 @@ */ -#ifdef _STDC_C99 -#define _XOPEN_SOURCE 600 -#else -#define _XOPEN_SOURCE 500 -#endif #include #include "adio.h" diff --git a/ompi/mca/io/romio/romio/adio/common/ad_write.c b/ompi/mca/io/romio/romio/adio/common/ad_write.c index ad318e4117..34a31d963f 100644 --- a/ompi/mca/io/romio/romio/adio/common/ad_write.c +++ b/ompi/mca/io/romio/romio/adio/common/ad_write.c @@ -6,11 +6,6 @@ */ -#ifdef _STDC_C99 -#define _XOPEN_SOURCE 600 -#else -#define _XOPEN_SOURCE 500 -#endif #include #include "adio.h" diff --git a/ompi/mca/io/romio/romio/adio/common/utils.c b/ompi/mca/io/romio/romio/adio/common/utils.c index 98142208da..e8cc6ae109 100644 --- a/ompi/mca/io/romio/romio/adio/common/utils.c +++ b/ompi/mca/io/romio/romio/adio/common/utils.c @@ -8,7 +8,6 @@ #include #include - /* utility function for creating large contiguous types: algorithim from BigMPI * https://github.com/jeffhammond/BigMPI */ @@ -78,6 +77,35 @@ int ADIOI_Type_create_hindexed_x(int count, 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 +#include + +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 */ diff --git a/ompi/mca/io/romio/romio/adio/include/adioi.h b/ompi/mca/io/romio/romio/adio/include/adioi.h index cb9560ce91..eb8efd0fb7 100644 --- a/ompi/mca/io/romio/romio/adio/include/adioi.h +++ b/ompi/mca/io/romio/romio/adio/include/adioi.h @@ -1046,3 +1046,10 @@ void *ADIOI_IO_Thread_Func(void *vptr_args); #endif + +#if (HAVE_DECL_PWRITE == 0) +#include +#include +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 diff --git a/ompi/mca/io/romio/romio/configure.ac b/ompi/mca/io/romio/romio/configure.ac index 8570948352..0c56647035 100644 --- a/ompi/mca/io/romio/romio/configure.ac +++ b/ompi/mca/io/romio/romio/configure.ac @@ -1477,6 +1477,14 @@ if test "$ac_cv_header_unistd_h" = "yes" ; then 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,