Skip to content

Commit 8dc7715

Browse files
committed
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: David Brown <[email protected]>
1 parent acac09e commit 8dc7715

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

include/zephyr/kernel/thread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ typedef struct k_thread_runtime_stats {
237237
uint64_t idle_cycles;
238238
#endif /* CONFIG_SCHED_THREAD_USAGE_ALL */
239239

240-
#if defined(__cplusplus) && !defined(CONFIG_SCHED_THREAD_USAGE) && \
240+
#if (defined(__cplusplus) || CONFIG_RUST) && !defined(CONFIG_SCHED_THREAD_USAGE) && \
241241
!defined(CONFIG_SCHED_THREAD_USAGE_ANALYSIS) && !defined(CONFIG_SCHED_THREAD_USAGE_ALL)
242242
/* If none of the above Kconfig values are defined, this struct will have a size 0 in C
243243
* which is not allowed in C++ (it'll have a size 1). To prevent this, we add a 1 byte dummy

include/zephyr/spinlock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct k_spinlock {
7878
#endif /* CONFIG_SPIN_LOCK_TIME_LIMIT */
7979
#endif /* CONFIG_SPIN_VALIDATE */
8080

81-
#if defined(CONFIG_CPP) && !defined(CONFIG_SMP) && \
81+
#if (defined(CONFIG_CPP) || defined(CONFIG_RUST)) && !defined(CONFIG_SMP) && \
8282
!defined(CONFIG_SPIN_VALIDATE)
8383
/* If CONFIG_SMP and CONFIG_SPIN_VALIDATE are both not defined
8484
* the k_spinlock struct will have no members. The result

0 commit comments

Comments
 (0)