Skip to content

Commit 54763bb

Browse files
committed
EXPERIMENT: use new windows-bindgen
1 parent 5e1ec9c commit 54763bb

16 files changed

Lines changed: 3024 additions & 2800 deletions

File tree

library/std/src/os/windows/process.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,8 @@ impl<'a> Drop for ProcThreadAttributeList<'a> {
502502
///
503503
/// [1]: <https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-deleteprocthreadattributelist>
504504
fn drop(&mut self) {
505-
let lp_attribute_list = self.attribute_list.as_mut_ptr().cast::<c_void>();
505+
let lp_attribute_list =
506+
self.attribute_list.as_mut_ptr().cast::<sys::c::_PROC_THREAD_ATTRIBUTE_LIST>();
506507
unsafe { sys::c::DeleteProcThreadAttributeList(lp_attribute_list) }
507508
}
508509
}
@@ -672,7 +673,7 @@ impl<'a> ProcThreadAttributeListBuilder<'a> {
672673
// `InitializeProcThreadAttributeList` to properly initialize the list.
673674
sys::cvt(unsafe {
674675
sys::c::InitializeProcThreadAttributeList(
675-
attribute_list.as_mut_ptr().cast::<c_void>(),
676+
attribute_list.as_mut_ptr().cast::<sys::c::_PROC_THREAD_ATTRIBUTE_LIST>(),
676677
attribute_count,
677678
0,
678679
&mut required_size,
@@ -686,7 +687,7 @@ impl<'a> ProcThreadAttributeListBuilder<'a> {
686687
for (&attribute, value) in self.attributes.iter().take(attribute_count as usize) {
687688
sys::cvt(unsafe {
688689
sys::c::UpdateProcThreadAttribute(
689-
attribute_list.as_mut_ptr().cast::<c_void>(),
690+
attribute_list.as_mut_ptr().cast::<sys::c::_PROC_THREAD_ATTRIBUTE_LIST>(),
690691
0,
691692
attribute,
692693
value.ptr,

library/std/src/sys/fs/windows.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ impl File {
406406
self.fsync()
407407
}
408408

409-
fn acquire_lock(&self, flags: c::LOCK_FILE_FLAGS) -> io::Result<()> {
409+
fn acquire_lock(&self, flags: u32) -> io::Result<()> {
410410
unsafe {
411411
let mut overlapped: c::OVERLAPPED = mem::zeroed();
412412
let event = c::CreateEventW(ptr::null_mut(), c::FALSE, c::FALSE, ptr::null());
@@ -1169,7 +1169,7 @@ impl FilePermissions {
11691169
}
11701170

11711171
pub fn file_attributes(&self) -> u32 {
1172-
self.attrs as u32
1172+
self.attrs
11731173
}
11741174
}
11751175

library/std/src/sys/fs/windows/dir.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn to_u16s_without_nul(path: &Path) -> io::Result<Vec<u16>> {
3030
unsafe fn nt_create_file(
3131
opts: &OpenOptions,
3232
object_attributes: &c::OBJECT_ATTRIBUTES,
33-
create_options: c::NTCREATEFILE_CREATE_OPTIONS,
33+
create_options: u32,
3434
) -> io::Result<Handle> {
3535
let mut handle = ptr::null_mut();
3636
let mut io_status = c::IO_STATUS_BLOCK::PENDING;
@@ -116,7 +116,8 @@ impl Dir {
116116
let name = UnicodeStrRef::from_slice(path);
117117
let object_attributes = c::OBJECT_ATTRIBUTES {
118118
RootDirectory: self.handle.as_raw_handle(),
119-
ObjectName: name.as_ptr(),
119+
// Note: the ptr is only mutable for API reasons, it's never actually written to.
120+
ObjectName: name.as_ptr().cast_mut(),
120121
..c::OBJECT_ATTRIBUTES::with_length()
121122
};
122123
let create_opt = if dir { c::FILE_DIRECTORY_FILE } else { c::FILE_NON_DIRECTORY_FILE };

library/std/src/sys/fs/windows/remove_dir_all.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn open_link_no_reparse(
9191

9292
let result = unsafe {
9393
let mut object = c::OBJECT_ATTRIBUTES {
94-
ObjectName: path.as_ptr(),
94+
ObjectName: path.as_ptr().cast_mut(),
9595
RootDirectory: parent.as_raw_handle(),
9696
Attributes: ATTRIBUTES.load(Ordering::Relaxed),
9797
..c::OBJECT_ATTRIBUTES::with_length()

library/std/src/sys/io/error/windows.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ pub fn decode_error_kind(errno: i32) -> io::ErrorKind {
4040
| c::ERROR_RESOURCE_CALL_TIMED_OUT
4141
| c::ERROR_CTX_MODEM_RESPONSE_TIMEOUT
4242
| c::ERROR_CTX_CLIENT_QUERY_TIMEOUT
43-
| c::FRS_ERR_SYSVOL_POPULATE_TIMEOUT
4443
| c::ERROR_DS_TIMELIMIT_EXCEEDED
4544
| c::DNS_ERROR_RECORD_TIMED_OUT
4645
| c::ERROR_IPSEC_IKE_TIMED_OUT

library/std/src/sys/io/error/windows/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::sys::pal::c;
44
// tests `error_string` above
55
#[test]
66
fn ntstatus_error() {
7-
const STATUS_UNSUCCESSFUL: u32 = 0xc000_0001;
7+
const STATUS_UNSUCCESSFUL: i32 = 0xc000_0001_u32 as i32;
88
assert!(
99
!Error::from_raw_os_error((STATUS_UNSUCCESSFUL | c::FACILITY_NT_BIT) as _)
1010
.to_string()

library/std/src/sys/net/connection/socket/windows.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub(super) mod netc {
8888
}
8989

9090
pub unsafe fn send(socket: SOCKET, buf: *const c_void, len: c_int, flags: c_int) -> c_int {
91-
unsafe { c::send(socket, buf.cast::<u8>(), len, flags) }
91+
unsafe { c::send(socket, buf.cast::<i8>(), len, flags) }
9292
}
9393
pub unsafe fn sendto(
9494
socket: SOCKET,
@@ -98,7 +98,7 @@ pub(super) mod netc {
9898
addr: *const SOCKADDR,
9999
addrlen: c_int,
100100
) -> c_int {
101-
unsafe { c::sendto(socket, buf.cast::<u8>(), len, flags, addr, addrlen) }
101+
unsafe { c::sendto(socket, buf.cast::<i8>(), len, flags, addr, addrlen) }
102102
}
103103
pub unsafe fn getaddrinfo(
104104
node: *const c_char,

0 commit comments

Comments
 (0)