Skip to content

Change main function to use extern rust instead of C #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use rustix_futex_sync::Mutex;
/// `mem` should point to the stack as provided by the operating system.
#[cfg(any(feature = "origin-start", feature = "external-start"))]
pub(super) unsafe extern "C" fn entry(mem: *mut usize) -> ! {
extern "C" {
extern "Rust" {
fn main(argc: c_int, argv: *mut *mut u8, envp: *mut *mut u8) -> c_int;
}

Expand Down
2 changes: 1 addition & 1 deletion test-crates/external-start/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static EARLY_INIT_ARRAY: unsafe extern "C" fn(i32, *mut *mut u8) = {
};

#[no_mangle]
extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 {
fn main(_argc: i32, _argv: *const *const u8) -> i32 {
eprintln!("Hello from main thread");

at_exit(Box::new(|| eprintln!("Hello from an at_exit handler")));
Expand Down
2 changes: 1 addition & 1 deletion test-crates/origin-start-no-alloc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn panic(panic: &core::panic::PanicInfo<'_>) -> ! {
extern "C" fn eh_personality() {}

#[no_mangle]
extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 {
fn main(_argc: i32, _argv: *const *const u8) -> i32 {
eprintln!("Hello!");

// Unlike origin-start, this example can't create threads because origin's
Expand Down
4 changes: 2 additions & 2 deletions test-crates/origin-start/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ extern crate compiler_builtins;

use alloc::boxed::Box;
use atomic_dbg::{dbg, eprintln};
use origin::thread::*;
use origin::program::*;
use origin::thread::*;

#[panic_handler]
fn panic(panic: &core::panic::PanicInfo<'_>) -> ! {
Expand All @@ -27,7 +27,7 @@ extern "C" fn eh_personality() {}
static GLOBAL_ALLOCATOR: rustix_dlmalloc::GlobalDlmalloc = rustix_dlmalloc::GlobalDlmalloc;

#[no_mangle]
extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 {
fn main(_argc: i32, _argv: *const *const u8) -> i32 {
eprintln!("Hello from main thread");

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