Skip to content

Commit 2ea761a

Browse files
authored
Minor code simplifications. (#90)
Reorder the arguments on the target-specific `clone` functions so they match each other. They aren't ABI-exposed, and making them all the same means the calling code doesn't need to be platform-specific.
1 parent 362246d commit 2ea761a

6 files changed

Lines changed: 5 additions & 20 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ For fully static linking, there are two options:
7676

7777
- Build with `RUSTFLAGS=-C target-feature=+crt-static` and enable Origin's
7878
`experimental-relocate` feature. This allows PIE mode to work, however it
79-
does so by enabling some experimental code in origin for performing
79+
does so by enabling some experimental code in Origin for performing
8080
relocations.
8181

8282
[basic example]: https://github.com/sunfishcode/origin/blob/main/example-crates/basic/README.md

src/arch/aarch64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ pub(super) unsafe fn clone(
142142
flags: u32,
143143
child_stack: *mut c_void,
144144
parent_tid: *mut RawPid,
145-
newtls: *mut c_void,
146145
child_tid: *mut RawPid,
146+
newtls: *mut c_void,
147147
fn_: *mut Box<dyn FnOnce() -> Option<Box<dyn Any>> + Send>,
148148
) -> isize {
149149
let r0;

src/arch/arm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ pub(super) unsafe fn clone(
142142
flags: u32,
143143
child_stack: *mut c_void,
144144
parent_tid: *mut RawPid,
145-
newtls: *mut c_void,
146145
child_tid: *mut RawPid,
146+
newtls: *mut c_void,
147147
fn_: *mut Box<dyn FnOnce() -> Option<Box<dyn Any>> + Send>,
148148
) -> isize {
149149
let r0;

src/arch/riscv64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ pub(super) unsafe fn clone(
142142
flags: u32,
143143
child_stack: *mut c_void,
144144
parent_tid: *mut RawPid,
145-
newtls: *mut c_void,
146145
child_tid: *mut RawPid,
146+
newtls: *mut c_void,
147147
fn_: *mut Box<dyn FnOnce() -> Option<Box<dyn Any>> + Send>,
148148
) -> isize {
149149
let r0;

src/arch/x86.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ pub(super) unsafe fn clone(
147147
flags: u32,
148148
child_stack: *mut c_void,
149149
parent_tid: *mut RawPid,
150-
newtls: *mut c_void,
151150
child_tid: *mut RawPid,
151+
newtls: *mut c_void,
152152
fn_: *mut Box<dyn FnOnce() -> Option<Box<dyn Any>> + Send>,
153153
) -> isize {
154154
let mut gs: u32 = 0;

src/thread/linux_raw.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,6 @@ pub fn create_thread(
514514
| CloneFlags::CHILD_SETTID
515515
| CloneFlags::PARENT_SETTID;
516516
let thread_id_ptr = (*metadata).thread.thread_id.as_ptr();
517-
#[cfg(target_arch = "x86_64")]
518517
let clone_res = clone(
519518
flags.bits(),
520519
stack.cast(),
@@ -523,20 +522,6 @@ pub fn create_thread(
523522
newtls.cast::<u8>().cast(),
524523
Box::into_raw(Box::new(fn_)),
525524
);
526-
#[cfg(any(
527-
target_arch = "x86",
528-
target_arch = "aarch64",
529-
target_arch = "arm",
530-
target_arch = "riscv64"
531-
))]
532-
let clone_res = clone(
533-
flags.bits(),
534-
stack.cast(),
535-
thread_id_ptr,
536-
newtls.cast::<u8>().cast(),
537-
thread_id_ptr,
538-
Box::into_raw(Box::new(fn_)),
539-
);
540525
if clone_res >= 0 {
541526
#[cfg(feature = "log")]
542527
log::trace!(

0 commit comments

Comments
 (0)