summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2019-01-12 00:09:24 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2019-01-12 00:09:24 +0000
commit0df20e893f295ca16fded1b96167a490344a728d (patch)
tree2f9e17bec8d2b6981ed6c596539729a27f9ae01e
parent5be959c88ed297705b0ec1debaf7ccaa8dfe0db8 (diff)
downloadbcm5719-llvm-0df20e893f295ca16fded1b96167a490344a728d.tar.gz
bcm5719-llvm-0df20e893f295ca16fded1b96167a490344a728d.zip
[sanitizer] Move android's GetPageSize to a header (NFC)
No need to pay function call overhead for a function that returns a constant. llvm-svn: 350983
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common.h10
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_linux.cc7
2 files changed, 13 insertions, 4 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index 3e54ca435f3..d0aebd99412 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -61,6 +61,15 @@ INLINE int Verbosity() {
return atomic_load(&current_verbosity, memory_order_relaxed);
}
+#if SANITIZER_ANDROID
+INLINE uptr GetPageSize() {
+// Android post-M sysconf(_SC_PAGESIZE) crashes if called from .preinit_array.
+ return 4096;
+}
+INLINE uptr GetPageSizeCached() {
+ return 4096;
+}
+#else
uptr GetPageSize();
extern uptr PageSizeCached;
INLINE uptr GetPageSizeCached() {
@@ -68,6 +77,7 @@ INLINE uptr GetPageSizeCached() {
PageSizeCached = GetPageSize();
return PageSizeCached;
}
+#endif
uptr GetMmapGranularity();
uptr GetMaxVirtualAddress();
uptr GetMaxUserVirtualAddress();
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
index 836c0247150..48795674c54 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
@@ -1077,11 +1077,9 @@ uptr GetMaxUserVirtualAddress() {
return addr;
}
+#if !SANITIZER_ANDROID
uptr GetPageSize() {
-// Android post-M sysconf(_SC_PAGESIZE) crashes if called from .preinit_array.
-#if SANITIZER_ANDROID
- return 4096;
-#elif SANITIZER_LINUX && (defined(__x86_64__) || defined(__i386__))
+#if SANITIZER_LINUX && (defined(__x86_64__) || defined(__i386__))
return EXEC_PAGESIZE;
#elif SANITIZER_USE_GETAUXVAL
return getauxval(AT_PAGESZ);
@@ -1097,6 +1095,7 @@ uptr GetPageSize() {
return sysconf(_SC_PAGESIZE); // EXEC_PAGESIZE may not be trustworthy.
#endif
}
+#endif // !SANITIZER_ANDROID
#if !SANITIZER_OPENBSD
uptr ReadBinaryName(/*out*/char *buf, uptr buf_len) {
OpenPOWER on IntegriCloud