107bd4394SRoseZhang03 //===-- Implementation of quick_exit --------------------------------------===// 207bd4394SRoseZhang03 // 307bd4394SRoseZhang03 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 407bd4394SRoseZhang03 // See https://llvm.org/LICENSE.txt for license information. 507bd4394SRoseZhang03 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 607bd4394SRoseZhang03 // 707bd4394SRoseZhang03 //===----------------------------------------------------------------------===// 807bd4394SRoseZhang03 907bd4394SRoseZhang03 #include "src/stdlib/quick_exit.h" 1007bd4394SRoseZhang03 #include "src/__support/OSUtil/exit.h" 1107bd4394SRoseZhang03 #include "src/__support/common.h" 125ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 1339d38d66Saaryanshukla #include "src/stdlib/exit_handler.h" 1407bd4394SRoseZhang03 1507bd4394SRoseZhang03 // extern "C" void __cxa_finalize(void *); 165ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 1707bd4394SRoseZhang03 1839d38d66Saaryanshukla extern ExitCallbackList at_quick_exit_callbacks; 19*779a4440SSchrodinger ZHU Yifan [[gnu::weak]] extern void teardown_main_tls(); 2039d38d66Saaryanshukla 2107bd4394SRoseZhang03 [[noreturn]] LLVM_LIBC_FUNCTION(void, quick_exit, (int status)) { 2239d38d66Saaryanshukla call_exit_callbacks(at_quick_exit_callbacks); 23*779a4440SSchrodinger ZHU Yifan if (teardown_main_tls) 24*779a4440SSchrodinger ZHU Yifan teardown_main_tls(); 2507bd4394SRoseZhang03 internal::exit(status); 2607bd4394SRoseZhang03 } 2707bd4394SRoseZhang03 285ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 29