Skip to content

Commit eae6707

Browse files
committed
rustfmt
1 parent 2d4998d commit eae6707

File tree

24 files changed

+1673
-1551
lines changed

24 files changed

+1673
-1551
lines changed

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

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,55 +22,59 @@ static GLOBAL_ALLOCATOR: rustix_dlmalloc::GlobalDlmalloc = rustix_dlmalloc::Glob
2222
#[unsafe(link_section = ".init_array.00000")]
2323
#[used]
2424
static EARLY_INIT_ARRAY: unsafe extern "C" fn(i32, *mut *mut u8) = {
25-
unsafe extern "C" fn function(_argc: i32, argv: *mut *mut u8) { unsafe {
26-
// Libc was calling constructors (we're one of them), but origin will
27-
// be doing that now, so just exit when we're called a second time.
28-
static FIRST: AtomicBool = AtomicBool::new(false);
29-
if FIRST
30-
.compare_exchange(false, true, Ordering::Relaxed, Ordering::Relaxed)
31-
.is_err()
32-
{
33-
return;
34-
}
25+
unsafe extern "C" fn function(_argc: i32, argv: *mut *mut u8) {
26+
unsafe {
27+
// Libc was calling constructors (we're one of them), but origin will
28+
// be doing that now, so just exit when we're called a second time.
29+
static FIRST: AtomicBool = AtomicBool::new(false);
30+
if FIRST
31+
.compare_exchange(false, true, Ordering::Relaxed, Ordering::Relaxed)
32+
.is_err()
33+
{
34+
return;
35+
}
3536

36-
// Compute the initial stack address provided by the kernel.
37-
let mem = argv.sub(1);
37+
// Compute the initial stack address provided by the kernel.
38+
let mem = argv.sub(1);
3839

39-
origin::program::start(mem as _);
40-
}}
40+
origin::program::start(mem as _);
41+
}
42+
}
4143
function
4244
};
4345

