bionic: Use getauxval(AT_PAGESZ) for page agnostic targets
When the C flag -D__BIONIC_NO_PAGE_SIZE_MACRO is defined,
the function getauxval(AT_PAGESZ) will be called instead of
using the PAGE_SIZE macro for the arm64 architectures.
Bug: 277272383
Bug: 289419664
Test: source build/envsetup.sh
lunch aosp_raven_pgagnostic_64-userdebug
m
source build/envsetup.sh
lunch aosp_cf_x86_64_phone
m
Change-Id: Ie904ee5601365abbcf93ee371922a351844eccff
diff --git a/libc/platform/bionic/page.h b/libc/platform/bionic/page.h
index 5f4bb6f..a75b3ac 100644
--- a/libc/platform/bionic/page.h
+++ b/libc/platform/bionic/page.h
@@ -24,16 +24,11 @@
#include <sys/user.h>
inline size_t page_size() {
- /*
- * PAGE_SIZE defines the maximum supported page size. Since 4096 is the
- * minimum supported page size we can just let it be constant folded if it's
- * also the maximum.
- */
-#if PAGE_SIZE == 4096
+#if defined(PAGE_SIZE)
return PAGE_SIZE;
#else
- static size_t size = getauxval(AT_PAGESZ);
- return size;
+ static const size_t page_size = getauxval(PAGE_SIZE);
+ return page_size;
#endif
}