Skip to content

Commit

Permalink
Remove ULONG
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDenton committed Jul 15, 2024
1 parent d89bce6 commit 7d18991
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
9 changes: 4 additions & 5 deletions std/src/sys/pal/windows/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub use windows_sys::*;

pub type DWORD = c_ulong;
pub type WCHAR = u16;
pub type ULONG = c_ulong;

pub type socklen_t = c_int;
pub type ADDRESS_FAMILY = c_ushort;
Expand Down Expand Up @@ -252,9 +251,9 @@ pub unsafe fn NtReadFile(
apccontext: *mut c_void,
iostatusblock: &mut IO_STATUS_BLOCK,
buffer: *mut crate::mem::MaybeUninit<u8>,
length: ULONG,
length: u32,
byteoffset: Option<&i64>,
key: Option<&ULONG>,
key: Option<&u32>,
) -> NTSTATUS {
windows_sys::NtReadFile(
filehandle.as_raw_handle(),
Expand All @@ -275,9 +274,9 @@ pub unsafe fn NtWriteFile(
apccontext: *mut c_void,
iostatusblock: &mut IO_STATUS_BLOCK,
buffer: *const u8,
length: ULONG,
length: u32,
byteoffset: Option<&i64>,
key: Option<&ULONG>,
key: Option<&u32>,
) -> NTSTATUS {
windows_sys::NtWriteFile(
filehandle.as_raw_handle(),
Expand Down
12 changes: 6 additions & 6 deletions std/src/sys/pal/windows/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ pub struct IoSlice<'a> {
impl<'a> IoSlice<'a> {
#[inline]
pub fn new(buf: &'a [u8]) -> IoSlice<'a> {
assert!(buf.len() <= c::ULONG::MAX as usize);
assert!(buf.len() <= u32::MAX as usize);
IoSlice {
vec: c::WSABUF { len: buf.len() as c::ULONG, buf: buf.as_ptr() as *mut u8 },
vec: c::WSABUF { len: buf.len() as u32, buf: buf.as_ptr() as *mut u8 },
_p: PhantomData,
}
}
Expand All @@ -29,7 +29,7 @@ impl<'a> IoSlice<'a> {
}

unsafe {
self.vec.len -= n as c::ULONG;
self.vec.len -= n as u32;
self.vec.buf = self.vec.buf.add(n);
}
}
Expand All @@ -49,9 +49,9 @@ pub struct IoSliceMut<'a> {
impl<'a> IoSliceMut<'a> {
#[inline]
pub fn new(buf: &'a mut [u8]) -> IoSliceMut<'a> {
assert!(buf.len() <= c::ULONG::MAX as usize);
assert!(buf.len() <= u32::MAX as usize);
IoSliceMut {
vec: c::WSABUF { len: buf.len() as c::ULONG, buf: buf.as_mut_ptr() },
vec: c::WSABUF { len: buf.len() as u32, buf: buf.as_mut_ptr() },
_p: PhantomData,
}
}
Expand All @@ -63,7 +63,7 @@ impl<'a> IoSliceMut<'a> {
}

unsafe {
self.vec.len -= n as c::ULONG;
self.vec.len -= n as u32;
self.vec.buf = self.vec.buf.add(n);
}
}
Expand Down
2 changes: 1 addition & 1 deletion std/src/sys/pal/windows/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn hashmap_random_keys() -> (u64, u64) {

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

if ret != 0 { v } else { panic!("RNG broken: {}", io::Error::last_os_error()) }
Expand Down
4 changes: 2 additions & 2 deletions std/src/sys/pal/windows/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,9 @@ fn read_u16s(handle: c::HANDLE, buf: &mut [MaybeUninit<u16>]) -> io::Result<usiz
// traditional DOS method to indicate end of character stream / user input (SUB).
// See #38274 and https://stackoverflow.com/questions/43836040/win-api-readconsole.
const CTRL_Z: u16 = 0x1A;
const CTRL_Z_MASK: c::ULONG = 1 << CTRL_Z;
const CTRL_Z_MASK: u32 = 1 << CTRL_Z;
let input_control = c::CONSOLE_READCONSOLE_CONTROL {
nLength: crate::mem::size_of::<c::CONSOLE_READCONSOLE_CONTROL>() as c::ULONG,
nLength: crate::mem::size_of::<c::CONSOLE_READCONSOLE_CONTROL>() as u32,
nInitialChars: 0,
dwCtrlWakeupMask: CTRL_Z_MASK,
dwControlKeyState: 0,
Expand Down

0 comments on commit 7d18991

Please sign in to comment.