Remove LPVOID
This commit is contained in:
parent
351f1f36f6
commit
84dd7e4959
6 changed files with 18 additions and 18 deletions
|
@ -115,7 +115,7 @@ extern "C" fn process_heap_init_and_alloc(
|
|||
_heap: MaybeUninit<c::HANDLE>, // We pass this argument to match the ABI of `HeapAlloc`
|
||||
flags: c::DWORD,
|
||||
dwBytes: usize,
|
||||
) -> c::LPVOID {
|
||||
) -> *mut c_void {
|
||||
let heap = init_or_get_process_heap();
|
||||
if core::intrinsics::unlikely(heap.is_null()) {
|
||||
return ptr::null_mut();
|
||||
|
@ -129,7 +129,7 @@ fn process_heap_alloc(
|
|||
_heap: MaybeUninit<c::HANDLE>, // We pass this argument to match the ABI of `HeapAlloc`,
|
||||
flags: c::DWORD,
|
||||
dwBytes: usize,
|
||||
) -> c::LPVOID {
|
||||
) -> *mut c_void {
|
||||
let heap = HEAP.load(Ordering::Relaxed);
|
||||
if core::intrinsics::likely(!heap.is_null()) {
|
||||
// SAFETY: `heap` is a non-null handle returned by `GetProcessHeap`.
|
||||
|
@ -240,7 +240,7 @@ unsafe impl GlobalAlloc for System {
|
|||
|
||||
// SAFETY: `heap` is a non-null handle returned by `GetProcessHeap`,
|
||||
// `block` is a pointer to the start of an allocated block.
|
||||
unsafe { HeapFree(heap, 0, block as c::LPVOID) };
|
||||
unsafe { HeapFree(heap, 0, block.cast::<c_void>()) };
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -253,7 +253,7 @@ unsafe impl GlobalAlloc for System {
|
|||
// SAFETY: `heap` is a non-null handle returned by `GetProcessHeap`,
|
||||
// `ptr` is a pointer to the start of an allocated block.
|
||||
// The returned pointer points to the start of an allocated block.
|
||||
unsafe { HeapReAlloc(heap, 0, ptr as c::LPVOID, new_size) as *mut u8 }
|
||||
unsafe { HeapReAlloc(heap, 0, ptr.cast::<c_void>(), new_size).cast::<u8>() }
|
||||
} else {
|
||||
// SAFETY: `realloc_fallback` is implemented using `dealloc` and `alloc`, which will
|
||||
// correctly handle `ptr` and return a pointer satisfying the guarantees of `System`
|
||||
|
|
|
@ -21,8 +21,6 @@ pub type DWORD = c_ulong;
|
|||
pub type WCHAR = u16;
|
||||
pub type ULONG = c_ulong;
|
||||
|
||||
pub type LPVOID = *mut c_void;
|
||||
|
||||
#[cfg(target_vendor = "win7")]
|
||||
pub type PSRWLOCK = *mut SRWLOCK;
|
||||
|
||||
|
@ -390,7 +388,7 @@ compat_fn_with_fallback! {
|
|||
pub fn NtCreateKeyedEvent(
|
||||
KeyedEventHandle: *mut HANDLE,
|
||||
DesiredAccess: DWORD,
|
||||
ObjectAttributes: LPVOID,
|
||||
ObjectAttributes: *mut c_void,
|
||||
Flags: ULONG
|
||||
) -> NTSTATUS {
|
||||
panic!("keyed events not available")
|
||||
|
@ -398,7 +396,7 @@ compat_fn_with_fallback! {
|
|||
#[cfg(target_vendor = "win7")]
|
||||
pub fn NtReleaseKeyedEvent(
|
||||
EventHandle: HANDLE,
|
||||
Key: LPVOID,
|
||||
Key: *mut c_void,
|
||||
Alertable: BOOLEAN,
|
||||
Timeout: *mut c_longlong
|
||||
) -> NTSTATUS {
|
||||
|
@ -407,7 +405,7 @@ compat_fn_with_fallback! {
|
|||
#[cfg(target_vendor = "win7")]
|
||||
pub fn NtWaitForKeyedEvent(
|
||||
EventHandle: HANDLE,
|
||||
Key: LPVOID,
|
||||
Key: *mut c_void,
|
||||
Alertable: BOOLEAN,
|
||||
Timeout: *mut c_longlong
|
||||
) -> NTSTATUS {
|
||||
|
|
|
@ -225,7 +225,7 @@ fn random_number() -> usize {
|
|||
// Abstracts over `ReadFileEx` and `WriteFileEx`
|
||||
type AlertableIoFn = unsafe extern "system" fn(
|
||||
BorrowedHandle<'_>,
|
||||
c::LPVOID,
|
||||
*mut core::ffi::c_void,
|
||||
c::DWORD,
|
||||
*mut c::OVERLAPPED,
|
||||
c::LPOVERLAPPED_COMPLETION_ROUTINE,
|
||||
|
@ -327,7 +327,7 @@ impl AnonPipe {
|
|||
unsafe fn alertable_io_internal(
|
||||
&self,
|
||||
io: AlertableIoFn,
|
||||
buf: c::LPVOID,
|
||||
buf: *mut core::ffi::c_void,
|
||||
len: c::DWORD,
|
||||
) -> io::Result<usize> {
|
||||
// Use "alertable I/O" to synchronize the pipe I/O.
|
||||
|
|
|
@ -355,7 +355,7 @@ fn read_u16s(handle: c::HANDLE, buf: &mut [MaybeUninit<u16>]) -> io::Result<usiz
|
|||
c::SetLastError(0);
|
||||
c::ReadConsoleW(
|
||||
handle,
|
||||
buf.as_mut_ptr() as c::LPVOID,
|
||||
buf.as_mut_ptr() as *mut core::ffi::c_void,
|
||||
buf.len() as u32,
|
||||
&mut amount,
|
||||
&input_control,
|
||||
|
|
|
@ -64,6 +64,7 @@ use crate::sync::atomic::{
|
|||
};
|
||||
use crate::sys::{c, dur2timeout};
|
||||
use crate::time::Duration;
|
||||
use core::ffi::c_void;
|
||||
|
||||
pub struct Parker {
|
||||
state: AtomicI8,
|
||||
|
@ -117,7 +118,7 @@ impl Parker {
|
|||
|
||||
loop {
|
||||
// Wait for something to happen, assuming it's still set to PARKED.
|
||||
c::WaitOnAddress(self.ptr(), &PARKED as *const _ as c::LPVOID, 1, c::INFINITE);
|
||||
c::WaitOnAddress(self.ptr(), &PARKED as *const _ as *const c_void, 1, c::INFINITE);
|
||||
// Change NOTIFIED=>EMPTY but leave PARKED alone.
|
||||
if self.state.compare_exchange(NOTIFIED, EMPTY, Acquire, Acquire).is_ok() {
|
||||
// Actually woken up by unpark().
|
||||
|
@ -144,7 +145,7 @@ impl Parker {
|
|||
}
|
||||
|
||||
// Wait for something to happen, assuming it's still set to PARKED.
|
||||
c::WaitOnAddress(self.ptr(), &PARKED as *const _ as c::LPVOID, 1, dur2timeout(timeout));
|
||||
c::WaitOnAddress(self.ptr(), &PARKED as *const _ as *const c_void, 1, dur2timeout(timeout));
|
||||
// Set the state back to EMPTY (from either PARKED or NOTIFIED).
|
||||
// Note that we don't just write EMPTY, but use swap() to also
|
||||
// include an acquire-ordered read to synchronize with unpark()'s
|
||||
|
@ -177,8 +178,8 @@ impl Parker {
|
|||
}
|
||||
}
|
||||
|
||||
fn ptr(&self) -> c::LPVOID {
|
||||
core::ptr::addr_of!(self.state) as c::LPVOID
|
||||
fn ptr(&self) -> *const c_void {
|
||||
core::ptr::addr_of!(self.state).cast::<c_void>()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
|
||||
use crate::ptr;
|
||||
use crate::sys::c;
|
||||
use core::ffi::c_void;
|
||||
|
||||
pub fn enable() {
|
||||
// When destructors are used, we don't want LLVM eliminating CALLBACK for any
|
||||
|
@ -74,9 +75,9 @@ pub fn enable() {
|
|||
|
||||
#[link_section = ".CRT$XLB"]
|
||||
#[cfg_attr(miri, used)] // Miri only considers explicitly `#[used]` statics for `lookup_link_section`
|
||||
pub static CALLBACK: unsafe extern "system" fn(c::LPVOID, c::DWORD, c::LPVOID) = tls_callback;
|
||||
pub static CALLBACK: unsafe extern "system" fn(*mut c_void, c::DWORD, *mut c_void) = tls_callback;
|
||||
|
||||
unsafe extern "system" fn tls_callback(_h: c::LPVOID, dw_reason: c::DWORD, _pv: c::LPVOID) {
|
||||
unsafe extern "system" fn tls_callback(_h: *mut c_void, dw_reason: c::DWORD, _pv: *mut c_void) {
|
||||
// See comments above for what this is doing. Note that we don't need this
|
||||
// trickery on GNU windows, just on MSVC.
|
||||
#[cfg(all(target_env = "msvc", not(target_thread_local)))]
|
||||
|
|
Loading…
Add table
Reference in a new issue