xref: /freebsd/contrib/llvm-project/libcxx/include/__verbose_abort (revision 6246ae0b85d8159978c01ae916a9ad6cde9378b5)
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___VERBOSE_ABORT
11#define _LIBCPP___VERBOSE_ABORT
12
13#include <__availability>
14#include <__config>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#  pragma GCC system_header
18#endif
19
20// Provide a default implementation of __libcpp_verbose_abort if we know that neither the built
21// library not the user is providing one. Otherwise, just declare it and use the one from the
22// built library or the one provided by the user.
23//
24// We can't provide a great implementation because it needs to be pretty much
25// dependency-free (this is included everywhere else in the library).
26#if defined(_LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY) && !defined(_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED)
27
28extern "C" void abort();
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32_LIBCPP_NORETURN _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) _LIBCPP_HIDE_FROM_ABI inline
33void __libcpp_verbose_abort(const char *, ...) {
34  ::abort();
35  __builtin_unreachable(); // never reached, but needed to tell the compiler that the function never returns
36}
37
38_LIBCPP_END_NAMESPACE_STD
39
40#else
41
42_LIBCPP_BEGIN_NAMESPACE_STD
43
44_LIBCPP_NORETURN _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2)
45void __libcpp_verbose_abort(const char *__format, ...);
46
47_LIBCPP_END_NAMESPACE_STD
48
49#endif
50
51#endif // _LIBCPP___VERBOSE_ABORT
52