Remove COMPILER_FENCE

Replace it by `std::atomic_signal_fence(std::memory_order::seq_cst)`.
This commit is contained in:
phosit
2026-09-08 11:20:33 +02:00
parent 7bcee2ea0e
commit 89ea0ee4af
4 changed files with 10 additions and 21 deletions
+1 -14
View File
@@ -1,4 +1,4 @@
/* Copyright (c) 2025 Wildfire Games.
/* Copyright (c) 2026 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -224,19 +224,6 @@ switch(x % 2)
# define SENTINEL_ARG
#endif
/**
* prevent the compiler from reordering loads or stores across this point.
**/
#if MSC_VERSION
# include <intrin.h>
# pragma intrinsic(_ReadWriteBarrier)
# define COMPILER_FENCE _ReadWriteBarrier()
#elif GCC_VERSION
# define COMPILER_FENCE asm volatile("" : : : "memory")
#else
# define COMPILER_FENCE
#endif
// try to define _W64, if not already done
// (this is useful for catching pointer size bugs)
+2 -2
View File
@@ -263,7 +263,7 @@ static inline Status Run(const Operation& op, const Parameters& p = Parameters()
#if ENABLE_IO_STATS
const double t0 = timer_Time();
COMPILER_FENCE;
std::atomic_signal_fence(std::memory_order::seq_cst);
#endif
size_t numBlocks = p.blockSize? DivideRoundUp(static_cast<size_t>(op.m_Size), p.blockSize) : 1;
@@ -290,7 +290,7 @@ static inline Status Run(const Operation& op, const Parameters& p = Parameters()
}
#if ENABLE_IO_STATS
COMPILER_FENCE;
std::atomic_signal_fence(std::memory_order::seq_cst);
const double t1 = timer_Time();
const off_t totalSize = p.blockSize? numBlocks*p.blockSize : op.m_Size;
debug_printf("IO: %.2f MB/s (%.2f)\n", totalSize/(t1-t0)/1e6, (t1-t0)*1e3);
+2 -2
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2025 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -657,7 +657,7 @@ ssize_t aio_return(struct aiocb* cb)
const ULONG_PTR bytesTransferred = ovl->InternalHigh;
cb->ovl = 0; // prevent further calls to aio_error/aio_return
COMPILER_FENCE;
std::atomic_signal_fence(std::memory_order::seq_cst);
fcb->ovl.Deallocate(ovl);
return (status == ERROR_SUCCESS)? bytesTransferred : -1;
+5 -3
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2025 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -153,9 +153,11 @@ static void* AllocateLargeOrSmallPages(uintptr_t address, size_t size, DWORD all
// note: this call can take SECONDS, which is why several checks are
// undertaken before we even try. these aren't authoritative, so we
// at least prevent future attempts if it takes too long.
const double startTime = timer_Time(); COMPILER_FENCE;
const double startTime = timer_Time();
std::atomic_signal_fence(std::memory_order::seq_cst);
void* largePages = VirtualAllocExNuma(hProcess, LPVOID(alignedAddress), alignedSize, allocationType|MEM_LARGE_PAGES, protect, node);
const double elapsedTime = timer_Time() - startTime; COMPILER_FENCE;
const double elapsedTime = timer_Time() - startTime;
std::atomic_signal_fence(std::memory_order::seq_cst);
if(elapsedTime > 0.5)
largePageAllocationTookTooLong = true; // avoid large pages next time
if(largePages)