diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt --- a/libc/src/__support/CMakeLists.txt +++ b/libc/src/__support/CMakeLists.txt @@ -64,7 +64,6 @@ DEPENDS .ctype_utils .str_to_num_result - libc.include.errno libc.src.errno.errno libc.src.__support.CPP.limits libc.src.__support.common diff --git a/libc/src/__support/File/CMakeLists.txt b/libc/src/__support/File/CMakeLists.txt --- a/libc/src/__support/File/CMakeLists.txt +++ b/libc/src/__support/File/CMakeLists.txt @@ -11,7 +11,7 @@ HDRS file.h DEPENDS - libc.include.errno + libc.src.__support.CPP.new libc.src.__support.CPP.span libc.src.__support.threads.mutex @@ -37,7 +37,7 @@ ${LIBC_TARGET_OS}_file.cpp DEPENDS .file - libc.include.errno + libc.include.fcntl libc.include.stdio libc.include.sys_syscall @@ -55,7 +55,6 @@ ${LIBC_TARGET_OS}_dir.cpp DEPENDS .dir - libc.include.errno libc.include.fcntl libc.include.sys_syscall libc.src.__support.OSUtil.osutil diff --git a/libc/src/__support/File/dir.cpp b/libc/src/__support/File/dir.cpp --- a/libc/src/__support/File/dir.cpp +++ b/libc/src/__support/File/dir.cpp @@ -10,8 +10,8 @@ #include "src/__support/CPP/new.h" #include "src/__support/error_or.h" +#include "src/errno/libc_errno.h" // For error macros -#include #include namespace __llvm_libc { diff --git a/libc/src/__support/File/file.cpp b/libc/src/__support/File/file.cpp --- a/libc/src/__support/File/file.cpp +++ b/libc/src/__support/File/file.cpp @@ -10,8 +10,8 @@ #include "src/__support/CPP/new.h" #include "src/__support/CPP/span.h" +#include "src/errno/libc_errno.h" // For error macros -#include // For error macros #include #include diff --git a/libc/src/__support/File/linux_file.cpp b/libc/src/__support/File/linux_file.cpp --- a/libc/src/__support/File/linux_file.cpp +++ b/libc/src/__support/File/linux_file.cpp @@ -10,8 +10,8 @@ #include "src/__support/CPP/new.h" #include "src/__support/OSUtil/syscall.h" // For internal syscall function. +#include "src/errno/libc_errno.h" // For error macros -#include // For error macros #include // For mode_t and other flags to the open syscall #include #include // For syscall numbers diff --git a/libc/src/__support/StringUtil/CMakeLists.txt b/libc/src/__support/StringUtil/CMakeLists.txt --- a/libc/src/__support/StringUtil/CMakeLists.txt +++ b/libc/src/__support/StringUtil/CMakeLists.txt @@ -15,7 +15,6 @@ error_to_string.cpp DEPENDS .message_mapper - libc.include.errno libc.src.__support.CPP.span libc.src.__support.CPP.string_view libc.src.__support.CPP.stringstream diff --git a/libc/src/__support/StringUtil/error_to_string.cpp b/libc/src/__support/StringUtil/error_to_string.cpp --- a/libc/src/__support/StringUtil/error_to_string.cpp +++ b/libc/src/__support/StringUtil/error_to_string.cpp @@ -13,8 +13,8 @@ #include "src/__support/CPP/stringstream.h" #include "src/__support/StringUtil/message_mapper.h" #include "src/__support/integer_to_string.h" +#include "src/errno/libc_errno.h" // For error macros -#include #include namespace __llvm_libc { diff --git a/libc/src/__support/str_to_float.h b/libc/src/__support/str_to_float.h --- a/libc/src/__support/str_to_float.h +++ b/libc/src/__support/str_to_float.h @@ -21,7 +21,7 @@ #include "src/__support/high_precision_decimal.h" #include "src/__support/str_to_integer.h" #include "src/__support/str_to_num_result.h" -#include +#include "src/errno/libc_errno.h" // For ERANGE namespace __llvm_libc { namespace internal { diff --git a/libc/src/__support/str_to_integer.h b/libc/src/__support/str_to_integer.h --- a/libc/src/__support/str_to_integer.h +++ b/libc/src/__support/str_to_integer.h @@ -13,7 +13,7 @@ #include "src/__support/common.h" #include "src/__support/ctype_utils.h" #include "src/__support/str_to_num_result.h" -#include +#include "src/errno/libc_errno.h" // For ERANGE #include namespace __llvm_libc { diff --git a/libc/src/__support/threads/linux/thread.cpp b/libc/src/__support/threads/linux/thread.cpp --- a/libc/src/__support/threads/linux/thread.cpp +++ b/libc/src/__support/threads/linux/thread.cpp @@ -15,12 +15,12 @@ #include "src/__support/common.h" #include "src/__support/error_or.h" #include "src/__support/threads/linux/futex_word.h" // For FutexWordType +#include "src/errno/libc_errno.h" // For error macros #ifdef LIBC_TARGET_ARCH_IS_AARCH64 #include #endif -#include #include #include #include // For PR_SET_NAME diff --git a/libc/src/stdio/CMakeLists.txt b/libc/src/stdio/CMakeLists.txt --- a/libc/src/stdio/CMakeLists.txt +++ b/libc/src/stdio/CMakeLists.txt @@ -25,7 +25,6 @@ fclose.h DEPENDS libc.include.stdio - libc.include.errno libc.src.__support.File.file libc.src.__support.File.platform_file ) @@ -109,7 +108,6 @@ HDRS fgetc.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -122,7 +120,6 @@ HDRS fgetc_unlocked.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -135,7 +132,6 @@ HDRS getc.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -148,7 +144,6 @@ HDRS getc_unlocked.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -161,7 +156,6 @@ HDRS fgets.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -174,7 +168,6 @@ HDRS fflush.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -211,7 +204,6 @@ HDRS fread_unlocked.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -224,7 +216,6 @@ HDRS fread.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -237,7 +228,6 @@ HDRS fwrite_unlocked.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -250,7 +240,6 @@ HDRS fwrite.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -263,7 +252,6 @@ HDRS fputc.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -276,7 +264,6 @@ HDRS putc.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -289,7 +276,6 @@ HDRS putchar.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -302,7 +288,6 @@ HDRS fputs.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -316,7 +301,6 @@ HDRS puts.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -329,7 +313,6 @@ HDRS fseek.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -402,7 +385,6 @@ HDRS setbuf.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -415,7 +397,6 @@ HDRS setvbuf.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file @@ -512,7 +493,6 @@ HDRS ftell.h DEPENDS - libc.include.errno libc.include.stdio libc.src.__support.File.file libc.src.__support.File.platform_file diff --git a/libc/src/stdio/fclose.cpp b/libc/src/stdio/fclose.cpp --- a/libc/src/stdio/fclose.cpp +++ b/libc/src/stdio/fclose.cpp @@ -9,7 +9,7 @@ #include "src/stdio/fclose.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -18,7 +18,7 @@ auto *file = reinterpret_cast<__llvm_libc::File *>(stream); int result = File::cleanup(file); if (result != 0) { - errno = result; + libc_errno = result; return EOF; } return 0; diff --git a/libc/src/stdio/fflush.cpp b/libc/src/stdio/fflush.cpp --- a/libc/src/stdio/fflush.cpp +++ b/libc/src/stdio/fflush.cpp @@ -9,7 +9,7 @@ #include "src/stdio/fflush.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -17,7 +17,7 @@ LLVM_LIBC_FUNCTION(int, fflush, (::FILE * stream)) { int result = reinterpret_cast<__llvm_libc::File *>(stream)->flush(); if (result != 0) { - errno = result; + libc_errno = result; return EOF; } return 0; diff --git a/libc/src/stdio/fgetc.cpp b/libc/src/stdio/fgetc.cpp --- a/libc/src/stdio/fgetc.cpp +++ b/libc/src/stdio/fgetc.cpp @@ -9,7 +9,7 @@ #include "src/stdio/fgetc.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -19,7 +19,7 @@ auto result = reinterpret_cast<__llvm_libc::File *>(stream)->read(&c, 1); size_t r = result.value; if (result.has_error()) - errno = result.error; + libc_errno = result.error; if (r != 1) return EOF; diff --git a/libc/src/stdio/fgetc_unlocked.cpp b/libc/src/stdio/fgetc_unlocked.cpp --- a/libc/src/stdio/fgetc_unlocked.cpp +++ b/libc/src/stdio/fgetc_unlocked.cpp @@ -9,7 +9,7 @@ #include "src/stdio/fgetc_unlocked.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -20,7 +20,7 @@ reinterpret_cast<__llvm_libc::File *>(stream)->read_unlocked(&c, 1); size_t r = result.value; if (result.has_error()) - errno = result.error; + libc_errno = result.error; if (r != 1) return EOF; return c; diff --git a/libc/src/stdio/fgets.cpp b/libc/src/stdio/fgets.cpp --- a/libc/src/stdio/fgets.cpp +++ b/libc/src/stdio/fgets.cpp @@ -9,7 +9,7 @@ #include "src/stdio/fgets.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include #include @@ -32,7 +32,7 @@ auto result = stream->read_unlocked(&c, 1); size_t r = result.value; if (result.has_error()) - errno = result.error; + libc_errno = result.error; if (r != 1) break; diff --git a/libc/src/stdio/fopen.cpp b/libc/src/stdio/fopen.cpp --- a/libc/src/stdio/fopen.cpp +++ b/libc/src/stdio/fopen.cpp @@ -9,7 +9,7 @@ #include "src/stdio/fopen.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -18,7 +18,7 @@ (const char *__restrict name, const char *__restrict mode)) { auto result = __llvm_libc::openfile(name, mode); if (!result.has_value()) { - errno = result.error(); + libc_errno = result.error(); return nullptr; } return reinterpret_cast<::FILE *>(result.value()); diff --git a/libc/src/stdio/fopencookie.cpp b/libc/src/stdio/fopencookie.cpp --- a/libc/src/stdio/fopencookie.cpp +++ b/libc/src/stdio/fopencookie.cpp @@ -10,7 +10,7 @@ #include "src/__support/CPP/new.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include #include diff --git a/libc/src/stdio/fputc.cpp b/libc/src/stdio/fputc.cpp --- a/libc/src/stdio/fputc.cpp +++ b/libc/src/stdio/fputc.cpp @@ -9,7 +9,7 @@ #include "src/stdio/fputc.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -19,7 +19,7 @@ auto result = reinterpret_cast<__llvm_libc::File *>(stream)->write(&uc, 1); if (result.has_error()) - errno = result.error; + libc_errno = result.error; size_t written = result.value; if (1 != written) { diff --git a/libc/src/stdio/fputs.cpp b/libc/src/stdio/fputs.cpp --- a/libc/src/stdio/fputs.cpp +++ b/libc/src/stdio/fputs.cpp @@ -10,7 +10,7 @@ #include "src/__support/CPP/string_view.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -22,7 +22,7 @@ auto result = reinterpret_cast<__llvm_libc::File *>(stream)->write( str, str_view.size()); if (result.has_error()) - errno = result.error; + libc_errno = result.error; size_t written = result.value; if (str_view.size() != written) { diff --git a/libc/src/stdio/fread.cpp b/libc/src/stdio/fread.cpp --- a/libc/src/stdio/fread.cpp +++ b/libc/src/stdio/fread.cpp @@ -9,7 +9,7 @@ #include "src/stdio/fread.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -22,7 +22,7 @@ auto result = reinterpret_cast<__llvm_libc::File *>(stream)->read(buffer, size * nmemb); if (result.has_error()) - errno = result.error; + libc_errno = result.error; return result.value / size; } diff --git a/libc/src/stdio/fread_unlocked.cpp b/libc/src/stdio/fread_unlocked.cpp --- a/libc/src/stdio/fread_unlocked.cpp +++ b/libc/src/stdio/fread_unlocked.cpp @@ -9,7 +9,7 @@ #include "src/stdio/fread_unlocked.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -22,7 +22,7 @@ auto result = reinterpret_cast<__llvm_libc::File *>(stream)->read_unlocked( buffer, size * nmemb); if (result.has_error()) - errno = result.error; + libc_errno = result.error; return result.value / size; } diff --git a/libc/src/stdio/fseek.cpp b/libc/src/stdio/fseek.cpp --- a/libc/src/stdio/fseek.cpp +++ b/libc/src/stdio/fseek.cpp @@ -9,7 +9,7 @@ #include "src/stdio/fseek.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -18,7 +18,7 @@ auto result = reinterpret_cast<__llvm_libc::File *>(stream)->seek(offset, whence); if (!result.has_value()) { - errno = result.error(); + libc_errno = result.error(); return -1; } return 0; diff --git a/libc/src/stdio/ftell.cpp b/libc/src/stdio/ftell.cpp --- a/libc/src/stdio/ftell.cpp +++ b/libc/src/stdio/ftell.cpp @@ -9,7 +9,7 @@ #include "src/stdio/ftell.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -17,7 +17,7 @@ LLVM_LIBC_FUNCTION(long, ftell, (::FILE * stream)) { auto result = reinterpret_cast<__llvm_libc::File *>(stream)->tell(); if (!result.has_value()) { - errno = result.error(); + libc_errno = result.error(); return -1; } return result.value(); diff --git a/libc/src/stdio/fwrite.cpp b/libc/src/stdio/fwrite.cpp --- a/libc/src/stdio/fwrite.cpp +++ b/libc/src/stdio/fwrite.cpp @@ -9,7 +9,7 @@ #include "src/stdio/fwrite.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -22,7 +22,7 @@ auto result = reinterpret_cast<__llvm_libc::File *>(stream)->write( buffer, size * nmemb); if (result.has_error()) - errno = result.error; + libc_errno = result.error; return result.value / size; } diff --git a/libc/src/stdio/fwrite_unlocked.cpp b/libc/src/stdio/fwrite_unlocked.cpp --- a/libc/src/stdio/fwrite_unlocked.cpp +++ b/libc/src/stdio/fwrite_unlocked.cpp @@ -9,7 +9,7 @@ #include "src/stdio/fwrite_unlocked.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -23,7 +23,7 @@ auto result = reinterpret_cast<__llvm_libc::File *>(stream)->write_unlocked( buffer, size * nmemb); if (result.has_error()) - errno = result.error; + libc_errno = result.error; return result.value / size; } diff --git a/libc/src/stdio/getc.cpp b/libc/src/stdio/getc.cpp --- a/libc/src/stdio/getc.cpp +++ b/libc/src/stdio/getc.cpp @@ -9,7 +9,7 @@ #include "src/stdio/getc.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -19,7 +19,7 @@ auto result = reinterpret_cast<__llvm_libc::File *>(stream)->read(&c, 1); size_t r = result.value; if (result.has_error()) - errno = result.error; + libc_errno = result.error; if (r != 1) return EOF; diff --git a/libc/src/stdio/getc_unlocked.cpp b/libc/src/stdio/getc_unlocked.cpp --- a/libc/src/stdio/getc_unlocked.cpp +++ b/libc/src/stdio/getc_unlocked.cpp @@ -9,7 +9,7 @@ #include "src/stdio/getc_unlocked.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -20,7 +20,7 @@ reinterpret_cast<__llvm_libc::File *>(stream)->read_unlocked(&c, 1); size_t r = result.value; if (result.has_error()) - errno = result.error; + libc_errno = result.error; if (r != 1) return EOF; diff --git a/libc/src/stdio/linux/remove.cpp b/libc/src/stdio/linux/remove.cpp --- a/libc/src/stdio/linux/remove.cpp +++ b/libc/src/stdio/linux/remove.cpp @@ -11,7 +11,7 @@ #include "src/__support/OSUtil/syscall.h" // For internal syscall function. #include "src/__support/common.h" -#include +#include "src/errno/libc_errno.h" #include // For AT_* macros. #include // For syscall numbers. @@ -25,7 +25,7 @@ ret = __llvm_libc::syscall_impl(SYS_unlinkat, AT_FDCWD, path, AT_REMOVEDIR); if (ret >= 0) return 0; - errno = -ret; + libc_errno = -ret; return -1; } diff --git a/libc/src/stdio/putc.cpp b/libc/src/stdio/putc.cpp --- a/libc/src/stdio/putc.cpp +++ b/libc/src/stdio/putc.cpp @@ -9,7 +9,7 @@ #include "src/stdio/putc.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -19,7 +19,7 @@ auto result = reinterpret_cast<__llvm_libc::File *>(stream)->write(&uc, 1); if (result.has_error()) - errno = result.error; + libc_errno = result.error; size_t written = result.value; if (1 != written) { diff --git a/libc/src/stdio/putchar.cpp b/libc/src/stdio/putchar.cpp --- a/libc/src/stdio/putchar.cpp +++ b/libc/src/stdio/putchar.cpp @@ -9,7 +9,7 @@ #include "src/stdio/putchar.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -19,7 +19,7 @@ auto result = __llvm_libc::stdout->write(&uc, 1); if (result.has_error()) - errno = result.error; + libc_errno = result.error; size_t written = result.value; if (1 != written) { diff --git a/libc/src/stdio/puts.cpp b/libc/src/stdio/puts.cpp --- a/libc/src/stdio/puts.cpp +++ b/libc/src/stdio/puts.cpp @@ -10,7 +10,7 @@ #include "src/__support/CPP/string_view.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -19,7 +19,7 @@ cpp::string_view str_view(str); auto result = __llvm_libc::stdout->write(str, str_view.size()); if (result.has_error()) - errno = result.error; + libc_errno = result.error; size_t written = result.value; if (str_view.size() != written) { // The stream should be in an error state in this case. @@ -27,7 +27,7 @@ } result = __llvm_libc::stdout->write("\n", 1); if (result.has_error()) - errno = result.error; + libc_errno = result.error; written = result.value; if (1 != written) { // The stream should be in an error state in this case. diff --git a/libc/src/stdio/setbuf.cpp b/libc/src/stdio/setbuf.cpp --- a/libc/src/stdio/setbuf.cpp +++ b/libc/src/stdio/setbuf.cpp @@ -9,7 +9,7 @@ #include "src/stdio/setbuf.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -22,7 +22,7 @@ int err = reinterpret_cast<__llvm_libc::File *>(stream)->set_buffer( buf, BUFSIZ, mode); if (err != 0) - errno = err; + libc_errno = err; } } // namespace __llvm_libc diff --git a/libc/src/stdio/setvbuf.cpp b/libc/src/stdio/setvbuf.cpp --- a/libc/src/stdio/setvbuf.cpp +++ b/libc/src/stdio/setvbuf.cpp @@ -9,7 +9,7 @@ #include "src/stdio/setvbuf.h" #include "src/__support/File/file.h" -#include +#include "src/errno/libc_errno.h" #include namespace __llvm_libc { @@ -20,7 +20,7 @@ int err = reinterpret_cast<__llvm_libc::File *>(stream)->set_buffer(buf, size, type); if (err != 0) - errno = err; + libc_errno = err; return err; } diff --git a/libc/src/stdlib/atof.cpp b/libc/src/stdlib/atof.cpp --- a/libc/src/stdlib/atof.cpp +++ b/libc/src/stdlib/atof.cpp @@ -9,14 +9,14 @@ #include "src/stdlib/atof.h" #include "src/__support/common.h" #include "src/__support/str_to_float.h" -#include +#include "src/errno/libc_errno.h" namespace __llvm_libc { LLVM_LIBC_FUNCTION(double, atof, (const char *str)) { auto result = internal::strtofloatingpoint(str); if (result.has_error()) - errno = result.error; + libc_errno = result.error; return result.value; } diff --git a/libc/src/stdlib/atoi.cpp b/libc/src/stdlib/atoi.cpp --- a/libc/src/stdlib/atoi.cpp +++ b/libc/src/stdlib/atoi.cpp @@ -9,6 +9,7 @@ #include "src/stdlib/atoi.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)(strtol). auto result = internal::strtointeger(str, 10); if (result.has_error()) - errno = result.error; + libc_errno = result.error; return static_cast(result); } diff --git a/libc/src/stdlib/atol.cpp b/libc/src/stdlib/atol.cpp --- a/libc/src/stdlib/atol.cpp +++ b/libc/src/stdlib/atol.cpp @@ -9,13 +9,14 @@ #include "src/stdlib/atol.h" #include "src/__support/common.h" #include "src/__support/str_to_integer.h" +#include "src/errno/libc_errno.h" namespace __llvm_libc { LLVM_LIBC_FUNCTION(long, atol, (const char *str)) { auto result = internal::strtointeger(str, 10); if (result.has_error()) - errno = result.error; + libc_errno = result.error; return result; } diff --git a/libc/src/stdlib/atoll.cpp b/libc/src/stdlib/atoll.cpp --- a/libc/src/stdlib/atoll.cpp +++ b/libc/src/stdlib/atoll.cpp @@ -9,13 +9,14 @@ #include "src/stdlib/atoll.h" #include "src/__support/common.h" #include "src/__support/str_to_integer.h" +#include "src/errno/libc_errno.h" namespace __llvm_libc { LLVM_LIBC_FUNCTION(long long, atoll, (const char *str)) { auto result = internal::strtointeger(str, 10); if (result.has_error()) - errno = result.error; + libc_errno = result.error; return result; } diff --git a/libc/src/stdlib/strtod.cpp b/libc/src/stdlib/strtod.cpp --- a/libc/src/stdlib/strtod.cpp +++ b/libc/src/stdlib/strtod.cpp @@ -9,7 +9,7 @@ #include "src/stdlib/strtod.h" #include "src/__support/common.h" #include "src/__support/str_to_float.h" -#include +#include "src/errno/libc_errno.h" namespace __llvm_libc { @@ -17,7 +17,7 @@ (const char *__restrict str, char **__restrict str_end)) { auto result = internal::strtofloatingpoint(str); if (result.has_error()) - errno = result.error; + libc_errno = result.error; if (str_end != NULL) *str_end = const_cast(str + result.parsed_len); diff --git a/libc/src/stdlib/strtof.cpp b/libc/src/stdlib/strtof.cpp --- a/libc/src/stdlib/strtof.cpp +++ b/libc/src/stdlib/strtof.cpp @@ -9,7 +9,7 @@ #include "src/stdlib/strtof.h" #include "src/__support/common.h" #include "src/__support/str_to_float.h" -#include +#include "src/errno/libc_errno.h" namespace __llvm_libc { @@ -17,7 +17,7 @@ (const char *__restrict str, char **__restrict str_end)) { auto result = internal::strtofloatingpoint(str); if (result.has_error()) - errno = result.error; + libc_errno = result.error; if (str_end != NULL) *str_end = const_cast(str + result.parsed_len); diff --git a/libc/src/stdlib/strtol.cpp b/libc/src/stdlib/strtol.cpp --- a/libc/src/stdlib/strtol.cpp +++ b/libc/src/stdlib/strtol.cpp @@ -9,6 +9,7 @@ #include "src/stdlib/strtol.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/stdlib/strtold.cpp b/libc/src/stdlib/strtold.cpp --- a/libc/src/stdlib/strtold.cpp +++ b/libc/src/stdlib/strtold.cpp @@ -9,7 +9,7 @@ #include "src/stdlib/strtold.h" #include "src/__support/common.h" #include "src/__support/str_to_float.h" -#include +#include "src/errno/libc_errno.h" namespace __llvm_libc { @@ -17,7 +17,7 @@ (const char *__restrict str, char **__restrict str_end)) { auto result = internal::strtofloatingpoint(str); if (result.has_error()) - errno = result.error; + libc_errno = result.error; if (str_end != NULL) *str_end = const_cast(str + result.parsed_len); diff --git a/libc/src/stdlib/strtoll.cpp b/libc/src/stdlib/strtoll.cpp --- a/libc/src/stdlib/strtoll.cpp +++ b/libc/src/stdlib/strtoll.cpp @@ -9,6 +9,7 @@ #include "src/stdlib/strtoll.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/stdlib/strtoul.cpp b/libc/src/stdlib/strtoul.cpp --- a/libc/src/stdlib/strtoul.cpp +++ b/libc/src/stdlib/strtoul.cpp @@ -9,6 +9,7 @@ #include "src/stdlib/strtoul.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/stdlib/strtoull.cpp b/libc/src/stdlib/strtoull.cpp --- a/libc/src/stdlib/strtoull.cpp +++ b/libc/src/stdlib/strtoull.cpp @@ -9,6 +9,7 @@ #include "src/stdlib/strtoull.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/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel @@ -288,6 +288,7 @@ ":__support_cpp_limits", ":__support_ctype_utils", ":__support_str_to_num_result", + ":errno", ], ) @@ -309,6 +310,7 @@ ":__support_str_to_integer", ":__support_str_to_num_result", ":__support_uint128", + ":errno", ], ) @@ -1331,6 +1333,7 @@ deps = [ ":__support_common", ":__support_str_to_integer", + ":errno", ], ) @@ -1341,6 +1344,7 @@ deps = [ ":__support_common", ":__support_str_to_integer", + ":errno", ], ) @@ -1351,6 +1355,7 @@ deps = [ ":__support_common", ":__support_str_to_integer", + ":errno", ], ) @@ -1361,6 +1366,7 @@ deps = [ ":__support_common", ":__support_str_to_float", + ":errno", ], ) @@ -1389,6 +1395,7 @@ deps = [ ":__support_common", ":__support_str_to_integer", + ":errno", ], ) @@ -1399,6 +1406,7 @@ deps = [ ":__support_common", ":__support_str_to_integer", + ":errno", ], ) @@ -1409,6 +1417,7 @@ deps = [ ":__support_common", ":__support_str_to_integer", + ":errno", ], ) @@ -1419,6 +1428,7 @@ deps = [ ":__support_common", ":__support_str_to_integer", + ":errno", ], ) @@ -1429,6 +1439,7 @@ deps = [ ":__support_common", ":__support_str_to_float", + ":errno", ], ) @@ -1439,6 +1450,7 @@ deps = [ ":__support_common", ":__support_str_to_float", + ":errno", ], ) @@ -1449,6 +1461,7 @@ deps = [ ":__support_common", ":__support_str_to_float", + ":errno", ], )