mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-27 20:04:14 +01:00
Add detection for atomics
Atomic operations are both supported by the platform and the compiler. If we want to provide a threadsafe implementation of our compression function, we need to make sure that the proper settings are available.
This commit is contained in:
parent
771b91b795
commit
ca85a663a1
@ -144,6 +144,36 @@ IF( NOT HAS_INLINE_ASSEMBLY AND NOT HAS_INLINE_ASSEMBLY_WITH_FLAGS )
|
||||
SET( NO_INLINE_ASSEMBLY true )
|
||||
ENDIF()
|
||||
|
||||
# Check to see whether or not our compiler supports atomic operations
|
||||
IF( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
|
||||
|
||||
CHECK_CXX_SOURCE_RUNS("
|
||||
int main() {
|
||||
int x = 0;
|
||||
__sync_fetch_and_add(&x, 1);
|
||||
return !x;
|
||||
}"
|
||||
HAS_GCC_ATOMICS
|
||||
)
|
||||
|
||||
ELSEIF( MSVC )
|
||||
|
||||
CHECK_CXX_SOURCE_RUNS("
|
||||
#include <Windows.h>
|
||||
int main() {
|
||||
int *x = _aligned_malloc(sizeof(int), 32);
|
||||
x = InterlockedIncrement(&x);
|
||||
free(x);
|
||||
return !x;
|
||||
}"
|
||||
HAS_MSVC_ATOMICS
|
||||
)
|
||||
|
||||
ENDIF()
|
||||
IF( HAS_MSVC_ATOMICS OR HAS_GCC_ATOMICS )
|
||||
SET(HAS_ATOMICS true)
|
||||
ENDIF()
|
||||
|
||||
CONFIGURE_FILE(
|
||||
"config/BC7Config.h.in"
|
||||
"include/BC7Config.h"
|
||||
|
@ -48,3 +48,7 @@
|
||||
#cmakedefine NO_INLINE_ASSEMBLY
|
||||
#cmakedefine HAS_SSE_POPCNT
|
||||
#cmakedefine HAS_SSE_41
|
||||
|
||||
#cmakedefine HAS_ATOMICS
|
||||
#cmakedefine HAS_GCC_ATOMICS
|
||||
#cmakedefine HAS_MSVC_ATOMICS
|
||||
|
Loading…
Reference in New Issue
Block a user