Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7d18991

Browse files
committedJul 15, 2024
Remove ULONG
1 parent d89bce6 commit 7d18991

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed
 

‎std/src/sys/pal/windows/c.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub use windows_sys::*;
1919

2020
pub type DWORD = c_ulong;
2121
pub type WCHAR = u16;
22-
pub type ULONG = c_ulong;
2322

2423
pub type socklen_t = c_int;
2524
pub type ADDRESS_FAMILY = c_ushort;
@@ -252,9 +251,9 @@ pub unsafe fn NtReadFile(
252251
apccontext: *mut c_void,
253252
iostatusblock: &mut IO_STATUS_BLOCK,
254253
buffer: *mut crate::mem::MaybeUninit<u8>,
255-
length: ULONG,
254+
length: u32,
256255
byteoffset: Option<&i64>,
257-
key: Option<&ULONG>,
256+
key: Option<&u32>,
258257
) -> NTSTATUS {
259258
windows_sys::NtReadFile(
260259
filehandle.as_raw_handle(),
@@ -275,9 +274,9 @@ pub unsafe fn NtWriteFile(
275274
apccontext: *mut c_void,
276275
iostatusblock: &mut IO_STATUS_BLOCK,
277276
buffer: *const u8,
278-
length: ULONG,
277+
length: u32,
279278
byteoffset: Option<&i64>,
280-
key: Option<&ULONG>,
279+
key: Option<&u32>,
281280
) -> NTSTATUS {
282281
windows_sys::NtWriteFile(
283282
filehandle.as_raw_handle(),

‎std/src/sys/pal/windows/io.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ pub struct IoSlice<'a> {
1515
impl<'a> IoSlice<'a> {
1616
#[inline]
1717
pub fn new(buf: &'a [u8]) -> IoSlice<'a> {
18-
assert!(buf.len() <= c::ULONG::MAX as usize);
18+
assert!(buf.len() <= u32::MAX as usize);
1919
IoSlice {
20-
vec: c::WSABUF { len: buf.len() as c::ULONG, buf: buf.as_ptr() as *mut u8 },
20+
vec: c::WSABUF { len: buf.len() as u32, buf: buf.as_ptr() as *mut u8 },
2121
_p: PhantomData,
2222
}
2323
}
@@ -29,7 +29,7 @@ impl<'a> IoSlice<'a> {
2929
}
3030

3131
unsafe {
32-
self.vec.len -= n as c::ULONG;
32+
self.vec.len -= n as u32;
3333
self.vec.buf = self.vec.buf.add(n);
3434
}
3535
}
@@ -49,9 +49,9 @@ pub struct IoSliceMut<'a> {
4949
impl<'a> IoSliceMut<'a> {
5050
#[inline]
5151
pub fn new(buf: &'a mut [u8]) -> IoSliceMut<'a> {
52-
assert!(buf.len() <= c::ULONG::MAX as usize);
52+
assert!(buf.len() <= u32::MAX as usize);
5353
IoSliceMut {
54-
vec: c::WSABUF { len: buf.len() as c::ULONG, buf: buf.as_mut_ptr() },
54+
vec: c::WSABUF { len: buf.len() as u32, buf: buf.as_mut_ptr() },
5555
_p: PhantomData,
5656
}
5757
}
@@ -63,7 +63,7 @@ impl<'a> IoSliceMut<'a> {
6363
}
6464

6565
unsafe {
66-
self.vec.len -= n as c::ULONG;
66+
self.vec.len -= n as u32;
6767
self.vec.buf = self.vec.buf.add(n);
6868
}
6969
}

‎std/src/sys/pal/windows/rand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn hashmap_random_keys() -> (u64, u64) {
2020

2121
let mut v = (0, 0);
2222
let ret = unsafe {
23-
c::RtlGenRandom(ptr::addr_of_mut!(v).cast::<c_void>(), mem::size_of_val(&v) as c::ULONG)
23+
c::RtlGenRandom(ptr::addr_of_mut!(v).cast::<c_void>(), mem::size_of_val(&v) as u32)
2424
};
2525

2626
if ret != 0 { v } else { panic!("RNG broken: {}", io::Error::last_os_error()) }

‎std/src/sys/pal/windows/stdio.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ fn read_u16s(handle: c::HANDLE, buf: &mut [MaybeUninit<u16>]) -> io::Result<usiz
341341
// traditional DOS method to indicate end of character stream / user input (SUB).
342342
// See #38274 and https://stackoverflow.com/questions/43836040/win-api-readconsole.
343343
const CTRL_Z: u16 = 0x1A;
344-
const CTRL_Z_MASK: c::ULONG = 1 << CTRL_Z;
344+
const CTRL_Z_MASK: u32 = 1 << CTRL_Z;
345345
let input_control = c::CONSOLE_READCONSOLE_CONTROL {
346-
nLength: crate::mem::size_of::<c::CONSOLE_READCONSOLE_CONTROL>() as c::ULONG,
346+
nLength: crate::mem::size_of::<c::CONSOLE_READCONSOLE_CONTROL>() as u32,
347347
nInitialChars: 0,
348348
dwCtrlWakeupMask: CTRL_Z_MASK,
349349
dwControlKeyState: 0,

0 commit comments

Comments
 (0)
Failed to load comments.