Commit 8dc77158 authored by David Brown's avatar David Brown Committed by David Brown
Browse files

include: Add dummy field for Rust as well as CPP

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: default avatarDavid Brown <david.brown@linaro.org>
parent acac09ec
Loading
Loading
Loading
Loading
+1 −1
Changes for include/zephyr/kernel/thread.h: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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
+1 −1
Changes for include/zephyr/spinlock.h: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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