about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Denton <chris@chrisdenton.dev>2024-07-14 07:19:57 +0000
committerChris Denton <chris@chrisdenton.dev>2024-07-15 05:01:21 +0000
commit84dd7e4959bd1cadb67989f7a3234a46bcda2faf (patch)
tree03e9e0c594c2b1e5e136bd4cd247aafd9130c975
parent351f1f36f696b14b84ac784ee5a6b3a7879699cc (diff)
downloadrust-84dd7e4959bd1cadb67989f7a3234a46bcda2faf.tar.gz
rust-84dd7e4959bd1cadb67989f7a3234a46bcda2faf.zip
Remove LPVOID
-rw-r--r--library/std/src/sys/pal/windows/alloc.rs8
-rw-r--r--library/std/src/sys/pal/windows/c.rs8
-rw-r--r--library/std/src/sys/pal/windows/pipe.rs4
-rw-r--r--library/std/src/sys/pal/windows/stdio.rs2
-rw-r--r--library/std/src/sys/sync/thread_parking/windows.rs9
-rw-r--r--library/std/src/sys/thread_local/guard/windows.rs5
6 files changed, 18 insertions, 18 deletions
diff --git a/library/std/src/sys/pal/windows/alloc.rs b/library/std/src/sys/pal/windows/alloc.rs
index c2fb0c2b876..f85d29c00a9 100644
--- a/library/std/src/sys/pal/windows/alloc.rs
+++ b/library/std/src/sys/pal/windows/alloc.rs
@@ -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`
diff --git a/library/std/src/sys/pal/windows/c.rs b/library/std/src/sys/pal/windows/c.rs
index 48d46296d98..e284804c2c8 100644
--- a/library/std/src/sys/pal/windows/c.rs
+++ b/library/std/src/sys/pal/windows/c.rs
@@ -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 {
diff --git a/library/std/src/sys/pal/windows/pipe.rs b/library/std/src/sys/pal/windows/pipe.rs
index 408653f538f..03166033548 100644
--- a/library/std/src/sys/pal/windows/pipe.rs
+++ b/library/std/src/sys/pal/windows/pipe.rs
@@ -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.
diff --git a/library/std/src/sys/pal/windows/stdio.rs b/library/std/src/sys/pal/windows/stdio.rs
index 995be689b46..07686ab2933 100644
--- a/library/std/src/sys/pal/windows/stdio.rs
+++ b/library/std/src/sys/pal/windows/stdio.rs
@@ -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,
diff --git a/library/std/src/sys/sync/thread_parking/windows.rs b/library/std/src/sys/sync/thread_parking/windows.rs
index 4b8102d505a..3a8d40dc5cf 100644
--- a/library/std/src/sys/sync/thread_parking/windows.rs
+++ b/library/std/src/sys/sync/thread_parking/windows.rs
@@ -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>()
     }
 }
 
diff --git a/library/std/src/sys/thread_local/guard/windows.rs b/library/std/src/sys/thread_local/guard/windows.rs
index 81797f55170..c35b717fe75 100644
--- a/library/std/src/sys/thread_local/guard/windows.rs
+++ b/library/std/src/sys/thread_local/guard/windows.rs
@@ -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)))]