fix: cpu_CAS64 should use i64 for compatibility with 64-bit CAS
This was SVN commit r7786.
This commit is contained in:
parent
aa44bac652
commit
8ab70776a5
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user