diff --git a/libc/src/dirent/closedir.cpp b/libc/src/dirent/closedir.cpp --- a/libc/src/dirent/closedir.cpp +++ b/libc/src/dirent/closedir.cpp @@ -10,9 +10,9 @@ #include "src/__support/File/dir.h" #include "src/__support/common.h" +#include "src/errno/libc_errno.h" #include -#include namespace __llvm_libc { @@ -20,7 +20,7 @@ auto *d = reinterpret_cast<__llvm_libc::Dir *>(dir); int retval = d->close(); if (retval != 0) { - errno = retval; + libc_errno = retval; return -1; } return 0; diff --git a/libc/src/dirent/opendir.cpp b/libc/src/dirent/opendir.cpp --- a/libc/src/dirent/opendir.cpp +++ b/libc/src/dirent/opendir.cpp @@ -10,16 +10,16 @@ #include "src/__support/File/dir.h" #include "src/__support/common.h" +#include "src/errno/libc_errno.h" #include -#include namespace __llvm_libc { LLVM_LIBC_FUNCTION(::DIR *, opendir, (const char *name)) { auto dir = Dir::open(name); if (!dir) { - errno = dir.error(); + libc_errno = dir.error(); return nullptr; } return reinterpret_cast(dir.value()); diff --git a/libc/src/dirent/readdir.cpp b/libc/src/dirent/readdir.cpp --- a/libc/src/dirent/readdir.cpp +++ b/libc/src/dirent/readdir.cpp @@ -10,9 +10,9 @@ #include "src/__support/File/dir.h" #include "src/__support/common.h" +#include "src/errno/libc_errno.h" #include -#include namespace __llvm_libc { @@ -20,7 +20,7 @@ auto *d = reinterpret_cast<__llvm_libc::Dir *>(dir); auto dirent_val = d->read(); if (!dirent_val) { - errno = dirent_val.error(); + libc_errno = dirent_val.error(); return nullptr; } return dirent_val; diff --git a/libc/src/fcntl/linux/CMakeLists.txt b/libc/src/fcntl/linux/CMakeLists.txt --- a/libc/src/fcntl/linux/CMakeLists.txt +++ b/libc/src/fcntl/linux/CMakeLists.txt @@ -5,7 +5,6 @@ HDRS ../creat.h DEPENDS - libc.include.errno libc.include.fcntl libc.src.__support.OSUtil.osutil libc.src.errno.errno @@ -18,7 +17,6 @@ HDRS ../open.h DEPENDS - libc.include.errno libc.include.fcntl libc.src.__support.OSUtil.osutil libc.src.errno.errno @@ -31,7 +29,6 @@ HDRS ../openat.h DEPENDS - libc.include.errno libc.include.fcntl libc.src.__support.OSUtil.osutil libc.src.errno.errno diff --git a/libc/src/fcntl/linux/creat.cpp b/libc/src/fcntl/linux/creat.cpp --- a/libc/src/fcntl/linux/creat.cpp +++ b/libc/src/fcntl/linux/creat.cpp @@ -10,8 +10,8 @@ #include "src/__support/OSUtil/syscall.h" // For internal syscall function. #include "src/__support/common.h" +#include "src/errno/libc_errno.h" -#include #include #include // For syscall numbers. @@ -29,7 +29,7 @@ if (fd > 0) return fd; - errno = -fd; + libc_errno = -fd; return -1; } diff --git a/libc/src/fcntl/linux/open.cpp b/libc/src/fcntl/linux/open.cpp --- a/libc/src/fcntl/linux/open.cpp +++ b/libc/src/fcntl/linux/open.cpp @@ -10,8 +10,8 @@ #include "src/__support/OSUtil/syscall.h" // For internal syscall function. #include "src/__support/common.h" +#include "src/errno/libc_errno.h" -#include #include #include #include // For syscall numbers. @@ -38,7 +38,7 @@ if (fd > 0) return fd; - errno = -fd; + libc_errno = -fd; return -1; } diff --git a/libc/src/fcntl/linux/openat.cpp b/libc/src/fcntl/linux/openat.cpp --- a/libc/src/fcntl/linux/openat.cpp +++ b/libc/src/fcntl/linux/openat.cpp @@ -10,8 +10,8 @@ #include "src/__support/OSUtil/syscall.h" // For internal syscall function. #include "src/__support/common.h" +#include "src/errno/libc_errno.h" -#include #include #include #include // For syscall numbers. @@ -33,7 +33,7 @@ if (fd > 0) return fd; - errno = -fd; + libc_errno = -fd; return -1; } diff --git a/libc/src/inttypes/CMakeLists.txt b/libc/src/inttypes/CMakeLists.txt --- a/libc/src/inttypes/CMakeLists.txt +++ b/libc/src/inttypes/CMakeLists.txt @@ -6,6 +6,7 @@ strtoimax.h DEPENDS libc.src.__support.str_to_integer + libc.src.errno.errno ) add_entrypoint_object( @@ -16,6 +17,7 @@ strtoumax.h DEPENDS libc.src.__support.str_to_integer + libc.src.errno.errno ) add_entrypoint_object( diff --git a/libc/src/inttypes/strtoimax.cpp b/libc/src/inttypes/strtoimax.cpp --- a/libc/src/inttypes/strtoimax.cpp +++ b/libc/src/inttypes/strtoimax.cpp @@ -9,6 +9,7 @@ #include "src/inttypes/strtoimax.h" #include "src/__support/common.h" #include "src/__support/str_to_integer.h" +#include "src/errno/libc_errno.h" namespace __llvm_libc { @@ -17,7 +18,7 @@ int base)) { auto result = internal::strtointeger(str, base); if (result.has_error()) - errno = result.error; + libc_errno = result.error; if (str_end != nullptr) *str_end = const_cast(str + result.parsed_len); diff --git a/libc/src/inttypes/strtoumax.cpp b/libc/src/inttypes/strtoumax.cpp --- a/libc/src/inttypes/strtoumax.cpp +++ b/libc/src/inttypes/strtoumax.cpp @@ -9,6 +9,7 @@ #include "src/inttypes/strtoumax.h" #include "src/__support/common.h" #include "src/__support/str_to_integer.h" +#include "src/errno/libc_errno.h" namespace __llvm_libc { @@ -17,7 +18,7 @@ int base)) { auto result = internal::strtointeger(str, base); if (result.has_error()) - errno = result.error; + libc_errno = result.error; if (str_end != nullptr) *str_end = const_cast(str + result.parsed_len); diff --git a/libc/src/sched/linux/CMakeLists.txt b/libc/src/sched/linux/CMakeLists.txt --- a/libc/src/sched/linux/CMakeLists.txt +++ b/libc/src/sched/linux/CMakeLists.txt @@ -5,7 +5,6 @@ HDRS ../sched_getaffinity.h DEPENDS - libc.include.errno libc.include.sched libc.src.__support.OSUtil.osutil libc.src.errno.errno @@ -18,7 +17,6 @@ HDRS ../sched_setaffinity.h DEPENDS - libc.include.errno libc.include.sched libc.src.__support.OSUtil.osutil libc.src.errno.errno diff --git a/libc/src/sched/linux/sched_getaffinity.cpp b/libc/src/sched/linux/sched_getaffinity.cpp --- a/libc/src/sched/linux/sched_getaffinity.cpp +++ b/libc/src/sched/linux/sched_getaffinity.cpp @@ -10,8 +10,8 @@ #include "src/__support/OSUtil/syscall.h" // For internal syscall function. #include "src/__support/common.h" +#include "src/errno/libc_errno.h" -#include #include #include #include // For syscall numbers. @@ -23,7 +23,7 @@ long ret = __llvm_libc::syscall_impl(SYS_sched_getaffinity, tid, cpuset_size, mask); if (ret < 0) { - errno = -ret; + libc_errno = -ret; return -1; } if (size_t(ret) < cpuset_size) { diff --git a/libc/src/sched/linux/sched_setaffinity.cpp b/libc/src/sched/linux/sched_setaffinity.cpp --- a/libc/src/sched/linux/sched_setaffinity.cpp +++ b/libc/src/sched/linux/sched_setaffinity.cpp @@ -10,8 +10,8 @@ #include "src/__support/OSUtil/syscall.h" // For internal syscall function. #include "src/__support/common.h" +#include "src/errno/libc_errno.h" -#include #include #include // For syscall numbers. @@ -22,7 +22,7 @@ long ret = __llvm_libc::syscall_impl(SYS_sched_setaffinity, tid, cpuset_size, mask); if (ret < 0) { - errno = -ret; + libc_errno = -ret; return -1; } return 0;