[libc][NFC] Standardize missing syscalls error messages.
authorMikhail R. Gadelha <mikhail@igalia.com>
Mon, 17 Apr 2023 13:16:56 +0000 (10:16 -0300)
committerMikhail R. Gadelha <mikhail@igalia.com>
Mon, 17 Apr 2023 13:17:26 +0000 (10:17 -0300)
This patch standardizes the error messages when a syscall is not
available to be in the format: "ABC and DEF syscalls are not available."

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D148373

18 files changed:
libc/src/__support/File/linux_file.cpp
libc/src/__support/threads/linux/thread.cpp
libc/src/spawn/linux/posix_spawn.cpp
libc/src/sys/mman/linux/mmap.cpp
libc/src/sys/stat/linux/chmod.cpp
libc/src/sys/stat/linux/mkdirat.cpp
libc/src/unistd/linux/access.cpp
libc/src/unistd/linux/dup2.cpp
libc/src/unistd/linux/fork.cpp
libc/src/unistd/linux/link.cpp
libc/src/unistd/linux/readlink.cpp
libc/src/unistd/linux/symlink.cpp
libc/src/unistd/linux/unlink.cpp
libc/src/unistd/linux/unlinkat.cpp
libc/startup/linux/aarch64/start.cpp
libc/startup/linux/riscv64/start.cpp
libc/startup/linux/x86_64/start.cpp
libc/test/src/unistd/syscall_test.cpp

