From 8ab70776a507d101cd35ba70dd0baa34c4a98c92 Mon Sep 17 00:00:00 2001 From: janwas Date: Thu, 22 Jul 2010 18:57:36 +0000 Subject: [PATCH] fix: cpu_CAS64 should use i64 for compatibility with 64-bit CAS This was SVN commit r7786. --- source/lib/sysdep/arch/ia32/ia32.cpp | 2 +- source/lib/sysdep/arch/ia32/ia32_asm.asm | 2 +- source/lib/sysdep/arch/ia32/ia32_asm.h | 2 +- source/lib/sysdep/cpu.cpp | 2 +- source/lib/sysdep/cpu.h | 2 +- source/lib/timer.h | 10 +++++----- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/lib/sysdep/arch/ia32/ia32.cpp b/source/lib/sysdep/arch/ia32/ia32.cpp index 7710951956..add2aa6ecf 100644 --- a/source/lib/sysdep/arch/ia32/ia32.cpp +++ b/source/lib/sysdep/arch/ia32/ia32.cpp @@ -158,7 +158,7 @@ bool cpu_CAS(volatile intptr_t* location, intptr_t expected, intptr_t new_value) return ia32_asm_CAS(location, expected, new_value); } -bool cpu_CAS64(volatile u64* location, u64 expected, u64 new_value) +bool cpu_CAS64(volatile i64* location, i64 expected, i64 new_value) { return ia32_asm_CAS64(location, expected, new_value); } diff --git a/source/lib/sysdep/arch/ia32/ia32_asm.asm b/source/lib/sysdep/arch/ia32/ia32_asm.asm index 1f5addb997..b87c56383a 100644 --- a/source/lib/sysdep/arch/ia32/ia32_asm.asm +++ b/source/lib/sysdep/arch/ia32/ia32_asm.asm @@ -92,7 +92,7 @@ db 0xf0 ; LOCK prefix ret -; extern bool CALL_CONV ia32_asm_CAS64(volatile u64* location, u64 expected, u64 new_value); +; extern bool CALL_CONV ia32_asm_CAS64(volatile i64* location, i64 expected, i64 new_value); global sym(ia32_asm_CAS64) sym(ia32_asm_CAS64): push ebx diff --git a/source/lib/sysdep/arch/ia32/ia32_asm.h b/source/lib/sysdep/arch/ia32/ia32_asm.h index 2ac7c18e15..c37350df5d 100644 --- a/source/lib/sysdep/arch/ia32/ia32_asm.h +++ b/source/lib/sysdep/arch/ia32/ia32_asm.h @@ -36,7 +36,7 @@ extern void CALL_CONV ia32_asm_cpuid(x86_x64_CpuidRegs* regs); extern intptr_t CALL_CONV ia32_asm_AtomicAdd(volatile intptr_t* location, intptr_t increment); extern bool CALL_CONV ia32_asm_CAS(volatile intptr_t* location, intptr_t expected, intptr_t new_value); -extern bool CALL_CONV ia32_asm_CAS64(volatile u64* location, u64 expected, u64 new_value); +extern bool CALL_CONV ia32_asm_CAS64(volatile i64* location, i64 expected, i64 new_value); /// control87 // FPU control word diff --git a/source/lib/sysdep/cpu.cpp b/source/lib/sysdep/cpu.cpp index 6e9e3cc22e..b5940f437c 100644 --- a/source/lib/sysdep/cpu.cpp +++ b/source/lib/sysdep/cpu.cpp @@ -34,7 +34,7 @@ ERROR_ASSOCIATE(ERR::CPU_UNKNOWN_VENDOR, L"CPU vendor unknown", -1); static void TestCAS64() { - volatile u64 var = 1; + volatile i64 var = 1; cpu_CAS64(&var, 1ull, 2ull); debug_assert(var == 2ull); } diff --git a/source/lib/sysdep/cpu.h b/source/lib/sysdep/cpu.h index 6fbc669067..3d287e2677 100644 --- a/source/lib/sysdep/cpu.h +++ b/source/lib/sysdep/cpu.h @@ -93,7 +93,7 @@ bool cpu_CAS(volatile T* location, T expected, T new_value) #if ARCH_AMD64 # define cpu_CAS64 cpu_CAS #else -LIB_API bool cpu_CAS64(volatile u64* location, u64 expected, u64 newValue); +LIB_API bool cpu_CAS64(volatile i64* location, i64 expected, i64 newValue); #endif diff --git a/source/lib/timer.h b/source/lib/timer.h index f77df574de..a56c6f8883 100644 --- a/source/lib/timer.h +++ b/source/lib/timer.h @@ -175,7 +175,7 @@ public: void AddDifferenceAtomic(TimerUnit t0, TimerUnit t1) { - const u64 delta = t1.m_ticks - t0.m_ticks; + const i64 delta = t1.m_ticks - t0.m_ticks; #if ARCH_AMD64 cpu_AtomicAdd((volatile intptr_t*)&m_ticks, (intptr_t)delta); #else @@ -216,7 +216,7 @@ retry: } private: - u64 m_ticks; + i64 m_ticks; }; #else @@ -242,14 +242,14 @@ public: void AddDifferenceAtomic(TimerUnit t0, TimerUnit t1) { retry: - intptr_t oldRepresentation; + i64 oldRepresentation; memcpy(&oldRepresentation, &m_seconds, sizeof(oldRepresentation)); const double seconds = m_seconds + t1.m_seconds - t0.m_seconds; - intptr_t newRepresentation; + i64 newRepresentation; memcpy(&newRepresentation, &seconds, sizeof(newRepresentation)); - if(!cpu_CAS64((volatile intptr_t*)&m_seconds, oldRepresentation, newRepresentation)) + if(!cpu_CAS64((volatile i64*)&m_seconds, oldRepresentation, newRepresentation)) goto retry; }