brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · f26d48a Raw
38 lines · cpp
1//===-- Implementation of exit --------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/stdlib/exit.h"10#include "src/__support/OSUtil/exit.h"11#include "src/__support/common.h"12#include "src/__support/macros/config.h"13 14namespace LIBC_NAMESPACE_DECL {15 16extern "C" void __cxa_finalize(void *);17 18// exit needs to clean up TLS and call associated destructors.19// TODO: Strictly speaking, it is not valid to call exit in overlay mode20//       as we have no way to ensure system libc will call the TLS destructors.21//       We should run exit related tests in hermetic mode but this is currently22//       blocked by https://github.com/llvm/llvm-project/issues/133925.23extern "C" [[gnu::weak]] void __cxa_thread_finalize();24 25// TODO: use recursive mutex to protect this routine.26[[noreturn]] LLVM_LIBC_FUNCTION(void, exit, (int status)) {27// FIXME: The NVPTX target does not support external weak symbols correctly28//        despite being an ELF platform. Disable pending a future split.29#if !defined(LIBC_TARGET_ARCH_IS_NVPTX)30  if (__cxa_thread_finalize)31    __cxa_thread_finalize();32#endif33  __cxa_finalize(nullptr);34  internal::exit(status);35}36 37} // namespace LIBC_NAMESPACE_DECL38