4446
#[unsafe(no_mangle)]
45-
unsafe fn origin_main(_argc: usize, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 { unsafe {
46-
eprintln!("Hello from main thread");
47+
unsafe fn origin_main(_argc: usize, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
48+
unsafe {
49+
eprintln!("Hello from main thread");
4750

48-
program::at_exit(Box::new(|| {
49-
eprintln!("Hello from a `program::at_exit` handler")
50-
}));
51-
thread::at_exit(Box::new(|| {
52-
eprintln!("Hello from a main-thread `thread::at_exit` handler")
53-
}));
51+
program::at_exit(Box::new(|| {
52+
eprintln!("Hello from a `program::at_exit` handler")
53+
}));
54+
thread::at_exit(Box::new(|| {
55+
eprintln!("Hello from a main-thread `thread::at_exit` handler")
56+
}));
5457

55-
let thread = thread::create(
56-
|_args| {
57-
eprintln!("Hello from child thread");
58-
thread::at_exit(Box::new(|| {
59-
eprintln!("Hello from child thread's `thread::at_exit` handler")
60-
}));
61-
None
62-
},
63-
&[],
64-
thread::default_stack_size(),
65-
thread::default_guard_size(),
66-
)
67-
.unwrap();
58+
let thread = thread::create(
59+
|_args| {
60+
eprintln!("Hello from child thread");
61+
thread::at_exit(Box::new(|| {
62+
eprintln!("Hello from child thread's `thread::at_exit` handler")
63+
}));
64+
None
65+
},
66+
&[],
67+
thread::default_stack_size(),
68+
thread::default_guard_size(),
69+
)
70+
.unwrap();
6871

69-
thread::join(thread);
72+
thread::join(thread);
7073

71-
eprintln!("Goodbye from main");
72-
program::exit(0);
73-
}}
74+
eprintln!("Goodbye from main");
75+
program::exit(0);
76+
}
77+
}
7478

7579
// Libc calls `main` so we need to provide a definition to satisfy the
7680
// linker, however origin gains control before libc can call this `main`.

example-crates/origin-start-dynamic-linker/src/lib.rs

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,34 @@ use origin::{program, thread};
1313
static GLOBAL_ALLOCATOR: rustix_dlmalloc::GlobalDlmalloc = rustix_dlmalloc::GlobalDlmalloc;
1414

1515
#[unsafe(no_mangle)]
16-
unsafe fn origin_main(_argc: usize, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 { unsafe {
17-
eprintln!("Hello from main thread");
18-
19-
program::at_exit(Box::new(|| {
20-
eprintln!("Hello from a `program::at_exit` handler")
21-
}));
22-
thread::at_exit(Box::new(|| {
23-
eprintln!("Hello from a main-thread `thread::at_exit` handler")
24-
}));
25-
26-
let thread = thread::create(
27-
|_args| {
28-
eprintln!("Hello from child thread");
29-
thread::at_exit(Box::new(|| {
30-
eprintln!("Hello from child thread's `thread::at_exit` handler")
31-
}));
32-
None
33-
},
34-
&[],
35-
thread::default_stack_size(),
36-
thread::default_guard_size(),
37-
)
38-
.unwrap();
39-
40-
thread::join(thread);
41-
42-
eprintln!("Goodbye from main");
43-
program::exit(0);
44-
}}
16+
unsafe fn origin_main(_argc: usize, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
17+
unsafe {
18+
eprintln!("Hello from main thread");
19+
20+
program::at_exit(Box::new(|| {
21+
eprintln!("Hello from a `program::at_exit` handler")
22+
}));
23+
thread::at_exit(Box::new(|| {
24+
eprintln!("Hello from a main-thread `thread::at_exit` handler")
25+
}));
26+
27+
let thread = thread::create(
28+
|_args| {
29+
eprintln!("Hello from child thread");
30+
thread::at_exit(Box::new(|| {
31+
eprintln!("Hello from child thread's `thread::at_exit` handler")
32+
}));
33+
None
34+
},
35+
&[],
36+
thread::default_stack_size(),
37+
thread::default_guard_size(),
38+
)
39+
.unwrap();
40+
41+
thread::join(thread);
42+
43+
eprintln!("Goodbye from main");
44+
program::exit(0);
45+
}
46+
}

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

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,34 @@ use origin::{program, thread};
1313
static GLOBAL_ALLOCATOR: rustix_dlmalloc::GlobalDlmalloc = rustix_dlmalloc::GlobalDlmalloc;
1414

1515
#[unsafe(no_mangle)]
16-
unsafe fn origin_main(_argc: usize, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 { unsafe {
17-
eprintln!("Hello from main thread");
18-
19-
program::at_exit(Box::new(|| {
20-
eprintln!("Hello from a `program::at_exit` handler")
21-
}));
22-
thread::at_exit(Box::new(|| {
23-
eprintln!("Hello from a main-thread `thread::at_exit` handler")
24-
}));
25-
26-
let thread = thread::create(
27-
|_args| {
28-
eprintln!("Hello from child thread");
29-
thread::at_exit(Box::new(|| {
30-
eprintln!("Hello from child thread's `thread::at_exit` handler")
31-
}));
32-
None
33-
},
34-
&[],
35-
thread::default_stack_size(),
36-
thread::default_guard_size(),
37-
)
38-
.unwrap();
39-
40-
thread::join(thread);
41-
42-
eprintln!("Goodbye from main");
43-
program::exit(0);
44-
}}
16+
unsafe fn origin_main(_argc: usize, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
17+
unsafe {
18+
eprintln!("Hello from main thread");
19+
20+
program::at_exit(Box::new(|| {
21+
eprintln!("Hello from a `program::at_exit` handler")
22+
}));
23+
thread::at_exit(Box::new(|| {
24+
eprintln!("Hello from a main-thread `thread::at_exit` handler")
25+
}));
26+
27+
let thread = thread::create(
28+
|_args| {
29+
eprintln!("Hello from child thread");
30+
thread::at_exit(Box::new(|| {
31+
eprintln!("Hello from child thread's `thread::at_exit` handler")
32+
}));
33+
None
34+
},
35+
&[],
36+
thread::default_stack_size(),
37+
thread::default_guard_size(),
38+
)
39+
.unwrap();
40+
41+
thread::join(thread);
42+
43+
eprintln!("Goodbye from main");
44+
program::exit(0);
45+
}
46+
}

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

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,34 @@ use origin::{program, thread};
1313
static GLOBAL_ALLOCATOR: rustix_dlmalloc::GlobalDlmalloc = rustix_dlmalloc::GlobalDlmalloc;
1414

1515
#[unsafe(no_mangle)]
16-
unsafe fn origin_main(_argc: usize, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 { unsafe {
17-
eprintln!("Hello from main thread");
18-
19-
program::at_exit(Box::new(|| {
20-
eprintln!("Hello from a `program::at_exit` handler")
21-
}));
22-
thread::at_exit(Box::new(|| {
23-
eprintln!("Hello from a main-thread `thread::at_exit` handler")
24-
}));
25-
26-
let thread = thread::create(
27-
|_args| {
28-
eprintln!("Hello from child thread");
29-
thread::at_exit(Box::new(|| {
30-
eprintln!("Hello from child thread's `thread::at_exit` handler")
31-
}));
32-
None
33-
},
34-
&[],
35-
thread::default_stack_size(),
36-
thread::default_guard_size(),
37-
)
38-
.unwrap();
39-
40-
thread::join(thread);
41-
42-
eprintln!("Goodbye from main");
43-
program::exit(0);
44-
}}
16+
unsafe fn origin_main(_argc: usize, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
17+
unsafe {
18+
eprintln!("Hello from main thread");
19+
20+
program::at_exit(Box::new(|| {
21+
eprintln!("Hello from a `program::at_exit` handler")
22+
}));
23+
thread::at_exit(Box::new(|| {
24+
eprintln!("Hello from a main-thread `thread::at_exit` handler")
25+
}));
26+
27+
let thread = thread::create(
28+
|_args| {
29+
eprintln!("Hello from child thread");
30+
thread::at_exit(Box::new(|| {
31+
eprintln!("Hello from child thread's `thread::at_exit` handler")
32+
}));
33+
None
34+
},
35+
&[],
36+
thread::default_stack_size(),
37+
thread::default_guard_size(),
38+
)
39+
.unwrap();
40+
41+
thread::join(thread);
42+
43+
eprintln!("Goodbye from main");
44+
program::exit(0);
45+
}
46+
}

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

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,34 @@ use origin::{program, thread};
1313
static GLOBAL_ALLOCATOR: rustix_dlmalloc::GlobalDlmalloc = rustix_dlmalloc::GlobalDlmalloc;
1414

1515
#[unsafe(no_mangle)]
16-
unsafe fn origin_main(_argc: usize, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 { unsafe {
17-
eprintln!("Hello from main thread");
18-
19-
program::at_exit(Box::new(|| {
20-
eprintln!("Hello from a `program::at_exit` handler")
21-
}));
22-
thread::at_exit(Box::new(|| {
23-
eprintln!("Hello from a main-thread `thread::at_exit` handler")
24-
}));
25-
26-
let thread = thread::create(
27-
|_args| {
28-
eprintln!("Hello from child thread");
29-
thread::at_exit(Box::new(|| {
30-
eprintln!("Hello from child thread's `thread::at_exit` handler")
31-
}));
32-
None
33-
},
34-
&[],
35-
thread::default_stack_size(),
36-
thread::default_guard_size(),
37-
)
38-
.unwrap();
39-
40-
thread::join(thread);
41-
42-
eprintln!("Goodbye from main");
43-
program::exit(0);
44-
}}
16+
unsafe fn origin_main(_argc: usize, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
17+
unsafe {
18+
eprintln!("Hello from main thread");
19+
20+
program::at_exit(Box::new(|| {
21+
eprintln!("Hello from a `program::at_exit` handler")
22+
}));
23+
thread::at_exit(Box::new(|| {
24+
eprintln!("Hello from a main-thread `thread::at_exit` handler")
25+
}));
26+
27+
let thread = thread::create(
28+
|_args| {
29+
eprintln!("Hello from child thread");
30+
thread::at_exit(Box::new(|| {
31+
eprintln!("Hello from child thread's `thread::at_exit` handler")
32+
}));
33+
None
34+
},
35+
&[],
36+
thread::default_stack_size(),
37+
thread::default_guard_size(),
38+
)
39+
.unwrap();
40+
41+
thread::join(thread);
42+
43+
eprintln!("Goodbye from main");
44+
program::exit(0);
45+
}
46+
}

0 commit comments

Comments
 (0)