From ded746df9c8bb557665f4e954567d92275dc893e Mon Sep 17 00:00:00 2001 From: Rob Swindell <rob@synchro.net> Date: Mon, 22 Feb 2021 17:53:35 -0800 Subject: [PATCH] Don't try to use atomics for GCC versions < 4.9 Apparently GNU forgot to include stdatomic.h in GCC 4.8. For Altere and his CentOS 7 system. --- src/xpdev/threadwrap.c | 2 +- src/xpdev/threadwrap.h | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/xpdev/threadwrap.c b/src/xpdev/threadwrap.c index 04a0a22f5b..9615166a9e 100644 --- a/src/xpdev/threadwrap.c +++ b/src/xpdev/threadwrap.c @@ -217,7 +217,7 @@ int DLLCALL pthread_mutex_destroy(pthread_mutex_t* mutex) /* Protected (thread-safe) Integers (e.g. atomic/interlocked variables) */ /************************************************************************/ -#ifndef __unix__ +#if __STDC_NO_ATOMICS__ void DLLCALL protected_int32_init(protected_int32_t* prot, int32_t value) { prot->value = value; diff --git a/src/xpdev/threadwrap.h b/src/xpdev/threadwrap.h index a19fc227cc..592d0d839a 100644 --- a/src/xpdev/threadwrap.h +++ b/src/xpdev/threadwrap.h @@ -40,7 +40,14 @@ #include "gen_defs.h" /* HANDLE */ #include "wrapdll.h" /* DLLEXPORT and DLLCALL */ -#ifdef __unix__ +#if !__STDC_NO_ATOMICS__ + #if defined __GNUC__ && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 9)) + #define __STDC_NO_ATOMICS__ 1 + #elif defined __BORLANDC__ + #define __STDC_NO_ATOMICS__ 1 + #endif +#endif +#if !__STDC_NO_ATOMICS__ #include <stdbool.h> #ifdef __cplusplus #include <atomic> @@ -157,7 +164,7 @@ DLLEXPORT int DLLCALL pthread_once(pthread_once_t *oc, void (*init)(void)); /* working and being thread-safe on all platforms that support pthread */ /* mutexes. */ /************************************************************************/ -#ifdef __unix__ +#if !__STDC_NO_ATOMICS__ #ifdef __cplusplus typedef std::atomic<int32_t> protected_int32_t; typedef std::atomic<uint32_t> protected_uint32_t; -- GitLab