Skip to content

Commit cccfb08

Browse files
committed
replace winbase winnt to windows-sys
1 parent d01909a commit cccfb08

File tree

6 files changed

+22
-17
lines changed

6 files changed

+22
-17
lines changed

vm/Cargo.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,15 @@ features = [
125125
version = "0.52.0"
126126
features = [
127127
"Win32_Foundation",
128+
"Win32_Networking_WinSock",
128129
"Win32_Security",
129130
"Win32_Storage_FileSystem",
130131
"Win32_System_Console",
131132
"Win32_System_Diagnostics_Debug",
132133
"Win32_System_LibraryLoader",
133134
"Win32_System_Memory",
134135
"Win32_System_Pipes",
136+
"Win32_System_Registry",
135137
"Win32_System_SystemInformation",
136138
"Win32_System_SystemServices",
137139
"Win32_System_Threading",
@@ -141,11 +143,7 @@ features = [
141143

142144
[target.'cfg(windows)'.dependencies.winapi]
143145
version = "0.3.9"
144-
features = [
145-
"winsock2", "std", "winbase",
146-
"winnt",
147-
"impl-default",
148-
]
146+
features = ["std", "winnt"]
149147

150148
[target.'cfg(target_arch = "wasm32")'.dependencies]
151149
wasm-bindgen = "0.2.80"

vm/src/stdlib/msvcrt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod msvcrt {
1515
};
1616

1717
#[pyattr]
18-
use winapi::um::winbase::{
18+
use windows_sys::Win32::System::Diagnostics::Debug::{
1919
SEM_FAILCRITICALERRORS, SEM_NOALIGNMENTFAULTEXCEPT, SEM_NOGPFAULTERRORBOX,
2020
SEM_NOOPENFILEERRORBOX,
2121
};

vm/src/stdlib/nt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,6 @@ pub fn init_winsock() {
428428
static WSA_INIT: parking_lot::Once = parking_lot::Once::new();
429429
WSA_INIT.call_once(|| unsafe {
430430
let mut wsa_data = std::mem::MaybeUninit::uninit();
431-
let _ = winapi::um::winsock2::WSAStartup(0x0101, wsa_data.as_mut_ptr());
431+
let _ = windows_sys::Win32::Networking::WinSock::WSAStartup(0x0101, wsa_data.as_mut_ptr());
432432
})
433433
}

vm/src/stdlib/os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ pub(super) mod _os {
13771377

13781378
let f = OpenOptions::new()
13791379
.write(true)
1380-
.custom_flags(winapi::um::winbase::FILE_FLAG_BACKUP_SEMANTICS)
1380+
.custom_flags(windows_sys::Win32::Storage::FileSystem::FILE_FLAG_BACKUP_SEMANTICS)
13811381
.open(path)
13821382
.map_err(|err| err.into_pyexception(vm))?;
13831383

vm/src/stdlib/signal.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub(crate) mod _signal {
1919

2020
cfg_if::cfg_if! {
2121
if #[cfg(windows)] {
22-
use winapi::um::winsock2;
2322
type WakeupFd = libc::SOCKET;
2423
const INVALID_WAKEUP: WakeupFd = (-1isize) as usize;
2524
static WAKEUP: atomic::AtomicUsize = atomic::AtomicUsize::new(INVALID_WAKEUP);
@@ -200,14 +199,16 @@ pub(crate) mod _signal {
200199

201200
#[cfg(windows)]
202201
let is_socket = if fd != INVALID_WAKEUP {
202+
use windows_sys::Win32::Networking::WinSock;
203+
203204
crate::stdlib::nt::init_winsock();
204205
let mut res = 0i32;
205206
let mut res_size = std::mem::size_of::<i32>() as i32;
206207
let res = unsafe {
207-
winsock2::getsockopt(
208+
WinSock::getsockopt(
208209
fd,
209-
winsock2::SOL_SOCKET,
210-
winsock2::SO_ERROR,
210+
WinSock::SOL_SOCKET,
211+
WinSock::SO_ERROR,
211212
&mut res as *mut i32 as *mut _,
212213
&mut res_size,
213214
)
@@ -217,7 +218,7 @@ pub(crate) mod _signal {
217218
if !is_socket {
218219
let err = std::io::Error::last_os_error();
219220
// if getsockopt failed for some other reason, throw
220-
if err.raw_os_error() != Some(winsock2::WSAENOTSOCK) {
221+
if err.raw_os_error() != Some(WinSock::WSAENOTSOCK) {
221222
return Err(err.into_pyexception(vm));
222223
}
223224
}
@@ -263,8 +264,14 @@ pub(crate) mod _signal {
263264
let sigbyte = signum as u8;
264265
#[cfg(windows)]
265266
if WAKEUP_IS_SOCKET.load(Ordering::Relaxed) {
266-
let _res =
267-
unsafe { winsock2::send(wakeup_fd, &sigbyte as *const u8 as *const _, 1, 0) };
267+
let _res = unsafe {
268+
windows_sys::Win32::Networking::WinSock::send(
269+
wakeup_fd,
270+
&sigbyte as *const u8 as *const _,
271+
1,
272+
0,
273+
)
274+
};
268275
return;
269276
}
270277
let _res = unsafe { libc::write(wakeup_fd as _, &sigbyte as *const u8 as *const _, 1) };

vm/src/stdlib/winreg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ mod winreg {
3838

3939
// access rights
4040
#[pyattr]
41-
pub use winapi::um::winnt::{
41+
pub use windows_sys::Win32::System::Registry::{
4242
KEY_ALL_ACCESS, KEY_CREATE_LINK, KEY_CREATE_SUB_KEY, KEY_ENUMERATE_SUB_KEYS, KEY_EXECUTE,
4343
KEY_NOTIFY, KEY_QUERY_VALUE, KEY_READ, KEY_SET_VALUE, KEY_WOW64_32KEY, KEY_WOW64_64KEY,
4444
KEY_WRITE,
4545
};
4646
// value types
4747
#[pyattr]
48-
pub use winapi::um::winnt::{
48+
pub use windows_sys::Win32::System::Registry::{
4949
REG_BINARY, REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_DWORD_LITTLE_ENDIAN, REG_EXPAND_SZ,
5050
REG_FULL_RESOURCE_DESCRIPTOR, REG_LINK, REG_MULTI_SZ, REG_NONE, REG_QWORD,
5151
REG_QWORD_LITTLE_ENDIAN, REG_RESOURCE_LIST, REG_RESOURCE_REQUIREMENTS_LIST, REG_SZ,

0 commit comments

Comments
 (0)