1*70ae480cSAlex Brachet //===-- Implementation of abort -------------------------------------------===// 2*70ae480cSAlex Brachet // 3*70ae480cSAlex Brachet // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*70ae480cSAlex Brachet // See https://llvm.org/LICENSE.txt for license information. 5*70ae480cSAlex Brachet // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*70ae480cSAlex Brachet // 7*70ae480cSAlex Brachet //===----------------------------------------------------------------------===// 8*70ae480cSAlex Brachet 9*70ae480cSAlex Brachet #include "src/__support/common.h" 10*70ae480cSAlex Brachet #include "src/signal/raise.h" 11*70ae480cSAlex Brachet #include "src/stdlib/_Exit.h" 12*70ae480cSAlex Brachet 13*70ae480cSAlex Brachet #include "src/stdlib/abort.h" 14*70ae480cSAlex Brachet 15*70ae480cSAlex Brachet namespace __llvm_libc { 16*70ae480cSAlex Brachet 17*70ae480cSAlex Brachet LLVM_LIBC_FUNCTION(void, abort, ()) { 18*70ae480cSAlex Brachet // TODO: When sigprocmask and sigaction land: 19*70ae480cSAlex Brachet // Unblock SIGABRT, raise it, if it was ignored or the handler returned, 20*70ae480cSAlex Brachet // change its action to SIG_DFL, raise it again. 21*70ae480cSAlex Brachet // TODO: When C11 mutexes land: 22*70ae480cSAlex Brachet // Acquire recursive mutex (in case the current signal handler for SIGABRT 23*70ae480cSAlex Brachet // itself calls abort we don't want to deadlock on the same thread trying 24*70ae480cSAlex Brachet // to acquire it's own mutex.) 25*70ae480cSAlex Brachet __llvm_libc::raise(SIGABRT); 26*70ae480cSAlex Brachet __llvm_libc::raise(SIGKILL); 27*70ae480cSAlex Brachet __llvm_libc::_Exit(127); 28*70ae480cSAlex Brachet } 29*70ae480cSAlex Brachet 30*70ae480cSAlex Brachet } // namespace __llvm_libc 31