Skip to content

Commit

Permalink
Remove LARGE_INTEGER
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDenton committed Jul 15, 2024
1 parent aa45985 commit 4eaaf7d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
11 changes: 5 additions & 6 deletions std/src/sys/pal/windows/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use crate::ffi::CStr;
use crate::mem;
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::ptr;

Expand All @@ -18,7 +18,6 @@ mod windows_sys;
pub use windows_sys::*;

pub type DWORD = c_ulong;
pub type LARGE_INTEGER = c_longlong;
#[cfg_attr(target_vendor = "uwp", allow(unused))]
pub type LONG = c_long;
pub type UINT = c_uint;
Expand Down Expand Up @@ -270,7 +269,7 @@ pub unsafe fn NtReadFile(
iostatusblock: &mut IO_STATUS_BLOCK,
buffer: *mut crate::mem::MaybeUninit<u8>,
length: ULONG,
byteoffset: Option<&LARGE_INTEGER>,
byteoffset: Option<&i64>,
key: Option<&ULONG>,
) -> NTSTATUS {
windows_sys::NtReadFile(
Expand All @@ -293,7 +292,7 @@ pub unsafe fn NtWriteFile(
iostatusblock: &mut IO_STATUS_BLOCK,
buffer: *const u8,
length: ULONG,
byteoffset: Option<&LARGE_INTEGER>,
byteoffset: Option<&i64>,
key: Option<&ULONG>,
) -> NTSTATUS {
windows_sys::NtWriteFile(
Expand Down Expand Up @@ -452,7 +451,7 @@ compat_fn_with_fallback! {
iostatusblock: &mut IO_STATUS_BLOCK,
buffer: *mut crate::mem::MaybeUninit<u8>,
length: ULONG,
byteoffset: Option<&LARGE_INTEGER>,
byteoffset: Option<&i64>,
key: Option<&ULONG>
) -> NTSTATUS {
STATUS_NOT_IMPLEMENTED
Expand All @@ -466,7 +465,7 @@ compat_fn_with_fallback! {
iostatusblock: &mut IO_STATUS_BLOCK,
buffer: *const u8,
length: ULONG,
byteoffset: Option<&LARGE_INTEGER>,
byteoffset: Option<&i64>,
key: Option<&ULONG>
) -> NTSTATUS {
STATUS_NOT_IMPLEMENTED
Expand Down
10 changes: 5 additions & 5 deletions std/src/sys/pal/windows/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ impl File {
SeekFrom::End(n) => (c::FILE_END, n),
SeekFrom::Current(n) => (c::FILE_CURRENT, n),
};
let pos = pos as c::LARGE_INTEGER;
let pos = pos as i64;
let mut newpos = 0;
cvt(unsafe { c::SetFilePointerEx(self.handle.as_raw_handle(), pos, &mut newpos, whence) })?;
Ok(newpos as u64)
Expand Down Expand Up @@ -1417,10 +1417,10 @@ pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {

pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
unsafe extern "system" fn callback(
_TotalFileSize: c::LARGE_INTEGER,
_TotalBytesTransferred: c::LARGE_INTEGER,
_StreamSize: c::LARGE_INTEGER,
StreamBytesTransferred: c::LARGE_INTEGER,
_TotalFileSize: i64,
_TotalBytesTransferred: i64,
_StreamSize: i64,
StreamBytesTransferred: i64,
dwStreamNumber: c::DWORD,
_dwCallbackReason: c::DWORD,
_hSourceFile: c::HANDLE,
Expand Down
10 changes: 5 additions & 5 deletions std/src/sys/pal/windows/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ mod perf_counter {
use crate::time::Duration;

pub struct PerformanceCounterInstant {
ts: c::LARGE_INTEGER,
ts: i64,
}
impl PerformanceCounterInstant {
pub fn now() -> Self {
Expand All @@ -196,7 +196,7 @@ mod perf_counter {
}
}

fn frequency() -> c::LARGE_INTEGER {
fn frequency() -> i64 {
// Either the cached result of `QueryPerformanceFrequency` or `0` for
// uninitialized. Storing this as a single `AtomicU64` allows us to use
// `Relaxed` operations, as we are only interested in the effects on a
Expand All @@ -206,7 +206,7 @@ mod perf_counter {
let cached = FREQUENCY.load(Ordering::Relaxed);
// If a previous thread has filled in this global state, use that.
if cached != 0 {
return cached as c::LARGE_INTEGER;
return cached as i64;
}
// ... otherwise learn for ourselves ...
let mut frequency = 0;
Expand All @@ -218,8 +218,8 @@ mod perf_counter {
frequency
}

fn query() -> c::LARGE_INTEGER {
let mut qpc_value: c::LARGE_INTEGER = 0;
fn query() -> i64 {
let mut qpc_value: i64 = 0;
cvt(unsafe { c::QueryPerformanceCounter(&mut qpc_value) }).unwrap();
qpc_value
}
Expand Down

0 comments on commit 4eaaf7d

Please sign in to comment.