Skip to content

Commit

Permalink
Auto merge of rust-lang#114882 - ChrisDenton:riddle-me, r=dtolnay
Browse files Browse the repository at this point in the history
Update windows ffi bindings

Bump `windows-bindgen` to version 0.51.1. This brings with it some changes to the generated FFI bindings, but little that affects the code.

One change that does have more of an impact is `SOCKET` being `usize` instead of either `u64` or `u32` (as is used in std's public `SOCKET` type). However, it's now easy enough to abstract over that difference.

Finally I added a few new bindings that are likely to be used in pending PRs, mostly to make sure they're ok with the new metadata.

r? libs
  • Loading branch information
bors committed Sep 28, 2023
2 parents c01d8d2 + e790860 commit dd91aba
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 154 deletions.
18 changes: 7 additions & 11 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6025,19 +6025,21 @@ dependencies = [

[[package]]
name = "windows-bindgen"
version = "0.49.0"
version = "0.51.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6935fb09b84ee57929ae92518b475f5dfdfbeb87c5334756acc28ee8e202b60"
checksum = "bc1f16b778125675feee0d15d6dd9f6af0e3ac52b3233d63a10aa39230c1cd75"
dependencies = [
"proc-macro2",
"rayon",
"syn 2.0.29",
"windows-metadata",
"windows-tokens",
]

[[package]]
name = "windows-metadata"
version = "0.49.0"
version = "0.51.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f5bca94a32bf1e6a376522b6601275a3b611ee885ec0f1b6a05f17e8cfd3385"
checksum = "753135d996f9da437c0b31dbde3032489a61708361929bcc07d4fba0b161000e"

[[package]]
name = "windows-sys"
Expand Down Expand Up @@ -6087,12 +6089,6 @@ dependencies = [
"windows_x86_64_msvc 0.48.0",
]

[[package]]
name = "windows-tokens"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b34c9a3b28cb41db7385546f7f9a8179348dffc89923dde66857b1ba5312f6b4"

[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.2"
Expand Down
8 changes: 4 additions & 4 deletions library/std/src/os/windows/io/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl BorrowedSocket<'_> {
let mut info = unsafe { mem::zeroed::<sys::c::WSAPROTOCOL_INFOW>() };
let result = unsafe {
sys::c::WSADuplicateSocketW(
self.as_raw_socket(),
self.as_raw_socket() as sys::c::SOCKET,
sys::c::GetCurrentProcessId(),
&mut info,
)
Expand All @@ -134,7 +134,7 @@ impl BorrowedSocket<'_> {
};

if socket != sys::c::INVALID_SOCKET {
unsafe { Ok(OwnedSocket::from_raw_socket(socket)) }
unsafe { Ok(OwnedSocket::from_raw_socket(socket as RawSocket)) }
} else {
let error = unsafe { sys::c::WSAGetLastError() };

Expand All @@ -158,7 +158,7 @@ impl BorrowedSocket<'_> {
}

unsafe {
let socket = OwnedSocket::from_raw_socket(socket);
let socket = OwnedSocket::from_raw_socket(socket as RawSocket);
socket.set_no_inherit()?;
Ok(socket)
}
Expand Down Expand Up @@ -211,7 +211,7 @@ impl Drop for OwnedSocket {
#[inline]
fn drop(&mut self) {
unsafe {
let _ = sys::c::closesocket(self.socket);
let _ = sys::c::closesocket(self.socket as sys::c::SOCKET);
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions library/std/src/sys/windows/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ pub use FD_SET as fd_set;
pub use LINGER as linger;
pub use TIMEVAL as timeval;

pub type CONDITION_VARIABLE = RTL_CONDITION_VARIABLE;
pub type SRWLOCK = RTL_SRWLOCK;
pub type INIT_ONCE = RTL_RUN_ONCE;

pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = CONDITION_VARIABLE { Ptr: ptr::null_mut() };
pub const SRWLOCK_INIT: SRWLOCK = SRWLOCK { Ptr: ptr::null_mut() };
pub const INIT_ONCE_STATIC_INIT: INIT_ONCE = INIT_ONCE { Ptr: ptr::null_mut() };
Expand Down Expand Up @@ -224,7 +220,7 @@ pub unsafe extern "system" fn ReadFileEx(
) -> BOOL {
windows_sys::ReadFileEx(
hFile.as_raw_handle(),
lpBuffer,
lpBuffer.cast::<u8>(),
nNumberOfBytesToRead,
lpOverlapped,
lpCompletionRoutine,
Expand Down
16 changes: 5 additions & 11 deletions library/std/src/sys/windows/c/windows_sys.lst
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
--out windows_sys.rs
--config flatten std
--filter
// tidy-alphabetical-start
Windows.Wdk.Storage.FileSystem.FILE_COMPLETE_IF_OPLOCKED
Windows.Wdk.Storage.FileSystem.FILE_CONTAINS_EXTENDED_CREATE_INFORMATION
Expand Down Expand Up @@ -2108,7 +2111,6 @@ Windows.Win32.Networking.WinSock.WSABASEERR
Windows.Win32.Networking.WinSock.WSABUF
Windows.Win32.Networking.WinSock.WSACleanup
Windows.Win32.Networking.WinSock.WSADATA
Windows.Win32.Networking.WinSock.WSADATA
Windows.Win32.Networking.WinSock.WSADuplicateSocketW
Windows.Win32.Networking.WinSock.WSAEACCES
Windows.Win32.Networking.WinSock.WSAEADDRINUSE
Expand Down Expand Up @@ -2328,7 +2330,6 @@ Windows.Win32.Storage.FileSystem.FileStandardInfo
Windows.Win32.Storage.FileSystem.FileStorageInfo
Windows.Win32.Storage.FileSystem.FileStreamInfo
Windows.Win32.Storage.FileSystem.FindClose
Windows.Win32.Storage.FileSystem.FindFileHandle
Windows.Win32.Storage.FileSystem.FindFirstFileW
Windows.Win32.Storage.FileSystem.FindNextFileW
Windows.Win32.Storage.FileSystem.FlushFileBuffers
Expand Down Expand Up @@ -2420,8 +2421,6 @@ Windows.Win32.System.Console.STD_OUTPUT_HANDLE
Windows.Win32.System.Console.WriteConsoleW
Windows.Win32.System.Diagnostics.Debug.ARM64_NT_NEON128
Windows.Win32.System.Diagnostics.Debug.CONTEXT
Windows.Win32.System.Diagnostics.Debug.CONTEXT
Windows.Win32.System.Diagnostics.Debug.CONTEXT
Windows.Win32.System.Diagnostics.Debug.EXCEPTION_RECORD
Windows.Win32.System.Diagnostics.Debug.FACILITY_CODE
Windows.Win32.System.Diagnostics.Debug.FACILITY_NT_BIT
Expand All @@ -2435,7 +2434,6 @@ Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_OPTIONS
Windows.Win32.System.Diagnostics.Debug.FormatMessageW
Windows.Win32.System.Diagnostics.Debug.M128A
Windows.Win32.System.Diagnostics.Debug.XSAVE_FORMAT
Windows.Win32.System.Diagnostics.Debug.XSAVE_FORMAT
Windows.Win32.System.Environment.FreeEnvironmentStringsW
Windows.Win32.System.Environment.GetCommandLineW
Windows.Win32.System.Environment.GetCurrentDirectoryW
Expand All @@ -2456,7 +2454,6 @@ Windows.Win32.System.Kernel.ExceptionContinueExecution
Windows.Win32.System.Kernel.ExceptionContinueSearch
Windows.Win32.System.Kernel.ExceptionNestedException
Windows.Win32.System.Kernel.FLOATING_SAVE_AREA
Windows.Win32.System.Kernel.FLOATING_SAVE_AREA
Windows.Win32.System.Kernel.OBJ_DONT_REPARSE
Windows.Win32.System.LibraryLoader.GetModuleFileNameW
Windows.Win32.System.LibraryLoader.GetModuleHandleA
Expand All @@ -2482,6 +2479,7 @@ Windows.Win32.System.SystemInformation.GetSystemTimeAsFileTime
Windows.Win32.System.SystemInformation.GetWindowsDirectoryW
Windows.Win32.System.SystemInformation.PROCESSOR_ARCHITECTURE
Windows.Win32.System.SystemInformation.SYSTEM_INFO
Windows.Win32.System.SystemServices.ALL_PROCESSOR_GROUPS
Windows.Win32.System.SystemServices.DLL_PROCESS_DETACH
Windows.Win32.System.SystemServices.DLL_THREAD_DETACH
Windows.Win32.System.SystemServices.EXCEPTION_MAXIMUM_PARAMETERS
Expand Down Expand Up @@ -2514,6 +2512,7 @@ Windows.Win32.System.Threading.DeleteProcThreadAttributeList
Windows.Win32.System.Threading.DETACHED_PROCESS
Windows.Win32.System.Threading.ExitProcess
Windows.Win32.System.Threading.EXTENDED_STARTUPINFO_PRESENT
Windows.Win32.System.Threading.GetActiveProcessorCount
Windows.Win32.System.Threading.GetCurrentProcess
Windows.Win32.System.Threading.GetCurrentProcessId
Windows.Win32.System.Threading.GetCurrentThread
Expand Down Expand Up @@ -2542,9 +2541,6 @@ Windows.Win32.System.Threading.PROFILE_USER
Windows.Win32.System.Threading.REALTIME_PRIORITY_CLASS
Windows.Win32.System.Threading.ReleaseSRWLockExclusive
Windows.Win32.System.Threading.ReleaseSRWLockShared
Windows.Win32.System.Threading.RTL_CONDITION_VARIABLE
Windows.Win32.System.Threading.RTL_RUN_ONCE
Windows.Win32.System.Threading.RTL_SRWLOCK
Windows.Win32.System.Threading.SetThreadStackGuarantee
Windows.Win32.System.Threading.Sleep
Windows.Win32.System.Threading.SleepConditionVariableSRW
Expand Down Expand Up @@ -2584,8 +2580,6 @@ Windows.Win32.System.Threading.WaitForMultipleObjects
Windows.Win32.System.Threading.WaitForSingleObject
Windows.Win32.System.Threading.WakeAllConditionVariable
Windows.Win32.System.Threading.WakeConditionVariable
Windows.Win32.System.WindowsProgramming.IO_STATUS_BLOCK
Windows.Win32.System.WindowsProgramming.OBJECT_ATTRIBUTES
Windows.Win32.System.WindowsProgramming.PROGRESS_CONTINUE
Windows.Win32.UI.Shell.GetUserProfileDirectoryW
// tidy-alphabetical-end
Expand Down
Loading

0 comments on commit dd91aba

Please sign in to comment.