Skip to content

Commit

Permalink
[libc] Remove src/errno/errno.h (llvm#98759)
Browse files Browse the repository at this point in the history
This addresses the build error introduced in llvm#98287 where
src/errno/errno.h is included instead of the system errno.h.

We instead move the declaration to libc_errno.h.
  • Loading branch information
petrhosek committed Jul 13, 2024
1 parent f96e4e8 commit 4a68654
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 25 deletions.
1 change: 0 additions & 1 deletion libc/src/errno/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ add_entrypoint_object(
SRCS
libc_errno.cpp
HDRS
errno.h
libc_errno.h # Include this
COMPILE_OPTIONS
${full_build_flag}
Expand Down
14 changes: 0 additions & 14 deletions libc/src/errno/errno.h

This file was deleted.

15 changes: 5 additions & 10 deletions libc/src/errno/libc_errno.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {}
Expand All @@ -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; }
Expand All @@ -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; }
Expand All @@ -93,4 +85,7 @@ Errno::operator int() { return errno; }

#endif

// Define the global `libc_errno` instance.
Errno libc_errno;

} // namespace LIBC_NAMESPACE_DECL
2 changes: 2 additions & 0 deletions libc/src/errno/libc_errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

namespace LIBC_NAMESPACE_DECL {

extern "C" int *__llvm_libc_errno();

struct Errno {
void operator=(int);
operator int();
Expand Down

0 comments on commit 4a68654

Please sign in to comment.