1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

core: apply uncrustify patches

This commit is contained in:
Martine Lenders 2021-01-19 17:47:23 +01:00
parent 459e28c7d5
commit 9b40bb63c2
No known key found for this signature in database
GPG Key ID: CCD317364F63286F
11 changed files with 41 additions and 16 deletions

View File

@ -281,6 +281,7 @@ void __atomic_load_c(size_t size, const void *src, void *dest, int memorder)
{ {
(void)memorder; (void)memorder;
unsigned int mask = irq_disable(); unsigned int mask = irq_disable();
memcpy(dest, src, size); memcpy(dest, src, size);
irq_restore(mask); irq_restore(mask);
} }
@ -297,6 +298,7 @@ void __atomic_store_c(size_t size, void *dest, const void *src, int memorder)
{ {
(void)memorder; (void)memorder;
unsigned int mask = irq_disable(); unsigned int mask = irq_disable();
memcpy(dest, src, size); memcpy(dest, src, size);
irq_restore(mask); irq_restore(mask);
} }
@ -315,6 +317,7 @@ void __atomic_exchange_c(size_t size, void *ptr, void *val, void *ret,
{ {
(void)memorder; (void)memorder;
unsigned int mask = irq_disable(); unsigned int mask = irq_disable();
memcpy(ret, ptr, size); memcpy(ret, ptr, size);
memcpy(ptr, val, size); memcpy(ptr, val, size);
irq_restore(mask); irq_restore(mask);
@ -361,6 +364,7 @@ bool __atomic_compare_exchange_c(size_t len, void *ptr, void *expected,
(void)failure_memorder; (void)failure_memorder;
unsigned int mask = irq_disable(); unsigned int mask = irq_disable();
bool ret; bool ret;
if (memcmp(ptr, expected, len) == 0) { if (memcmp(ptr, expected, len) == 0) {
memcpy(ptr, desired, len); memcpy(ptr, desired, len);
ret = true; ret = true;

View File

@ -61,6 +61,7 @@ static inline void cib_init(cib_t *__restrict cib, unsigned int size)
assert(!(size & (size - 1))); assert(!(size & (size - 1)));
cib_t c = CIB_INIT(size); cib_t c = CIB_INIT(size);
*cib = c; *cib = c;
} }

View File

@ -20,7 +20,7 @@
#define MACROS_UNITS_H #define MACROS_UNITS_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/** /**

View File

@ -101,7 +101,8 @@ static inline uint16_t msg_bus_get_type(const msg_t *msg)
{ {
if (msg->sender_pid & MSB_BUS_PID_FLAG) { if (msg->sender_pid & MSB_BUS_PID_FLAG) {
return msg->type & 0x1F; return msg->type & 0x1F;
} else { }
else {
return msg->type; return msg->type;
} }
} }

View File

@ -37,7 +37,8 @@
#include "debug.h" #include "debug.h"
#ifndef CONFIG_BOOT_MSG_STRING #ifndef CONFIG_BOOT_MSG_STRING
#define CONFIG_BOOT_MSG_STRING "main(): This is RIOT! (Version: " RIOT_VERSION ")" #define CONFIG_BOOT_MSG_STRING "main(): This is RIOT! (Version: " \
RIOT_VERSION ")"
#endif #endif
extern int main(void); extern int main(void);
@ -73,7 +74,6 @@ static void *idle_thread(void *arg)
return NULL; return NULL;
} }
void kernel_init(void) void kernel_init(void)
{ {
irq_disable(); irq_disable();

View File

@ -36,6 +36,7 @@ static void _wake_waiter(thread_t *thread, unsigned irqstate)
"%" PRIkernel_pid ".\n", thread_getpid(), thread->pid); "%" PRIkernel_pid ".\n", thread_getpid(), thread->pid);
uint16_t process_priority = thread->priority; uint16_t process_priority = thread->priority;
irq_restore(irqstate); irq_restore(irqstate);
sched_switch(process_priority); sched_switch(process_priority);
} }
@ -46,6 +47,7 @@ static void _wait(list_node_t *wait_list, unsigned irqstate)
thread_getpid()); thread_getpid());
thread_t *me = thread_get_active(); thread_t *me = thread_get_active();
sched_set_status(me, STATUS_MBOX_BLOCKED); sched_set_status(me, STATUS_MBOX_BLOCKED);
thread_add_to_list(wait_list, me); thread_add_to_list(wait_list, me);
irq_restore(irqstate); irq_restore(irqstate);

