From 876219985141d8ef1f3ef012afd370712f6e8e1f Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 3 Dec 2026 11:50:24 +0000 Subject: [PATCH 1/6] posix: add a stub with the Zephyr semantics The non-Zephyr host builds (the host library and the testbench) compile the shared code against posix/include, which gives it the SOF atomic names from rtos/atomic.h. To switch that code to the Zephyr names, these builds need a that behaves like Zephyr's. Zephyr builds, native_sim included, keep using the Zephyr header. Add the stub with atomic_get(), atomic_set(), atomic_add() and atomic_sub(). Like Zephyr, atomic_set(), atomic_add() and atomic_sub() return the previous value. The GCC version of the host atomics returned the new value from add and sub, while the xt-xcc version (for the xt-run testbench) already returned the previous one. Make the GCC version return the previous value too, and replace the set and init functions with a swap that returns it. No host caller uses these return values. rtos/atomic.h now keeps only atomic_read() and atomic_init() on top of the stub, as on Zephyr. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- posix/include/rtos/atomic.h | 22 +++--------- posix/include/zephyr/sys/atomic.h | 41 ++++++++++++++++++++++ src/kernel/arch/host/include/arch/atomic.h | 33 ++++++++--------- 3 files changed, 60 insertions(+), 36 deletions(-) create mode 100644 posix/include/zephyr/sys/atomic.h diff --git a/posix/include/rtos/atomic.h b/posix/include/rtos/atomic.h index 6d16b6b6c9e6..c01635031fec 100644 --- a/posix/include/rtos/atomic.h +++ b/posix/include/rtos/atomic.h @@ -8,32 +8,18 @@ #ifndef __SOF_ATOMIC_H__ #define __SOF_ATOMIC_H__ -#include +#include #include +/* SOF names for atomic_set() and atomic_get(), as in zephyr/include/rtos/atomic.h */ static inline void atomic_init(atomic_t *a, int32_t value) { - arch_atomic_init(a, value); + atomic_set(a, value); } static inline int32_t atomic_read(const atomic_t *a) { - return arch_atomic_read(a); -} - -static inline void atomic_set(atomic_t *a, int32_t value) -{ - arch_atomic_set(a, value); -} - -static inline int32_t atomic_add(atomic_t *a, int32_t value) -{ - return arch_atomic_add(a, value); -} - -static inline int32_t atomic_sub(atomic_t *a, int32_t value) -{ - return arch_atomic_sub(a, value); + return atomic_get(a); } #endif /* __SOF_ATOMIC_H__ */ diff --git a/posix/include/zephyr/sys/atomic.h b/posix/include/zephyr/sys/atomic.h new file mode 100644 index 000000000000..9ea325134778 --- /dev/null +++ b/posix/include/zephyr/sys/atomic.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* + * Copyright(c) 2026 Intel Corporation. All rights reserved. + * + * Stub for used by the non-Zephyr host builds (the host + * library and the testbench), which compile the shared code against + * posix/include. Zephyr builds, native_sim included, use the Zephyr header. + * + * The functions have the Zephyr names and return values: atomic_set(), + * atomic_add() and atomic_sub() return the previous value. + */ + +#ifndef __POSIX_ZEPHYR_SYS_ATOMIC_H__ +#define __POSIX_ZEPHYR_SYS_ATOMIC_H__ + +#include +#include + +typedef int32_t atomic_val_t; + +static inline atomic_val_t atomic_get(const atomic_t *target) +{ + return arch_atomic_read(target); +} + +static inline atomic_val_t atomic_set(atomic_t *target, atomic_val_t value) +{ + return arch_atomic_swap(target, value); +} + +static inline atomic_val_t atomic_add(atomic_t *target, atomic_val_t value) +{ + return arch_atomic_add(target, value); +} + +static inline atomic_val_t atomic_sub(atomic_t *target, atomic_val_t value) +{ + return arch_atomic_sub(target, value); +} + +#endif /* __POSIX_ZEPHYR_SYS_ATOMIC_H__ */ diff --git a/src/kernel/arch/host/include/arch/atomic.h b/src/kernel/arch/host/include/arch/atomic.h index 797ba5f5e1d4..180a0ba69140 100644 --- a/src/kernel/arch/host/include/arch/atomic.h +++ b/src/kernel/arch/host/include/arch/atomic.h @@ -6,7 +6,7 @@ * Ranjani Sridharan */ -#ifdef __SOF_ATOMIC_H__ +#if defined(__SOF_ATOMIC_H__) || defined(__POSIX_ZEPHYR_SYS_ATOMIC_H__) #ifndef __ARCH_ATOMIC_H__ #define __ARCH_ATOMIC_H__ @@ -24,24 +24,20 @@ static inline int32_t arch_atomic_read(const atomic_t *a) return __atomic_load_n(&a->value, __ATOMIC_SEQ_CST); } -static inline void arch_atomic_set(atomic_t *a, int32_t value) +/* The swap, add and sub functions return the previous value, like Zephyr */ +static inline int32_t arch_atomic_swap(atomic_t *a, int32_t value) { - __atomic_store_n(&a->value, value, __ATOMIC_SEQ_CST); -} - -static inline void arch_atomic_init(atomic_t *a, int32_t value) -{ - __atomic_store_n(&a->value, value, __ATOMIC_SEQ_CST); + return __atomic_exchange_n(&a->value, value, __ATOMIC_SEQ_CST); } static inline int32_t arch_atomic_add(atomic_t *a, int32_t value) { - return __atomic_add_fetch(&a->value, value, __ATOMIC_SEQ_CST); + return __atomic_fetch_add(&a->value, value, __ATOMIC_SEQ_CST); } static inline int32_t arch_atomic_sub(atomic_t *a, int32_t value) { - return __atomic_sub_fetch(&a->value, value, __ATOMIC_SEQ_CST); + return __atomic_fetch_sub(&a->value, value, __ATOMIC_SEQ_CST); } #elif defined __XCC__ @@ -57,14 +53,15 @@ static inline int32_t arch_atomic_read(const atomic_t *a) return a->value; } -static inline void arch_atomic_set(atomic_t *a, int32_t value) +static inline int32_t arch_atomic_swap(atomic_t *a, int32_t value) { - a->value = value; -} + int32_t tmp; -static inline void arch_atomic_init(atomic_t *a, int32_t value) -{ - arch_atomic_set(a, value); + lock(); + tmp = a->value; + a->value = value; + unlock(); + return tmp; } static inline int32_t arch_atomic_add(atomic_t *a, int32_t value) @@ -99,6 +96,6 @@ static inline int32_t arch_atomic_sub(atomic_t *a, int32_t value) #else -#error "This file shouldn't be included from outside of sof/atomic.h" +#error "This file shouldn't be included from outside of rtos/atomic.h or zephyr/sys/atomic.h" -#endif /* __SOF_ATOMIC_H__ */ +#endif /* __SOF_ATOMIC_H__ || __POSIX_ZEPHYR_SYS_ATOMIC_H__ */ From 06ba39296a586db215705d99208963a83edeb3af Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 3 Dec 2026 11:50:24 +0000 Subject: [PATCH 2/6] posix: add a stub In the non-Zephyr host builds (the host library and the testbench), shared code calls the SOF cache wrappers because posix/include has no . Add a stub with sys_cache_data_flush_range(), sys_cache_data_invd_range(), sys_cache_data_flush_and_invd_range() and sys_cache_instr_invd_range(). The host has no cache to maintain, so they return -ENOTSUP, like Zephyr built without CONFIG_CACHE_MANAGEMENT. Zephyr builds, native_sim included, keep using the Zephyr header. The cached and uncached pointer conversions are not stubbed yet: the host currently reports every pointer as uncached, which does not map directly onto the Zephyr calls. They come with their first user. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- posix/include/zephyr/cache.h | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 posix/include/zephyr/cache.h diff --git a/posix/include/zephyr/cache.h b/posix/include/zephyr/cache.h new file mode 100644 index 000000000000..c42f8fc291e6 --- /dev/null +++ b/posix/include/zephyr/cache.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* + * Copyright(c) 2026 Intel Corporation. All rights reserved. + * + * Stub for used by the non-Zephyr host builds (the host + * library and the testbench), which compile the shared code against + * posix/include. Zephyr builds, native_sim included, use the Zephyr header. + * + * The host has no cache to maintain, so these return -ENOTSUP, like Zephyr + * built without CONFIG_CACHE_MANAGEMENT. + */ + +#ifndef __POSIX_ZEPHYR_CACHE_H__ +#define __POSIX_ZEPHYR_CACHE_H__ + +#include +#include + +static inline int sys_cache_data_flush_range(void *addr, size_t size) +{ + (void)addr; + (void)size; + return -ENOTSUP; +} + +static inline int sys_cache_data_invd_range(void *addr, size_t size) +{ + (void)addr; + (void)size; + return -ENOTSUP; +} + +static inline int sys_cache_data_flush_and_invd_range(void *addr, size_t size) +{ + (void)addr; + (void)size; + return -ENOTSUP; +} + +static inline int sys_cache_instr_invd_range(void *addr, size_t size) +{ + (void)addr; + (void)size; + return -ENOTSUP; +} + +#endif /* __POSIX_ZEPHYR_CACHE_H__ */ From 9063ab7a4cd88e6550f81252cc34277d320ce45f Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 3 Dec 2026 11:50:24 +0000 Subject: [PATCH 3/6] posix: add Zephyr assert and k_panic() stubs Shared code uses assert() and sof_panic() because the non-Zephyr host builds (the host library and the testbench) have neither nor k_panic() in posix/include. Code that already uses the Zephyr names has to be hidden from these builds, such as the coherent API checks. Add with __ASSERT() and __ASSERT_NO_MSG(). As in Zephyr, the __ASSERT() message is optional and its format does not have to be a string literal. The host checks its assertions in every build, as assert() does: a failed assertion prints the condition and any message, then panics with SOF_IPC_PANIC_ASSERT. Add k_panic() to rtos/panic.h, which already defines sof_panic(). It takes no panic code, so it reports SOF_IPC_PANIC_ASSERT, the code of a failed assert(): Zephyr also ends a failed assertion with k_panic(). Zephyr builds, native_sim included, keep using the Zephyr macros. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- posix/include/rtos/panic.h | 6 ++++ posix/include/zephyr/sys/__assert.h | 54 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 posix/include/zephyr/sys/__assert.h diff --git a/posix/include/rtos/panic.h b/posix/include/rtos/panic.h index e4aca1661f56..2ba24eed48bc 100644 --- a/posix/include/rtos/panic.h +++ b/posix/include/rtos/panic.h @@ -38,6 +38,12 @@ void __panic(uint32_t p, const char *filename, uint32_t linenum) SOF_NORETURN; #define sof_panic(x) __panic((x), (RELATIVE_FILE), (__LINE__)) +/* + * Zephyr k_panic() takes no panic code. Report SOF_IPC_PANIC_ASSERT, the code + * of a failed assert(): Zephyr also ends a failed assertion with k_panic(). + */ +#define k_panic() sof_panic(SOF_IPC_PANIC_ASSERT) + /* runtime assertion */ #ifndef assert #define assert(cond) (void)((cond) || (sof_panic(SOF_IPC_PANIC_ASSERT), 0)) diff --git a/posix/include/zephyr/sys/__assert.h b/posix/include/zephyr/sys/__assert.h new file mode 100644 index 000000000000..227e0bcc52eb --- /dev/null +++ b/posix/include/zephyr/sys/__assert.h @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* + * Copyright(c) 2026 Intel Corporation. All rights reserved. + * + * Stub for used by the non-Zephyr host builds (the host + * library and the testbench), which compile the shared code against + * posix/include. Zephyr builds, native_sim included, use the Zephyr header. + * + * The host checks its assertions in every build, as assert() does: a failed + * assertion prints the condition and any message, then panics with + * SOF_IPC_PANIC_ASSERT. + */ + +#ifndef __POSIX_ZEPHYR_SYS___ASSERT_H__ +#define __POSIX_ZEPHYR_SYS___ASSERT_H__ + +#include +#include +#include +#include + +/* + * Print a failed assertion. The variable arguments are the optional message + * format and its arguments, then NULL: NULL alone means there is no message. + */ +static inline void posix_assert_print(const char *test, const char *file, int line, ...) +{ + const char *fmt; + va_list ap; + + fprintf(stderr, "ASSERTION FAIL [%s] @ %s:%d\n", test, file, line); + va_start(ap, line); + fmt = va_arg(ap, const char *); + if (fmt) { + fprintf(stderr, "\t"); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + } + va_end(ap); +} + +/* as in Zephyr, the message format and its arguments are optional */ +#define __ASSERT(test, ...) \ + do { \ + if (!(test)) { \ + posix_assert_print(#test, RELATIVE_FILE, __LINE__, \ + ##__VA_ARGS__, NULL); \ + sof_panic(SOF_IPC_PANIC_ASSERT); \ + } \ + } while (0) + +#define __ASSERT_NO_MSG(test) __ASSERT(test) + +#endif /* __POSIX_ZEPHYR_SYS___ASSERT_H__ */ From 56fc1eeb3d6c567ab0ec2470a05b407ba2ec4230 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 3 Dec 2026 11:50:38 +0000 Subject: [PATCH 4/6] test: ztest: check the non-Zephyr host stubs of the Zephyr APIs SOF has two kinds of host build. The Zephyr ones, such as the native_sim ztests and the IPC fuzzer, use Zephyr itself and never see the stubs in posix/include. The non-Zephyr host library and testbench compile the shared code against posix/include, and nothing tested its stubs of the Zephyr APIs. Add a test that compiles one source file the way the non-Zephyr host builds compile the shared code: with the host include paths only, so that resolves to the stubs. The ztest code, built normally against Zephyr, calls it and compares the results with the Zephyr implementations. ztest and native_sim are only the harness here; the Zephyr builds do not depend on the stubs. The test checks that: - atomic_set(), atomic_add() and atomic_sub() return the previous value, and the values match Zephyr's; - the cache functions return -ENOTSUP, as on native_sim; - __ASSERT() and __ASSERT_NO_MSG() pass on a true condition and panic with SOF_IPC_PANIC_ASSERT on a false one, with a literal message, a format that is not a literal and no message, and evaluate the condition once; - k_panic() panics with SOF_IPC_PANIC_ASSERT. It catches panics by replacing the host __panic() with a longjmp() back to the test. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- test/ztest/unit/host_stubs/CMakeLists.txt | 35 ++++++ test/ztest/unit/host_stubs/host_stubs.c | 111 ++++++++++++++++++ test/ztest/unit/host_stubs/host_stubs.h | 45 +++++++ test/ztest/unit/host_stubs/prj.conf | 2 + .../unit/host_stubs/test_host_stubs_ztest.c | 99 ++++++++++++++++ test/ztest/unit/host_stubs/testcase.yaml | 14 +++ 6 files changed, 306 insertions(+) create mode 100644 test/ztest/unit/host_stubs/CMakeLists.txt create mode 100644 test/ztest/unit/host_stubs/host_stubs.c create mode 100644 test/ztest/unit/host_stubs/host_stubs.h create mode 100644 test/ztest/unit/host_stubs/prj.conf create mode 100644 test/ztest/unit/host_stubs/test_host_stubs_ztest.c create mode 100644 test/ztest/unit/host_stubs/testcase.yaml diff --git a/test/ztest/unit/host_stubs/CMakeLists.txt b/test/ztest/unit/host_stubs/CMakeLists.txt new file mode 100644 index 000000000000..e8f5d0d5c09b --- /dev/null +++ b/test/ztest/unit/host_stubs/CMakeLists.txt @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(test_host_stubs) + +set(SOF_ROOT "${PROJECT_SOURCE_DIR}/../../../..") + +include(${SOF_ROOT}/scripts/cmake/misc.cmake) + +# SOF has two kinds of host build. The Zephyr ones (these ztests, the IPC +# fuzzer) use Zephyr itself. The non-Zephyr host library and testbench +# compile the shared code against posix/include, which has stubs of some +# Zephyr APIs. This test checks those stubs against Zephyr: ztest and +# native_sim are only the harness. +# +# host_stubs.c is compiled the way the non-Zephyr host builds compile the +# shared code: with the host include paths only, so that +# resolves to posix/include, not to Zephyr. +add_library(host_stubs STATIC host_stubs.c) +target_include_directories(host_stubs PRIVATE + ${SOF_ROOT}/posix/include + ${SOF_ROOT}/src/kernel/arch/host/include + ${SOF_ROOT}/src/include +) +target_compile_options(host_stubs PRIVATE -Wall -Werror) +if(NOT CONFIG_64BIT) + target_compile_options(host_stubs PRIVATE -m32) +endif() +sof_append_relative_path_definitions(host_stubs) + +target_include_directories(app PRIVATE ${SOF_ROOT}/src/include) +target_sources(app PRIVATE test_host_stubs_ztest.c) +target_link_libraries(app PRIVATE host_stubs) diff --git a/test/ztest/unit/host_stubs/host_stubs.c b/test/ztest/unit/host_stubs/host_stubs.c new file mode 100644 index 000000000000..b0acf57d03c7 --- /dev/null +++ b/test/ztest/unit/host_stubs/host_stubs.c @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: BSD-3-Clause +// +// Copyright(c) 2026 Intel Corporation. +// +// Uses the posix/include stubs of the Zephyr APIs, as the non-Zephyr host +// builds do. Built with the host include paths only, see CMakeLists.txt. + +#include +#include +#include +#include +#include + +#include +#include + +#include "host_stubs.h" + +static jmp_buf panic_env; +/* volatile: written between setjmp() and longjmp() */ +static volatile uint32_t panic_code; + +/* the host __panic() aborts, return to the caller of the stub instead */ +void __panic(uint32_t p, const char *filename, uint32_t linenum) +{ + (void)filename; + (void)linenum; + panic_code = p; + longjmp(panic_env, 1); +} + +void host_stub_atomic_seq(struct stub_atomic_seq *seq) +{ + atomic_t a; + + atomic_init(&a, STUB_ATOMIC_INIT); + seq->read_after_init = atomic_read(&a); + seq->set_ret = atomic_set(&a, STUB_ATOMIC_SET); + seq->add_ret = atomic_add(&a, STUB_ATOMIC_ADD); + seq->sub_ret = atomic_sub(&a, STUB_ATOMIC_SUB); + seq->get_final = atomic_get(&a); +} + +void host_stub_cache(int ret[STUB_CACHE_FUNCS]) +{ + static char buf[64]; + + ret[0] = sys_cache_data_flush_range(buf, sizeof(buf)); + ret[1] = sys_cache_data_invd_range(buf, sizeof(buf)); + ret[2] = sys_cache_data_flush_and_invd_range(buf, sizeof(buf)); + ret[3] = sys_cache_instr_invd_range(buf, sizeof(buf)); +} + +uint32_t host_stub_assert_no_msg(int cond) +{ + panic_code = 0; + if (!setjmp(panic_env)) { + __ASSERT_NO_MSG(cond); + } + return panic_code; +} + +uint32_t host_stub_assert_msg(int cond) +{ + panic_code = 0; + if (!setjmp(panic_env)) { + __ASSERT(cond, "condition is %d", cond); + } + return panic_code; +} + +uint32_t host_stub_assert_no_fmt(int cond) +{ + panic_code = 0; + if (!setjmp(panic_env)) { + __ASSERT(cond); + } + return panic_code; +} + +uint32_t host_stub_assert_var_fmt(int cond) +{ + const char *fmt = "condition is %d"; + + panic_code = 0; + if (!setjmp(panic_env)) { + __ASSERT(cond, fmt, cond); + } + return panic_code; +} + +uint32_t host_stub_k_panic(void) +{ + panic_code = 0; + if (!setjmp(panic_env)) { + k_panic(); + } + return panic_code; +} + +int host_stub_assert_eval_count(void) +{ + /* volatile: written between setjmp() and longjmp() */ + volatile int count = 0; + + panic_code = 0; + if (!setjmp(panic_env)) { + __ASSERT(++count > 0, "count %d", count); + } + return count; +} diff --git a/test/ztest/unit/host_stubs/host_stubs.h b/test/ztest/unit/host_stubs/host_stubs.h new file mode 100644 index 000000000000..160a1a5e50a9 --- /dev/null +++ b/test/ztest/unit/host_stubs/host_stubs.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* + * Copyright(c) 2026 Intel Corporation. + * + * Interface between the ztest code and host_stubs.c, which is compiled with + * the host headers. Only plain C types cross it. + */ + +#ifndef __TEST_HOST_STUBS_H__ +#define __TEST_HOST_STUBS_H__ + +#include + +/* values returned by one sequence of atomic operations */ +struct stub_atomic_seq { + int32_t read_after_init; + int32_t set_ret; + int32_t add_ret; + int32_t sub_ret; + int32_t get_final; +}; + +#define STUB_ATOMIC_INIT 5 +#define STUB_ATOMIC_SET 10 +#define STUB_ATOMIC_ADD 3 +#define STUB_ATOMIC_SUB 4 + +/* number of sys_cache_*() functions in the stub */ +#define STUB_CACHE_FUNCS 4 + +void host_stub_atomic_seq(struct stub_atomic_seq *seq); +void host_stub_cache(int ret[STUB_CACHE_FUNCS]); + +/* return 0 if nothing panicked, else the panic code */ +uint32_t host_stub_assert_no_msg(int cond); +uint32_t host_stub_assert_msg(int cond); +/* __ASSERT() without a message, and with a format that is not a literal */ +uint32_t host_stub_assert_no_fmt(int cond); +uint32_t host_stub_assert_var_fmt(int cond); +uint32_t host_stub_k_panic(void); + +/* number of times __ASSERT() evaluates its condition */ +int host_stub_assert_eval_count(void); + +#endif /* __TEST_HOST_STUBS_H__ */ diff --git a/test/ztest/unit/host_stubs/prj.conf b/test/ztest/unit/host_stubs/prj.conf new file mode 100644 index 000000000000..d34c7781cd0a --- /dev/null +++ b/test/ztest/unit/host_stubs/prj.conf @@ -0,0 +1,2 @@ +CONFIG_ZTEST=y +CONFIG_SOF_FULL_ZEPHYR_APPLICATION=n diff --git a/test/ztest/unit/host_stubs/test_host_stubs_ztest.c b/test/ztest/unit/host_stubs/test_host_stubs_ztest.c new file mode 100644 index 000000000000..6c055f0ee3d1 --- /dev/null +++ b/test/ztest/unit/host_stubs/test_host_stubs_ztest.c @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: BSD-3-Clause +// +// Copyright(c) 2026 Intel Corporation. +// +// The non-Zephyr host builds (the host library and the testbench) compile +// the shared code against the posix/include stubs of the Zephyr APIs. Check +// that the stubs behave like the Zephyr implementations, which this test is +// linked with. + +#include +#include +#include +#include + +#include + +#include "host_stubs.h" + +/* the same sequence as host_stub_atomic_seq(), with the Zephyr atomics */ +static void zephyr_atomic_seq(struct stub_atomic_seq *seq) +{ + atomic_t a; + + atomic_set(&a, STUB_ATOMIC_INIT); + seq->read_after_init = atomic_get(&a); + seq->set_ret = atomic_set(&a, STUB_ATOMIC_SET); + seq->add_ret = atomic_add(&a, STUB_ATOMIC_ADD); + seq->sub_ret = atomic_sub(&a, STUB_ATOMIC_SUB); + seq->get_final = atomic_get(&a); +} + +ZTEST(host_stubs, test_atomic_like_zephyr) +{ + struct stub_atomic_seq host, zephyr; + + host_stub_atomic_seq(&host); + zephyr_atomic_seq(&zephyr); + + /* set, add and sub return the previous value */ + zassert_equal(host.read_after_init, STUB_ATOMIC_INIT); + zassert_equal(host.set_ret, STUB_ATOMIC_INIT); + zassert_equal(host.add_ret, STUB_ATOMIC_SET); + zassert_equal(host.sub_ret, STUB_ATOMIC_SET + STUB_ATOMIC_ADD); + zassert_equal(host.get_final, STUB_ATOMIC_SET + STUB_ATOMIC_ADD - STUB_ATOMIC_SUB); + + zassert_equal(host.read_after_init, zephyr.read_after_init); + zassert_equal(host.set_ret, zephyr.set_ret); + zassert_equal(host.add_ret, zephyr.add_ret); + zassert_equal(host.sub_ret, zephyr.sub_ret); + zassert_equal(host.get_final, zephyr.get_final); +} + +ZTEST(host_stubs, test_cache_like_zephyr) +{ + static char buf[64]; + int host[STUB_CACHE_FUNCS]; + int zephyr[STUB_CACHE_FUNCS] = { + sys_cache_data_flush_range(buf, sizeof(buf)), + sys_cache_data_invd_range(buf, sizeof(buf)), + sys_cache_data_flush_and_invd_range(buf, sizeof(buf)), + sys_cache_instr_invd_range(buf, sizeof(buf)), + }; + + host_stub_cache(host); + + for (int i = 0; i < STUB_CACHE_FUNCS; i++) { + /* native_sim has no cache management, like the host */ + zassert_equal(host[i], -ENOTSUP, "function %d", i); + zassert_equal(host[i], zephyr[i], "function %d", i); + } +} + +ZTEST(host_stubs, test_assert_pass) +{ + zassert_equal(host_stub_assert_no_msg(1), 0); + zassert_equal(host_stub_assert_msg(1), 0); + zassert_equal(host_stub_assert_no_fmt(1), 0); + zassert_equal(host_stub_assert_var_fmt(1), 0); +} + +ZTEST(host_stubs, test_assert_fail_panics) +{ + zassert_equal(host_stub_assert_no_msg(0), SOF_IPC_PANIC_ASSERT); + zassert_equal(host_stub_assert_msg(0), SOF_IPC_PANIC_ASSERT); + zassert_equal(host_stub_assert_no_fmt(0), SOF_IPC_PANIC_ASSERT); + zassert_equal(host_stub_assert_var_fmt(0), SOF_IPC_PANIC_ASSERT); +} + +ZTEST(host_stubs, test_assert_evaluates_once) +{ + zassert_equal(host_stub_assert_eval_count(), 1); +} + +ZTEST(host_stubs, test_k_panic) +{ + zassert_equal(host_stub_k_panic(), SOF_IPC_PANIC_ASSERT); +} + +ZTEST_SUITE(host_stubs, NULL, NULL, NULL, NULL, NULL); diff --git a/test/ztest/unit/host_stubs/testcase.yaml b/test/ztest/unit/host_stubs/testcase.yaml new file mode 100644 index 000000000000..9cff19adf32a --- /dev/null +++ b/test/ztest/unit/host_stubs/testcase.yaml @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: BSD-3-Clause +# +# Copyright(c) 2026 Intel Corporation. +# +# Checks that the posix/include stubs of Zephyr APIs, used by the non-Zephyr +# host builds, behave like Zephyr + +tests: + sof.unit.host_stubs: + tags: unit + platform_allow: native_sim + integration_platforms: + - native_sim + build_only: false From 73bd01cb2ad337ffc6df898a33b8a57483fb0d73 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 1 Dec 2026 22:24:24 +0000 Subject: [PATCH 5/6] treewide: use atomic_get() and atomic_set() instead of the SOF names atomic_read() and atomic_init() are SOF names for the Zephyr atomic_get() and atomic_set(). Now that the host builds have a stub with the Zephyr names and semantics, use the Zephyr names in all code and remove the SOF ones from both versions of rtos/atomic.h. atomic_set() returns the previous value where atomic_init() returned nothing; no caller uses it. The Zephyr atomic_read() cast the value to long for the printf formats, but atomic_get() returns long on Zephyr already, so the formats are unaffected. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- posix/include/rtos/atomic.h | 12 ------------ posix/include/sof/lib/agent.h | 2 +- src/audio/module_adapter/module/dolby/dax.c | 2 +- src/include/sof/lib/agent.h | 2 +- src/include/sof/schedule/ll_schedule_domain.h | 4 ++-- src/kernel/drivers/amd/common/acp_dmic_dma.c | 2 +- src/kernel/drivers/amd/common/acp_sp_dma.c | 2 +- src/kernel/drivers/amd/rembrandt/acp_bt_dma.c | 2 +- src/kernel/drivers/amd/rembrandt/acp_hs_dma.c | 2 +- src/kernel/drivers/generic/dummy-dma.c | 2 +- src/kernel/ipc/ipc4/handler-kernel.c | 4 ++-- src/kernel/lib/agent.c | 2 +- src/kernel/lib/dma-kernel.c | 8 ++++---- src/kernel/schedule/zephyr_domain-kernel.c | 4 ++-- src/schedule/zephyr_ll.c | 2 +- test/ztest/unit/host_stubs/host_stubs.c | 5 ++--- zephyr/include/rtos/atomic.h | 9 --------- 17 files changed, 22 insertions(+), 44 deletions(-) diff --git a/posix/include/rtos/atomic.h b/posix/include/rtos/atomic.h index c01635031fec..3b6f595d1944 100644 --- a/posix/include/rtos/atomic.h +++ b/posix/include/rtos/atomic.h @@ -9,17 +9,5 @@ #define __SOF_ATOMIC_H__ #include -#include - -/* SOF names for atomic_set() and atomic_get(), as in zephyr/include/rtos/atomic.h */ -static inline void atomic_init(atomic_t *a, int32_t value) -{ - atomic_set(a, value); -} - -static inline int32_t atomic_read(const atomic_t *a) -{ - return atomic_get(a); -} #endif /* __SOF_ATOMIC_H__ */ diff --git a/posix/include/sof/lib/agent.h b/posix/include/sof/lib/agent.h index 6e70a4ce997d..cee04b7cba2e 100644 --- a/posix/include/sof/lib/agent.h +++ b/posix/include/sof/lib/agent.h @@ -48,7 +48,7 @@ static inline void sa_set_panic_on_delay(bool enabled) atomic_sub(&sa->panic_cnt, 1); /* enable panic only if no refs */ - sa->panic_on_delay = !atomic_read(&sa->panic_cnt); + sa->panic_on_delay = !atomic_get(&sa->panic_cnt); } diff --git a/src/audio/module_adapter/module/dolby/dax.c b/src/audio/module_adapter/module/dolby/dax.c index 79fbb61aaf8a..f404c43b59a8 100644 --- a/src/audio/module_adapter/module/dolby/dax.c +++ b/src/audio/module_adapter/module/dolby/dax.c @@ -82,7 +82,7 @@ static int32_t flag_process(struct dax_adapter_data *adapter_data, } #else /* Non-Zephyr builds run single-threaded (no DP mode), there is no synchronous problem */ - int32_t old_flags = atomic_read(&adapter_data->proc_flags); + int32_t old_flags = atomic_get(&adapter_data->proc_flags); switch (opt_mode) { case DAX_FLAG_READ: diff --git a/src/include/sof/lib/agent.h b/src/include/sof/lib/agent.h index 6aaa740761f2..35dccf64f16d 100644 --- a/src/include/sof/lib/agent.h +++ b/src/include/sof/lib/agent.h @@ -48,7 +48,7 @@ static inline void sa_set_panic_on_delay(bool enabled) atomic_sub(&sa->panic_cnt, 1); /* enable panic only if no refs */ - sa->panic_on_delay = !atomic_read(&sa->panic_cnt); + sa->panic_on_delay = !atomic_get(&sa->panic_cnt); } diff --git a/src/include/sof/schedule/ll_schedule_domain.h b/src/include/sof/schedule/ll_schedule_domain.h index b960c085920d..2bd9bc6c28af 100644 --- a/src/include/sof/schedule/ll_schedule_domain.h +++ b/src/include/sof/schedule/ll_schedule_domain.h @@ -354,8 +354,8 @@ static inline struct ll_schedule_domain *domain_init #else k_spinlock_init(&domain->lock); #endif - atomic_init(&domain->total_num_tasks, 0); - atomic_init(&domain->enabled_cores, 0); + atomic_set(&domain->total_num_tasks, 0); + atomic_set(&domain->enabled_cores, 0); return domain; } diff --git a/src/kernel/drivers/amd/common/acp_dmic_dma.c b/src/kernel/drivers/amd/common/acp_dmic_dma.c index 12464fab0430..963068be6cf1 100644 --- a/src/kernel/drivers/amd/common/acp_dmic_dma.c +++ b/src/kernel/drivers/amd/common/acp_dmic_dma.c @@ -165,7 +165,7 @@ static int acp_dmic_dma_probe(struct dma *dma) dma->chan[channel].index = channel; dma->chan[channel].status = COMP_STATE_INIT; } - atomic_init(&dma->num_channels_busy, 0); + atomic_set(&dma->num_channels_busy, 0); return 0; } diff --git a/src/kernel/drivers/amd/common/acp_sp_dma.c b/src/kernel/drivers/amd/common/acp_sp_dma.c index bc0276041ed5..1bacbc1ddd47 100644 --- a/src/kernel/drivers/amd/common/acp_sp_dma.c +++ b/src/kernel/drivers/amd/common/acp_sp_dma.c @@ -126,7 +126,7 @@ static int acp_dai_sp_dma_probe(struct dma *dma) dma->chan[channel].index = channel; dma->chan[channel].status = COMP_STATE_INIT; } - atomic_init(&dma->num_channels_busy, 0); + atomic_set(&dma->num_channels_busy, 0); return 0; } diff --git a/src/kernel/drivers/amd/rembrandt/acp_bt_dma.c b/src/kernel/drivers/amd/rembrandt/acp_bt_dma.c index cb146dcf3172..ce50708c8246 100644 --- a/src/kernel/drivers/amd/rembrandt/acp_bt_dma.c +++ b/src/kernel/drivers/amd/rembrandt/acp_bt_dma.c @@ -310,7 +310,7 @@ static int acp_dai_bt_dma_probe(struct dma *dma) dma->chan[channel].index = channel; dma->chan[channel].status = COMP_STATE_INIT; } - atomic_init(&dma->num_channels_busy, 0); + atomic_set(&dma->num_channels_busy, 0); return 0; } diff --git a/src/kernel/drivers/amd/rembrandt/acp_hs_dma.c b/src/kernel/drivers/amd/rembrandt/acp_hs_dma.c index 3502731212bd..bc08fb3a76a4 100644 --- a/src/kernel/drivers/amd/rembrandt/acp_hs_dma.c +++ b/src/kernel/drivers/amd/rembrandt/acp_hs_dma.c @@ -299,7 +299,7 @@ static int acp_dai_hs_dma_probe(struct dma *dma) dma->chan[channel].index = channel; dma->chan[channel].status = COMP_STATE_INIT; } - atomic_init(&dma->num_channels_busy, 0); + atomic_set(&dma->num_channels_busy, 0); return 0; } diff --git a/src/kernel/drivers/generic/dummy-dma.c b/src/kernel/drivers/generic/dummy-dma.c index fd4efea90603..0d47f9a3c17e 100644 --- a/src/kernel/drivers/generic/dummy-dma.c +++ b/src/kernel/drivers/generic/dummy-dma.c @@ -447,7 +447,7 @@ static int dummy_dma_probe(struct dma *dma) dma_chan_set_data(&dma->chan[i], &chanp[i]); } - atomic_init(&dma->num_channels_busy, 0); + atomic_set(&dma->num_channels_busy, 0); return 0; } diff --git a/src/kernel/ipc/ipc4/handler-kernel.c b/src/kernel/ipc/ipc4/handler-kernel.c index b8d02c3771ae..67a694dc2d6a 100644 --- a/src/kernel/ipc/ipc4/handler-kernel.c +++ b/src/kernel/ipc/ipc4/handler-kernel.c @@ -195,7 +195,7 @@ void z_vrfy_ipc_compound_post_start(uint32_t msg_id, int ret, bool delayed) void ipc_compound_msg_done(uint32_t msg_id, int error) { - if (!atomic_read(&msg_data.delayed_reply)) { + if (!atomic_get(&msg_data.delayed_reply)) { ipc_cmd_err(&ipc_tr, "unexpected delayed reply"); return; } @@ -224,7 +224,7 @@ int z_impl_ipc_wait_for_compound_msg(void) { int try_count = 30; - while (atomic_read(&msg_data.delayed_reply)) { + while (atomic_get(&msg_data.delayed_reply)) { k_sleep(Z_TIMEOUT_US(250)); if (!try_count--) { diff --git a/src/kernel/lib/agent.c b/src/kernel/lib/agent.c index 2d62a57b38ca..384e76d93c02 100644 --- a/src/kernel/lib/agent.c +++ b/src/kernel/lib/agent.c @@ -114,7 +114,7 @@ __cold void sa_init(struct sof *sof, uint64_t timeout) sof->sa->panic_timeout = 2 * ticks; /* 100% delay */ sof->sa->warn_timeout = ticks + ticks / 20; /* 5% delay */ - atomic_init(&sof->sa->panic_cnt, 0); + atomic_set(&sof->sa->panic_cnt, 0); sof->sa->panic_on_delay = true; if (ticks > UINT_MAX || sof->sa->warn_timeout > UINT_MAX || diff --git a/src/kernel/lib/dma-kernel.c b/src/kernel/lib/dma-kernel.c index 32e76a433395..2f02be84db8d 100644 --- a/src/kernel/lib/dma-kernel.c +++ b/src/kernel/lib/dma-kernel.c @@ -133,7 +133,7 @@ __cold struct sof_dma *z_impl_sof_dma_get(uint32_t dir, uint32_t cap, uint32_t d d++) { tr_err(&dma_tr, " DMAC ID %d users %d busy channels %ld", d->plat_data.id, d->sref, - atomic_read(&d->num_channels_busy)); + atomic_get(&d->num_channels_busy)); tr_err(&dma_tr, " caps 0x%x dev 0x%x", d->plat_data.caps, d->plat_data.devs); } @@ -166,7 +166,7 @@ __cold struct sof_dma *z_impl_sof_dma_get(uint32_t dir, uint32_t cap, uint32_t d tr_info(&dma_tr, "dma_get() ID %d sref = %d busy channels %ld", dmin->plat_data.id, dmin->sref, - atomic_read(&dmin->num_channels_busy)); + atomic_get(&dmin->num_channels_busy)); out: k_spin_unlock(dma_lock(dmin), key); return !ret ? dmin : NULL; @@ -325,7 +325,7 @@ struct dma *dma_get(uint32_t dir, uint32_t cap, uint32_t dev, uint32_t flags) d++) { tr_err(&dma_tr, " DMAC ID %d users %d busy channels %ld", d->plat_data.id, d->sref, - atomic_read(&d->num_channels_busy)); + atomic_get(&d->num_channels_busy)); tr_err(&dma_tr, " caps 0x%x dev 0x%x", d->plat_data.caps, d->plat_data.devs); } @@ -356,7 +356,7 @@ struct dma *dma_get(uint32_t dir, uint32_t cap, uint32_t dev, uint32_t flags) tr_info(&dma_tr, "dma_get() ID %d sref = %d busy channels %ld", dmin->plat_data.id, dmin->sref, - atomic_read(&dmin->num_channels_busy)); + atomic_get(&dmin->num_channels_busy)); k_spin_unlock(&dmin->lock, key); return !ret ? dmin : NULL; diff --git a/src/kernel/schedule/zephyr_domain-kernel.c b/src/kernel/schedule/zephyr_domain-kernel.c index c99760e18c2a..1a8b9a2a1163 100644 --- a/src/kernel/schedule/zephyr_domain-kernel.c +++ b/src/kernel/schedule/zephyr_domain-kernel.c @@ -181,7 +181,7 @@ static int zephyr_domain_unregister(struct ll_schedule_domain *domain, key = k_spin_lock(&domain->lock); - if (!atomic_read(&domain->total_num_tasks)) { + if (!atomic_get(&domain->total_num_tasks)) { /* Disable the watchdog */ watchdog_disable(core); @@ -338,7 +338,7 @@ static void zephyr_domain_thread_free(struct ll_schedule_domain *domain, /* Still tasks on other cores, only clean up this core's thread */ k_mutex_lock(domain->lock, K_FOREVER); - if (!num_tasks && !atomic_read(&domain->total_num_tasks)) { + if (!num_tasks && !atomic_get(&domain->total_num_tasks)) { /* Last task globally: stop the timer and watchdog */ watchdog_disable(core); diff --git a/src/schedule/zephyr_ll.c b/src/schedule/zephyr_ll.c index 73704f1b961c..fcf5b363b27e 100644 --- a/src/schedule/zephyr_ll.c +++ b/src/schedule/zephyr_ll.c @@ -117,7 +117,7 @@ static void zephyr_ll_task_done(struct zephyr_ll *sch, tr_info(&ll_tr, "task complete %p %pU", task, task->uid); tr_info(&ll_tr, "num_tasks %d total_num_tasks %ld", - sch->n_tasks, atomic_read(&sch->ll_domain->total_num_tasks)); + sch->n_tasks, atomic_get(&sch->ll_domain->total_num_tasks)); /* * If this is the last task, domain_unregister() won't return. It is diff --git a/test/ztest/unit/host_stubs/host_stubs.c b/test/ztest/unit/host_stubs/host_stubs.c index b0acf57d03c7..42d44a591eb2 100644 --- a/test/ztest/unit/host_stubs/host_stubs.c +++ b/test/ztest/unit/host_stubs/host_stubs.c @@ -5,7 +5,6 @@ // Uses the posix/include stubs of the Zephyr APIs, as the non-Zephyr host // builds do. Built with the host include paths only, see CMakeLists.txt. -#include #include #include #include @@ -33,8 +32,8 @@ void host_stub_atomic_seq(struct stub_atomic_seq *seq) { atomic_t a; - atomic_init(&a, STUB_ATOMIC_INIT); - seq->read_after_init = atomic_read(&a); + atomic_set(&a, STUB_ATOMIC_INIT); + seq->read_after_init = atomic_get(&a); seq->set_ret = atomic_set(&a, STUB_ATOMIC_SET); seq->add_ret = atomic_add(&a, STUB_ATOMIC_ADD); seq->sub_ret = atomic_sub(&a, STUB_ATOMIC_SUB); diff --git a/zephyr/include/rtos/atomic.h b/zephyr/include/rtos/atomic.h index 60b1ba3b9180..53e232cd0fe3 100644 --- a/zephyr/include/rtos/atomic.h +++ b/zephyr/include/rtos/atomic.h @@ -8,13 +8,4 @@ #include -/* Zephyr commit 174cb7f9f183 switched 'atomic_t' from 'int' to - * 'long'. As we don't support 64 bits, this should have made no - * difference but in reality it broke printk("%d / %ld",...) The no-op - * cast to 'long' below provides a transition by making it possible to - * compile SOF both before _and_ after the Zephyr switch. - */ -#define atomic_read(p) ((long)atomic_get(p)) -#define atomic_init(p, v) atomic_set(p, v) - #endif /*__ZEPHYR_RTOS_ATOMIC_H__ */ From 0214abc3312f9429ac46ac042706a7dd8be1c4b5 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 1 Dec 2026 22:24:52 +0000 Subject: [PATCH 6/6] treewide: include and remove rtos/atomic.h Both versions of rtos/atomic.h only include now: Zephyr's header on Zephyr, the posix stub on the host. Include it directly and remove rtos/atomic.h. The host arch atomics are now only included from the stub. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- posix/include/rtos/atomic.h | 13 ------------- posix/include/sof/lib/agent.h | 2 +- posix/include/sof/lib/dma.h | 2 +- src/audio/module_adapter/module/dolby/dax.c | 2 +- src/audio/module_adapter/module/dolby/dax.h | 2 +- src/include/sof/lib/agent.h | 2 +- src/include/sof/schedule/ll_schedule_domain.h | 2 +- src/ipc/ipc4/handler-user.c | 2 +- src/kernel/arch/host/include/arch/atomic.h | 6 +++--- src/kernel/drivers/amd/common/acp_dmic_dma.c | 2 +- src/kernel/drivers/amd/common/acp_sp_dma.c | 2 +- src/kernel/drivers/amd/rembrandt/acp_bt_dma.c | 2 +- src/kernel/drivers/amd/rembrandt/acp_dmic_dma.c | 2 +- src/kernel/drivers/amd/rembrandt/acp_hs_dma.c | 2 +- src/kernel/drivers/amd/rembrandt/acp_sp_dma.c | 2 +- src/kernel/drivers/generic/dummy-dma.c | 2 +- src/kernel/ipc/ipc4/handler-kernel.c | 2 +- src/kernel/ipc/ipc4/handler-ll-kernel.c | 2 +- src/kernel/ipc/ipc4/handler-ll-user.c | 2 +- src/kernel/ipc/ipc4/handler-user-kernel.c | 2 +- src/kernel/lib/dma-kernel.c | 2 +- src/kernel/platform/amd/acp_7_0/lib/clk.c | 2 +- src/kernel/platform/amd/acp_7_x/lib/clk.c | 2 +- src/lib/dma.c | 2 +- zephyr/include/rtos/atomic.h | 11 ----------- zephyr/include/sof/lib/dma.h | 2 +- 26 files changed, 26 insertions(+), 50 deletions(-) delete mode 100644 posix/include/rtos/atomic.h delete mode 100644 zephyr/include/rtos/atomic.h diff --git a/posix/include/rtos/atomic.h b/posix/include/rtos/atomic.h deleted file mode 100644 index 3b6f595d1944..000000000000 --- a/posix/include/rtos/atomic.h +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * - * Copyright(c) 2018 Intel Corporation. All rights reserved. - * - * Author: Liam Girdwood - */ - -#ifndef __SOF_ATOMIC_H__ -#define __SOF_ATOMIC_H__ - -#include - -#endif /* __SOF_ATOMIC_H__ */ diff --git a/posix/include/sof/lib/agent.h b/posix/include/sof/lib/agent.h index cee04b7cba2e..32837c576030 100644 --- a/posix/include/sof/lib/agent.h +++ b/posix/include/sof/lib/agent.h @@ -8,7 +8,7 @@ #ifndef __SOF_LIB_AGENT_H__ #define __SOF_LIB_AGENT_H__ -#include +#include #include #include #include diff --git a/posix/include/sof/lib/dma.h b/posix/include/sof/lib/dma.h index 3135cf72e58a..f6095952aeac 100644 --- a/posix/include/sof/lib/dma.h +++ b/posix/include/sof/lib/dma.h @@ -17,7 +17,7 @@ #define __SOF_LIB_DMA_H__ #include -#include +#include #include #include #include diff --git a/src/audio/module_adapter/module/dolby/dax.c b/src/audio/module_adapter/module/dolby/dax.c index f404c43b59a8..2bceed9f854b 100644 --- a/src/audio/module_adapter/module/dolby/dax.c +++ b/src/audio/module_adapter/module/dolby/dax.c @@ -7,7 +7,7 @@ // Author: Jun Lai // -#include +#include #include #include #include diff --git a/src/audio/module_adapter/module/dolby/dax.h b/src/audio/module_adapter/module/dolby/dax.h index 34d7efb50596..31049bdd55eb 100644 --- a/src/audio/module_adapter/module/dolby/dax.h +++ b/src/audio/module_adapter/module/dolby/dax.h @@ -10,7 +10,7 @@ #ifndef DAX_H #define DAX_H -#include +#include #include #include #include diff --git a/src/include/sof/lib/agent.h b/src/include/sof/lib/agent.h index 35dccf64f16d..3002d59e215d 100644 --- a/src/include/sof/lib/agent.h +++ b/src/include/sof/lib/agent.h @@ -8,7 +8,7 @@ #ifndef __SOF_LIB_AGENT_H__ #define __SOF_LIB_AGENT_H__ -#include +#include #include #include #include diff --git a/src/include/sof/schedule/ll_schedule_domain.h b/src/include/sof/schedule/ll_schedule_domain.h index 2bd9bc6c28af..3c53978c5154 100644 --- a/src/include/sof/schedule/ll_schedule_domain.h +++ b/src/include/sof/schedule/ll_schedule_domain.h @@ -14,7 +14,7 @@ #ifndef __SOF_SCHEDULE_LL_SCHEDULE_DOMAIN_H__ #define __SOF_SCHEDULE_LL_SCHEDULE_DOMAIN_H__ -#include +#include #include #include #include diff --git a/src/ipc/ipc4/handler-user.c b/src/ipc/ipc4/handler-user.c index 5e210bcf246b..bdefbf4438b3 100644 --- a/src/ipc/ipc4/handler-user.c +++ b/src/ipc/ipc4/handler-user.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include diff --git a/src/kernel/arch/host/include/arch/atomic.h b/src/kernel/arch/host/include/arch/atomic.h index 180a0ba69140..d2ae2d3d6bec 100644 --- a/src/kernel/arch/host/include/arch/atomic.h +++ b/src/kernel/arch/host/include/arch/atomic.h @@ -6,7 +6,7 @@ * Ranjani Sridharan */ -#if defined(__SOF_ATOMIC_H__) || defined(__POSIX_ZEPHYR_SYS_ATOMIC_H__) +#ifdef __POSIX_ZEPHYR_SYS_ATOMIC_H__ #ifndef __ARCH_ATOMIC_H__ #define __ARCH_ATOMIC_H__ @@ -96,6 +96,6 @@ static inline int32_t arch_atomic_sub(atomic_t *a, int32_t value) #else -#error "This file shouldn't be included from outside of rtos/atomic.h or zephyr/sys/atomic.h" +#error "This file shouldn't be included from outside of zephyr/sys/atomic.h" -#endif /* __SOF_ATOMIC_H__ || __POSIX_ZEPHYR_SYS_ATOMIC_H__ */ +#endif /* __POSIX_ZEPHYR_SYS_ATOMIC_H__ */ diff --git a/src/kernel/drivers/amd/common/acp_dmic_dma.c b/src/kernel/drivers/amd/common/acp_dmic_dma.c index 963068be6cf1..475d39ac53c2 100644 --- a/src/kernel/drivers/amd/common/acp_dmic_dma.c +++ b/src/kernel/drivers/amd/common/acp_dmic_dma.c @@ -5,7 +5,7 @@ //Author: Basavaraj Hiregoudar // SaiSurya, Ch -#include +#include #include #include #include diff --git a/src/kernel/drivers/amd/common/acp_sp_dma.c b/src/kernel/drivers/amd/common/acp_sp_dma.c index 1bacbc1ddd47..31aaca2dc3d4 100644 --- a/src/kernel/drivers/amd/common/acp_sp_dma.c +++ b/src/kernel/drivers/amd/common/acp_sp_dma.c @@ -5,7 +5,7 @@ //Author: Basavaraj Hiregoudar // SaiSurya, Ch -#include +#include #include #include #include diff --git a/src/kernel/drivers/amd/rembrandt/acp_bt_dma.c b/src/kernel/drivers/amd/rembrandt/acp_bt_dma.c index ce50708c8246..62c367ccc4d4 100644 --- a/src/kernel/drivers/amd/rembrandt/acp_bt_dma.c +++ b/src/kernel/drivers/amd/rembrandt/acp_bt_dma.c @@ -5,7 +5,7 @@ //Author: Basavaraj Hiregoudar // Bala Kishore -#include +#include #include #include #include diff --git a/src/kernel/drivers/amd/rembrandt/acp_dmic_dma.c b/src/kernel/drivers/amd/rembrandt/acp_dmic_dma.c index 39bfa090a282..8cb0def6fdc1 100644 --- a/src/kernel/drivers/amd/rembrandt/acp_dmic_dma.c +++ b/src/kernel/drivers/amd/rembrandt/acp_dmic_dma.c @@ -5,7 +5,7 @@ //Author: Basavaraj Hiregoudar // Bala Kishore -#include +#include #include #include #include diff --git a/src/kernel/drivers/amd/rembrandt/acp_hs_dma.c b/src/kernel/drivers/amd/rembrandt/acp_hs_dma.c index bc08fb3a76a4..6ff96d066963 100644 --- a/src/kernel/drivers/amd/rembrandt/acp_hs_dma.c +++ b/src/kernel/drivers/amd/rembrandt/acp_hs_dma.c @@ -5,7 +5,7 @@ //Author: Basavaraj Hiregoudar // Bala Kishore -#include +#include #include #include #include diff --git a/src/kernel/drivers/amd/rembrandt/acp_sp_dma.c b/src/kernel/drivers/amd/rembrandt/acp_sp_dma.c index d63e84be0f00..01f581459db5 100644 --- a/src/kernel/drivers/amd/rembrandt/acp_sp_dma.c +++ b/src/kernel/drivers/amd/rembrandt/acp_sp_dma.c @@ -5,7 +5,7 @@ //Author: Basavaraj Hiregoudar // Bala Kishore -#include +#include #include #include #include diff --git a/src/kernel/drivers/generic/dummy-dma.c b/src/kernel/drivers/generic/dummy-dma.c index 0d47f9a3c17e..af5bfad70595 100644 --- a/src/kernel/drivers/generic/dummy-dma.c +++ b/src/kernel/drivers/generic/dummy-dma.c @@ -25,7 +25,7 @@ * holds if you have CONFIG_HOST_PTABLE enabled, at least currently. */ -#include +#include #include #include #include diff --git a/src/kernel/ipc/ipc4/handler-kernel.c b/src/kernel/ipc/ipc4/handler-kernel.c index 67a694dc2d6a..cf9188850ed6 100644 --- a/src/kernel/ipc/ipc4/handler-kernel.c +++ b/src/kernel/ipc/ipc4/handler-kernel.c @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/kernel/ipc/ipc4/handler-ll-kernel.c b/src/kernel/ipc/ipc4/handler-ll-kernel.c index da0f1b667393..ed5796ec0342 100644 --- a/src/kernel/ipc/ipc4/handler-ll-kernel.c +++ b/src/kernel/ipc/ipc4/handler-ll-kernel.c @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include diff --git a/src/kernel/ipc/ipc4/handler-ll-user.c b/src/kernel/ipc/ipc4/handler-ll-user.c index e2f0c32ab744..d5a6b6452b9b 100644 --- a/src/kernel/ipc/ipc4/handler-ll-user.c +++ b/src/kernel/ipc/ipc4/handler-ll-user.c @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include diff --git a/src/kernel/ipc/ipc4/handler-user-kernel.c b/src/kernel/ipc/ipc4/handler-user-kernel.c index 076976ac3991..d50896bf4ae4 100644 --- a/src/kernel/ipc/ipc4/handler-user-kernel.c +++ b/src/kernel/ipc/ipc4/handler-user-kernel.c @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include diff --git a/src/kernel/lib/dma-kernel.c b/src/kernel/lib/dma-kernel.c index 2f02be84db8d..56d8db72c811 100644 --- a/src/kernel/lib/dma-kernel.c +++ b/src/kernel/lib/dma-kernel.c @@ -4,7 +4,7 @@ // // Author: Ranjani Sridharan -#include +#include #include #include #include diff --git a/src/kernel/platform/amd/acp_7_0/lib/clk.c b/src/kernel/platform/amd/acp_7_0/lib/clk.c index a1fdc35285ca..ee0c4fde3192 100644 --- a/src/kernel/platform/amd/acp_7_0/lib/clk.c +++ b/src/kernel/platform/amd/acp_7_0/lib/clk.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/kernel/platform/amd/acp_7_x/lib/clk.c b/src/kernel/platform/amd/acp_7_x/lib/clk.c index a23e762ce676..babe954ad96f 100644 --- a/src/kernel/platform/amd/acp_7_x/lib/clk.c +++ b/src/kernel/platform/amd/acp_7_x/lib/clk.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/lib/dma.c b/src/lib/dma.c index 8464f1c9e3d8..b47f4f0b8cda 100644 --- a/src/lib/dma.c +++ b/src/lib/dma.c @@ -4,7 +4,7 @@ // // Author: Ranjani Sridharan -#include +#include #include #include #include diff --git a/zephyr/include/rtos/atomic.h b/zephyr/include/rtos/atomic.h deleted file mode 100644 index 53e232cd0fe3..000000000000 --- a/zephyr/include/rtos/atomic.h +++ /dev/null @@ -1,11 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2020 Intel Corporation. All rights reserved. -// - -#ifndef __ZEPHYR_RTOS_ATOMIC_H__ -#define __ZEPHYR_RTOS_ATOMIC_H__ - -#include - -#endif /*__ZEPHYR_RTOS_ATOMIC_H__ */ diff --git a/zephyr/include/sof/lib/dma.h b/zephyr/include/sof/lib/dma.h index 9d24a7097e55..4e3086b64b0f 100644 --- a/zephyr/include/sof/lib/dma.h +++ b/zephyr/include/sof/lib/dma.h @@ -18,7 +18,7 @@ #include #endif -#include +#include #include #include #include