[libc-commits] [libc] [libc] fix sysconf (PR #79159)

via libc-commits libc-commits at lists.llvm.org
Tue Jan 23 07:59:24 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

<details>
<summary>Changes</summary>

Reland previous fix for `sysconf`

---
Full diff: https://github.com/llvm/llvm-project/pull/79159.diff


2 Files Affected:

- (modified) libc/src/unistd/linux/CMakeLists.txt (+2) 
- (modified) libc/src/unistd/linux/sysconf.cpp (+3-3) 


``````````diff
diff --git a/libc/src/unistd/linux/CMakeLists.txt b/libc/src/unistd/linux/CMakeLists.txt
index ab9eca19e650834..42190079141b067 100644
--- a/libc/src/unistd/linux/CMakeLists.txt
+++ b/libc/src/unistd/linux/CMakeLists.txt
@@ -402,7 +402,9 @@ add_entrypoint_object(
     ../sysconf.h
   DEPENDS
     libc.include.unistd
+    libc.include.sys_auxv
     libc.src.errno.errno
+    libc.src.sys.auxv.getauxval
 )
 
 add_entrypoint_object(
diff --git a/libc/src/unistd/linux/sysconf.cpp b/libc/src/unistd/linux/sysconf.cpp
index b16e15551fc7889..16ca8e6a27d3ce2 100644
--- a/libc/src/unistd/linux/sysconf.cpp
+++ b/libc/src/unistd/linux/sysconf.cpp
@@ -11,7 +11,8 @@
 #include "src/__support/common.h"
 
 #include "src/errno/libc_errno.h"
-#include <linux/param.h> // For EXEC_PAGESIZE.
+#include "src/sys/auxv/getauxval.h"
+#include <sys/auxv.h>
 #include <unistd.h>
 
 namespace LIBC_NAMESPACE {
@@ -19,8 +20,7 @@ namespace LIBC_NAMESPACE {
 LLVM_LIBC_FUNCTION(long, sysconf, (int name)) {
   long ret = 0;
   if (name == _SC_PAGESIZE) {
-    // TODO: get this information from the auxvector.
-    return EXEC_PAGESIZE;
+    return static_cast<long>(getauxval(AT_PAGESZ));
   }
   // TODO: Complete the rest of the sysconf options.
   if (ret < 0) {

``````````

</details>


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


More information about the libc-commits mailing list