[libc-commits] [libc] [libc] Move the internal extern "C" symbols inside the namespace (PR #98232)
Petr Hosek via libc-commits
libc-commits at lists.llvm.org
Tue Jul 9 15:08:10 PDT 2024
https://github.com/petrhosek created https://github.com/llvm/llvm-project/pull/98232
This ensures that these symbols inherit the namespace visibility.
>From 1055a45e67ad9856d36104d60df1deeb39d1b968 Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Tue, 9 Jul 2024 15:06:54 -0700
Subject: [PATCH] [libc] Move the internal extern "C" symbols inside the
namespace
This ensures that these symbols inherit the namespace visibility.
---
libc/src/__support/OSUtil/baremetal/exit.cpp | 4 ++--
libc/src/__support/OSUtil/baremetal/io.cpp | 4 ++--
libc/src/stdlib/exit.cpp | 4 ++--
libc/startup/baremetal/fini.cpp | 4 ++--
libc/startup/baremetal/init.cpp | 4 ++--
5 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/libc/src/__support/OSUtil/baremetal/exit.cpp b/libc/src/__support/OSUtil/baremetal/exit.cpp
index 08473f7f3b00b..26088c28b0a50 100644
--- a/libc/src/__support/OSUtil/baremetal/exit.cpp
+++ b/libc/src/__support/OSUtil/baremetal/exit.cpp
@@ -8,11 +8,11 @@
#include "src/__support/OSUtil/exit.h"
+namespace LIBC_NAMESPACE::internal {
+
// This is intended to be provided by the vendor.
extern "C" [[noreturn]] void __llvm_libc_exit(int status);
-namespace LIBC_NAMESPACE::internal {
-
[[noreturn]] void exit(int status) { __llvm_libc_exit(status); }
} // namespace LIBC_NAMESPACE::internal
diff --git a/libc/src/__support/OSUtil/baremetal/io.cpp b/libc/src/__support/OSUtil/baremetal/io.cpp
index 5dd92e4a56ce4..c97bd5ae65b13 100644
--- a/libc/src/__support/OSUtil/baremetal/io.cpp
+++ b/libc/src/__support/OSUtil/baremetal/io.cpp
@@ -10,6 +10,8 @@
#include "src/__support/CPP/string_view.h"
+namespace LIBC_NAMESPACE {
+
// This is intended to be provided by the vendor.
extern struct __llvm_libc_stdin __llvm_libc_stdin;
@@ -17,8 +19,6 @@ extern "C" ssize_t __llvm_libc_stdin_read(void *cookie, char *buf, size_t size);
extern "C" void __llvm_libc_log_write(const char *msg, size_t len);
-namespace LIBC_NAMESPACE {
-
ssize_t read_from_stdin(char *buf, size_t size) {
return __llvm_libc_stdin_read(reinterpret_cast<void *>(&__llvm_libc_stdin),
buf, size);
diff --git a/libc/src/stdlib/exit.cpp b/libc/src/stdlib/exit.cpp
index 1f7ccbb556607..1afeec5a460da 100644
--- a/libc/src/stdlib/exit.cpp
+++ b/libc/src/stdlib/exit.cpp
@@ -10,10 +10,10 @@
#include "src/__support/OSUtil/exit.h"
#include "src/__support/common.h"
-extern "C" void __cxa_finalize(void *);
-
namespace LIBC_NAMESPACE {
+extern "C" void __cxa_finalize(void *);
+
[[noreturn]] LLVM_LIBC_FUNCTION(void, exit, (int status)) {
__cxa_finalize(nullptr);
internal::exit(status);
diff --git a/libc/startup/baremetal/fini.cpp b/libc/startup/baremetal/fini.cpp
index 84997fb4fa1d8..745bd094b24fe 100644
--- a/libc/startup/baremetal/fini.cpp
+++ b/libc/startup/baremetal/fini.cpp
@@ -9,13 +9,13 @@
#include <stddef.h>
#include <stdint.h>
+namespace LIBC_NAMESPACE {
+
extern "C" {
extern uintptr_t __fini_array_start[];
extern uintptr_t __fini_array_end[];
}
-namespace LIBC_NAMESPACE {
-
using FiniCallback = void(void);
extern "C" void __libc_fini_array(void) {
diff --git a/libc/startup/baremetal/init.cpp b/libc/startup/baremetal/init.cpp
index 08dff74f05198..21ec0e5ca756d 100644
--- a/libc/startup/baremetal/init.cpp
+++ b/libc/startup/baremetal/init.cpp
@@ -9,6 +9,8 @@
#include <stddef.h>
#include <stdint.h>
+namespace LIBC_NAMESPACE {
+
extern "C" {
extern uintptr_t __preinit_array_start[];
extern uintptr_t __preinit_array_end[];
@@ -16,8 +18,6 @@ extern uintptr_t __init_array_start[];
extern uintptr_t __init_array_end[];
}
-namespace LIBC_NAMESPACE {
-
using InitCallback = void(void);
extern "C" void __libc_init_array(void) {
More information about the libc-commits
mailing list