[libc-commits] [libc] [libc] Remove src/errno/errno.h (PR #98759)
Petr Hosek via libc-commits
libc-commits at lists.llvm.org
Sat Jul 13 11:22:19 PDT 2024
https://github.com/petrhosek created https://github.com/llvm/llvm-project/pull/98759
This addresses the build error introduced in #98287 where src/errno/errno.h is included instead of the system errno.h.
We instead move the declaration to libc_errno.h.
>From 18c8b52f8873d1ad9c0e2243aa9077153b29a08f Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Sat, 13 Jul 2024 11:20:14 -0700
Subject: [PATCH] [libc] Remove src/errno/errno.h
This addresses the build error introduced in #98287 where
src/errno/errno.h is included instead of the system errno.h.
We instead move the declaration to libc_errno.h.
---
libc/src/errno/CMakeLists.txt | 1 -
libc/src/errno/errno.h | 14 --------------
libc/src/errno/libc_errno.cpp | 15 +++++----------
libc/src/errno/libc_errno.h | 2 ++
4 files changed, 7 insertions(+), 25 deletions(-)
delete mode 100644 libc/src/errno/errno.h
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();
More information about the libc-commits
mailing list