]> Savannah Git Hosting - gnulib.git/commitdiff
hamt: Fix compilation error on NetBSD 7.
authorBruno Haible <bruno@clisp.org>
Fri, 24 Dec 2021 16:32:20 +0000 (17:32 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 24 Dec 2021 16:32:20 +0000 (17:32 +0100)
* lib/hamt.h (GL_HAMT_THREAD_SAFE): Define to 0 if the compiler is a
GCC version < 4.9.

ChangeLog
lib/hamt.h

index dba79b9082e3bd17fb820b49ec7d77842a3e050a..c8ffa3907fcf0940f2b6a8ec7049c88b233ad3ba 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-12-24  Bruno Haible  <bruno@clisp.org>
+
+       hamt: Fix compilation error on NetBSD 7.
+       * lib/hamt.h (GL_HAMT_THREAD_SAFE): Define to 0 if the compiler is a
+       GCC version < 4.9.
+
 2021-12-24  Bruno Haible  <bruno@clisp.org>
 
        search: Fix compilation errors with SunPRO C++ on Solaris 10.
index 5d553fc7d18ebc390839af12bd0986a6413cd2ce..9f90534350ab4adb2afaf44ed9e443e6b0adcbfa 100644 (file)
@@ -56,13 +56,16 @@ _GL_INLINE_HEADER_BEGIN
 /* The GL_HAMT_THREAD_SAFE flag is set if the implementation of hamts
    is thread-safe as long as two threads do not simultaneously access
    the same hamt.  This is non-trivial as different hamts may share
-   some structure.  */
+   some structure.
+   We can define it only when the compiler supports _Atomic.  For GCC,
+   it is supported starting with GCC 4.9.  */
 
-#if (__STDC_VERSION__ < 201112 || defined __STD_NO_ATOMICS__) \
-  && __GNUC__ + (__GNUC_MINOR >= 9) <= 4
-# define GL_HAMT_THREAD_SAFE 0
-#else
+#if (__GNUC__ + (__GNUC_MINOR >= 9) > 4) \
+    && __STDC_VERSION__ >= 201112L && !defined __STD_NO_ATOMICS__ \
+    && !defined __cplusplus
 # define GL_HAMT_THREAD_SAFE 1
+#else
+# define GL_HAMT_THREAD_SAFE 0
 #endif
 
 #include <stdbool.h>