View File

@ -52,6 +52,7 @@ static int queue_msg(thread_t *target, const msg_t *m)
DEBUG("queue_msg(): queuing message\n"); DEBUG("queue_msg(): queuing message\n");
msg_t *dest = &target->msg_array[n]; msg_t *dest = &target->msg_array[n];
*dest = *m; *dest = *m;
#if MODULE_CORE_THREAD_FLAGS #if MODULE_CORE_THREAD_FLAGS
target->flags |= THREAD_FLAG_MSG_WAITING; target->flags |= THREAD_FLAG_MSG_WAITING;
@ -242,7 +243,7 @@ int msg_send_bus(msg_t *m, msg_bus_t *bus)
int count = 0; int count = 0;
m->sender_pid = (in_irq ? KERNEL_PID_ISR : thread_getpid()) m->sender_pid = (in_irq ? KERNEL_PID_ISR : thread_getpid())
| MSB_BUS_PID_FLAG; | MSB_BUS_PID_FLAG;
unsigned state = irq_disable(); unsigned state = irq_disable();
@ -272,6 +273,7 @@ int msg_send_receive(msg_t *m, msg_t *reply, kernel_pid_t target_pid)
assert(thread_getpid() != target_pid); assert(thread_getpid() != target_pid);
unsigned state = irq_disable(); unsigned state = irq_disable();
thread_t *me = thread_get_active(); thread_t *me = thread_get_active();
sched_set_status(me, STATUS_REPLY_BLOCKED); sched_set_status(me, STATUS_REPLY_BLOCKED);
me->wait_data = reply; me->wait_data = reply;
@ -302,9 +304,11 @@ int msg_reply(msg_t *m, msg_t *reply)
thread_getpid()); thread_getpid());
/* copy msg to target */ /* copy msg to target */
msg_t *target_message = (msg_t *)target->wait_data; msg_t *target_message = (msg_t *)target->wait_data;
*target_message = *reply; *target_message = *reply;
sched_set_status(target, STATUS_PENDING); sched_set_status(target, STATUS_PENDING);
uint16_t target_prio = target->priority; uint16_t target_prio = target->priority;
irq_restore(state); irq_restore(state);
sched_switch(target_prio); sched_switch(target_prio);
@ -323,6 +327,7 @@ int msg_reply_int(msg_t *m, msg_t *reply)
} }
msg_t *target_message = (msg_t *)target->wait_data; msg_t *target_message = (msg_t *)target->wait_data;
*target_message = *reply; *target_message = *reply;
sched_set_status(target, STATUS_PENDING); sched_set_status(target, STATUS_PENDING);
sched_context_switch_request = 1; sched_context_switch_request = 1;
@ -394,7 +399,7 @@ static int _msg_receive(msg_t *m, int block)
} }
else { else {
DEBUG("_msg_receive: %" PRIkernel_pid ": _msg_receive(): Waking up " DEBUG("_msg_receive: %" PRIkernel_pid ": _msg_receive(): Waking up "
"waiting thread.\n", thread_getpid()); "waiting thread.\n", thread_getpid());
thread_t *sender = thread_t *sender =
container_of((clist_node_t *)next, thread_t, rq_entry); container_of((clist_node_t *)next, thread_t, rq_entry);

View File

@ -45,9 +45,11 @@
* function into both @ref mutex_lock and @ref mutex_lock_cancelable is, * function into both @ref mutex_lock and @ref mutex_lock_cancelable is,
* therefore, beneficial for the majority of applications. * therefore, beneficial for the majority of applications.
*/ */
static inline __attribute__((always_inline)) void _block(mutex_t *mutex, unsigned irq_state) static inline __attribute__((always_inline)) void _block(mutex_t *mutex,
unsigned irq_state)
{ {
thread_t *me = thread_get_active(); thread_t *me = thread_get_active();
DEBUG("PID[%" PRIkernel_pid "] mutex_lock() Adding node to mutex queue: " DEBUG("PID[%" PRIkernel_pid "] mutex_lock() Adding node to mutex queue: "
"prio: %" PRIu32 "\n", thread_getpid(), (uint32_t)me->priority); "prio: %" PRIu32 "\n", thread_getpid(), (uint32_t)me->priority);
sched_set_status(me, STATUS_MUTEX_BLOCKED); sched_set_status(me, STATUS_MUTEX_BLOCKED);
@ -97,6 +99,7 @@ int mutex_lock_cancelable(mutex_cancel_t *mc)
} }
mutex_t *mutex = mc->mutex; mutex_t *mutex = mc->mutex;
if (mutex->queue.next == NULL) { if (mutex->queue.next == NULL) {
/* mutex is unlocked. */ /* mutex is unlocked. */
mutex->queue.next = MUTEX_LOCKED; mutex->queue.next = MUTEX_LOCKED;
@ -111,7 +114,7 @@ int mutex_lock_cancelable(mutex_cancel_t *mc)
DEBUG("PID[%" PRIkernel_pid "] mutex_lock_cancelable() " DEBUG("PID[%" PRIkernel_pid "] mutex_lock_cancelable() "
"cancelled.\n", thread_getpid()); "cancelled.\n", thread_getpid());
} }
return (mc->cancelled) ? -ECANCELED: 0; return (mc->cancelled) ? -ECANCELED : 0;
} }
} }
@ -148,6 +151,7 @@ void mutex_unlock(mutex_t *mutex)
} }
uint16_t process_priority = process->priority; uint16_t process_priority = process->priority;
irq_restore(irqstate); irq_restore(irqstate);
sched_switch(process_priority); sched_switch(process_priority);
} }
@ -185,10 +189,12 @@ void mutex_unlock_and_sleep(mutex_t *mutex)
void mutex_cancel(mutex_cancel_t *mc) void mutex_cancel(mutex_cancel_t *mc)
{ {
unsigned irq_state = irq_disable(); unsigned irq_state = irq_disable();
mc->cancelled = 1; mc->cancelled = 1;
mutex_t *mutex = mc->mutex; mutex_t *mutex = mc->mutex;
thread_t *thread = mc->thread; thread_t *thread = mc->thread;
if (thread_is_active(thread)) { if (thread_is_active(thread)) {
/* thread is still running or about to run, so it will check /* thread is still running or about to run, so it will check
* `mc-cancelled` in time */ * `mc-cancelled` in time */
@ -197,8 +203,8 @@ void mutex_cancel(mutex_cancel_t *mc)
} }
if ((mutex->queue.next != MUTEX_LOCKED) if ((mutex->queue.next != MUTEX_LOCKED)
&& (mutex->queue.next != NULL) && (mutex->queue.next != NULL)
&& list_remove(&mutex->queue, (list_node_t *)&thread->rq_entry)) { && list_remove(&mutex->queue, (list_node_t *)&thread->rq_entry)) {
/* Thread was queued and removed from list, wake it up */ /* Thread was queued and removed from list, wake it up */
if (mutex->queue.next == NULL) { if (mutex->queue.next == NULL) {
mutex->queue.next = MUTEX_LOCKED; mutex->queue.next = MUTEX_LOCKED;

View File

@ -48,8 +48,10 @@ const char assert_crash_message[] = "FAILED ASSERTION.";
/* flag preventing "recursive crash printing loop" */ /* flag preventing "recursive crash printing loop" */
static int crashed = 0; static int crashed = 0;
void __attribute__((weak)) panic_arch(void) {} void __attribute__((weak)) panic_arch(void)
void __attribute__((weak)) panic_app(core_panic_t crash_code, const char *message) {}
void __attribute__((weak)) panic_app(core_panic_t crash_code,
const char *message)
{ {
(void)crash_code; (void)crash_code;
(void)message; (void)message;

View File

@ -102,6 +102,7 @@ void thread_sleep(void)
} }
unsigned state = irq_disable(); unsigned state = irq_disable();
sched_set_status(thread_get_active(), STATUS_SLEEPING); sched_set_status(thread_get_active(), STATUS_SLEEPING);
irq_restore(state); irq_restore(state);
thread_yield_higher(); thread_yield_higher();
@ -183,6 +184,7 @@ uintptr_t thread_measure_stack_free(const char *stack)
} }
uintptr_t space_free = (uintptr_t)stackp - (uintptr_t)stack; uintptr_t space_free = (uintptr_t)stackp - (uintptr_t)stack;
return space_free; return space_free;
} }
#endif #endif
@ -199,7 +201,7 @@ kernel_pid_t thread_create(char *stack, int stacksize, uint8_t priority,
int total_stacksize = stacksize; int total_stacksize = stacksize;
#endif #endif
#ifndef CONFIG_THREAD_NAMES #ifndef CONFIG_THREAD_NAMES
(void) name; (void)name;
#endif #endif
/* align the stack on a 16/32bit boundary */ /* align the stack on a 16/32bit boundary */
@ -342,7 +344,7 @@ const char *thread_state_to_string(thread_status_t state)
const char *name = state_names[state] ? state_names[state] : NULL; const char *name = state_names[state] ? state_names[state] : NULL;
assert(name != NULL); /* if compiling with assertions, this is an error that assert(name != NULL); /* if compiling with assertions, this is an error that
indicates that the table above is incomplete */ indicates that the table above is incomplete */
return (name != NULL) ? name : STATE_NAME_UNKNOWN; return (name != NULL) ? name : STATE_NAME_UNKNOWN;
} }

View File

@ -18,7 +18,6 @@
* @} * @}
*/ */
#include "thread_flags.h" #include "thread_flags.h"
#include "irq.h" #include "irq.h"
#include "thread.h" #include "thread.h"
@ -26,7 +25,8 @@
#define ENABLE_DEBUG 0 #define ENABLE_DEBUG 0
#include "debug.h" #include "debug.h"
static inline int __attribute__((always_inline)) _thread_flags_wake(thread_t *thread) static inline int __attribute__((always_inline)) _thread_flags_wake(
thread_t *thread)
{ {
unsigned wakeup; unsigned wakeup;
thread_flags_t mask = (uint16_t)(unsigned)thread->wait_data; thread_flags_t mask = (uint16_t)(unsigned)thread->wait_data;
@ -118,6 +118,7 @@ thread_flags_t thread_flags_wait_one(thread_flags_t mask)
_thread_flags_wait_any(mask); _thread_flags_wait_any(mask);
thread_t *me = thread_get_active(); thread_t *me = thread_get_active();
thread_flags_t tmp = me->flags & mask; thread_flags_t tmp = me->flags & mask;
/* clear all but least significant bit */ /* clear all but least significant bit */
tmp &= (~tmp + 1); tmp &= (~tmp + 1);
return _thread_flags_clear_atomic(me, tmp); return _thread_flags_clear_atomic(me, tmp);
@ -146,6 +147,7 @@ void thread_flags_set(thread_t *thread, thread_flags_t mask)
DEBUG("thread_flags_set(): setting 0x%08x for pid %" PRIkernel_pid "\n", DEBUG("thread_flags_set(): setting 0x%08x for pid %" PRIkernel_pid "\n",
mask, thread->pid); mask, thread->pid);
unsigned state = irq_disable(); unsigned state = irq_disable();
thread->flags |= mask; thread->flags |= mask;
if (_thread_flags_wake(thread)) { if (_thread_flags_wake(thread)) {
irq_restore(state); irq_restore(state);