/* * Common declarations for the transpiled C code that the bootstrap * compiler outputs. * * Copyright © 2025 Samuel Lidén Borell * * SPDX-License-Identifier: EUPL-1.2+ OR LGPL-2.1-or-later OR MIT-0 */ #ifndef SLUL_RTL_H #define SLUL_RTL_H #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L #undef bool #undef true #undef false #define bool int #define true 1 #define false 0 #elif __STDC_VERSION__ < 202311L #include #endif #include /* for uint64_t. Not actually part of C89 */ #include #include /* Define unreachable() */ #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L /* C23 already has unreachable in stddef.h */ #elif (defined(__GNUC__) && __GNUC__ > 4) || defined(__clang__) #define SLUL_unreachable() __builtin_unreachable() #else #define SLUL_unreachable() ((void)0) #endif /* Define NORETURN */ #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L #define SLUL_NORETURN [[noreturn]] #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #define SLUL_NORETURN _Noreturn #elif (defined(__GNUC__) && __GNUC__ > 2) || defined(__clang__) #define SLUL_NORETURN __attribute__((__noreturn__)) #else #define SLUL_NORETURN #endif enum SlulStrLen { SLUL_SL_UPTO_17F = 0x80, SLUL_SL_UPTO_1017F, SLUL_SL_UPTO_10001017F }; #define SLUL_ASSERT(c_expr, orig_expr, file, line) do { \ if (!(c_expr)) { \ SLUL_assert_fail((orig_expr), (file), (line)); \ } \ } while (0) SLUL_NORETURN void SLUL_assert_fail(const char *expr, const char *file, int line); #endif