|
1 | | -//===-- Implementation header for abort_handler_s ---------------*- C++ -*-===// |
| 1 | +//===-- Implementation for abort_handler_s ----------------------*- C++ -*-===// |
2 | 2 | // |
3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | 6 | // |
7 | 7 | //===----------------------------------------------------------------------===// |
8 | 8 |
|
9 | | -#ifndef LLVM_LIBC_SRC___SUPPORT_ANNEX_K_ABORT_HANDLER_S_H |
10 | | -#define LLVM_LIBC_SRC___SUPPORT_ANNEX_K_ABORT_HANDLER_S_H |
11 | | - |
| 9 | +#include "src/stdlib/abort_handler_s.h" |
12 | 10 | #include "hdr/stdio_macros.h" |
13 | 11 | #include "hdr/types/errno_t.h" |
| 12 | +#include "src/__support/common.h" |
14 | 13 | #include "src/__support/libc_errno.h" |
15 | | -#include "src/__support/macros/attributes.h" |
16 | | -#include "src/__support/macros/config.h" |
17 | | -#include "src/__support/OSUtil/io.h" |
| 14 | +#include <stdio.h> |
18 | 15 | #include <stdlib.h> |
19 | 16 |
|
20 | 17 | namespace LIBC_NAMESPACE_DECL { |
21 | 18 |
|
22 | | -LIBC_INLINE static void abort_handler_s(const char *__restrict msg, |
23 | | - [[maybe_unused]] void *__restrict ptr, |
24 | | - errno_t error) { |
| 19 | +LLVM_LIBC_FUNCTION(void, abort_handler_s, |
| 20 | + (const char *__restrict msg, |
| 21 | + [[maybe_unused]] void *__restrict ptr, errno_t error)) { |
25 | 22 | libc_errno = error; |
26 | | - write_to_stderr("abort_handler_s was called in response to a " |
| 23 | + fprintf(stderr, "abort_handler_s was called in response to a " |
27 | 24 | "runtime-constraint violation.\n\n"); |
28 | | - if (msg) { |
29 | | - write_to_stderr(msg); |
30 | | - write_to_stderr("\n"); |
31 | | - } |
32 | | - |
33 | | - write_to_stderr( |
| 25 | + if (msg) |
| 26 | + fprintf(stderr, "%s\n", msg); |
| 27 | + fprintf(stderr, |
34 | 28 | "\n\nNote to end users: This program was terminated as a result\ |
35 | 29 | of a bug present in the software. Please reach out to your \ |
36 | 30 | software's vendor to get more help.\n"); |
37 | 31 |
|
| 32 | + fflush(stderr); |
| 33 | + |
38 | 34 | abort(); |
39 | 35 | } |
40 | 36 |
|
41 | 37 | } // namespace LIBC_NAMESPACE_DECL |
42 | | - |
43 | | -#endif // LLVM_LIBC_SRC___SUPPORT_ANNEX_K_ABORT_HANDLER_S_H |
0 commit comments