diff --git a/libc/src/errno/CMakeLists.txt b/libc/src/errno/CMakeLists.txt index b05fd4e31ff68..1d78a5eedff96 100644 --- a/libc/src/errno/CMakeLists.txt +++ b/libc/src/errno/CMakeLists.txt @@ -18,7 +18,6 @@ add_entrypoint_object( SRCS libc_errno.cpp HDRS - errno.h libc_errno.h # Include this COMPILE_OPTIONS ${full_build_flag} diff --git a/libc/src/errno/errno.h b/libc/src/errno/errno.h deleted file mode 100644 index a2df93513ec62..0000000000000 --- a/libc/src/errno/errno.h +++ /dev/null @@ -1,14 +0,0 @@ -//===-- Implementation header for errno -------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIBC_SRC_ERRNO_ERRNO_H -#define LLVM_LIBC_SRC_ERRNO_ERRNO_H - -extern "C" int *__llvm_libc_errno(); - -#endif // LLVM_LIBC_SRC_ERRNO_ERRNO_H diff --git a/libc/src/errno/libc_errno.cpp b/libc/src/errno/libc_errno.cpp index f7bd3a3b9eb4b..7b28a62c786b0 100644 --- a/libc/src/errno/libc_errno.cpp +++ b/libc/src/errno/libc_errno.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "libc_errno.h" -#include "src/errno/errno.h" #include "src/__support/macros/config.h" // libc never stores a value; `errno` macro uses get link-time failure. @@ -47,9 +46,6 @@ LIBC_ERRNO_MODE_SYSTEM namespace LIBC_NAMESPACE_DECL { -// Define the global `libc_errno` instance. -Errno libc_errno; - #if LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_UNDEFINED void Errno::operator=(int) {} @@ -61,9 +57,7 @@ namespace { LIBC_THREAD_LOCAL int thread_errno; } -extern "C" { -int *__llvm_libc_errno() { return &thread_errno; } -} +extern "C" int *__llvm_libc_errno() { return &thread_errno; } void Errno::operator=(int a) { thread_errno = a; } Errno::operator int() { return thread_errno; } @@ -74,9 +68,7 @@ namespace { int shared_errno; } -extern "C" { -int *__llvm_libc_errno() { return &shared_errno; } -} +extern "C" int *__llvm_libc_errno() { return &shared_errno; } void Errno::operator=(int a) { shared_errno = a; } Errno::operator int() { return shared_errno; } @@ -93,4 +85,7 @@ Errno::operator int() { return errno; } #endif +// Define the global `libc_errno` instance. +Errno libc_errno; + } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/errno/libc_errno.h b/libc/src/errno/libc_errno.h index c6c6b20b48251..82c65f5a0b7f6 100644 --- a/libc/src/errno/libc_errno.h +++ b/libc/src/errno/libc_errno.h @@ -33,6 +33,8 @@ namespace LIBC_NAMESPACE_DECL { +extern "C" int *__llvm_libc_errno(); + struct Errno { void operator=(int); operator int();