[libc-commits] [libc] [libc] fix sysconf test for rv32 (PR #162685)

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Thu Oct 9 09:53:20 PDT 2025


================
@@ -90,7 +91,7 @@ LIBC_INLINE void Vector::fallback_initialize_unsync() {
                                      PROT_READ | PROT_WRITE,
                                      MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   // We do not proceed if mmap fails.
-  if (mmap_ret <= 0)
+  if (mmap_ret <= 0 && mmap_ret > -EXEC_PAGESIZE)
----------------
SchrodingerZhu wrote:

https://github.com/llvm/llvm-project/blob/ec15cdfb328c504298d0ab14e287448804e6bea5/libc/src/sys/mman/linux/mmap.cpp#L2

So the original mmap.cpp always have this check logic.

However, I read the comment again and the argument looks suspicious. `EXEC_PAGESIZE` is not always the page size in general. 

Inside linux kernel, the logic is defined in https://elixir.bootlin.com/linux/v6.17.1/source/tools/include/linux/err.h#L33.

I think the checking logic should be provided as a common function and used in both cases.

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


More information about the libc-commits mailing list