From: Mikhail R. Gadelha Date: Mon, 17 Apr 2023 13:16:56 +0000 (-0300) Subject: [libc][NFC] Standardize missing syscalls error messages. X-Git-Tag: upstream/17.0.6~11377 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5b22df9984001d11ac279dbc3697112778f98f10;p=platform%2Fupstream%2Fllvm.git [libc][NFC] Standardize missing syscalls error messages. 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 --- diff --git a/libc/src/__support/File/linux_file.cpp b/libc/src/__support/File/linux_file.cpp index 658bffc..001aa0c 100644 --- a/libc/src/__support/File/linux_file.cpp +++ b/libc/src/__support/File/linux_file.cpp @@ -139,7 +139,7 @@ ErrorOr 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) diff --git a/libc/src/__support/threads/linux/thread.cpp b/libc/src/__support/threads/linux/thread.cpp index e9b95ee..aba8cf0 100644 --- a/libc/src/__support/threads/linux/thread.cpp +++ b/libc/src/__support/threads/linux/thread.cpp @@ -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 diff --git a/libc/src/spawn/linux/posix_spawn.cpp b/libc/src/spawn/linux/posix_spawn.cpp index 504ac5d..5ce8617 100644 --- a/libc/src/spawn/linux/posix_spawn.cpp +++ b/libc/src/spawn/linux/posix_spawn.cpp @@ -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; } diff --git a/libc/src/sys/mman/linux/mmap.cpp b/libc/src/sys/mman/linux/mmap.cpp index daf29f4..fea3a47 100644 --- a/libc/src/sys/mman/linux/mmap.cpp +++ b/libc/src/sys/mman/linux/mmap.cpp @@ -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 = diff --git a/libc/src/sys/stat/linux/chmod.cpp b/libc/src/sys/stat/linux/chmod.cpp index 9962146..6617f9d 100644 --- a/libc/src/sys/stat/linux/chmod.cpp +++ b/libc/src/sys/stat/linux/chmod.cpp @@ -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) { diff --git a/libc/src/sys/stat/linux/mkdirat.cpp b/libc/src/sys/stat/linux/mkdirat.cpp index 71bc1ce..94f642f 100644 --- a/libc/src/sys/stat/linux/mkdirat.cpp +++ b/libc/src/sys/stat/linux/mkdirat.cpp @@ -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) { diff --git a/libc/src/unistd/linux/access.cpp b/libc/src/unistd/linux/access.cpp index 1b5321e..5a9b186 100644 --- a/libc/src/unistd/linux/access.cpp +++ b/libc/src/unistd/linux/access.cpp @@ -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) { diff --git a/libc/src/unistd/linux/dup2.cpp b/libc/src/unistd/linux/dup2.cpp index 877ba10..5cdd5d1 100644 --- a/libc/src/unistd/linux/dup2.cpp +++ b/libc/src/unistd/linux/dup2.cpp @@ -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; diff --git a/libc/src/unistd/linux/fork.cpp b/libc/src/unistd/linux/fork.cpp index 89d27d3..18b1c7b 100644 --- a/libc/src/unistd/linux/fork.cpp +++ b/libc/src/unistd/linux/fork.cpp @@ -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. diff --git a/libc/src/unistd/linux/link.cpp b/libc/src/unistd/linux/link.cpp index 7a1ed8d..67dc126 100644 --- a/libc/src/unistd/linux/link.cpp +++ b/libc/src/unistd/linux/link.cpp @@ -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; diff --git a/libc/src/unistd/linux/readlink.cpp b/libc/src/unistd/linux/readlink.cpp index 795be27..3bc26d9 100644 --- a/libc/src/unistd/linux/readlink.cpp +++ b/libc/src/unistd/linux/readlink.cpp @@ -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; diff --git a/libc/src/unistd/linux/symlink.cpp b/libc/src/unistd/linux/symlink.cpp index 0c54510..62a8b80 100644 --- a/libc/src/unistd/linux/symlink.cpp +++ b/libc/src/unistd/linux/symlink.cpp @@ -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; diff --git a/libc/src/unistd/linux/unlink.cpp b/libc/src/unistd/linux/unlink.cpp index cc74500..746d98a 100644 --- a/libc/src/unistd/linux/unlink.cpp +++ b/libc/src/unistd/linux/unlink.cpp @@ -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) { diff --git a/libc/src/unistd/linux/unlinkat.cpp b/libc/src/unistd/linux/unlinkat.cpp index e39300e..c9a36a6f 100644 --- a/libc/src/unistd/linux/unlinkat.cpp +++ b/libc/src/unistd/linux/unlinkat.cpp @@ -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) { diff --git a/libc/startup/linux/aarch64/start.cpp b/libc/startup/linux/aarch64/start.cpp index b02ea7d..9153c44 100644 --- a/libc/startup/linux/aarch64/start.cpp +++ b/libc/startup/linux/aarch64/start.cpp @@ -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; diff --git a/libc/startup/linux/riscv64/start.cpp b/libc/startup/linux/riscv64/start.cpp index 068658c..80e7d3f 100644 --- a/libc/startup/linux/riscv64/start.cpp +++ b/libc/startup/linux/riscv64/start.cpp @@ -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; diff --git a/libc/startup/linux/x86_64/start.cpp b/libc/startup/linux/x86_64/start.cpp index 15d5de5..eece066 100644 --- a/libc/startup/linux/x86_64/start.cpp +++ b/libc/startup/linux/x86_64/start.cpp @@ -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; diff --git a/libc/test/src/unistd/syscall_test.cpp b/libc/test/src/unistd/syscall_test.cpp index 9c9e242..5086996 100644 --- a/libc/test/src/unistd/syscall_test.cpp +++ b/libc/test/src/unistd/syscall_test.cpp @@ -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);