Skip to content

Commit 7dcbe72

Browse files
puppymatisunfishcode
authored andcommitted
Change main from extern "C" to extern "Rust".
This function is called from Rust code, so it doesn't need to be `extern "C"`.
1 parent 359bbba commit 7dcbe72

6 files changed

Lines changed: 6 additions & 6 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
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-
extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 {
59+
fn main(_argc: i32, _argv: *const *const u8) -> i32 {
6060
eprintln!("Hello from main thread");
6161

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

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-
extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 {
30+
fn main(_argc: i32, _argv: *const *const 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-
extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 {
24+
fn main(_argc: i32, _argv: *const *const u8) -> i32 {
2525
eprintln!("Hello!");
2626

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

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-
extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 {
30+
fn main(_argc: i32, _argv: *const *const u8) -> i32 {
3131
eprintln!("Hello from main thread");
3232

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

example-crates/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-
extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 {
21+
fn main(_argc: i32, _argv: *const *const u8) -> i32 {
2222
42
2323
}

src/program.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ unsafe fn init_runtime(mem: *mut usize, envp: *mut *mut u8) {
116116
#[cfg(any(feature = "origin-start", feature = "external-start"))]
117117
#[allow(unused_variables)]
118118
unsafe fn call_user_code(argc: c_int, argv: *mut *mut u8, envp: *mut *mut u8) -> i32 {
119-
extern "C" {
119+
extern "Rust" {
120120
fn main(argc: c_int, argv: *mut *mut u8, envp: *mut *mut u8) -> c_int;
121121
}
122122

0 commit comments

Comments
 (0)