bionic: Introduce max_page_size()
This can be used to "page-align" variables at build time -
__attribute__((aligned(max_pge_size()))), so it is a
preprocessor macro instead of an inline function.
There is no functional change to the 4kB-only build targets
(!defined(__BIONIC_NO_PAGE_SIZE_MACRO))
Bug: 296275298
Test: mma
Change-Id: I462e9f971a176b6b59e32e449a2e11f95c3f1b45
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
diff --git a/libc/platform/bionic/page.h b/libc/platform/bionic/page.h
index a75b3ac..15ad4c5 100644
--- a/libc/platform/bionic/page.h
+++ b/libc/platform/bionic/page.h
@@ -32,6 +32,14 @@
#endif
}
+constexpr size_t max_page_size() {
+#if defined(PAGE_SIZE)
+ return PAGE_SIZE;
+#else
+ return 65536;
+#endif
+}
+
// Returns the address of the page containing address 'x'.
inline uintptr_t page_start(uintptr_t x) {
return x & ~(page_size() - 1);