161cfbce3SDimitry Andric// -*- C++ -*- 261cfbce3SDimitry Andric//===----------------------------------------------------------------------===// 361cfbce3SDimitry Andric// 461cfbce3SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 561cfbce3SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 661cfbce3SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 761cfbce3SDimitry Andric// 861cfbce3SDimitry Andric//===----------------------------------------------------------------------===// 961cfbce3SDimitry Andric 1061cfbce3SDimitry Andric#ifndef _LIBCPP___VERBOSE_ABORT 1161cfbce3SDimitry Andric#define _LIBCPP___VERBOSE_ABORT 1261cfbce3SDimitry Andric 1361cfbce3SDimitry Andric#include <__availability> 1461cfbce3SDimitry Andric#include <__config> 1561cfbce3SDimitry Andric 1661cfbce3SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1761cfbce3SDimitry Andric# pragma GCC system_header 1861cfbce3SDimitry Andric#endif 1961cfbce3SDimitry Andric 2061cfbce3SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 2161cfbce3SDimitry Andric 22*bdd1243dSDimitry Andric// This function should never be called directly from the code -- it should only be called through 23*bdd1243dSDimitry Andric// the _LIBCPP_VERBOSE_ABORT macro. 2461cfbce3SDimitry Andric_LIBCPP_NORETURN _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) 2561cfbce3SDimitry Andricvoid __libcpp_verbose_abort(const char *__format, ...); 2661cfbce3SDimitry Andric 27*bdd1243dSDimitry Andric// _LIBCPP_VERBOSE_ABORT(format, args...) 28*bdd1243dSDimitry Andric// 29*bdd1243dSDimitry Andric// This macro is used to abort the program abnormally while providing additional diagnostic information. 30*bdd1243dSDimitry Andric// 31*bdd1243dSDimitry Andric// The first argument is a printf-style format string, and the remaining arguments are values to format 32*bdd1243dSDimitry Andric// into the format-string. This macro can be customized by users to provide fine-grained control over 33*bdd1243dSDimitry Andric// how verbose termination is triggered. 34*bdd1243dSDimitry Andric// 35*bdd1243dSDimitry Andric// If the user does not supply their own version of the _LIBCPP_VERBOSE_ABORT macro, we pick the default 36*bdd1243dSDimitry Andric// behavior based on whether we know the built library we're running against provides support for the 37*bdd1243dSDimitry Andric// verbose termination handler or not. If it does, we call it. If it doesn't, we call __builtin_abort to 38*bdd1243dSDimitry Andric// make sure that the program terminates but without taking any complex dependencies in this header. 39*bdd1243dSDimitry Andric#if !defined(_LIBCPP_VERBOSE_ABORT) 4061cfbce3SDimitry Andric 41*bdd1243dSDimitry Andric// Support _LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED until LLVM 18, but tell people 42*bdd1243dSDimitry Andric// to move to customizing _LIBCPP_VERBOSE_ABORT instead. 43*bdd1243dSDimitry Andric# if defined(_LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY) && defined(_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED) 44*bdd1243dSDimitry Andric# undef _LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY 45*bdd1243dSDimitry Andric# warning _LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED is deprecated, please customize _LIBCPP_VERBOSE_ABORT instead 4661cfbce3SDimitry Andric# endif 4761cfbce3SDimitry Andric 48*bdd1243dSDimitry Andric# if defined(_LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY) 49*bdd1243dSDimitry Andric# define _LIBCPP_VERBOSE_ABORT(...) __builtin_abort() 50*bdd1243dSDimitry Andric# else 51*bdd1243dSDimitry Andric# define _LIBCPP_VERBOSE_ABORT(...) ::std::__libcpp_verbose_abort(__VA_ARGS__) 52*bdd1243dSDimitry Andric# endif 53*bdd1243dSDimitry Andric#endif // !defined(_LIBCPP_VERBOSE_ABORT) 54*bdd1243dSDimitry Andric 55*bdd1243dSDimitry Andric_LIBCPP_END_NAMESPACE_STD 56*bdd1243dSDimitry Andric 5761cfbce3SDimitry Andric#endif // _LIBCPP___VERBOSE_ABORT 58