index 658bffc..001aa0c 100644 (file)
@@ -139,7 +139,7 @@ ErrorOr<File *> openfile(const char *path, const char *mode) {
   int fd = __llvm_libc::syscall_impl(SYS_openat, AT_FDCWD, path, open_flags,
                                      OPEN_MODE);
 #else
-#error "SYS_open and SYS_openat syscalls not available to perform a file open."
+#error "open and openat syscalls not available."
 #endif
 
   if (fd < 0)
index e9b95ee..aba8cf0 100644 (file)
@@ -33,10 +33,10 @@ namespace __llvm_libc {
 
 #ifdef SYS_mmap2
 static constexpr long MMAP_SYSCALL_NUMBER = SYS_mmap2;
-#elif SYS_mmap
+#elif defined(SYS_mmap)
 static constexpr long MMAP_SYSCALL_NUMBER = SYS_mmap;
 #else
-#error "SYS_mmap or SYS_mmap2 not available on the target platform"
+#error "mmap or mmap2 syscalls not available."
 #endif
 
 static constexpr size_t NAME_SIZE_MAX = 16; // Includes the null terminator
index 504ac5d..5ce8617 100644 (file)
@@ -31,7 +31,7 @@ pid_t fork() {
 #elif defined(SYS_clone)
   return __llvm_libc::syscall_impl(SYS_clone, SIGCHLD, 0);
 #else
-#error "SYS_fork or SYS_clone not available."
+#error "fork or clone syscalls not available."
 #endif
 }
 
@@ -58,7 +58,7 @@ bool dup2(int fd, int newfd) {
 #elif defined(SYS_dup3)
   long ret = __llvm_libc::syscall_impl(SYS_dup3, fd, newfd, 0);
 #else
-#error "SYS_dup2 and SYS_dup3 not available for the target."
+#error "dup2 and dup3 syscalls not available."
 #endif
   return ret < 0 ? false : true;
 }
index daf29f4..fea3a47 100644 (file)
@@ -33,10 +33,10 @@ LLVM_LIBC_FUNCTION(void *, mmap,
 #ifdef SYS_mmap2
   offset /= EXEC_PAGESIZE;
   long syscall_number = SYS_mmap2;
-#elif SYS_mmap
+#elif defined(SYS_mmap)
   long syscall_number = SYS_mmap;
 #else
-#error "Target platform does not have SYS_mmap or SYS_mmap2 defined"
+#error "mmap or mmap2 syscalls not available."
 #endif
 
   long ret_val =
index 9962146..6617f9d 100644 (file)
@@ -24,7 +24,7 @@ LLVM_LIBC_FUNCTION(int, chmod, (const char *path, mode_t mode)) {
 #elif defined(SYS_fchmodat)
   long ret = __llvm_libc::syscall_impl(SYS_fchmodat, AT_FDCWD, path, mode);
 #else
-#error "chmod and chmodat syscalls not available."
+#error "chmod and fchmodat syscalls not available."
 #endif
 
   if (ret < 0) {
index 71bc1ce..94f642f 100644 (file)
@@ -21,7 +21,7 @@ LLVM_LIBC_FUNCTION(int, mkdirat, (int dfd, const char *path, mode_t mode)) {
 #ifdef SYS_mkdirat
   long ret = __llvm_libc::syscall_impl(SYS_mkdirat, dfd, path, mode);
 #else
-#error "mkdirat syscalls not available."
+#error "mkdirat syscall not available."
 #endif
 
   if (ret < 0) {
index 1b5321e..5a9b186 100644 (file)
@@ -23,7 +23,7 @@ LLVM_LIBC_FUNCTION(int, access, (const char *path, int mode)) {
 #elif defined(SYS_faccessat)
   long ret = __llvm_libc::syscall_impl(SYS_faccessat, AT_FDCWD, path, mode, 0);
 #else
-#error "access syscalls not available."
+#error "access and faccessat syscalls not available."
 #endif
 
   if (ret < 0) {
index 877ba10..5cdd5d1 100644 (file)
@@ -35,7 +35,7 @@ LLVM_LIBC_FUNCTION(int, dup2, (int oldfd, int newfd)) {
   }
   long ret = __llvm_libc::syscall_impl(SYS_dup3, oldfd, newfd, 0);
 #else
-#error "SYS_dup2 and SYS_dup3 not available for the target."
+#error "dup2 and dup3 syscalls not available."
 #endif
   if (ret < 0) {
     libc_errno = -ret;
index 89d27d3..18b1c7b 100644 (file)
@@ -29,7 +29,7 @@ LLVM_LIBC_FUNCTION(pid_t, fork, (void)) {
 #elif defined(SYS_clone)
   pid_t ret = __llvm_libc::syscall_impl(SYS_clone, SIGCHLD, 0);
 #else
-#error "SYS_fork or SYS_clone not available."
+#error "fork and clone syscalls not available."
 #endif
   if (ret == 0) {
     // Return value is 0 in the child process.
index 7a1ed8d..67dc126 100644 (file)
@@ -24,7 +24,7 @@ LLVM_LIBC_FUNCTION(int, link, (const char *path1, const char *path2)) {
   long ret = __llvm_libc::syscall_impl(SYS_linkat, AT_FDCWD, path1, AT_FDCWD,
                                        path2, 0);
 #else
-#error "SYS_link or SYS_linkat not available."
+#error "link or linkat syscalls not available."
 #endif
   if (ret < 0) {
     libc_errno = -ret;
index 795be27..3bc26d9 100644 (file)
@@ -26,7 +26,7 @@ LLVM_LIBC_FUNCTION(ssize_t, readlink,
   ssize_t ret =
       __llvm_libc::syscall_impl(SYS_readlinkat, AT_FDCWD, path, buf, bufsize);
 #else
-#error "SYS_readlink or SYS_readlinkat not available."
+#error "readlink or readlinkat syscalls not available."
 #endif
   if (ret < 0) {
     libc_errno = -ret;
index 0c54510..62a8b80 100644 (file)
@@ -23,7 +23,7 @@ LLVM_LIBC_FUNCTION(int, symlink, (const char *path1, const char *path2)) {
 #elif defined(SYS_symlinkat)
   long ret = __llvm_libc::syscall_impl(SYS_symlinkat, path1, AT_FDCWD, path2);
 #else
-#error "SYS_symlink or SYS_symlinkat not available."
+#error "symlink or symlinkat syscalls not available."
 #endif
   if (ret < 0) {
     libc_errno = -ret;
index cc74500..746d98a 100644 (file)
@@ -23,7 +23,7 @@ LLVM_LIBC_FUNCTION(int, unlink, (const char *path)) {
 #elif defined(SYS_unlinkat)
   long ret = __llvm_libc::syscall_impl(SYS_unlinkat, AT_FDCWD, path, 0);
 #else
-#error "Unlink syscalls not available."
+#error "unlink and unlinkat syscalls not available."
 #endif
 
   if (ret < 0) {
index e39300e..c9a36a6 100644 (file)
@@ -21,7 +21,7 @@ LLVM_LIBC_FUNCTION(int, unlinkat, (int dfd, const char *path, int flags)) {
 #ifdef SYS_unlinkat
   long ret = __llvm_libc::syscall_impl(SYS_unlinkat, dfd, path, flags);
 #else
-#error "unlinkat syscall not available."
+#error "unlinkat syscalls not available."
 #endif
 
   if (ret < 0) {
index b02ea7d..9153c44 100644 (file)
@@ -34,7 +34,7 @@ static constexpr long MMAP_SYSCALL_NUMBER = SYS_mmap2;
 #elif SYS_mmap
 static constexpr long MMAP_SYSCALL_NUMBER = SYS_mmap;
 #else
-#error "Target platform does not have SYS_mmap or SYS_mmap2 defined"
+#error "mmap and mmap2 syscalls not available."
 #endif
 
 AppProperties app;
index 068658c..80e7d3f 100644 (file)
@@ -29,7 +29,7 @@ static constexpr long MMAP_SYSCALL_NUMBER = SYS_mmap2;
 #elif SYS_mmap
 static constexpr long MMAP_SYSCALL_NUMBER = SYS_mmap;
 #else
-#error "Target platform does not have SYS_mmap or SYS_mmap2 defined"
+#error "mmap and mmap2 syscalls not available."
 #endif
 
 AppProperties app;
index 15d5de5..eece066 100644 (file)
@@ -30,7 +30,7 @@ static constexpr long mmapSyscallNumber = SYS_mmap2;
 #elif SYS_mmap
 static constexpr long mmapSyscallNumber = SYS_mmap;
 #else
-#error "Target platform does not have SYS_mmap or SYS_mmap2 defined"
+#error "mmap and mmap2 syscalls not available."
 #endif
 
 AppProperties app;
index 9c9e242..5086996 100644 (file)
@@ -41,7 +41,7 @@ TEST(LlvmLibcSyscallTest, SymlinkCreateDestroy) {
 #elif defined(SYS_symlinkat)
   ASSERT_GE(__llvm_libc::syscall(SYS_symlinkat, LINK_VAL, AT_FDCWD, LINK), 0l);
 #else
-#error "Symlink syscalls not available."
+#error "symlink and symlinkat syscalls not available."
 #endif
   ASSERT_EQ(libc_errno, 0);
 
@@ -61,7 +61,7 @@ TEST(LlvmLibcSyscallTest, SymlinkCreateDestroy) {
 #elif defined(SYS_unlinkat)
   ASSERT_GE(__llvm_libc::syscall(SYS_unlinkat, AT_FDCWD, LINK, 0), 0l);
 #else
-#error "Unlink syscalls not available."
+#error "unlink and unlinkat syscalls not available."
 #endif
   ASSERT_EQ(libc_errno, 0);
 }
@@ -79,7 +79,7 @@ TEST(LlvmLibcSyscallTest, FileReadWrite) {
   int fd = __llvm_libc::syscall(SYS_openat, AT_FDCWD, TEST_FILE,
                                 O_WRONLY | O_CREAT, S_IRWXU);
 #else
-#error "Open syscalls not available to available."
+#error "open and openat syscalls not available."
 #endif
   ASSERT_GT(fd, 0);
   ASSERT_EQ(libc_errno, 0);
@@ -115,7 +115,7 @@ TEST(LlvmLibcSyscallTest, FileLinkCreateDestroy) {
   int write_fd = __llvm_libc::syscall(SYS_openat, AT_FDCWD, TEST_FILE_PATH,
                                       O_WRONLY | O_CREAT, S_IRWXU);
 #else
-#error "Open syscalls not available to available."
+#error "open and openat syscalls not available."
 #endif
   ASSERT_GT(write_fd, 0);
   ASSERT_EQ(libc_errno, 0);
@@ -129,7 +129,7 @@ TEST(LlvmLibcSyscallTest, FileLinkCreateDestroy) {
   int dir_fd =
       __llvm_libc::syscall(SYS_openat, AT_FDCWD, TEST_DIR, O_DIRECTORY, 0);
 #else
-#error "Open syscalls not available to available."
+#error "open and openat syscalls not available."
 #endif
   ASSERT_GT(dir_fd, 0);
   ASSERT_EQ(libc_errno, 0);
@@ -144,7 +144,7 @@ TEST(LlvmLibcSyscallTest, FileLinkCreateDestroy) {
   int link_fd = __llvm_libc::syscall(SYS_openat, AT_FDCWD, TEST_FILE_LINK_PATH,
                                      O_PATH, 0);
 #else
-#error "Open syscalls not available to available."
+#error "open and openat syscalls not available."
 #endif
   ASSERT_GT(link_fd, 0);
   ASSERT_EQ(libc_errno, 0);
@@ -155,7 +155,7 @@ TEST(LlvmLibcSyscallTest, FileLinkCreateDestroy) {
   ASSERT_GE(__llvm_libc::syscall(SYS_unlinkat, AT_FDCWD, TEST_FILE_PATH, 0),
             0l);
 #else
-#error "Unlink syscalls not available."
+#error "unlink and unlinkat syscalls not available."
 #endif
   ASSERT_EQ(libc_errno, 0);
 
@@ -165,7 +165,7 @@ TEST(LlvmLibcSyscallTest, FileLinkCreateDestroy) {
   ASSERT_GE(
       __llvm_libc::syscall(SYS_unlinkat, AT_FDCWD, TEST_FILE_LINK_PATH, 0), 0l);
 #else
-#error "Unlink syscalls not available."
+#error "unlink and unlinkat syscalls not available."
 #endif
   ASSERT_EQ(libc_errno, 0);