Skip to content

Commit

Permalink
Fix temporary references for volatile read (MSxDOS#12)
Browse files Browse the repository at this point in the history
* Bump Rust toolchain version for CI to 1.64

* Fix temporary references for volatile read
  • Loading branch information
bdbai authored and ryoqun committed Jun 4, 2023
1 parent cbea31e commit 5980bba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ environment:
- host: i686-pc-windows-gnu
channel: nightly
- host: x86_64-pc-windows-gnu
channel: 1.33.0
channel: 1.64.0
- host: i686-pc-windows-gnu
channel: 1.33.0
channel: 1.64.0

install:
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
Expand Down
6 changes: 4 additions & 2 deletions src/ntexapi.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#[allow(deprecated)] //fixme
use core::mem::uninitialized;
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
use core::ptr::addr_of;
use core::ptr::read_volatile;
#[cfg(target_arch = "x86")]
use core::sync::atomic::spin_loop_hint;
Expand Down Expand Up @@ -2782,7 +2784,7 @@ pub unsafe fn NtGetTickCount64() -> ULONGLONG {
#[allow(deprecated)] //fixme
let mut tick_count: ULARGE_INTEGER = uninitialized();
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] {
*tick_count.QuadPart_mut() = read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad);
*tick_count.QuadPart_mut() = read_volatile(addr_of!((*USER_SHARED_DATA).u.TickCountQuad));
}
#[cfg(target_arch = "x86")] {
loop {
Expand All @@ -2806,7 +2808,7 @@ pub unsafe fn NtGetTickCount64() -> ULONGLONG {
#[inline]
pub unsafe fn NtGetTickCount() -> ULONG {
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] {
((read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad)
((read_volatile(addr_of!((*USER_SHARED_DATA).u.TickCountQuad))
* (*USER_SHARED_DATA).TickCountMultiplier as u64) >> 24) as u32
}
#[cfg(target_arch = "x86")] {
Expand Down

0 comments on commit 5980bba

Please sign in to comment.