[libc] [llvm] [libc] add basic arena allocator (PR #121173)
Nick Desaulniers via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 6 15:27:33 PST 2025
================
@@ -0,0 +1,29 @@
+//===-- Implementation of getpagesize -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/unistd/getpagesize.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/page_size.h"
+#include "src/sys/auxv/getauxval.h"
+#include "src/unistd/sysconf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, getpagesize, ()) {
+#if LIBC_PAGE_SIZE == LIBC_PAGE_SIZE_SYSTEM
+ int r = (int)LIBC_NAMESPACE::getauxval(AT_PAGESZ);
+ if (r == 0)
+ return (int)LIBC_NAMESPACE::sysconf(_SC_PAGESIZE);
+ return r;
+#else
+ return LIBC_PAGE_SIZE;
+#endif
----------------
nickdesaulniers wrote:
I don't think we should allow for the user to hardcode their page size for hosted environments.
https://github.com/llvm/llvm-project/pull/121173
More information about the llvm-commits
mailing list