[libc-commits] [libc] 7e6462d - [libc][NFC] Switch nanosleep_test and getcwd_test to libc_errno.
Siva Chandra Reddy via libc-commits
libc-commits at lists.llvm.org
Mon Mar 13 18:27:26 PDT 2023
Author: Siva Chandra Reddy
Date: 2023-03-14T01:25:47Z
New Revision: 7e6462d90cddb2e1f328285303f999071fb61c0f
URL: https://github.com/llvm/llvm-project/commit/7e6462d90cddb2e1f328285303f999071fb61c0f
DIFF: https://github.com/llvm/llvm-project/commit/7e6462d90cddb2e1f328285303f999071fb61c0f.diff
LOG: [libc][NFC] Switch nanosleep_test and getcwd_test to libc_errno.
Added:
Modified:
libc/src/time/nanosleep.cpp
libc/test/integration/src/unistd/CMakeLists.txt
libc/test/integration/src/unistd/getcwd_test.cpp
Removed:
################################################################################
diff --git a/libc/src/time/nanosleep.cpp b/libc/src/time/nanosleep.cpp
index fe042fc0f1c60..ef20f28b639b9 100644
--- a/libc/src/time/nanosleep.cpp
+++ b/libc/src/time/nanosleep.cpp
@@ -20,7 +20,7 @@ LLVM_LIBC_FUNCTION(int, nanosleep,
(const struct timespec *req, struct timespec *rem)) {
int ret = __llvm_libc::syscall_impl(SYS_nanosleep, req, rem);
if (ret < 0) {
- errno = -ret;
+ libc_errno = -ret;
return -1;
}
return ret;
diff --git a/libc/test/integration/src/unistd/CMakeLists.txt b/libc/test/integration/src/unistd/CMakeLists.txt
index 1abe01697ab54..046dc6c4bfbfe 100644
--- a/libc/test/integration/src/unistd/CMakeLists.txt
+++ b/libc/test/integration/src/unistd/CMakeLists.txt
@@ -10,8 +10,8 @@ add_integration_test(
STARTUP
libc.startup.linux.crt1
DEPENDS
- libc.include.errno
libc.src.__support.CPP.string_view
+ libc.src.errno.errno
libc.src.stdlib.getenv
libc.src.unistd.getcwd
)
diff --git a/libc/test/integration/src/unistd/getcwd_test.cpp b/libc/test/integration/src/unistd/getcwd_test.cpp
index 96af6dc2e3a7c..3214ebf7085cf 100644
--- a/libc/test/integration/src/unistd/getcwd_test.cpp
+++ b/libc/test/integration/src/unistd/getcwd_test.cpp
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/__support/CPP/string_view.h"
+#include "src/errno/libc_errno.h"
#include "src/stdlib/getenv.h"
#include "src/unistd/getcwd.h"
#include "test/IntegrationTest/test.h"
-#include <errno.h>
#include <stdlib.h> // For malloc and free
using __llvm_libc::cpp::string_view;
@@ -30,13 +30,13 @@ TEST_MAIN(int argc, char **argv, char **envp) {
// Bad size
cwd = __llvm_libc::getcwd(buffer, 0);
ASSERT_TRUE(cwd == nullptr);
- ASSERT_EQ(errno, EINVAL);
- errno = 0;
+ ASSERT_EQ(libc_errno, EINVAL);
+ libc_errno = 0;
// Insufficient size
cwd = __llvm_libc::getcwd(buffer, 2);
ASSERT_TRUE(cwd == nullptr);
- int err = errno;
+ int err = libc_errno;
ASSERT_EQ(err, ERANGE);
return 0;
More information about the libc-commits
mailing list