From 0d763e0a10ffcb79051cb39f72465808f3f9506f Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Tue, 7 Sep 2021 15:34:04 -0700 Subject: [PATCH] cmake/compiler/xcc: sched: Support XCC inlining semantics Cadence XCC is based off of a very old 4.2 gcc compiler, which didn't perfectly support C99 "inline" semantics with respect to cross-translation-unit inline linkage (which Zephyr does not use, our inlines are static only) and declaration order. Fix the one spot where we were calling an inline before its ALWAYS_INLINE definition, and add a flag to suppress the warning so CI's trying to build with XCC and -Werror don't flip out. Signed-off-by: Andy Ross --- cmake/compiler/xcc/compiler_flags.cmake | 6 +++++ kernel/sched.c | 34 ++++++++++++------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/cmake/compiler/xcc/compiler_flags.cmake b/cmake/compiler/xcc/compiler_flags.cmake index b089f3c7b93..a6205bbf546 100644 --- a/cmake/compiler/xcc/compiler_flags.cmake +++ b/cmake/compiler/xcc/compiler_flags.cmake @@ -4,4 +4,10 @@ if(CC STREQUAL "clang") include(${ZEPHYR_BASE}/cmake/compiler/clang/compiler_flags.cmake) else() include(${ZEPHYR_BASE}/cmake/compiler/gcc/compiler_flags.cmake) + + # XCC is based on GCC 4.2 which has a somewhat pedantic take on the + # fact that linkage semantics differed between C99 and GNU at the + # time. Suppress the warning, it's the best we can do given that + # it's a legacy compiler. + set_compiler_property(APPEND PROPERTY warning_base "-fgnu89-inline") endif() diff --git a/kernel/sched.c b/kernel/sched.c index c49354c1022..e7393278529 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -170,6 +170,23 @@ static ALWAYS_INLINE struct k_thread *_priq_dumb_mask_best(sys_dlist_t *pq) } #endif +ALWAYS_INLINE void z_priq_dumb_add(sys_dlist_t *pq, struct k_thread *thread) +{ + struct k_thread *t; + + __ASSERT_NO_MSG(!z_is_idle_thread_object(thread)); + + SYS_DLIST_FOR_EACH_CONTAINER(pq, t, base.qnode_dlist) { + if (z_sched_prio_cmp(thread, t) > 0) { + sys_dlist_insert(&t->base.qnode_dlist, + &thread->base.qnode_dlist); + return; + } + } + + sys_dlist_append(pq, &thread->base.qnode_dlist); +} + /* _current is never in the run queue until context switch on * SMP configurations, see z_requeue_current() */ @@ -927,23 +944,6 @@ void *z_get_next_switch_handle(void *interrupted) } #endif -ALWAYS_INLINE void z_priq_dumb_add(sys_dlist_t *pq, struct k_thread *thread) -{ - struct k_thread *t; - - __ASSERT_NO_MSG(!z_is_idle_thread_object(thread)); - - SYS_DLIST_FOR_EACH_CONTAINER(pq, t, base.qnode_dlist) { - if (z_sched_prio_cmp(thread, t) > 0) { - sys_dlist_insert(&t->base.qnode_dlist, - &thread->base.qnode_dlist); - return; - } - } - - sys_dlist_append(pq, &thread->base.qnode_dlist); -} - void z_priq_dumb_remove(sys_dlist_t *pq, struct k_thread *thread) { __ASSERT_NO_MSG(!z_is_idle_thread_object(thread));