Skip to content

Commit

Permalink
include: Add dummy field for Rust as well as CPP
Browse files Browse the repository at this point in the history
For CPP builds, a few structs that end up empty in some configurations will
generate compile errors.  With the Rust tools, bindgen ends up producing
empty structsw for these as well.  Although the code compiles, it generates
warnings.  For now, add CONFIG_RUST to the ifdef checks so that these
structs don't end up empty with Rust either.

Signed-off-by: David Brown <david.brown@linaro.org>
  • Loading branch information
d3zd3z committed Aug 27, 2024
1 parent 1d9d675 commit 2046760
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/zephyr/kernel/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ typedef struct k_thread_runtime_stats {
uint64_t idle_cycles;
#endif /* CONFIG_SCHED_THREAD_USAGE_ALL */

#if defined(__cplusplus) && !defined(CONFIG_SCHED_THREAD_USAGE) && \
#if (defined(__cplusplus) || CONFIG_RUST) && !defined(CONFIG_SCHED_THREAD_USAGE) && \
!defined(CONFIG_SCHED_THREAD_USAGE_ANALYSIS) && !defined(CONFIG_SCHED_THREAD_USAGE_ALL)
/* If none of the above Kconfig values are defined, this struct will have a size 0 in C
* which is not allowed in C++ (it'll have a size 1). To prevent this, we add a 1 byte dummy
Expand Down
2 changes: 1 addition & 1 deletion include/zephyr/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct k_spinlock {
#endif /* CONFIG_SPIN_LOCK_TIME_LIMIT */
#endif /* CONFIG_SPIN_VALIDATE */

#if defined(CONFIG_CPP) && !defined(CONFIG_SMP) && \
#if (defined(CONFIG_CPP) || defined(CONFIG_RUST)) && !defined(CONFIG_SMP) && \
!defined(CONFIG_SPIN_VALIDATE)
/* If CONFIG_SMP and CONFIG_SPIN_VALIDATE are both not defined
* the k_spinlock struct will have no members. The result
Expand Down

0 comments on commit 2046760

Please sign in to comment.