Skip to content

Commit

Permalink
Update to the latest Rust nightly. (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode authored Apr 22, 2024
1 parent 4f27a7d commit 68abe3a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions c-scape/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ cc = { version = "1.0.68", optional = true }

[dependencies]
libm = "0.2.1"
rustix = { version = "0.38.31", default-features = false, features = ["event", "fs", "itoa", "mm", "net", "param", "pipe", "process", "rand", "runtime", "shm", "stdio", "system", "termios", "thread", "time"] }
rustix = { version = "0.38.33", default-features = false, features = ["event", "fs", "itoa", "mm", "net", "param", "pipe", "process", "rand", "runtime", "shm", "stdio", "system", "termios", "thread", "time"] }
rustix-futex-sync = { version = "0.2.1", features = ["atomic_usize"] }
memoffset = "0.9.0"
realpath-ext = { version = "0.1.0", default-features = false }
origin = { version = "0.18.1", default-features = false, features = ["thread", "init-fini-arrays", "alloc"] }
origin = { version = "0.18.3", default-features = false, features = ["thread", "init-fini-arrays", "alloc"] }
# We use the libc crate for C ABI types and constants, but we don't depend on
# the actual platform libc.
libc = { version = "0.2.138", default-features = false }
Expand Down
8 changes: 6 additions & 2 deletions c-scape/src/process_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ fn _pathconf(name: c_int) -> c_long {
#[cfg(feature = "take-charge")]
#[no_mangle]
unsafe extern "C" fn getauxval(type_: c_ulong) -> *mut c_void {
libc!(ptr::from_exposed_addr_mut(libc::getauxval(type_) as _));
libc!(ptr::with_exposed_provenance_mut(libc::getauxval(type_) as _));
_getauxval(type_)
}

Expand All @@ -187,9 +187,13 @@ unsafe extern "C" fn __getauxval(type_: c_ulong) -> *mut c_void {

#[cfg(feature = "take-charge")]
fn _getauxval(type_: c_ulong) -> *mut c_void {
// FIXME: reuse const from libc when available?
const AT_MINSIGSTKSZ: libc::c_ulong = 51;

match type_ {
libc::AT_HWCAP => ptr::without_provenance_mut(rustix::param::linux_hwcap().0),
libc::AT_HWCAP2 => ptr::without_provenance_mut(rustix::param::linux_hwcap().1),
AT_MINSIGSTKSZ => ptr::without_provenance_mut(rustix::param::linux_minsigstksz()),
_ => todo!("unrecognized __getauxval {}", type_),
}
}
Expand All @@ -214,7 +218,7 @@ unsafe extern "C" fn dl_iterate_phdr(

let (phdr, _phent, phnum) = rustix::runtime::exe_phdrs();
let mut info = libc::dl_phdr_info {
dlpi_addr: addr_of!(__executable_start).expose_addr() as _,
dlpi_addr: addr_of!(__executable_start).expose_provenance() as _,
dlpi_name: c"/proc/self/exe".as_ptr(),
dlpi_phdr: phdr.cast(),
dlpi_phnum: phnum.try_into().unwrap(),
Expand Down
15 changes: 9 additions & 6 deletions c-scape/src/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ libc_type!(PthreadRwlockattrT, pthread_rwlockattr_t);

#[no_mangle]
unsafe extern "C" fn pthread_self() -> PthreadT {
libc!(ptr::from_exposed_addr_mut(libc::pthread_self() as _));
libc!(ptr::with_exposed_provenance_mut(libc::pthread_self() as _));
thread::current().to_raw().cast()
}

#[no_mangle]
unsafe extern "C" fn pthread_getattr_np(thread: PthreadT, attr: *mut PthreadAttrT) -> c_int {
libc!(libc::pthread_getattr_np(
thread.expose_addr() as _,
thread.expose_provenance() as _,
checked_cast!(attr)
));
let (stack_addr, stack_size, guard_size) = thread::stack(Thread::from_raw(thread.cast()));
Expand Down Expand Up @@ -741,14 +741,14 @@ unsafe extern "C" fn pthread_create(

#[no_mangle]
unsafe extern "C" fn pthread_detach(pthread: PthreadT) -> c_int {
libc!(libc::pthread_detach(pthread.expose_addr() as _));
libc!(libc::pthread_detach(pthread.expose_provenance() as _));
thread::detach(Thread::from_raw(pthread.cast()));
0
}

#[no_mangle]
unsafe extern "C" fn pthread_join(pthread: PthreadT, retval: *mut *mut c_void) -> c_int {
libc!(libc::pthread_join(pthread.expose_addr() as _, retval));
libc!(libc::pthread_join(pthread.expose_provenance() as _, retval));

let return_value = thread::join(Thread::from_raw(pthread.cast()));

Expand Down Expand Up @@ -852,7 +852,7 @@ unsafe extern "C" fn pthread_getname_np(
len: size_t,
) -> c_int {
libc!(libc::pthread_getname_np(
pthread.expose_addr() as _,
pthread.expose_provenance() as _,
name,
len
));
Expand Down Expand Up @@ -909,7 +909,10 @@ unsafe extern "C" fn pthread_getname_np(
#[cfg(target_os = "linux")]
#[no_mangle]
unsafe extern "C" fn pthread_setname_np(pthread: PthreadT, name: *const libc::c_char) -> c_int {
libc!(libc::pthread_setname_np(pthread.expose_addr() as _, name));
libc!(libc::pthread_setname_np(
pthread.expose_provenance() as _,
name
));

let name = core::ffi::CStr::from_ptr(name);
let bytes = name.to_bytes();
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2024-02-26"
channel = "nightly-2024-04-21"
components = ["rustc", "cargo", "rust-std", "rust-src", "rustfmt"]

0 comments on commit 68abe3a

Please sign in to comment.