blob: 8690c8a3bab1d1e48f0d80ff60dda25276c3a0b1 [file] [log] [blame]
Imre Kisef5c2642021-12-17 14:07:35 +01001// SPDX-License-Identifier: BSD-3-Clause
2/*
Imre Kisd47a1452024-05-29 14:25:59 +02003 * Copyright (c) 2021-2024, Arm Limited and Contributors. All rights reserved.
Imre Kisef5c2642021-12-17 14:07:35 +01004 */
5
Imre Kisd47a1452024-05-29 14:25:59 +02006#include "libc_platform.h"
Imre Kisef5c2642021-12-17 14:07:35 +01007#include "trace.h"
8
9/*
10 * The generic trace function called on assert fail.
11 */
Imre Kisd47a1452024-05-29 14:25:59 +020012void __noreturn platform_assert(const char *file, int line, const char *func,
13 const char *failedexpr)
Imre Kisef5c2642021-12-17 14:07:35 +010014{
15#if TRACE_LEVEL >= TRACE_LEVEL_ERROR
Gabor Toth121288a2024-10-03 18:02:15 +020016 ts_trace_printf(func, line, TRACE_LEVEL_ERROR, "assertion %s failed", failedexpr);
Imre Kisef5c2642021-12-17 14:07:35 +010017#endif /* TRACE_LEVEL */
18
19 while (1)
20 ;
21}
Imre Kisd47a1452024-05-29 14:25:59 +020022
23void __noreturn platform_abort(void)
24{
25#if TRACE_LEVEL >= TRACE_LEVEL_ERROR
26 trace_puts("abort()");
27#endif /* TRACE_LEVEL */
28
29 while (1)
30 ;
31}