Skip to content
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
4 changes: 4 additions & 0 deletions libc/test/src/sys/mman/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ add_libc_unittest(
libc.src.sys.mman.mincore
libc.src.sys.mman.mlock
libc.src.sys.mman.munlock
libc.src.unistd.sysconf
libc.test.UnitTest.ErrnoCheckingTest
libc.test.UnitTest.ErrnoSetterMatcher
)
Expand All @@ -123,6 +124,7 @@ add_libc_unittest(
libc.src.sys.mman.mlockall
libc.src.sys.mman.munlockall
libc.src.sys.resource.getrlimit
libc.src.unistd.sysconf
libc.src.__support.OSUtil.osutil
libc.test.UnitTest.ErrnoCheckingTest
libc.test.UnitTest.ErrnoSetterMatcher
Expand All @@ -144,6 +146,7 @@ add_libc_unittest(
libc.src.sys.mman.mincore
libc.src.sys.mman.mlock
libc.src.sys.mman.munlock
libc.src.unistd.sysconf
libc.test.UnitTest.ErrnoCheckingTest
libc.test.UnitTest.ErrnoSetterMatcher
)
Expand All @@ -165,6 +168,7 @@ add_libc_unittest(
libc.src.sys.mman.munmap
libc.src.fcntl.open
libc.src.unistd.close
libc.src.unistd.sysconf
)

add_libc_unittest(
Expand Down
4 changes: 2 additions & 2 deletions libc/test/src/sys/mman/linux/mincore_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "src/sys/mman/mmap.h"
#include "src/sys/mman/munlock.h"
#include "src/sys/mman/munmap.h"
#include "src/unistd/sysconf.h"
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
Expand All @@ -20,8 +21,7 @@ using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
using LlvmLibcMincoreTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;

// TODO: Replace with sysconf call once the function is properly implemented.
constexpr size_t PAGE_SIZE = 4096;
const size_t PAGE_SIZE = LIBC_NAMESPACE::sysconf(_SC_PAGESIZE);

TEST_F(LlvmLibcMincoreTest, UnMappedMemory) {
unsigned char vec;
Expand Down
4 changes: 2 additions & 2 deletions libc/test/src/sys/mman/linux/mlock_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
#include "src/sys/mman/munlockall.h"
#include "src/sys/mman/munmap.h"
#include "src/sys/resource/getrlimit.h"
#include "src/unistd/sysconf.h"
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"

#include <sys/syscall.h>

// TODO: Replace with sysconf call once the function is properly implemented.
constexpr size_t PAGE_SIZE = 4096;
const size_t PAGE_SIZE = LIBC_NAMESPACE::sysconf(_SC_PAGESIZE);

using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
using LlvmLibcMlockTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
Expand Down
4 changes: 2 additions & 2 deletions libc/test/src/sys/mman/linux/msync_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
#include "src/sys/mman/msync.h"
#include "src/sys/mman/munlock.h"
#include "src/sys/mman/munmap.h"
#include "src/unistd/sysconf.h"
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"

// TODO: Replace with sysconf call once the function is properly implemented.
constexpr size_t PAGE_SIZE = 4096;
const size_t PAGE_SIZE = LIBC_NAMESPACE::sysconf(_SC_PAGESIZE);

using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
using LlvmLibcMsyncTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
Expand Down
4 changes: 2 additions & 2 deletions libc/test/src/sys/mman/linux/remap_file_pages_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
#include "src/sys/mman/munmap.h"
#include "src/sys/mman/remap_file_pages.h"
#include "src/unistd/close.h"
#include "src/unistd/sysconf.h"
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"

#include <sys/mman.h>
#include <sys/stat.h> // For S_IRWXU

// TODO: Replace with sysconf call once the function is properly implemented.
constexpr size_t PAGE_SIZE = 4096;
const size_t PAGE_SIZE = LIBC_NAMESPACE::sysconf(_SC_PAGESIZE);

using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
Expand Down
28 changes: 28 additions & 0 deletions utils/bazel/llvm-project-overlay/libc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,21 @@ libc_support_library(
],
)

libc_support_library(
name = "__support_osutil_linux_auxv",
hdrs = ["src/__support/OSUtil/linux/auxv.h"],
target_compatible_with = select({
"@platforms//os:linux": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
deps = [
":__support_common",
":__support_osutil_syscall",
":__support_threads_callonce",
":hdr_fcntl_macros",
],
)

libc_support_library(
name = "__support_osutil_vdso",
hdrs = [
Expand Down Expand Up @@ -6336,6 +6351,19 @@ libc_function(
],
)

# WARNING: NOT FULLY IMPLEMENTED, FOR TESTING USE ONLY
libc_function(
name = "sysconf",
srcs = ["src/unistd/linux/sysconf.cpp"],
hdrs = ["src/unistd/sysconf.h"],
deps = [
":__support_common",
":__support_osutil_linux_auxv",
":errno",
":hdr_unistd_macros",
],
)

libc_function(
name = "write",
srcs = ["src/unistd/linux/write.cpp"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ libc_test(
"//libc:mmap",
"//libc:munlock",
"//libc:munmap",
"//libc:sysconf",
],
)

Expand All @@ -48,6 +49,7 @@ libc_test(
"//libc:munlock",
"//libc:munlockall",
"//libc:munmap",
"//libc:sysconf",
],
)

Expand Down Expand Up @@ -89,6 +91,7 @@ libc_test(
"//libc:msync",
"//libc:munlock",
"//libc:munmap",
"//libc:sysconf",
],
)

Expand All @@ -111,6 +114,7 @@ libc_test(
"//libc:munmap",
"//libc:open",
"//libc:remap_file_pages",
"//libc:sysconf",
],
)

Expand Down
Loading