[libc-commits] [libc] 0e91c48 - [libc] Enable creat, fsync, open, openat, read and write for aarch64.

Siva Chandra via libc-commits libc-commits at lists.llvm.org
Fri Jan 28 12:06:44 PST 2022


Author: Siva Chandra
Date: 2022-01-28T12:06:08-08:00
New Revision: 0e91c48df0a2351a82bde2d9cb350872914bddce

URL: https://github.com/llvm/llvm-project/commit/0e91c48df0a2351a82bde2d9cb350872914bddce
DIFF: https://github.com/llvm/llvm-project/commit/0e91c48df0a2351a82bde2d9cb350872914bddce.diff

LOG: [libc] Enable creat, fsync, open, openat, read and write for aarch64.

Added: 
    

Modified: 
    libc/config/linux/aarch64/entrypoints.txt
    libc/src/fcntl/linux/creat.cpp
    libc/src/fcntl/linux/open.cpp

Removed: 
    


################################################################################
diff  --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 65dacdef31222..fe43f2e40a37d 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 50b5d5e0a9b30..9bca317006699 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 71872b2c93e2a..3b8e08a7169ab 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;
 


        


More information about the libc-commits mailing list