aboutsummaryrefslogtreecommitdiff
path: root/libc/startup
diff options
context:
space:
mode:
authorGuillaume Chatelet <gchatelet@google.com>2023-09-26 11:45:04 +0200
committerGitHub <noreply@github.com>2023-09-26 11:45:04 +0200
commitb6bc9d72f65a5086f310f321e969d96e9a559e75 (patch)
tree1e9a9f8c36c9dfc0106507f7b7a0055af83c4a07 /libc/startup
parent7675f541f75baa20e8ec007cd625a837e89fc01f (diff)
downloadllvm-b6bc9d72f65a5086f310f321e969d96e9a559e75.zip
llvm-b6bc9d72f65a5086f310f321e969d96e9a559e75.tar.gz
llvm-b6bc9d72f65a5086f310f321e969d96e9a559e75.tar.bz2
[libc] Mass replace enclosing namespace (#67032)
This is step 4 of https://discourse.llvm.org/t/rfc-customizable-namespace-to-allow-testing-the-libc-when-the-system-libc-is-also-llvms-libc/73079
Diffstat (limited to 'libc/startup')
-rw-r--r--libc/startup/gpu/amdgpu/start.cpp12
-rw-r--r--libc/startup/gpu/nvptx/start.cpp10
-rw-r--r--libc/startup/linux/aarch64/start.cpp46
-rw-r--r--libc/startup/linux/riscv64/start.cpp54
-rw-r--r--libc/startup/linux/x86_64/start.cpp50
5 files changed, 86 insertions, 86 deletions
diff --git a/libc/startup/gpu/amdgpu/start.cpp b/libc/startup/gpu/amdgpu/start.cpp
index e6304ab..9e642db 100644
--- a/libc/startup/gpu/amdgpu/start.cpp
+++ b/libc/startup/gpu/amdgpu/start.cpp
@@ -13,13 +13,13 @@
extern "C" int main(int argc, char **argv, char **envp);
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
// The AMDGPU architecture provides a fixed frequency clock used for obtaining
// real time. However, the frequency of this clock varies between cards and can
// only be obtained via the driver. The loader will set this so we can use it.
extern "C" [[gnu::visibility("protected")]] uint64_t
- [[clang::address_space(4)]] __llvm_libc_clock_freq = 0;
+ [[clang::address_space(4)]] LIBC_NAMESPACE_clock_freq = 0;
extern "C" uintptr_t __init_array_start[];
extern "C" uintptr_t __init_array_end[];
@@ -41,7 +41,7 @@ static void call_fini_array_callbacks() {
reinterpret_cast<FiniCallback *>(__fini_array_start[i])();
}
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
extern "C" [[gnu::visibility("protected"), clang::amdgpu_kernel]] void
_begin(int argc, char **argv, char **env) {
@@ -49,8 +49,8 @@ _begin(int argc, char **argv, char **env) {
// callbacks are run. So, we register them before running the init
// array callbacks as they can potentially register their own atexit
// callbacks.
- __llvm_libc::atexit(&__llvm_libc::call_fini_array_callbacks);
- __llvm_libc::call_init_array_callbacks(argc, argv, env);
+ LIBC_NAMESPACE::atexit(&LIBC_NAMESPACE::call_fini_array_callbacks);
+ LIBC_NAMESPACE::call_init_array_callbacks(argc, argv, env);
}
extern "C" [[gnu::visibility("protected"), clang::amdgpu_kernel]] void
@@ -65,5 +65,5 @@ _end(int retval) {
// Only a single thread should call `exit` here, the rest should gracefully
// return from the kernel. This is so only one thread calls the destructors
// registred with 'atexit' above.
- __llvm_libc::exit(retval);
+ LIBC_NAMESPACE::exit(retval);
}
diff --git a/libc/startup/gpu/nvptx/start.cpp b/libc/startup/gpu/nvptx/start.cpp
index d5d3ad2..1ff187a 100644
--- a/libc/startup/gpu/nvptx/start.cpp
+++ b/libc/startup/gpu/nvptx/start.cpp
@@ -13,7 +13,7 @@
extern "C" int main(int argc, char **argv, char **envp);
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
extern "C" {
// Nvidia's 'nvlink' linker does not provide these symbols. We instead need
@@ -39,7 +39,7 @@ static void call_fini_array_callbacks() {
reinterpret_cast<FiniCallback *>(__fini_array_start[i])();
}
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
extern "C" [[gnu::visibility("protected"), clang::nvptx_kernel]] void
_begin(int argc, char **argv, char **env) {
@@ -47,8 +47,8 @@ _begin(int argc, char **argv, char **env) {
// callbacks are run. So, we register them before running the init
// array callbacks as they can potentially register their own atexit
// callbacks.
- __llvm_libc::atexit(&__llvm_libc::call_fini_array_callbacks);
- __llvm_libc::call_init_array_callbacks(argc, argv, env);
+ LIBC_NAMESPACE::atexit(&LIBC_NAMESPACE::call_fini_array_callbacks);
+ LIBC_NAMESPACE::call_init_array_callbacks(argc, argv, env);
}
extern "C" [[gnu::visibility("protected"), clang::nvptx_kernel]] void
@@ -62,5 +62,5 @@ extern "C" [[gnu::visibility("protected"), clang::nvptx_kernel]] void
_end(int retval) {
// To finis the execution we invoke all the callbacks registered via 'atexit'
// and then exit with the appropriate return value.
- __llvm_libc::exit(retval);
+ LIBC_NAMESPACE::exit(retval);
}
diff --git a/libc/startup/linux/aarch64/start.cpp b/libc/startup/linux/aarch64/start.cpp
index 7b94ae6..002af53 100644
--- a/libc/startup/linux/aarch64/start.cpp
+++ b/libc/startup/linux/aarch64/start.cpp
@@ -27,7 +27,7 @@ extern "C" int main(int, char **, char **);
// Source documentation:
// https://github.com/ARM-software/abi-aa/tree/main/sysvabi64
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
#ifdef SYS_mmap2
static constexpr long MMAP_SYSCALL_NUMBER = SYS_mmap2;
@@ -69,18 +69,18 @@ void init_tls(TLSDescriptor &tls_descriptor) {
// We cannot call the mmap function here as the functions set errno on
// failure. Since errno is implemented via a thread local variable, we cannot
// use errno before TLS is setup.
- long mmap_ret_val = __llvm_libc::syscall_impl<long>(
+ long mmap_ret_val = LIBC_NAMESPACE::syscall_impl<long>(
MMAP_SYSCALL_NUMBER, nullptr, alloc_size, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
// We cannot check the return value with MAP_FAILED as that is the return
// of the mmap function and not the mmap syscall.
if (mmap_ret_val < 0 && static_cast<uintptr_t>(mmap_ret_val) > -app.pageSize)
- __llvm_libc::syscall_impl<long>(SYS_exit, 1);
+ LIBC_NAMESPACE::syscall_impl<long>(SYS_exit, 1);
uintptr_t thread_ptr = uintptr_t(reinterpret_cast<uintptr_t *>(mmap_ret_val));
uintptr_t tls_addr = thread_ptr + size_of_pointers + padding;
- __llvm_libc::inline_memcpy(reinterpret_cast<char *>(tls_addr),
- reinterpret_cast<const char *>(app.tls.address),
- app.tls.init_size);
+ LIBC_NAMESPACE::inline_memcpy(reinterpret_cast<char *>(tls_addr),
+ reinterpret_cast<const char *>(app.tls.address),
+ app.tls.init_size);
tls_descriptor.size = alloc_size;
tls_descriptor.addr = thread_ptr;
tls_descriptor.tp = thread_ptr;
@@ -89,7 +89,7 @@ void init_tls(TLSDescriptor &tls_descriptor) {
void cleanup_tls(uintptr_t addr, uintptr_t size) {
if (size == 0)
return;
- __llvm_libc::syscall_impl<long>(SYS_munmap, addr, size);
+ LIBC_NAMESPACE::syscall_impl<long>(SYS_munmap, addr, size);
}
static void set_thread_ptr(uintptr_t val) { __arm_wsr64("tpidr_el0", val); }
@@ -123,9 +123,9 @@ static void call_fini_array_callbacks() {
reinterpret_cast<FiniCallback *>(__fini_array_start[i - 1])();
}
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
-using __llvm_libc::app;
+using LIBC_NAMESPACE::app;
// TODO: Would be nice to use the aux entry structure from elf.h when available.
struct AuxEntry {
@@ -134,10 +134,10 @@ struct AuxEntry {
};
__attribute__((noinline)) static void do_start() {
- auto tid = __llvm_libc::syscall_impl<long>(SYS_gettid);
+ auto tid = LIBC_NAMESPACE::syscall_impl<long>(SYS_gettid);
if (tid <= 0)
- __llvm_libc::syscall_impl<long>(SYS_exit, 1);
- __llvm_libc::main_thread_attrib.tid = static_cast<int>(tid);
+ LIBC_NAMESPACE::syscall_impl<long>(SYS_exit, 1);
+ LIBC_NAMESPACE::main_thread_attrib.tid = static_cast<int>(tid);
// After the argv array, is a 8-byte long NULL value before the array of env
// values. The end of the env values is marked by another 8-byte long NULL
@@ -184,22 +184,22 @@ __attribute__((noinline)) static void do_start() {
app.tls.align = phdr->p_align;
}
- __llvm_libc::TLSDescriptor tls;
- __llvm_libc::init_tls(tls);
+ LIBC_NAMESPACE::TLSDescriptor tls;
+ LIBC_NAMESPACE::init_tls(tls);
if (tls.size != 0)
- __llvm_libc::set_thread_ptr(tls.tp);
+ LIBC_NAMESPACE::set_thread_ptr(tls.tp);
- __llvm_libc::self.attrib = &__llvm_libc::main_thread_attrib;
- __llvm_libc::main_thread_attrib.atexit_callback_mgr =
- __llvm_libc::internal::get_thread_atexit_callback_mgr();
+ LIBC_NAMESPACE::self.attrib = &LIBC_NAMESPACE::main_thread_attrib;
+ LIBC_NAMESPACE::main_thread_attrib.atexit_callback_mgr =
+ LIBC_NAMESPACE::internal::get_thread_atexit_callback_mgr();
// We want the fini array callbacks to be run after other atexit
// callbacks are run. So, we register them before running the init
// array callbacks as they can potentially register their own atexit
// callbacks.
- __llvm_libc::atexit(&__llvm_libc::call_fini_array_callbacks);
+ LIBC_NAMESPACE::atexit(&LIBC_NAMESPACE::call_fini_array_callbacks);
- __llvm_libc::call_init_array_callbacks(
+ LIBC_NAMESPACE::call_init_array_callbacks(
static_cast<int>(app.args->argc),
reinterpret_cast<char **>(app.args->argv),
reinterpret_cast<char **>(env_ptr));
@@ -211,8 +211,8 @@ __attribute__((noinline)) static void do_start() {
// TODO: TLS cleanup should be done after all other atexit callbacks
// are run. So, register a cleanup callback for it with atexit before
// everything else.
- __llvm_libc::cleanup_tls(tls.addr, tls.size);
- __llvm_libc::exit(retval);
+ LIBC_NAMESPACE::cleanup_tls(tls.addr, tls.size);
+ LIBC_NAMESPACE::exit(retval);
}
extern "C" void _start() {
@@ -226,7 +226,7 @@ extern "C" void _start() {
// will take us to the previous stack pointer. That is the reason why the
// actual business logic of the startup code is pushed into a non-inline
// function do_start so that this function is free of any stack usage.
- app.args = reinterpret_cast<__llvm_libc::Args *>(
+ app.args = reinterpret_cast<LIBC_NAMESPACE::Args *>(
reinterpret_cast<uintptr_t *>(__builtin_frame_address(0)) + 2);
do_start();
}
diff --git a/libc/startup/linux/riscv64/start.cpp b/libc/startup/linux/riscv64/start.cpp
index 1bf05b9..ed976d2 100644
--- a/libc/startup/linux/riscv64/start.cpp
+++ b/libc/startup/linux/riscv64/start.cpp
@@ -22,7 +22,7 @@
extern "C" int main(int, char **, char **);
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
#ifdef SYS_mmap2
static constexpr long MMAP_SYSCALL_NUMBER = SYS_mmap2;
@@ -56,18 +56,18 @@ void init_tls(TLSDescriptor &tls_descriptor) {
// We cannot call the mmap function here as the functions set errno on
// failure. Since errno is implemented via a thread local variable, we cannot
// use errno before TLS is setup.
- long mmap_ret_val = __llvm_libc::syscall_impl<long>(
+ long mmap_ret_val = LIBC_NAMESPACE::syscall_impl<long>(
MMAP_SYSCALL_NUMBER, nullptr, alloc_size, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
// We cannot check the return value with MAP_FAILED as that is the return
// of the mmap function and not the mmap syscall.
if (mmap_ret_val < 0 && static_cast<uintptr_t>(mmap_ret_val) > -app.pageSize)
- __llvm_libc::syscall_impl<long>(SYS_exit, 1);
+ LIBC_NAMESPACE::syscall_impl<long>(SYS_exit, 1);
uintptr_t thread_ptr = uintptr_t(reinterpret_cast<uintptr_t *>(mmap_ret_val));
uintptr_t tls_addr = thread_ptr + size_of_pointers + padding;
- __llvm_libc::inline_memcpy(reinterpret_cast<char *>(tls_addr),
- reinterpret_cast<const char *>(app.tls.address),
- app.tls.init_size);
+ LIBC_NAMESPACE::inline_memcpy(reinterpret_cast<char *>(tls_addr),
+ reinterpret_cast<const char *>(app.tls.address),
+ app.tls.init_size);
tls_descriptor.size = alloc_size;
tls_descriptor.addr = thread_ptr;
tls_descriptor.tp = tls_addr;
@@ -76,7 +76,7 @@ void init_tls(TLSDescriptor &tls_descriptor) {
void cleanup_tls(uintptr_t addr, uintptr_t size) {
if (size == 0)
return;
- __llvm_libc::syscall_impl<long>(SYS_munmap, addr, size);
+ LIBC_NAMESPACE::syscall_impl<long>(SYS_munmap, addr, size);
}
static void set_thread_ptr(uintptr_t val) {
@@ -112,14 +112,14 @@ static void call_fini_array_callbacks() {
reinterpret_cast<FiniCallback *>(__fini_array_start[i - 1])();
}
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
-using __llvm_libc::app;
+using LIBC_NAMESPACE::app;
// TODO: Would be nice to use the aux entry structure from elf.h when available.
struct AuxEntry {
- __llvm_libc::AuxEntryType type;
- __llvm_libc::AuxEntryType value;
+ LIBC_NAMESPACE::AuxEntryType type;
+ LIBC_NAMESPACE::AuxEntryType value;
};
#if defined(LIBC_TARGET_ARCH_IS_X86_64) || \
@@ -137,16 +137,16 @@ __attribute__((noinline)) static void do_start() {
".option norelax\n\t"
"lla gp, __global_pointer$\n\t"
".option pop\n\t");
- auto tid = __llvm_libc::syscall_impl<long>(SYS_gettid);
+ auto tid = LIBC_NAMESPACE::syscall_impl<long>(SYS_gettid);
if (tid <= 0)
- __llvm_libc::syscall_impl<long>(SYS_exit, 1);
- __llvm_libc::main_thread_attrib.tid = static_cast<int>(tid);
+ LIBC_NAMESPACE::syscall_impl<long>(SYS_exit, 1);
+ LIBC_NAMESPACE::main_thread_attrib.tid = static_cast<int>(tid);
// After the argv array, is a 8-byte long NULL value before the array of env
// values. The end of the env values is marked by another 8-byte long NULL
// value. We step over it (the "+ 1" below) to get to the env values.
- __llvm_libc::ArgVEntryType *env_ptr = app.args->argv + app.args->argc + 1;
- __llvm_libc::ArgVEntryType *env_end_marker = env_ptr;
+ LIBC_NAMESPACE::ArgVEntryType *env_ptr = app.args->argv + app.args->argc + 1;
+ LIBC_NAMESPACE::ArgVEntryType *env_end_marker = env_ptr;
app.envPtr = env_ptr;
while (*env_end_marker)
++env_end_marker;
@@ -187,22 +187,22 @@ __attribute__((noinline)) static void do_start() {
app.tls.align = phdr->p_align;
}
- __llvm_libc::TLSDescriptor tls;
- __llvm_libc::init_tls(tls);
+ LIBC_NAMESPACE::TLSDescriptor tls;
+ LIBC_NAMESPACE::init_tls(tls);
if (tls.size != 0)
- __llvm_libc::set_thread_ptr(tls.tp);
+ LIBC_NAMESPACE::set_thread_ptr(tls.tp);
- __llvm_libc::self.attrib = &__llvm_libc::main_thread_attrib;
- __llvm_libc::main_thread_attrib.atexit_callback_mgr =
- __llvm_libc::internal::get_thread_atexit_callback_mgr();
+ LIBC_NAMESPACE::self.attrib = &LIBC_NAMESPACE::main_thread_attrib;
+ LIBC_NAMESPACE::main_thread_attrib.atexit_callback_mgr =
+ LIBC_NAMESPACE::internal::get_thread_atexit_callback_mgr();
// We want the fini array callbacks to be run after other atexit
// callbacks are run. So, we register them before running the init
// array callbacks as they can potentially register their own atexit
// callbacks.
- __llvm_libc::atexit(&__llvm_libc::call_fini_array_callbacks);
+ LIBC_NAMESPACE::atexit(&LIBC_NAMESPACE::call_fini_array_callbacks);
- __llvm_libc::call_init_array_callbacks(
+ LIBC_NAMESPACE::call_init_array_callbacks(
static_cast<int>(app.args->argc),
reinterpret_cast<char **>(app.args->argv),
reinterpret_cast<char **>(env_ptr));
@@ -214,13 +214,13 @@ __attribute__((noinline)) static void do_start() {
// TODO: TLS cleanup should be done after all other atexit callbacks
// are run. So, register a cleanup callback for it with atexit before
// everything else.
- __llvm_libc::cleanup_tls(tls.addr, tls.size);
- __llvm_libc::exit(retval);
+ LIBC_NAMESPACE::cleanup_tls(tls.addr, tls.size);
+ LIBC_NAMESPACE::exit(retval);
}
extern "C" void _start() {
// Fetch the args using the frame pointer.
- app.args = reinterpret_cast<__llvm_libc::Args *>(
+ app.args = reinterpret_cast<LIBC_NAMESPACE::Args *>(
reinterpret_cast<uintptr_t *>(__builtin_frame_address(0)));
do_start();
}
diff --git a/libc/startup/linux/x86_64/start.cpp b/libc/startup/linux/x86_64/start.cpp
index 2f9dbfd..4b46a4f 100644
--- a/libc/startup/linux/x86_64/start.cpp
+++ b/libc/startup/linux/x86_64/start.cpp
@@ -23,7 +23,7 @@
extern "C" int main(int, char **, char **);
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
#ifdef SYS_mmap2
static constexpr long mmapSyscallNumber = SYS_mmap2;
@@ -59,13 +59,13 @@ void init_tls(TLSDescriptor &tls_descriptor) {
// We cannot call the mmap function here as the functions set errno on
// failure. Since errno is implemented via a thread local variable, we cannot
// use errno before TLS is setup.
- long mmapRetVal = __llvm_libc::syscall_impl<long>(
+ long mmapRetVal = LIBC_NAMESPACE::syscall_impl<long>(
mmapSyscallNumber, nullptr, tlsSizeWithAddr, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
// We cannot check the return value with MAP_FAILED as that is the return
// of the mmap function and not the mmap syscall.
if (mmapRetVal < 0 && static_cast<uintptr_t>(mmapRetVal) > -app.pageSize)
- __llvm_libc::syscall_impl<long>(SYS_exit, 1);
+ LIBC_NAMESPACE::syscall_impl<long>(SYS_exit, 1);
uintptr_t *tlsAddr = reinterpret_cast<uintptr_t *>(mmapRetVal);
// x86_64 TLS faces down from the thread pointer with the first entry
@@ -73,9 +73,9 @@ void init_tls(TLSDescriptor &tls_descriptor) {
uintptr_t endPtr = reinterpret_cast<uintptr_t>(tlsAddr) + tlsSize;
*reinterpret_cast<uintptr_t *>(endPtr) = endPtr;
- __llvm_libc::inline_memcpy(reinterpret_cast<char *>(tlsAddr),
- reinterpret_cast<const char *>(app.tls.address),
- app.tls.init_size);
+ LIBC_NAMESPACE::inline_memcpy(reinterpret_cast<char *>(tlsAddr),
+ reinterpret_cast<const char *>(app.tls.address),
+ app.tls.init_size);
tls_descriptor = {tlsSizeWithAddr, uintptr_t(tlsAddr), endPtr};
return;
@@ -84,12 +84,12 @@ void init_tls(TLSDescriptor &tls_descriptor) {
void cleanup_tls(uintptr_t addr, uintptr_t size) {
if (size == 0)
return;
- __llvm_libc::syscall_impl<long>(SYS_munmap, addr, size);
+ LIBC_NAMESPACE::syscall_impl<long>(SYS_munmap, addr, size);
}
// Sets the thread pointer to |val|. Returns true on success, false on failure.
static bool set_thread_ptr(uintptr_t val) {
- return __llvm_libc::syscall_impl(SYS_arch_prctl, ARCH_SET_FS, val) != -1;
+ return LIBC_NAMESPACE::syscall_impl(SYS_arch_prctl, ARCH_SET_FS, val) != -1;
}
using InitCallback = void(int, char **, char **);
@@ -121,9 +121,9 @@ static void call_fini_array_callbacks() {
reinterpret_cast<FiniCallback *>(__fini_array_start[i - 1])();
}
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
-using __llvm_libc::app;
+using LIBC_NAMESPACE::app;
// TODO: Would be nice to use the aux entry structure from elf.h when available.
struct AuxEntry {
@@ -135,7 +135,7 @@ extern "C" void _start() {
// This TU is compiled with -fno-omit-frame-pointer. Hence, the previous value
// of the base pointer is pushed on to the stack. So, we step over it (the
// "+ 1" below) to get to the args.
- app.args = reinterpret_cast<__llvm_libc::Args *>(
+ app.args = reinterpret_cast<LIBC_NAMESPACE::Args *>(
reinterpret_cast<uintptr_t *>(__builtin_frame_address(0)) + 1);
// The x86_64 ABI requires that the stack pointer is aligned to a 16-byte
@@ -152,10 +152,10 @@ extern "C" void _start() {
__asm__ __volatile__("andq $0xfffffffffffffff0, %rsp\n\t");
__asm__ __volatile__("andq $0xfffffffffffffff0, %rbp\n\t");
- auto tid = __llvm_libc::syscall_impl<long>(SYS_gettid);
+ auto tid = LIBC_NAMESPACE::syscall_impl<long>(SYS_gettid);
if (tid <= 0)
- __llvm_libc::syscall_impl<long>(SYS_exit, 1);
- __llvm_libc::main_thread_attrib.tid = static_cast<int>(tid);
+ LIBC_NAMESPACE::syscall_impl<long>(SYS_exit, 1);
+ LIBC_NAMESPACE::main_thread_attrib.tid = static_cast<int>(tid);
// After the argv array, is a 8-byte long NULL value before the array of env
// values. The end of the env values is marked by another 8-byte long NULL
@@ -202,22 +202,22 @@ extern "C" void _start() {
app.tls.align = phdr->p_align;
}
- __llvm_libc::TLSDescriptor tls;
- __llvm_libc::init_tls(tls);
- if (tls.size != 0 && !__llvm_libc::set_thread_ptr(tls.tp))
- __llvm_libc::syscall_impl<long>(SYS_exit, 1);
+ LIBC_NAMESPACE::TLSDescriptor tls;
+ LIBC_NAMESPACE::init_tls(tls);
+ if (tls.size != 0 && !LIBC_NAMESPACE::set_thread_ptr(tls.tp))
+ LIBC_NAMESPACE::syscall_impl<long>(SYS_exit, 1);
- __llvm_libc::self.attrib = &__llvm_libc::main_thread_attrib;
- __llvm_libc::main_thread_attrib.atexit_callback_mgr =
- __llvm_libc::internal::get_thread_atexit_callback_mgr();
+ LIBC_NAMESPACE::self.attrib = &LIBC_NAMESPACE::main_thread_attrib;
+ LIBC_NAMESPACE::main_thread_attrib.atexit_callback_mgr =
+ LIBC_NAMESPACE::internal::get_thread_atexit_callback_mgr();
// We want the fini array callbacks to be run after other atexit
// callbacks are run. So, we register them before running the init
// array callbacks as they can potentially register their own atexit
// callbacks.
- __llvm_libc::atexit(&__llvm_libc::call_fini_array_callbacks);
+ LIBC_NAMESPACE::atexit(&LIBC_NAMESPACE::call_fini_array_callbacks);
- __llvm_libc::call_init_array_callbacks(
+ LIBC_NAMESPACE::call_init_array_callbacks(
static_cast<int>(app.args->argc),
reinterpret_cast<char **>(app.args->argv),
reinterpret_cast<char **>(env_ptr));
@@ -229,6 +229,6 @@ extern "C" void _start() {
// TODO: TLS cleanup should be done after all other atexit callbacks
// are run. So, register a cleanup callback for it with atexit before
// everything else.
- __llvm_libc::cleanup_tls(tls.addr, tls.size);
- __llvm_libc::exit(retval);
+ LIBC_NAMESPACE::cleanup_tls(tls.addr, tls.size);
+ LIBC_NAMESPACE::exit(retval);
}