Skip to content

Commit bd01f22

Browse files
committed
zephyr-sys: Export stack alignment constants
Bindgen only exports defined values that are clearly numeric constants, which is thrown off when the defined value has a cast. Work around this by defining wrapper constants that bindgen is able to expose. We use the `ZR_` prefix (Zephyr Rust) to avoid conflicts with any other symbols. Signed-off-by: David Brown <[email protected]>
1 parent 5459545 commit bd01f22

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

zephyr-sys/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ fn main() -> Result<()> {
7171
.allowlist_function("k_.*")
7272
.allowlist_function("gpio_.*")
7373
.allowlist_function("sys_.*")
74+
.allowlist_item("ZR_.*")
7475
// Deprecated
7576
.blocklist_function("sys_clock_timeout_end_calc")
7677
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))

zephyr-sys/wrapper.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,15 @@ extern int errno;
3131
#endif
3232

3333
#include <zephyr/kernel.h>
34+
#include <zephyr/kernel/thread_stack.h>
3435
#include <zephyr/drivers/gpio.h>
36+
37+
/*
38+
* bindgen will output #defined constant that resolve to simple numbers. There are some symbols
39+
* that we want exported that, at least in some situations, are more complex, usually with a type
40+
* case.
41+
*
42+
* We'll use the prefix "ZR_" to avoid conflicts with other symbols.
43+
*/
44+
const uintptr_t ZR_STACK_ALIGN = Z_KERNEL_STACK_OBJ_ALIGN;
45+
const uintptr_t ZR_STACK_RESERVED = K_KERNEL_STACK_RESERVED;

0 commit comments

Comments
 (0)