Skip to content

Commit 148e135

Browse files
committed
rust: Simple main wrapper
Until further variants are needed, this provides a `main()` function that simply calls into the `rust_main()` function. This is adequate for applications where main can be directly written in Rust. The reason that this is written here, rather than just writing `main` directly in Rust is that `kernel/main_weak.c` provides a weak default implementation that will be brought in before the Rust application's `main` is linked in. Signed-off-by: David Brown <[email protected]>
1 parent 3496844 commit 148e135

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/rust/main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2024 Linaro LTD
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/* This main is brought into the Rust application. */
7+
8+
#ifdef CONFIG_RUST
9+
10+
extern void rust_main(void);
11+
12+
int main(void)
13+
{
14+
rust_main();
15+
return 0;
16+
}
17+
18+
#endif

0 commit comments

Comments
 (0)