Loading...
Searching...
No Matches
assert.h
Go to the documentation of this file.
/*
* (c) 2015 Adam Lackorzynski <adam@l4re.org>
*
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#pragma once
#ifdef NDEBUG
#define l4_assert(x) do { } while (0)
#define l4_check(x) do { (void)(x); } while (0)
#else
#include <l4/sys/compiler.h>
#include <l4/sys/thread.h>
#include <l4/sys/vcon.h>
#define l4_assert(expr) \
l4_assert_fn(!!(expr), __FILE__ ":" L4_stringify(__LINE__) ": Assertion \"" \
L4_stringify(expr) "\" failed.\n")
#define l4_check(expr) l4_assert(expr)
L4_ALWAYS_INLINE
void l4_assert_fn(unsigned expr, const char *text) L4_NOTHROW;
L4_INLINE L4_NORETURN
void l4_assert_abort(const char *text) L4_NOTHROW;
/* IMPLEMENTATION -----------------------------------------------------------*/
L4_INLINE L4_NORETURN
void l4_assert_abort(const char *text) L4_NOTHROW
{
l4_vcon_write(L4_BASE_LOG_CAP, text, __builtin_strlen(text));
for (;;)
l4_thread_ex_regs(L4_INVALID_CAP, ~0UL, ~0UL,
L4_THREAD_EX_REGS_TRIGGER_EXCEPTION);
}
L4_ALWAYS_INLINE
void l4_assert_fn(unsigned expr, const char *text) L4_NOTHROW
{
if (L4_LIKELY(expr))
return;
l4_assert_abort(text);
}
#endif /* NDEBUG */
compiler.h
L4 compiler related defines.
L4_BASE_LOG_CAP
@ L4_BASE_LOG_CAP
Capability selector for the log object.
Definition consts.h:347
L4_INVALID_CAP
@ L4_INVALID_CAP
Invalid capability selector.
Definition consts.h:153
l4_thread_ex_regs
l4_msgtag_t l4_thread_ex_regs(l4_cap_idx_t thread, l4_addr_t ip, l4_addr_t sp, l4_umword_t flags) L4_NOTHROW
Exchange basic thread registers.
Definition thread.h:942
L4_THREAD_EX_REGS_TRIGGER_EXCEPTION
@ L4_THREAD_EX_REGS_TRIGGER_EXCEPTION
Trigger artificial exception in thread.
Definition thread.h:800
l4_vcon_write
long l4_vcon_write(l4_cap_idx_t vcon, char const *buf, unsigned size) L4_NOTHROW
Write data to virtual console.
Definition vcon.h:336
L4_ALWAYS_INLINE
#define L4_ALWAYS_INLINE
Always inline a function.
Definition compiler.h:58
L4_NOTHROW
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:161
L4_INLINE
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
L4_NORETURN
#define L4_NORETURN
Noreturn function attribute.
Definition compiler.h:201
L4_LIKELY
#define L4_LIKELY(x)
Expression is likely to execute.
Definition compiler.h:283
thread.h
Common thread related definitions.
vcon.h
Virtual console interface.