MOS Source Code
Loading...
Searching...
No Matches
assert.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
#pragma once
4
5
#include "
mos/misc/panic.h
"
6
7
#include <
mos/mos_global.h
>
8
#include <
mos/types.h
>
9
10
#define MOS_UNIMPLEMENTED(content) mos_panic("\nUNIMPLEMENTED: %s", content)
11
#define MOS_UNREACHABLE() mos_panic("\nUNREACHABLE line %d reached in file: %s", __LINE__, __FILE__)
12
#define MOS_UNREACHABLE_X(msg, ...) mos_panic("\nUNREACHABLE line %d reached in file: %s\n" msg, __LINE__, __FILE__, ##__VA_ARGS__)
13
#define MOS_ASSERT_ONCE(...) MOS_ASSERT_X(once(), __VA_ARGS__)
14
#define MOS_ASSERT(cond) MOS_ASSERT_X(cond, "")
15
#define MOS_ASSERT_X(cond, msg, ...) \
16
do \
17
{ \
18
if (unlikely(!(cond))) \
19
mos_panic_inline("Assertion failed: %s\n" msg, #cond, ##__VA_ARGS__); \
20
} while (0)
21
22
// these two also invokes a warning/panic handler
23
#define mos_warn(fmt, ...) mos_kwarn(__func__, __LINE__, "WARN: " fmt "\r\n", ##__VA_ARGS__)
24
25
#define mos_warn_once(...) \
26
do \
27
{ \
28
if (once()) \
29
mos_warn(__VA_ARGS__); \
30
} while (0)
31
32
#define spinlock_assert_locked(lock) MOS_ASSERT(spinlock_is_locked(lock))
33
34
__BEGIN_DECLS
35
36
__printf
(3, 4)
void
mos_kwarn
(const
char
*func,
u32
line
, const
char
*
fmt
, ...);
37
38
__END_DECLS
line
u32 line
Definition
assert.h:36
fmt
u32 const char * fmt
Definition
assert.h:36
void
MOSAPI void(1, 2) fatal_abort(const char *fmt
mos_global.h
__END_DECLS
#define __END_DECLS
Definition
mos_global.h:23
__BEGIN_DECLS
#define __BEGIN_DECLS
Definition
mos_global.h:22
__printf
#define __printf(a, b)
Definition
mos_global.h:30
mos_kwarn
void mos_kwarn(const char *func, u32 line, const char *fmt,...)
Definition
panic.c:163
panic.h
types.h
u32
unsigned int u32
Definition
types.h:21
kernel
include
private
mos
assert.h
Generated on Sun Sep 1 2024 18:22:52 for MOS Source Code by
1.12.0