MOS Source Code
Loading...
Searching...
No Matches
moslib_global.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2// Preamble for MOS standard library headers.
3
4#pragma once
5
6#include <mos/types.h>
7
14#define MOS_LIB_ASSERT(cond) MOS_LIB_ASSERT_X(cond, "")
15
16#ifdef __MOS_KERNEL__ // ! Kernel
17
18#include "mos/assert.h"
19
20#define MOS_LIB_ASSERT_X(cond, msg, ...) MOS_ASSERT_X(cond, "" msg, ##__VA_ARGS__)
21#define MOS_LIB_UNIMPLEMENTED(content) MOS_UNIMPLEMENTED(content)
22#define MOS_LIB_UNREACHABLE() MOS_UNREACHABLE()
23
24#else // ! Userspace
25
26#include <mos/platform_syscall.h>
28
29#define MOS_LIB_ASSERT_X(cond, msg, ...) \
30 do \
31 { \
32 if (unlikely(!(cond))) \
33 fatal_abort("Assertion failed: '%s', " msg "\n", #cond, ##__VA_ARGS__); \
34 } while (0)
35
36MOSAPI void __printf(1, 2) fatal_abort(const char *fmt, ...);
37
38#define MOS_LIB_UNIMPLEMENTED(content) fatal_abort("Unimplemented: %s", content)
39#define MOS_LIB_UNREACHABLE() fatal_abort("Unreachable code reached")
40#define mos_panic(fmt, ...) fatal_abort(fmt "\n", ##__VA_ARGS__)
41#define mos_warn(fmt, ...) fprintf(stderr, "WARN: " fmt "\n", ##__VA_ARGS__)
42#endif
43
u32 const char * fmt
Definition assert.h:36
#define MOSAPI
Definition mos_global.h:102
#define __printf(a, b)
Definition mos_global.h:30