Remove DWORD
This commit is contained in:
parent
d8d7c5c3b9
commit
e2b062c9b5
15 changed files with 90 additions and 105 deletions
|
@ -385,29 +385,25 @@ fn test_interior_nul_in_env_value_is_error() {
|
|||
#[cfg(windows)]
|
||||
fn test_creation_flags() {
|
||||
use crate::os::windows::process::CommandExt;
|
||||
use crate::sys::c::{BOOL, DWORD, INFINITE};
|
||||
use crate::sys::c::{BOOL, INFINITE};
|
||||
#[repr(C)]
|
||||
struct DEBUG_EVENT {
|
||||
pub event_code: DWORD,
|
||||
pub process_id: DWORD,
|
||||
pub thread_id: DWORD,
|
||||
pub event_code: u32,
|
||||
pub process_id: u32,
|
||||
pub thread_id: u32,
|
||||
// This is a union in the real struct, but we don't
|
||||
// need this data for the purposes of this test.
|
||||
pub _junk: [u8; 164],
|
||||
}
|
||||
|
||||
extern "system" {
|
||||
fn WaitForDebugEvent(lpDebugEvent: *mut DEBUG_EVENT, dwMilliseconds: DWORD) -> BOOL;
|
||||
fn ContinueDebugEvent(
|
||||
dwProcessId: DWORD,
|
||||
dwThreadId: DWORD,
|
||||
dwContinueStatus: DWORD,
|
||||
) -> BOOL;
|
||||
fn WaitForDebugEvent(lpDebugEvent: *mut DEBUG_EVENT, dwMilliseconds: u32) -> BOOL;
|
||||
fn ContinueDebugEvent(dwProcessId: u32, dwThreadId: u32, dwContinueStatus: u32) -> BOOL;
|
||||
}
|
||||
|
||||
const DEBUG_PROCESS: DWORD = 1;
|
||||
const EXIT_PROCESS_DEBUG_EVENT: DWORD = 5;
|
||||
const DBG_EXCEPTION_NOT_HANDLED: DWORD = 0x80010001;
|
||||
const DEBUG_PROCESS: u32 = 1;
|
||||
const EXIT_PROCESS_DEBUG_EVENT: u32 = 5;
|
||||
const DBG_EXCEPTION_NOT_HANDLED: u32 = 0x80010001;
|
||||
|
||||
let mut child =
|
||||
Command::new("cmd").creation_flags(DEBUG_PROCESS).stdin(Stdio::piped()).spawn().unwrap();
|
||||
|
|
|
@ -15,7 +15,7 @@ mod tests;
|
|||
// See https://docs.microsoft.com/windows/win32/api/heapapi/
|
||||
|
||||
// Flag to indicate that the memory returned by `HeapAlloc` should be zeroed.
|
||||
const HEAP_ZERO_MEMORY: c::DWORD = 0x00000008;
|
||||
const HEAP_ZERO_MEMORY: u32 = 0x00000008;
|
||||
|
||||
// Get a handle to the default heap of the current process, or null if the operation fails.
|
||||
//
|
||||
|
@ -113,7 +113,7 @@ fn init_or_get_process_heap() -> c::HANDLE {
|
|||
#[cold]
|
||||
extern "C" fn process_heap_init_and_alloc(
|
||||
_heap: MaybeUninit<c::HANDLE>, // We pass this argument to match the ABI of `HeapAlloc`
|
||||
flags: c::DWORD,
|
||||
flags: u32,
|
||||
dwBytes: usize,
|
||||
) -> *mut c_void {
|
||||
let heap = init_or_get_process_heap();
|
||||
|
@ -127,7 +127,7 @@ extern "C" fn process_heap_init_and_alloc(
|
|||
#[inline(never)]
|
||||
fn process_heap_alloc(
|
||||
_heap: MaybeUninit<c::HANDLE>, // We pass this argument to match the ABI of `HeapAlloc`,
|
||||
flags: c::DWORD,
|
||||
flags: u32,
|
||||
dwBytes: usize,
|
||||
) -> *mut c_void {
|
||||
let heap = HEAP.load(Ordering::Relaxed);
|
||||
|
|
|
@ -17,7 +17,6 @@ pub(super) mod windows_targets;
|
|||
mod windows_sys;
|
||||
pub use windows_sys::*;
|
||||
|
||||
pub type DWORD = c_ulong;
|
||||
pub type WCHAR = u16;
|
||||
|
||||
pub type socklen_t = c_int;
|
||||
|
@ -316,13 +315,13 @@ compat_fn_with_fallback! {
|
|||
// >= Win10 1607
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription
|
||||
pub fn SetThreadDescription(hthread: HANDLE, lpthreaddescription: PCWSTR) -> HRESULT {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); E_NOTIMPL
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED as u32); E_NOTIMPL
|
||||
}
|
||||
|
||||
// >= Win10 1607
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getthreaddescription
|
||||
pub fn GetThreadDescription(hthread: HANDLE, lpthreaddescription: *mut PWSTR) -> HRESULT {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); E_NOTIMPL
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED as u32); E_NOTIMPL
|
||||
}
|
||||
|
||||
// >= Win8 / Server 2012
|
||||
|
@ -383,9 +382,9 @@ compat_fn_with_fallback! {
|
|||
#[cfg(target_vendor = "win7")]
|
||||
pub fn NtCreateKeyedEvent(
|
||||
KeyedEventHandle: *mut HANDLE,
|
||||
DesiredAccess: DWORD,
|
||||
DesiredAccess: u32,
|
||||
ObjectAttributes: *mut c_void,
|
||||
Flags: ULONG
|
||||
Flags: u32
|
||||
) -> NTSTATUS {
|
||||
panic!("keyed events not available")
|
||||
}
|
||||
|
@ -433,9 +432,9 @@ compat_fn_with_fallback! {
|
|||
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 {
|
||||
STATUS_NOT_IMPLEMENTED
|
||||
}
|
||||
|
@ -447,9 +446,9 @@ compat_fn_with_fallback! {
|
|||
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 {
|
||||
STATUS_NOT_IMPLEMENTED
|
||||
}
|
||||
|
|
|
@ -28,12 +28,12 @@ pub struct File {
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct FileAttr {
|
||||
attributes: c::DWORD,
|
||||
attributes: u32,
|
||||
creation_time: c::FILETIME,
|
||||
last_access_time: c::FILETIME,
|
||||
last_write_time: c::FILETIME,
|
||||
file_size: u64,
|
||||
reparse_tag: c::DWORD,
|
||||
reparse_tag: u32,
|
||||
volume_serial_number: Option<u32>,
|
||||
number_of_links: Option<u32>,
|
||||
file_index: Option<u64>,
|
||||
|
@ -41,8 +41,8 @@ pub struct FileAttr {
|
|||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
||||
pub struct FileType {
|
||||
attributes: c::DWORD,
|
||||
reparse_tag: c::DWORD,
|
||||
attributes: u32,
|
||||
reparse_tag: u32,
|
||||
}
|
||||
|
||||
pub struct ReadDir {
|
||||
|
@ -75,16 +75,16 @@ pub struct OpenOptions {
|
|||
create_new: bool,
|
||||
// system-specific
|
||||
custom_flags: u32,
|
||||
access_mode: Option<c::DWORD>,
|
||||
attributes: c::DWORD,
|
||||
share_mode: c::DWORD,
|
||||
security_qos_flags: c::DWORD,
|
||||
access_mode: Option<u32>,
|
||||
attributes: u32,
|
||||
share_mode: u32,
|
||||
security_qos_flags: u32,
|
||||
security_attributes: *mut c::SECURITY_ATTRIBUTES,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct FilePermissions {
|
||||
attrs: c::DWORD,
|
||||
attrs: u32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
|
@ -245,7 +245,7 @@ impl OpenOptions {
|
|||
self.security_attributes = attrs;
|
||||
}
|
||||
|
||||
fn get_access_mode(&self) -> io::Result<c::DWORD> {
|
||||
fn get_access_mode(&self) -> io::Result<u32> {
|
||||
match (self.read, self.write, self.append, self.access_mode) {
|
||||
(.., Some(mode)) => Ok(mode),
|
||||
(true, false, false, None) => Ok(c::GENERIC_READ),
|
||||
|
@ -261,7 +261,7 @@ impl OpenOptions {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_creation_mode(&self) -> io::Result<c::DWORD> {
|
||||
fn get_creation_mode(&self) -> io::Result<u32> {
|
||||
match (self.write, self.append) {
|
||||
(true, false) => {}
|
||||
(false, false) => {
|
||||
|
@ -287,7 +287,7 @@ impl OpenOptions {
|
|||
})
|
||||
}
|
||||
|
||||
fn get_flags_and_attributes(&self) -> c::DWORD {
|
||||
fn get_flags_and_attributes(&self) -> u32 {
|
||||
self.custom_flags
|
||||
| self.attributes
|
||||
| self.security_qos_flags
|
||||
|
@ -397,21 +397,21 @@ impl File {
|
|||
self.handle.as_raw_handle(),
|
||||
c::FileBasicInfo,
|
||||
core::ptr::addr_of_mut!(info) as *mut c_void,
|
||||
size as c::DWORD,
|
||||
size as u32,
|
||||
))?;
|
||||
let mut attr = FileAttr {
|
||||
attributes: info.FileAttributes,
|
||||
creation_time: c::FILETIME {
|
||||
dwLowDateTime: info.CreationTime as c::DWORD,
|
||||
dwHighDateTime: (info.CreationTime >> 32) as c::DWORD,
|
||||
dwLowDateTime: info.CreationTime as u32,
|
||||
dwHighDateTime: (info.CreationTime >> 32) as u32,
|
||||
},
|
||||
last_access_time: c::FILETIME {
|
||||
dwLowDateTime: info.LastAccessTime as c::DWORD,
|
||||
dwHighDateTime: (info.LastAccessTime >> 32) as c::DWORD,
|
||||
dwLowDateTime: info.LastAccessTime as u32,
|
||||
dwHighDateTime: (info.LastAccessTime >> 32) as u32,
|
||||
},
|
||||
last_write_time: c::FILETIME {
|
||||
dwLowDateTime: info.LastWriteTime as c::DWORD,
|
||||
dwHighDateTime: (info.LastWriteTime >> 32) as c::DWORD,
|
||||
dwLowDateTime: info.LastWriteTime as u32,
|
||||
dwHighDateTime: (info.LastWriteTime >> 32) as u32,
|
||||
},
|
||||
file_size: 0,
|
||||
reparse_tag: 0,
|
||||
|
@ -425,7 +425,7 @@ impl File {
|
|||
self.handle.as_raw_handle(),
|
||||
c::FileStandardInfo,
|
||||
core::ptr::addr_of_mut!(info) as *mut c_void,
|
||||
size as c::DWORD,
|
||||
size as u32,
|
||||
))?;
|
||||
attr.file_size = info.AllocationSize as u64;
|
||||
attr.number_of_links = Some(info.NumberOfLinks);
|
||||
|
@ -511,7 +511,7 @@ impl File {
|
|||
fn reparse_point(
|
||||
&self,
|
||||
space: &mut Align8<[MaybeUninit<u8>]>,
|
||||
) -> io::Result<(c::DWORD, *mut c::REPARSE_DATA_BUFFER)> {
|
||||
) -> io::Result<(u32, *mut c::REPARSE_DATA_BUFFER)> {
|
||||
unsafe {
|
||||
let mut bytes = 0;
|
||||
cvt({
|
||||
|
@ -524,7 +524,7 @@ impl File {
|
|||
ptr::null_mut(),
|
||||
0,
|
||||
space.0.as_mut_ptr().cast(),
|
||||
len as c::DWORD,
|
||||
len as u32,
|
||||
&mut bytes,
|
||||
ptr::null_mut(),
|
||||
)
|
||||
|
@ -609,8 +609,7 @@ impl File {
|
|||
"Cannot set file timestamp to 0",
|
||||
));
|
||||
}
|
||||
let is_max =
|
||||
|t: c::FILETIME| t.dwLowDateTime == c::DWORD::MAX && t.dwHighDateTime == c::DWORD::MAX;
|
||||
let is_max = |t: c::FILETIME| t.dwLowDateTime == u32::MAX && t.dwHighDateTime == u32::MAX;
|
||||
if times.accessed.map_or(false, is_max)
|
||||
|| times.modified.map_or(false, is_max)
|
||||
|| times.created.map_or(false, is_max)
|
||||
|
@ -641,7 +640,7 @@ impl File {
|
|||
self.handle.as_raw_handle(),
|
||||
c::FileBasicInfo,
|
||||
core::ptr::addr_of_mut!(info) as *mut c_void,
|
||||
size as c::DWORD,
|
||||
size as u32,
|
||||
))?;
|
||||
Ok(info)
|
||||
}
|
||||
|
@ -1020,7 +1019,7 @@ impl FileTimes {
|
|||
}
|
||||
|
||||
impl FileType {
|
||||
fn new(attrs: c::DWORD, reparse_tag: c::DWORD) -> FileType {
|
||||
fn new(attrs: u32, reparse_tag: u32) -> FileType {
|
||||
FileType { attributes: attrs, reparse_tag }
|
||||
}
|
||||
pub fn is_dir(&self) -> bool {
|
||||
|
@ -1421,12 +1420,12 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
|
|||
_TotalBytesTransferred: i64,
|
||||
_StreamSize: i64,
|
||||
StreamBytesTransferred: i64,
|
||||
dwStreamNumber: c::DWORD,
|
||||
_dwCallbackReason: c::DWORD,
|
||||
dwStreamNumber: u32,
|
||||
_dwCallbackReason: u32,
|
||||
_hSourceFile: c::HANDLE,
|
||||
_hDestinationFile: c::HANDLE,
|
||||
lpData: *const c_void,
|
||||
) -> c::DWORD {
|
||||
) -> u32 {
|
||||
if dwStreamNumber == 1 {
|
||||
*(lpData as *mut i64) = StreamBytesTransferred;
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ impl Handle {
|
|||
buf: &mut [u8],
|
||||
overlapped: *mut c::OVERLAPPED,
|
||||
) -> io::Result<Option<usize>> {
|
||||
let len = cmp::min(buf.len(), <c::DWORD>::MAX as usize) as c::DWORD;
|
||||
let len = cmp::min(buf.len(), u32::MAX as usize) as u32;
|
||||
let mut amt = 0;
|
||||
let res =
|
||||
cvt(c::ReadFile(self.as_raw_handle(), buf.as_mut_ptr(), len, &mut amt, overlapped));
|
||||
|
@ -209,12 +209,7 @@ impl Handle {
|
|||
Ok(Self(self.0.try_clone()?))
|
||||
}
|
||||
|
||||
pub fn duplicate(
|
||||
&self,
|
||||
access: c::DWORD,
|
||||
inherit: bool,
|
||||
options: c::DWORD,
|
||||
) -> io::Result<Self> {
|
||||
pub fn duplicate(&self, access: u32, inherit: bool, options: u32) -> io::Result<Self> {
|
||||
Ok(Self(self.0.as_handle().duplicate(access, inherit, options)?))
|
||||
}
|
||||
|
||||
|
@ -233,7 +228,7 @@ impl Handle {
|
|||
let mut io_status = c::IO_STATUS_BLOCK::PENDING;
|
||||
|
||||
// The length is clamped at u32::MAX.
|
||||
let len = cmp::min(len, c::DWORD::MAX as usize) as c::DWORD;
|
||||
let len = cmp::min(len, u32::MAX as usize) as u32;
|
||||
let status = c::NtReadFile(
|
||||
self.as_handle(),
|
||||
ptr::null_mut(),
|
||||
|
@ -281,7 +276,7 @@ impl Handle {
|
|||
let mut io_status = c::IO_STATUS_BLOCK::PENDING;
|
||||
|
||||
// The length is clamped at u32::MAX.
|
||||
let len = cmp::min(buf.len(), c::DWORD::MAX as usize) as c::DWORD;
|
||||
let len = cmp::min(buf.len(), u32::MAX as usize) as u32;
|
||||
let status = unsafe {
|
||||
c::NtWriteFile(
|
||||
self.as_handle(),
|
||||
|
|
|
@ -75,7 +75,7 @@ pub fn is_interrupted(_errno: i32) -> bool {
|
|||
pub fn decode_error_kind(errno: i32) -> ErrorKind {
|
||||
use ErrorKind::*;
|
||||
|
||||
match errno as c::DWORD {
|
||||
match errno as u32 {
|
||||
c::ERROR_ACCESS_DENIED => return PermissionDenied,
|
||||
c::ERROR_ALREADY_EXISTS => return AlreadyExists,
|
||||
c::ERROR_FILE_EXISTS => return AlreadyExists,
|
||||
|
@ -216,7 +216,7 @@ pub fn to_u16s<S: AsRef<OsStr>>(s: S) -> crate::io::Result<Vec<u16>> {
|
|||
// from this closure is then the return value of the function.
|
||||
pub fn fill_utf16_buf<F1, F2, T>(mut f1: F1, f2: F2) -> crate::io::Result<T>
|
||||
where
|
||||
F1: FnMut(*mut u16, c::DWORD) -> c::DWORD,
|
||||
F1: FnMut(*mut u16, u32) -> u32,
|
||||
F2: FnOnce(&[u16]) -> T,
|
||||
{
|
||||
// Start off with a stack buf but then spill over to the heap if we end up
|
||||
|
@ -238,7 +238,7 @@ where
|
|||
// We used `reserve` and not `reserve_exact`, so in theory we
|
||||
// may have gotten more than requested. If so, we'd like to use
|
||||
// it... so long as we won't cause overflow.
|
||||
n = heap_buf.capacity().min(c::DWORD::MAX as usize);
|
||||
n = heap_buf.capacity().min(u32::MAX as usize);
|
||||
// Safety: MaybeUninit<u16> does not need initialization
|
||||
heap_buf.set_len(n);
|
||||
&mut heap_buf[..]
|
||||
|
@ -254,13 +254,13 @@ where
|
|||
// error" is still 0 then we interpret it as a 0 length buffer and
|
||||
// not an actual error.
|
||||
c::SetLastError(0);
|
||||
let k = match f1(buf.as_mut_ptr().cast::<u16>(), n as c::DWORD) {
|
||||
let k = match f1(buf.as_mut_ptr().cast::<u16>(), n as u32) {
|
||||
0 if api::get_last_error().code == 0 => 0,
|
||||
0 => return Err(crate::io::Error::last_os_error()),
|
||||
n => n,
|
||||
} as usize;
|
||||
if k == n && api::get_last_error().code == c::ERROR_INSUFFICIENT_BUFFER {
|
||||
n = n.saturating_mul(2).min(c::DWORD::MAX as usize);
|
||||
n = n.saturating_mul(2).min(u32::MAX as usize);
|
||||
} else if k > n {
|
||||
n = k;
|
||||
} else if k == n {
|
||||
|
@ -308,7 +308,7 @@ pub fn cvt<I: IsZero>(i: I) -> crate::io::Result<I> {
|
|||
if i.is_zero() { Err(crate::io::Error::last_os_error()) } else { Ok(i) }
|
||||
}
|
||||
|
||||
pub fn dur2timeout(dur: Duration) -> c::DWORD {
|
||||
pub fn dur2timeout(dur: Duration) -> u32 {
|
||||
// Note that a duration is a (u64, u32) (seconds, nanoseconds) pair, and the
|
||||
// timeouts in windows APIs are typically u32 milliseconds. To translate, we
|
||||
// have two pieces to take care of:
|
||||
|
@ -320,7 +320,7 @@ pub fn dur2timeout(dur: Duration) -> c::DWORD {
|
|||
.checked_mul(1000)
|
||||
.and_then(|ms| ms.checked_add((dur.subsec_nanos() as u64) / 1_000_000))
|
||||
.and_then(|ms| ms.checked_add(if dur.subsec_nanos() % 1_000_000 > 0 { 1 } else { 0 }))
|
||||
.map(|ms| if ms > <c::DWORD>::MAX as u64 { c::INFINITE } else { ms as c::DWORD })
|
||||
.map(|ms| if ms > <u32>::MAX as u64 { c::INFINITE } else { ms as u32 })
|
||||
.unwrap_or(c::INFINITE)
|
||||
}
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ impl Socket {
|
|||
pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
|
||||
// On unix when a socket is shut down all further reads return 0, so we
|
||||
// do the same on windows to map a shut down socket to returning EOF.
|
||||
let length = cmp::min(bufs.len(), c::DWORD::MAX as usize) as c::DWORD;
|
||||
let length = cmp::min(bufs.len(), u32::MAX as usize) as u32;
|
||||
let mut nread = 0;
|
||||
let mut flags = 0;
|
||||
let result = unsafe {
|
||||
|
@ -335,7 +335,7 @@ impl Socket {
|
|||
}
|
||||
|
||||
pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
|
||||
let length = cmp::min(bufs.len(), c::DWORD::MAX as usize) as c::DWORD;
|
||||
let length = cmp::min(bufs.len(), u32::MAX as usize) as u32;
|
||||
let mut nwritten = 0;
|
||||
let result = unsafe {
|
||||
c::WSASend(
|
||||
|
@ -371,7 +371,7 @@ impl Socket {
|
|||
}
|
||||
|
||||
pub fn timeout(&self, kind: c_int) -> io::Result<Option<Duration>> {
|
||||
let raw: c::DWORD = net::getsockopt(self, c::SOL_SOCKET, kind)?;
|
||||
let raw: u32 = net::getsockopt(self, c::SOL_SOCKET, kind)?;
|
||||
if raw == 0 {
|
||||
Ok(None)
|
||||
} else {
|
||||
|
|
|
@ -52,10 +52,10 @@ pub fn error_string(mut errnum: i32) -> String {
|
|||
let res = c::FormatMessageW(
|
||||
flags | c::FORMAT_MESSAGE_FROM_SYSTEM | c::FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
module,
|
||||
errnum as c::DWORD,
|
||||
errnum as u32,
|
||||
0,
|
||||
buf.as_mut_ptr(),
|
||||
buf.len() as c::DWORD,
|
||||
buf.len() as u32,
|
||||
ptr::null(),
|
||||
) as usize;
|
||||
if res == 0 {
|
||||
|
|
|
@ -156,7 +156,7 @@ pub fn anon_pipe(ours_readable: bool, their_handle_inheritable: bool) -> io::Res
|
|||
opts.share_mode(0);
|
||||
let size = mem::size_of::<c::SECURITY_ATTRIBUTES>();
|
||||
let mut sa = c::SECURITY_ATTRIBUTES {
|
||||
nLength: size as c::DWORD,
|
||||
nLength: size as u32,
|
||||
lpSecurityDescriptor: ptr::null_mut(),
|
||||
bInheritHandle: their_handle_inheritable as i32,
|
||||
};
|
||||
|
@ -226,7 +226,7 @@ fn random_number() -> usize {
|
|||
type AlertableIoFn = unsafe extern "system" fn(
|
||||
BorrowedHandle<'_>,
|
||||
*mut core::ffi::c_void,
|
||||
c::DWORD,
|
||||
u32,
|
||||
*mut c::OVERLAPPED,
|
||||
c::LPOVERLAPPED_COMPLETION_ROUTINE,
|
||||
) -> c::BOOL;
|
||||
|
@ -244,7 +244,7 @@ impl AnonPipe {
|
|||
|
||||
pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
|
||||
let result = unsafe {
|
||||
let len = crate::cmp::min(buf.len(), c::DWORD::MAX as usize) as c::DWORD;
|
||||
let len = crate::cmp::min(buf.len(), u32::MAX as usize) as u32;
|
||||
self.alertable_io_internal(c::ReadFileEx, buf.as_mut_ptr() as _, len)
|
||||
};
|
||||
|
||||
|
@ -260,7 +260,7 @@ impl AnonPipe {
|
|||
|
||||
pub fn read_buf(&self, mut buf: BorrowedCursor<'_>) -> io::Result<()> {
|
||||
let result = unsafe {
|
||||
let len = crate::cmp::min(buf.capacity(), c::DWORD::MAX as usize) as c::DWORD;
|
||||
let len = crate::cmp::min(buf.capacity(), u32::MAX as usize) as u32;
|
||||
self.alertable_io_internal(c::ReadFileEx, buf.as_mut().as_mut_ptr() as _, len)
|
||||
};
|
||||
|
||||
|
@ -295,7 +295,7 @@ impl AnonPipe {
|
|||
|
||||
pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
|
||||
unsafe {
|
||||
let len = crate::cmp::min(buf.len(), c::DWORD::MAX as usize) as c::DWORD;
|
||||
let len = crate::cmp::min(buf.len(), u32::MAX as usize) as u32;
|
||||
self.alertable_io_internal(c::WriteFileEx, buf.as_ptr() as _, len)
|
||||
}
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ impl AnonPipe {
|
|||
&self,
|
||||
io: AlertableIoFn,
|
||||
buf: *mut core::ffi::c_void,
|
||||
len: c::DWORD,
|
||||
len: u32,
|
||||
) -> io::Result<usize> {
|
||||
// Use "alertable I/O" to synchronize the pipe I/O.
|
||||
// This has four steps.
|
||||
|
|
|
@ -174,7 +174,7 @@ pub struct Command {
|
|||
|
||||
pub enum Stdio {
|
||||
Inherit,
|
||||
InheritSpecific { from_stdio_id: c::DWORD },
|
||||
InheritSpecific { from_stdio_id: u32 },
|
||||
Null,
|
||||
MakePipe,
|
||||
Pipe(AnonPipe),
|
||||
|
@ -364,7 +364,7 @@ impl Command {
|
|||
};
|
||||
si_ptr = core::ptr::addr_of_mut!(si_ex) as _;
|
||||
} else {
|
||||
si.cb = mem::size_of::<c::STARTUPINFOW>() as c::DWORD;
|
||||
si.cb = mem::size_of::<c::STARTUPINFOW>() as u32;
|
||||
si_ptr = core::ptr::addr_of_mut!(si) as _;
|
||||
}
|
||||
|
||||
|
@ -566,7 +566,7 @@ fn program_exists(path: &Path) -> Option<Vec<u16>> {
|
|||
}
|
||||
|
||||
impl Stdio {
|
||||
fn to_handle(&self, stdio_id: c::DWORD, pipe: &mut Option<AnonPipe>) -> io::Result<Handle> {
|
||||
fn to_handle(&self, stdio_id: u32, pipe: &mut Option<AnonPipe>) -> io::Result<Handle> {
|
||||
let use_stdio_id = |stdio_id| match stdio::get_handle(stdio_id) {
|
||||
Ok(io) => unsafe {
|
||||
let io = Handle::from_raw_handle(io);
|
||||
|
@ -601,7 +601,7 @@ impl Stdio {
|
|||
Stdio::Null => {
|
||||
let size = mem::size_of::<c::SECURITY_ATTRIBUTES>();
|
||||
let mut sa = c::SECURITY_ATTRIBUTES {
|
||||
nLength: size as c::DWORD,
|
||||
nLength: size as u32,
|
||||
lpSecurityDescriptor: ptr::null_mut(),
|
||||
bInheritHandle: 1,
|
||||
};
|
||||
|
@ -713,7 +713,7 @@ impl Process {
|
|||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)]
|
||||
pub struct ExitStatus(c::DWORD);
|
||||
pub struct ExitStatus(u32);
|
||||
|
||||
impl ExitStatus {
|
||||
pub fn exit_ok(&self) -> Result<(), ExitStatusError> {
|
||||
|
@ -727,9 +727,9 @@ impl ExitStatus {
|
|||
}
|
||||
}
|
||||
|
||||
/// Converts a raw `c::DWORD` to a type-safe `ExitStatus` by wrapping it without copying.
|
||||
impl From<c::DWORD> for ExitStatus {
|
||||
fn from(u: c::DWORD) -> ExitStatus {
|
||||
/// Converts a raw `u32` to a type-safe `ExitStatus` by wrapping it without copying.
|
||||
impl From<u32> for ExitStatus {
|
||||
fn from(u: u32) -> ExitStatus {
|
||||
ExitStatus(u)
|
||||
}
|
||||
}
|
||||
|
@ -765,7 +765,7 @@ impl ExitStatusError {
|
|||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
||||
pub struct ExitCode(c::DWORD);
|
||||
pub struct ExitCode(u32);
|
||||
|
||||
impl ExitCode {
|
||||
pub const SUCCESS: ExitCode = ExitCode(EXIT_SUCCESS as _);
|
||||
|
@ -779,13 +779,13 @@ impl ExitCode {
|
|||
|
||||
impl From<u8> for ExitCode {
|
||||
fn from(code: u8) -> Self {
|
||||
ExitCode(c::DWORD::from(code))
|
||||
ExitCode(u32::from(code))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u32> for ExitCode {
|
||||
fn from(code: u32) -> Self {
|
||||
ExitCode(c::DWORD::from(code))
|
||||
ExitCode(u32::from(code))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ const MAX_BUFFER_SIZE: usize = 8192;
|
|||
// UTF-16 to UTF-8.
|
||||
pub const STDIN_BUF_SIZE: usize = MAX_BUFFER_SIZE / 2 * 3;
|
||||
|
||||
pub fn get_handle(handle_id: c::DWORD) -> io::Result<c::HANDLE> {
|
||||
pub fn get_handle(handle_id: u32) -> io::Result<c::HANDLE> {
|
||||
let handle = unsafe { c::GetStdHandle(handle_id) };
|
||||
if handle == c::INVALID_HANDLE_VALUE {
|
||||
Err(io::Error::last_os_error())
|
||||
|
@ -87,11 +87,7 @@ fn is_console(handle: c::HANDLE) -> bool {
|
|||
unsafe { c::GetConsoleMode(handle, &mut mode) != 0 }
|
||||
}
|
||||
|
||||
fn write(
|
||||
handle_id: c::DWORD,
|
||||
data: &[u8],
|
||||
incomplete_utf8: &mut IncompleteUtf8,
|
||||
) -> io::Result<usize> {
|
||||
fn write(handle_id: u32, data: &[u8], incomplete_utf8: &mut IncompleteUtf8) -> io::Result<usize> {
|
||||
if data.is_empty() {
|
||||
return Ok(0);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ impl Thread {
|
|||
Err(io::Error::last_os_error())
|
||||
};
|
||||
|
||||
unsafe extern "system" fn thread_start(main: *mut c_void) -> c::DWORD {
|
||||
unsafe extern "system" fn thread_start(main: *mut c_void) -> u32 {
|
||||
// Next, reserve some stack space for if we otherwise run out of stack.
|
||||
stack_overflow::reserve_stack();
|
||||
// Finally, let's run some code.
|
||||
|
|
|
@ -76,8 +76,8 @@ impl SystemTime {
|
|||
fn from_intervals(intervals: i64) -> SystemTime {
|
||||
SystemTime {
|
||||
t: c::FILETIME {
|
||||
dwLowDateTime: intervals as c::DWORD,
|
||||
dwHighDateTime: (intervals >> 32) as c::DWORD,
|
||||
dwLowDateTime: intervals as u32,
|
||||
dwHighDateTime: (intervals >> 32) as u32,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,9 +75,9 @@ pub fn enable() {
|
|||
|
||||
#[link_section = ".CRT$XLB"]
|
||||
#[cfg_attr(miri, used)] // Miri only considers explicitly `#[used]` statics for `lookup_link_section`
|
||||
pub static CALLBACK: unsafe extern "system" fn(*mut c_void, c::DWORD, *mut c_void) = tls_callback;
|
||||
pub static CALLBACK: unsafe extern "system" fn(*mut c_void, u32, *mut c_void) = tls_callback;
|
||||
|
||||
unsafe extern "system" fn tls_callback(_h: *mut c_void, dw_reason: c::DWORD, _pv: *mut c_void) {
|
||||
unsafe extern "system" fn tls_callback(_h: *mut c_void, dw_reason: u32, _pv: *mut c_void) {
|
||||
// See comments above for what this is doing. Note that we don't need this
|
||||
// trickery on GNU windows, just on MSVC.
|
||||
#[cfg(all(target_env = "msvc", not(target_thread_local)))]
|
||||
|
|
|
@ -33,11 +33,11 @@ use crate::sync::atomic::{
|
|||
use crate::sys::c;
|
||||
use crate::sys::thread_local::guard;
|
||||
|
||||
pub type Key = c::DWORD;
|
||||
pub type Key = u32;
|
||||
type Dtor = unsafe extern "C" fn(*mut u8);
|
||||
|
||||
pub struct LazyKey {
|
||||
/// The key value shifted up by one. Since TLS_OUT_OF_INDEXES == DWORD::MAX
|
||||
/// The key value shifted up by one. Since TLS_OUT_OF_INDEXES == u32::MAX
|
||||
/// is not a valid key value, this allows us to use zero as sentinel value
|
||||
/// without risking overflow.
|
||||
key: AtomicU32,
|
||||
|
|
Loading…
Add table
Reference in a new issue