From 0e91c48df0a2351a82bde2d9cb350872914bddce Mon Sep 17 00:00:00 2001 From: Siva Chandra Date: Fri, 28 Jan 2022 11:41:26 -0800 Subject: [PATCH] [libc] Enable creat, fsync, open, openat, read and write for aarch64. --- libc/config/linux/aarch64/entrypoints.txt | 11 +++++++++++ libc/src/fcntl/linux/creat.cpp | 6 ++++++ libc/src/fcntl/linux/open.cpp | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index 65dacde..fe43f2e 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -20,6 +20,11 @@ set(TARGET_LIBC_ENTRYPOINTS # errno.h entrypoints libc.src.errno.__errno_location + # fcntl.h entrypoints + libc.src.fcntl.creat + libc.src.fcntl.open + libc.src.fcntl.openat + # string.h entrypoints libc.src.string.bcmp libc.src.string.bzero @@ -75,6 +80,12 @@ set(TARGET_LIBC_ENTRYPOINTS libc.src.stdlib.strtoll libc.src.stdlib.strtoul libc.src.stdlib.strtoull + + # unistd.h entrypoints + libc.src.unistd.close + libc.src.unistd.fsync + libc.src.unistd.read + libc.src.unistd.write ) set(TARGET_LIBM_ENTRYPOINTS diff --git a/libc/src/fcntl/linux/creat.cpp b/libc/src/fcntl/linux/creat.cpp index 50b5d5e..9bca317 100644 --- a/libc/src/fcntl/linux/creat.cpp +++ b/libc/src/fcntl/linux/creat.cpp @@ -18,8 +18,14 @@ namespace __llvm_libc { LLVM_LIBC_FUNCTION(int, creat, (const char *path, int mode_flags)) { +#ifdef SYS_open int fd = __llvm_libc::syscall(SYS_open, path, O_CREAT | O_WRONLY | O_TRUNC, mode_flags); +#else + int fd = __llvm_libc::syscall(SYS_openat, AT_FDCWD, path, + O_CREAT | O_WRONLY | O_TRUNC, mode_flags); +#endif + if (fd > 0) return fd; diff --git a/libc/src/fcntl/linux/open.cpp b/libc/src/fcntl/linux/open.cpp index 71872b2..3b8e08a 100644 --- a/libc/src/fcntl/linux/open.cpp +++ b/libc/src/fcntl/linux/open.cpp @@ -29,7 +29,11 @@ LLVM_LIBC_FUNCTION(int, open, (const char *path, int flags, ...)) { va_end(varargs); } +#ifdef SYS_open int fd = __llvm_libc::syscall(SYS_open, path, flags, mode_flags); +#else + int fd = __llvm_libc::syscall(SYS_openat, AT_FDCWD, path, flags, mode_flags); +#endif if (fd > 0) return fd; -- 2.7.4