aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/rtl/fail.c
blob: 51593af4e9cf150d6daf0b183414e47a840366d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

/*
 * Minimal bootstrap RTL (runtime library) - Failure handling.
 *
 * Copyright © 2025 Samuel Lidén Borell <samuel@kodafritt.se>
 *
 * SPDX-License-Identifier: EUPL-1.2+ OR LGPL-2.1-or-later
 */
#include <stdlib.h>
#include <stdio.h>
#include "rtl.h"
#include "internal.h"

SLUL_NORETURN void SLUL_assert_fail(const char *expr, const char *file,
                                    int line)
{
    fprintf(stderr, "%s:%d: Assertion `%s` failed.\n", file, line, expr);
    abort();
}

SLUL_NORETURN void SLUL_oom(const char *file, int line)
{
    fprintf(stderr, "%s:%d: Out of memory\n", file, line);
    abort();
}

SLUL_NORETURN void SLUL_fail(const char *file, int line, const char *msg)
{
    fprintf(stderr, "%s:%d: Internal error: %s\n", file, line, msg);
    abort();
}