Skip to content

Commit afa2e61

Browse files
committed
Auto merge of #110152 - ChrisDenton:windows-sys, r=thomcc
Start using `windows sys` for Windows FFI bindings in std Switch to using windows-sys for FFI. In order to avoid some currently contentious issues, this uses windows-bindgen to generate a smaller set of bindings instead of using the full crate. Unlike the windows-sys crate, the generated bindings uses `*mut c_void` for handle types instead of `isize`. This to sidestep opsem concerns about mixing pointer types and integers between languages. Note that `SOCKET` remains defined as an integer but instead of being a usize, it's changed to fit the [standard library definition](https://github.com/rust-lang/rust/blob/a41fc00eaf352541008965fec0dee811e44373b3/library/std/src/os/windows/raw.rs#L12-L16): ```rust #[cfg(target_pointer_width = "32")] pub type SOCKET = u32; #[cfg(target_pointer_width = "64")] pub type SOCKET = u64; ``` The generated bindings also customizes the `#[link]` imports. I hope to switch to using raw-dylib but I don't want to tie that too closely with the switch to windows-sys. --- Changes outside of the bindings are, for the most part, fairly minimal (e.g. some differences in `*mut` vs. `*const` or a few types differ). One issue is that our own bindings sometimes mix in higher level types, like `BorrowedHandle`. This is pretty adhoc though.
2 parents 7e7d953 + c7e6ea0 commit afa2e61

File tree

16 files changed

+7089
-3098
lines changed

16 files changed

+7089
-3098
lines changed

std/src/os/windows/io/socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl BorrowedSocket<'_> {
110110
/// object as the existing `BorrowedSocket` instance.
111111
#[stable(feature = "io_safety", since = "1.63.0")]
112112
pub fn try_clone_to_owned(&self) -> io::Result<OwnedSocket> {
113-
let mut info = unsafe { mem::zeroed::<c::WSAPROTOCOL_INFO>() };
113+
let mut info = unsafe { mem::zeroed::<c::WSAPROTOCOL_INFOW>() };
114114
let result = unsafe {
115115
c::WSADuplicateSocketW(self.as_raw_socket(), c::GetCurrentProcessId(), &mut info)
116116
};

0 commit comments

Comments
 (0)