1
Fork 0

Remove LARGE_INTEGER

This commit is contained in:
Chris Denton 2024-07-14 06:32:22 +00:00
parent 1d1cae1ba5
commit 91ba4ebcfd
No known key found for this signature in database
GPG key ID: 713472F2F45627DE
3 changed files with 15 additions and 16 deletions

View file

@ -8,7 +8,7 @@
use crate::ffi::CStr; use crate::ffi::CStr;
use crate::mem; use crate::mem;
pub use crate::os::raw::c_int; pub use crate::os::raw::c_int;
use crate::os::raw::{c_char, c_long, c_longlong, c_uint, c_ulong, c_ushort, c_void}; use crate::os::raw::{c_char, c_long, c_uint, c_ulong, c_ushort, c_void};
use crate::os::windows::io::{AsRawHandle, BorrowedHandle}; use crate::os::windows::io::{AsRawHandle, BorrowedHandle};
use crate::ptr; use crate::ptr;
@ -18,7 +18,6 @@ mod windows_sys;
pub use windows_sys::*; pub use windows_sys::*;
pub type DWORD = c_ulong; pub type DWORD = c_ulong;
pub type LARGE_INTEGER = c_longlong;
#[cfg_attr(target_vendor = "uwp", allow(unused))] #[cfg_attr(target_vendor = "uwp", allow(unused))]
pub type LONG = c_long; pub type LONG = c_long;
pub type UINT = c_uint; pub type UINT = c_uint;
@ -270,7 +269,7 @@ pub unsafe fn NtReadFile(
iostatusblock: &mut IO_STATUS_BLOCK, iostatusblock: &mut IO_STATUS_BLOCK,
buffer: *mut crate::mem::MaybeUninit<u8>, buffer: *mut crate::mem::MaybeUninit<u8>,
length: ULONG, length: ULONG,
byteoffset: Option<&LARGE_INTEGER>, byteoffset: Option<&i64>,
key: Option<&ULONG>, key: Option<&ULONG>,
) -> NTSTATUS { ) -> NTSTATUS {
windows_sys::NtReadFile( windows_sys::NtReadFile(
@ -293,7 +292,7 @@ pub unsafe fn NtWriteFile(
iostatusblock: &mut IO_STATUS_BLOCK, iostatusblock: &mut IO_STATUS_BLOCK,
buffer: *const u8, buffer: *const u8,
length: ULONG, length: ULONG,
byteoffset: Option<&LARGE_INTEGER>, byteoffset: Option<&i64>,
key: Option<&ULONG>, key: Option<&ULONG>,
) -> NTSTATUS { ) -> NTSTATUS {
windows_sys::NtWriteFile( windows_sys::NtWriteFile(
@ -452,7 +451,7 @@ compat_fn_with_fallback! {
iostatusblock: &mut IO_STATUS_BLOCK, iostatusblock: &mut IO_STATUS_BLOCK,
buffer: *mut crate::mem::MaybeUninit<u8>, buffer: *mut crate::mem::MaybeUninit<u8>,
length: ULONG, length: ULONG,
byteoffset: Option<&LARGE_INTEGER>, byteoffset: Option<&i64>,
key: Option<&ULONG> key: Option<&ULONG>
) -> NTSTATUS { ) -> NTSTATUS {
STATUS_NOT_IMPLEMENTED STATUS_NOT_IMPLEMENTED
@ -466,7 +465,7 @@ compat_fn_with_fallback! {
iostatusblock: &mut IO_STATUS_BLOCK, iostatusblock: &mut IO_STATUS_BLOCK,
buffer: *const u8, buffer: *const u8,
length: ULONG, length: ULONG,
byteoffset: Option<&LARGE_INTEGER>, byteoffset: Option<&i64>,
key: Option<&ULONG> key: Option<&ULONG>
) -> NTSTATUS { ) -> NTSTATUS {
STATUS_NOT_IMPLEMENTED STATUS_NOT_IMPLEMENTED

View file

@ -495,7 +495,7 @@ impl File {
SeekFrom::End(n) => (c::FILE_END, n), SeekFrom::End(n) => (c::FILE_END, n),
SeekFrom::Current(n) => (c::FILE_CURRENT, n), SeekFrom::Current(n) => (c::FILE_CURRENT, n),
}; };
let pos = pos as c::LARGE_INTEGER; let pos = pos as i64;
let mut newpos = 0; let mut newpos = 0;
cvt(unsafe { c::SetFilePointerEx(self.handle.as_raw_handle(), pos, &mut newpos, whence) })?; cvt(unsafe { c::SetFilePointerEx(self.handle.as_raw_handle(), pos, &mut newpos, whence) })?;
Ok(newpos as u64) Ok(newpos as u64)
@ -1417,10 +1417,10 @@ pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {
pub fn copy(from: &Path, to: &Path) -> io::Result<u64> { pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
unsafe extern "system" fn callback( unsafe extern "system" fn callback(
_TotalFileSize: c::LARGE_INTEGER, _TotalFileSize: i64,
_TotalBytesTransferred: c::LARGE_INTEGER, _TotalBytesTransferred: i64,
_StreamSize: c::LARGE_INTEGER, _StreamSize: i64,
StreamBytesTransferred: c::LARGE_INTEGER, StreamBytesTransferred: i64,
dwStreamNumber: c::DWORD, dwStreamNumber: c::DWORD,
_dwCallbackReason: c::DWORD, _dwCallbackReason: c::DWORD,
_hSourceFile: c::HANDLE, _hSourceFile: c::HANDLE,

View file

@ -172,7 +172,7 @@ mod perf_counter {
use crate::time::Duration; use crate::time::Duration;
pub struct PerformanceCounterInstant { pub struct PerformanceCounterInstant {
ts: c::LARGE_INTEGER, ts: i64,
} }
impl PerformanceCounterInstant { impl PerformanceCounterInstant {
pub fn now() -> Self { pub fn now() -> Self {
@ -196,7 +196,7 @@ mod perf_counter {
} }
} }
fn frequency() -> c::LARGE_INTEGER { fn frequency() -> i64 {
// Either the cached result of `QueryPerformanceFrequency` or `0` for // Either the cached result of `QueryPerformanceFrequency` or `0` for
// uninitialized. Storing this as a single `AtomicU64` allows us to use // uninitialized. Storing this as a single `AtomicU64` allows us to use
// `Relaxed` operations, as we are only interested in the effects on a // `Relaxed` operations, as we are only interested in the effects on a
@ -206,7 +206,7 @@ mod perf_counter {
let cached = FREQUENCY.load(Ordering::Relaxed); let cached = FREQUENCY.load(Ordering::Relaxed);
// If a previous thread has filled in this global state, use that. // If a previous thread has filled in this global state, use that.
if cached != 0 { if cached != 0 {
return cached as c::LARGE_INTEGER; return cached as i64;
} }
// ... otherwise learn for ourselves ... // ... otherwise learn for ourselves ...
let mut frequency = 0; let mut frequency = 0;
@ -218,8 +218,8 @@ mod perf_counter {
frequency frequency
} }
fn query() -> c::LARGE_INTEGER { fn query() -> i64 {
let mut qpc_value: c::LARGE_INTEGER = 0; let mut qpc_value: i64 = 0;
cvt(unsafe { c::QueryPerformanceCounter(&mut qpc_value) }).unwrap(); cvt(unsafe { c::QueryPerformanceCounter(&mut qpc_value) }).unwrap();
qpc_value qpc_value
} }