Skip to content

Commit be7c865

Browse files
author
Siva Chandra
committed
[libc] Add a few missing deps, includes, and fix a few typos.
This allows us to enable rmdir, mkdir, mkdirat, unlink and unlinkat for aarch64.
1 parent 3b8ffe6 commit be7c865

File tree

9 files changed

+18
-2
lines changed

9 files changed

+18
-2
lines changed

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,17 @@ set(TARGET_LIBC_ENTRYPOINTS
8181
libc.src.stdlib.strtoul
8282
libc.src.stdlib.strtoull
8383

84+
# sys/stat.h entrypoints
85+
libc.src.sys.stat.mkdir
86+
libc.src.sys.stat.mkdirat
87+
8488
# unistd.h entrypoints
8589
libc.src.unistd.close
8690
libc.src.unistd.fsync
8791
libc.src.unistd.read
92+
libc.src.unistd.rmdir
93+
libc.src.unistd.unlink
94+
libc.src.unistd.unlinkat
8895
libc.src.unistd.write
8996
)
9097

libc/src/sys/stat/linux/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ add_entrypoint_object(
55
HDRS
66
../mkdir.h
77
DEPENDS
8+
libc.include.fcntl
89
libc.include.sys_stat
910
libc.include.sys_syscall
1011
libc.src.__support.OSUtil.osutil

libc/src/sys/stat/linux/mkdir.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "src/__support/common.h"
1313

1414
#include <errno.h>
15+
#include <fcntl.h>
1516
#include <sys/stat.h>
1617
#include <sys/syscall.h> // For syscall numbers.
1718

libc/src/unistd/linux/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ add_entrypoint_object(
4444
HDRS
4545
../rmdir.h
4646
DEPENDS
47+
libc.include.fcntl
4748
libc.include.unistd
4849
libc.include.sys_syscall
4950
libc.src.__support.OSUtil.osutil
@@ -57,6 +58,7 @@ add_entrypoint_object(
5758
HDRS
5859
../unlink.h
5960
DEPENDS
61+
libc.include.fcntl
6062
libc.include.unistd
6163
libc.include.sys_syscall
6264
libc.src.__support.OSUtil.osutil
@@ -70,6 +72,7 @@ add_entrypoint_object(
7072
HDRS
7173
../unlinkat.h
7274
DEPENDS
75+
libc.include.fcntl
7376
libc.include.unistd
7477
libc.include.sys_syscall
7578
libc.src.__support.OSUtil.osutil

libc/src/unistd/linux/rmdir.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "src/__support/common.h"
1313

1414
#include <errno.h>
15+
#include <fcntl.h>
1516
#include <sys/syscall.h> // For syscall numbers.
1617

1718
namespace __llvm_libc {
@@ -20,7 +21,7 @@ LLVM_LIBC_FUNCTION(int, rmdir, (const char *path)) {
2021
#ifdef SYS_rmdir
2122
long ret = __llvm_libc::syscall(SYS_rmdir, path);
2223
#elif defined(SYS_unlinkat)
23-
long ret = __llvm_libc::syscall(SYS_unlinkat, AT_FDCWD, path, 0);
24+
long ret = __llvm_libc::syscall(SYS_unlinkat, AT_FDCWD, path, AT_REMOVEDIR);
2425
#else
2526
#error "rmdir and unlinkat syscalls not available."
2627
#endif

libc/src/unistd/linux/unlink.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "src/__support/common.h"
1313

1414
#include <errno.h>
15+
#include <fcntl.h>
1516
#include <sys/syscall.h> // For syscall numbers.
1617

1718
namespace __llvm_libc {

libc/src/unistd/linux/unlinkat.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "src/__support/common.h"
1313

1414
#include <errno.h>
15+
#include <fcntl.h>
1516
#include <sys/syscall.h> // For syscall numbers.
1617

1718
namespace __llvm_libc {

libc/test/src/fcntl/openat_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "utils/testutils/FDReader.h"
1616

1717
#include <errno.h>
18+
#include <fcntl.h>
1819

1920
TEST(LlvmLibcUniStd, OpenAndReadTest) {
2021
using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds;

libc/test/src/sys/stat/mkdirat_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
TEST(LlvmLibcMkdiratTest, CreateAndRemove) {
1919
using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds;
20-
constexpr const char *TEST_DIR = "testdata/rmdir.testdir";
20+
constexpr const char *TEST_DIR = "testdata/mkdirat.testdir";
2121
ASSERT_THAT(__llvm_libc::mkdirat(AT_FDCWD, TEST_DIR, S_IRWXU), Succeeds(0));
2222
ASSERT_THAT(__llvm_libc::rmdir(TEST_DIR), Succeeds(0));
2323
}

0 commit comments

Comments
 (0)