From: Sandeep Patil <sspatil@google.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 4/6] direct_io: diotest4: use getpagesize() for mmap if shm header is absent
Date: Wed, 8 Nov 2017 16:34:36 -0800 [thread overview]
Message-ID: <20171109003438.130802-5-sspatil@google.com> (raw)
In-Reply-To: <20171109003438.130802-1-sspatil@google.com>
For some architectures, mmap(MAP_FIXED) has to be aligned to SHMLBA
(instead of getpagesize()) --
https://sourceforge.net/p/ltp/mailman/ltp-list/?viewmonth=200804
This dependency on SHMLBA causes the test to fail building for Android
due to absence of sys/shm.h. Make the header dependency configurable and
use getpagesize() as mmap granularity if the header is absent allowing
the test to work on Android while not breaking the architectures that
depend on the shm headers.
Signed-off-by: Sandeep Patil <sspatil@google.com>
---
v1->v2
------
- Instead of relying on __BIONIC__, fix by doing a header check for <sys/shm> and
if the header doesn't exist, use getpagesize() as mmap granularity, otherwise
use SHMBA (as before)
configure.ac | 1 +
include/lapi/mmap.h | 8 ++++++++
testcases/kernel/io/direct_io/diotest4.c | 4 ++--
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index ffcbf57c5..16c8e4692 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,6 +47,7 @@ AC_CHECK_HEADERS([ \
sys/fanotify.h \
sys/inotify.h \
sys/prctl.h \
+ sys/shm.h \
sys/ustat.h \
sys/xattr.h \
])
diff --git a/include/lapi/mmap.h b/include/lapi/mmap.h
index 10065a4df..7a5580079 100644
--- a/include/lapi/mmap.h
+++ b/include/lapi/mmap.h
@@ -71,4 +71,12 @@
# define MADV_FREE 8
#endif
+#ifdef HAVE_SYS_SHM_H
+# include <sys/shm.h>
+# define MMAP_GRANULARITY SHMLBA
+#else
+# include <unistd.h>
+# define MMAP_GRANULARITY getpagesize()
+#endif /* HAVE_SYS_SHM_H */
+
#endif /* LAPI_MMAP_H__ */
diff --git a/testcases/kernel/io/direct_io/diotest4.c b/testcases/kernel/io/direct_io/diotest4.c
index dbcacf1ae..e4616e400 100644
--- a/testcases/kernel/io/direct_io/diotest4.c
+++ b/testcases/kernel/io/direct_io/diotest4.c
@@ -65,12 +65,12 @@
#include <sys/mman.h>
#include <sys/syscall.h>
#include <errno.h>
-#include <sys/shm.h>
#include "diotest_routines.h"
#include "test.h"
#include "safe_macros.h"
+#include "lapi/mmap.h"
char *TCID = "diotest4"; /* Test program identifier. */
int TST_TOTAL = 17; /* Total number of test conditions */
@@ -196,7 +196,7 @@ int main(int argc, char *argv[])
int fd, newfd;
int i, l_fail = 0, fail_count = 0, total = 0;
int failed = 0;
- int shmsz = SHMLBA;
+ int shmsz = MMAP_GRANULARITY;
int pagemask = ~(sysconf(_SC_PAGE_SIZE) - 1);
char *buf0, *buf1, *buf2;
caddr_t shm_base;
--
2.15.0.448.gf294e3d99a-goog
next prev parent reply other threads:[~2017-11-09 0:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-09 0:34 [LTP] [PATCH 0/6] Miscellaneous fixes for Android systems Sandeep Patil
2017-11-09 0:34 ` [LTP] [PATCH v2 1/6] syscalls/cma: Make process_vm_{readv, writev} tests bionic friendly Sandeep Patil
2017-11-10 9:14 ` Jan Stancek
2017-11-09 0:34 ` [LTP] [PATCH 2/6] mm: mallocstress: use safe macros wherever possible Sandeep Patil
2017-11-10 9:41 ` Jan Stancek
2017-11-09 0:34 ` [LTP] [PATCH 3/6] mm: mallocstress: use futexes instead of SysV semaphores Sandeep Patil
2017-11-09 0:34 ` Sandeep Patil [this message]
2017-11-10 9:54 ` [LTP] [PATCH v2 4/6] direct_io: diotest4: use getpagesize() for mmap if shm header is absent Jan Stancek
2017-11-09 0:34 ` [LTP] [PATCH 5/6] syscalls/mkdir03: convert to new API and use .needsrofs for EROFS check Sandeep Patil
2017-11-10 11:21 ` Jan Stancek
2017-11-09 0:34 ` [LTP] [PATCH 6/6] lib: mkfs: use 'mke2fs' on android systems for formatting filesystems Sandeep Patil
2017-11-10 14:48 ` Jan Stancek
2017-11-10 19:23 ` Sandeep Patil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171109003438.130802-5-sspatil@google.com \
--to=sspatil@google.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox