Skip to content

Commit 0cf20c2

Browse files
[libc] fix sysconf (#79159)
Apply previously discussed fix for `sysconf`
1 parent cb528ec commit 0cf20c2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

libc/src/unistd/linux/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,9 @@ add_entrypoint_object(
402402
../sysconf.h
403403
DEPENDS
404404
libc.include.unistd
405+
libc.include.sys_auxv
405406
libc.src.errno.errno
407+
libc.src.sys.auxv.getauxval
406408
)
407409

408410
add_entrypoint_object(

libc/src/unistd/linux/sysconf.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
#include "src/__support/common.h"
1212

1313
#include "src/errno/libc_errno.h"
14-
#include <linux/param.h> // For EXEC_PAGESIZE.
14+
#include "src/sys/auxv/getauxval.h"
15+
#include <sys/auxv.h>
1516
#include <unistd.h>
1617

1718
namespace LIBC_NAMESPACE {
1819

1920
LLVM_LIBC_FUNCTION(long, sysconf, (int name)) {
2021
long ret = 0;
21-
if (name == _SC_PAGESIZE) {
22-
// TODO: get this information from the auxvector.
23-
return EXEC_PAGESIZE;
24-
}
22+
if (name == _SC_PAGESIZE)
23+
return static_cast<long>(getauxval(AT_PAGESZ));
24+
2525
// TODO: Complete the rest of the sysconf options.
2626
if (ret < 0) {
2727
libc_errno = EINVAL;

0 commit comments

Comments
 (0)