add src/assert.c, fix rt_atomic macro and use it for pointers also
This commit is contained in:
parent
8ce7957629
commit
28eb29e099
|
@ -1,4 +1,3 @@
|
|||
#include <rt/assert.h>
|
||||
#include <rt/context.h>
|
||||
#include <rt/cycle.h>
|
||||
#include <rt/idle.h>
|
||||
|
@ -77,17 +76,6 @@ void rt_syscall(void)
|
|||
__asm__("svc 0" ::: "memory");
|
||||
}
|
||||
|
||||
static const char *volatile rt_assert_msg;
|
||||
|
||||
__attribute__((weak)) void rt_assert(bool condition, const char *msg)
|
||||
{
|
||||
if (!condition)
|
||||
{
|
||||
rt_assert_msg = msg;
|
||||
rt_trap();
|
||||
}
|
||||
}
|
||||
|
||||
#if V6M
|
||||
#include "m/atomic-v6.c"
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <rt/atomic.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -14,7 +14,7 @@ extern "C" {
|
|||
* _Atomic as a macro in stdatomic.h, in terms of std::atomic. */
|
||||
#define rt_atomic(t) _Atomic(t)
|
||||
#else
|
||||
#define rt_atomic(t) _Atomic t
|
||||
#define rt_atomic(t) t _Atomic
|
||||
#endif
|
||||
|
||||
typedef rt_atomic(bool) rt_atomic_bool;
|
||||
|
|
|
@ -3,6 +3,7 @@ Import("env")
|
|||
librt = env.StaticLibrary(
|
||||
target="rt",
|
||||
source=[
|
||||
"assert.c",
|
||||
"barrier.c",
|
||||
"cond.c",
|
||||
"list.c",
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#include <rt/assert.h>
|
||||
|
||||
#include <rt/atomic.h>
|
||||
#include <rt/trap.h>
|
||||
|
||||
static rt_atomic(const char *) rt_assert_msg;
|
||||
|
||||
__attribute__((weak)) void rt_assert(bool condition, const char *msg)
|
||||
{
|
||||
if (!condition)
|
||||
{
|
||||
rt_atomic_store(&rt_assert_msg, msg, RT_ATOMIC_SEQ_CST);
|
||||
rt_trap();
|
||||
}
|
||||
}
|
2
src/rt.c
2
src/rt.c
|
@ -100,7 +100,7 @@ static void insert_mutex_by_priority(struct rt_list *list,
|
|||
|
||||
/* rt_pending_syscalls can be updated from user code, so we don't put it
|
||||
* in RT_MPU_PRIV_BSS. */
|
||||
static struct rt_syscall_record *_Atomic rt_pending_syscalls = NULL;
|
||||
static rt_atomic(struct rt_syscall_record *) rt_pending_syscalls = NULL;
|
||||
|
||||
RT_TASK(rt_idle, RT_STACK_MIN, 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue