diff --git a/c-scape/Cargo.toml b/c-scape/Cargo.toml index f81a7c9..a2fa32c 100644 --- a/c-scape/Cargo.toml +++ b/c-scape/Cargo.toml @@ -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 } diff --git a/c-scape/src/process_.rs b/c-scape/src/process_.rs index dfa9761..e720879 100644 --- a/c-scape/src/process_.rs +++ b/c-scape/src/process_.rs @@ -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_) } @@ -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_), } } @@ -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(), diff --git a/c-scape/src/thread/mod.rs b/c-scape/src/thread/mod.rs index 56f9737..1edff5d 100644 --- a/c-scape/src/thread/mod.rs +++ b/c-scape/src/thread/mod.rs @@ -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())); @@ -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())); @@ -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 )); @@ -909,7 +909,7 @@ 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(); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index c9a29fc..e51ce31 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2024-02-26" +channel = "nightly-2024-04-21" components = ["rustc", "cargo", "rust-std", "rust-src", "rustfmt"]