Repository navigation
Conversation
The host builds of the shared code use the SOF atomic names from posix/include/rtos/atomic.h. To switch that code to the Zephyr names, the host needs a <zephyr/sys/atomic.h> that behaves like Zephyr's. 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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Shared code calls the SOF cache wrappers because the host has no <zephyr/cache.h>. 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. 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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Shared code uses assert() and sof_panic() because the host has neither <zephyr/sys/__assert.h> nor k_panic(). Code that already uses the Zephyr names has to be hidden from the host builds, such as the coherent API checks. Add <zephyr/sys/__assert.h> with __ASSERT() and __ASSERT_NO_MSG(). The host checks its assertions in every build, as assert() does: a failed assertion prints the condition and the 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(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The host builds use the posix/include stubs instead of the Zephyr headers, and no test covered them. Add a test that compiles a source file the way the host builds do, with only the host include paths, so that <zephyr/...> resolves to the stubs. The ztest code calls it and compares the results with the Zephyr implementations it is linked with: - 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, panic with SOF_IPC_PANIC_ASSERT on a false one, and evaluate the condition once; - k_panic() panics with SOF_IPC_PANIC_ASSERT. The test catches panics by replacing the host __panic() with a longjmp() back to the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
atomic_read() and atomic_init() are SOF names for the Zephyr atomic_get() and atomic_set(). Now that the host builds have a <zephyr/sys/atomic.h> 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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Both versions of rtos/atomic.h only include <zephyr/sys/atomic.h> 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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use the Zephyr atomic names in all code and remove
rtos/atomic.h. Part of #11517 (steps 4 and 16). Depends on #11583, which adds the host<zephyr/sys/atomic.h>stub; the first four commits here are that PR.Patches
treewide:atomic_read()/atomic_init()→atomic_get()/atomic_set()(22 call sites), and remove the SOF names from both versions ofrtos/atomic.h.atomic_set()returns the previous value whereatomic_init()returned nothing; no caller uses it.atomic_read()cast its value tolongfor the%ldlog formats.atomic_get()already returnslongon Zephyr, so the formats are unaffected.treewide: include<zephyr/sys/atomic.h>and removertos/atomic.h. Both versions only included<zephyr/sys/atomic.h>after patch 1: Zephyr's header on Zephyr, the stub on the host. The host arch atomics are now only included from the stub.Functional change
None.
Testing
host-testbench.sh) pass all 19 component tests.🤖 Generated with Claude Code