Skip to content

Commit 0d763e0

Browse files
Andy Rossnashif
authored andcommitted
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 <[email protected]>
1 parent 8bc4539 commit 0d763e0

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

cmake/compiler/xcc/compiler_flags.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@ if(CC STREQUAL "clang")
44
include(${ZEPHYR_BASE}/cmake/compiler/clang/compiler_flags.cmake)
55
else()
66
include(${ZEPHYR_BASE}/cmake/compiler/gcc/compiler_flags.cmake)
7+
8+
# XCC is based on GCC 4.2 which has a somewhat pedantic take on the
9+
# fact that linkage semantics differed between C99 and GNU at the
10+
# time. Suppress the warning, it's the best we can do given that
11+
# it's a legacy compiler.
12+
set_compiler_property(APPEND PROPERTY warning_base "-fgnu89-inline")
713
endif()

kernel/sched.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,23 @@ static ALWAYS_INLINE struct k_thread *_priq_dumb_mask_best(sys_dlist_t *pq)
170170
}
171171
#endif
172172

173+
ALWAYS_INLINE void z_priq_dumb_add(sys_dlist_t *pq, struct k_thread *thread)
174+
{
175+
struct k_thread *t;
176+
177+
__ASSERT_NO_MSG(!z_is_idle_thread_object(thread));
178+
179+
SYS_DLIST_FOR_EACH_CONTAINER(pq, t, base.qnode_dlist) {
180+
if (z_sched_prio_cmp(thread, t) > 0) {
181+
sys_dlist_insert(&t->base.qnode_dlist,
182+
&thread->base.qnode_dlist);
183+
return;
184+
}
185+
}
186+
187+
sys_dlist_append(pq, &thread->base.qnode_dlist);
188+
}
189+
173190
/* _current is never in the run queue until context switch on
174191
* SMP configurations, see z_requeue_current()
175192
*/
@@ -927,23 +944,6 @@ void *z_get_next_switch_handle(void *interrupted)
927944
}
928945
#endif
929946

930-
ALWAYS_INLINE void z_priq_dumb_add(sys_dlist_t *pq, struct k_thread *thread)
931-
{
932-
struct k_thread *t;
933-
934-
__ASSERT_NO_MSG(!z_is_idle_thread_object(thread));
935-
936-
SYS_DLIST_FOR_EACH_CONTAINER(pq, t, base.qnode_dlist) {
937-
if (z_sched_prio_cmp(thread, t) > 0) {
938-
sys_dlist_insert(&t->base.qnode_dlist,
939-
&thread->base.qnode_dlist);
940-
return;
941-
}
942-
}
943-
944-
sys_dlist_append(pq, &thread->base.qnode_dlist);
945-
}
946-
947947
void z_priq_dumb_remove(sys_dlist_t *pq, struct k_thread *thread)
948948
{
949949
__ASSERT_NO_MSG(!z_is_idle_thread_object(thread));

0 commit comments

Comments
 (0)