Skip to content

Commit b662723

Browse files
committed
Use *mut pointers for argv and envp.
This memory is mutable, and users may want to mutate it, so use `*mut`.
1 parent f3c4baf commit b662723

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

example-crates/external-start/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static EARLY_INIT_ARRAY: unsafe extern "C" fn(i32, *mut *mut u8) = {
5656
};
5757

5858
#[no_mangle]
59-
unsafe fn origin_main(_argc: i32, _argv: *const *const u8, _envp: *const *const u8) -> i32 {
59+
unsafe fn origin_main(_argc: i32, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
6060
eprintln!("Hello from main thread");
6161

6262
at_exit(Box::new(|| eprintln!("Hello from an at_exit handler")));
@@ -86,6 +86,6 @@ unsafe fn origin_main(_argc: i32, _argv: *const *const u8, _envp: *const *const
8686
// Libc calls `main` so we need to provide a definition to satisfy the
8787
// linker, however origin gains control before libc can call this `main`.
8888
#[no_mangle]
89-
unsafe fn main(_argc: i32, _argv: *const *const u8, _envp: *const *const u8) -> i32 {
89+
unsafe fn main(_argc: i32, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
9090
core::intrinsics::abort();
9191
}

example-crates/origin-start-lto/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" fn eh_personality() {}
2727
static GLOBAL_ALLOCATOR: rustix_dlmalloc::GlobalDlmalloc = rustix_dlmalloc::GlobalDlmalloc;
2828

2929
#[no_mangle]
30-
unsafe fn origin_main(_argc: i32, _argv: *const *const u8, _envp: *const *const u8) -> i32 {
30+
unsafe fn origin_main(_argc: i32, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
3131
eprintln!("Hello from main thread");
3232

3333
at_exit(Box::new(|| eprintln!("Hello from an at_exit handler")));

example-crates/origin-start-no-alloc/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn panic(panic: &core::panic::PanicInfo<'_>) -> ! {
2121
extern "C" fn eh_personality() {}
2222

2323
#[no_mangle]
24-
unsafe fn origin_main(_argc: i32, _argv: *const *const u8, _envp: *const *const u8) -> i32 {
24+
unsafe fn origin_main(_argc: i32, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
2525
eprintln!("Hello!");
2626

2727
// Unlike origin-start, this example can't create threads because origin's

example-crates/origin-start-tiny/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ fn panic(_panic: &core::panic::PanicInfo<'_>) -> ! {
1818
extern "C" fn eh_personality() {}
1919

2020
#[no_mangle]
21-
unsafe fn origin_main(_argc: i32, _argv: *const *const u8, _envp: *const *const u8) -> i32 {
21+
unsafe fn origin_main(_argc: i32, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
2222
42
2323
}

example-crates/origin-start/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" fn eh_personality() {}
2727
static GLOBAL_ALLOCATOR: rustix_dlmalloc::GlobalDlmalloc = rustix_dlmalloc::GlobalDlmalloc;
2828

2929
#[no_mangle]
30-
unsafe fn origin_main(_argc: i32, _argv: *const *const u8, _envp: *const *const u8) -> i32 {
30+
unsafe fn origin_main(_argc: i32, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
3131
eprintln!("Hello from main thread");
3232

3333
at_exit(Box::new(|| eprintln!("Hello from an at_exit handler")));

0 commit comments

Comments
 (0)