[compiler-rt] [scudo] Add a method to use a hard-coded page size (PR #106646)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 14:27:45 PDT 2024


================
@@ -133,18 +133,39 @@ inline void computePercentage(uptr Numerator, uptr Denominator, uptr *Integral,
 
 // Platform specific functions.
 
+#if defined(SCUDO_PAGE_SIZE)
+
+inline constexpr uptr getPageSizeCached() { return SCUDO_PAGE_SIZE; }
+
+inline constexpr uptr getPageSizeSlow() { return getPageSizeCached(); }
+
+inline constexpr uptr getPageSizeLogCached() {
+  return static_cast<uptr>(__builtin_ctzl(SCUDO_PAGE_SIZE));
+}
+
+#else
+
 extern uptr PageSizeCached;
+extern uptr PageSizeLogCached;
+
 uptr getPageSizeSlow();
+
 inline uptr getPageSizeCached() {
-#if SCUDO_ANDROID && defined(PAGE_SIZE)
-  // Most Android builds have a build-time constant page size.
-  return PAGE_SIZE;
-#endif
   if (LIKELY(PageSizeCached))
     return PageSizeCached;
   return getPageSizeSlow();
 }
 
+inline uptr getPageSizeLogCached() {
+  if (LIKELY(PageSizeLogCached)) {
----------------
ChiaHungDuan wrote:

nit: single statement doesn't need braces

https://github.com/llvm/llvm-project/pull/106646


More information about the llvm-commits mailing list