Skip to content

[libc] fix sysconf #79159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libc/src/unistd/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions libc/src/unistd/linux/sysconf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
#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 {

LLVM_LIBC_FUNCTION(long, sysconf, (int name)) {
long ret = 0;
if (name == _SC_PAGESIZE) {
// TODO: get this information from the auxvector.
return EXEC_PAGESIZE;
}
if (name == _SC_PAGESIZE)
return static_cast<long>(getauxval(AT_PAGESZ));

// TODO: Complete the rest of the sysconf options.
if (ret < 0) {
libc_errno = EINVAL;
Expand Down