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

core/thread_flags: Avoid using inline w/o static

Apparently clang doesn't like static variables / functions being accessed called
from inline function (-Wstatic-in-inline). This commit results in the same
binary being generated while making clang happy.
This commit is contained in:
Marian Buschsieweke 2020-08-06 17:54:32 +02:00
parent 57264c5059
commit 13575b2131
No known key found for this signature in database
GPG Key ID: 61F64C6599B1539F

View File

@ -26,6 +26,38 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
static inline int __attribute__((always_inline)) _thread_flags_wake(thread_t *thread)
{
unsigned wakeup;
thread_flags_t mask = (uint16_t)(unsigned)thread->wait_data;
switch (thread->status) {
case STATUS_FLAG_BLOCKED_ANY:
wakeup = (thread->flags & mask);
break;
case STATUS_FLAG_BLOCKED_ALL:
wakeup = ((thread->flags & mask) == mask);
break;
default:
wakeup = 0;
break;
}
if (wakeup) {
DEBUG("_thread_flags_wake(): waking up pid %" PRIkernel_pid "\n",
thread->pid);
sched_set_status(thread, STATUS_PENDING);
sched_context_switch_request = 1;
}
return wakeup;
}
int thread_flags_wake(thread_t *thread)
{
return _thread_flags_wake(thread);
}
static thread_flags_t _thread_flags_clear_atomic(thread_t *thread,
thread_flags_t mask)
{
@ -109,40 +141,13 @@ thread_flags_t thread_flags_wait_all(thread_flags_t mask)
return _thread_flags_clear_atomic(me, mask);
}
inline int __attribute__((always_inline)) thread_flags_wake(thread_t *thread)
{
unsigned wakeup;
thread_flags_t mask = (uint16_t)(unsigned)thread->wait_data;
switch (thread->status) {
case STATUS_FLAG_BLOCKED_ANY:
wakeup = (thread->flags & mask);
break;
case STATUS_FLAG_BLOCKED_ALL:
wakeup = ((thread->flags & mask) == mask);
break;
default:
wakeup = 0;
break;
}
if (wakeup) {
DEBUG("_thread_flags_wake(): waking up pid %" PRIkernel_pid "\n",
thread->pid);
sched_set_status(thread, STATUS_PENDING);
sched_context_switch_request = 1;
}
return wakeup;
}
void thread_flags_set(thread_t *thread, thread_flags_t mask)
{
DEBUG("thread_flags_set(): setting 0x%08x for pid %" PRIkernel_pid "\n",
mask, thread->pid);
unsigned state = irq_disable();
thread->flags |= mask;
if (thread_flags_wake(thread)) {
if (_thread_flags_wake(thread)) {
irq_restore(state);
thread_yield_higher();
}