170ae480cSAlex Brachet //===-- Implementation of abort -------------------------------------------===// 270ae480cSAlex Brachet // 370ae480cSAlex Brachet // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 470ae480cSAlex Brachet // See https://llvm.org/LICENSE.txt for license information. 570ae480cSAlex Brachet // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 670ae480cSAlex Brachet // 770ae480cSAlex Brachet //===----------------------------------------------------------------------===// 870ae480cSAlex Brachet 970ae480cSAlex Brachet #include "src/__support/common.h" 10*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 1170ae480cSAlex Brachet #include "src/signal/raise.h" 1270ae480cSAlex Brachet #include "src/stdlib/_Exit.h" 1370ae480cSAlex Brachet 1470ae480cSAlex Brachet #include "src/stdlib/abort.h" 1570ae480cSAlex Brachet 16*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 1770ae480cSAlex Brachet 1870ae480cSAlex Brachet LLVM_LIBC_FUNCTION(void, abort, ()) { 1970ae480cSAlex Brachet // TODO: When sigprocmask and sigaction land: 2070ae480cSAlex Brachet // Unblock SIGABRT, raise it, if it was ignored or the handler returned, 2170ae480cSAlex Brachet // change its action to SIG_DFL, raise it again. 2270ae480cSAlex Brachet // TODO: When C11 mutexes land: 2370ae480cSAlex Brachet // Acquire recursive mutex (in case the current signal handler for SIGABRT 2470ae480cSAlex Brachet // itself calls abort we don't want to deadlock on the same thread trying 2570ae480cSAlex Brachet // to acquire it's own mutex.) 26b6bc9d72SGuillaume Chatelet LIBC_NAMESPACE::raise(SIGABRT); 27b6bc9d72SGuillaume Chatelet LIBC_NAMESPACE::raise(SIGKILL); 28b6bc9d72SGuillaume Chatelet LIBC_NAMESPACE::_Exit(127); 2970ae480cSAlex Brachet } 3070ae480cSAlex Brachet 31*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 32