From: Bruno Haible Date: Fri, 24 Dec 2021 16:32:20 +0000 (+0100) Subject: hamt: Fix compilation error on NetBSD 7. X-Git-Tag: v1.0~2492 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=a49c5844d75d6076700c5fdb1ff5cbbf6f0fdfc6;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index dba79b9082..c8ffa3907f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-12-24 Bruno Haible + + 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 search: Fix compilation errors with SunPRO C++ on Solaris 10. diff --git a/lib/hamt.h b/lib/hamt.h index 5d553fc7d1..9f90534350 100644 --- a/lib/hamt.h +++ b/lib/hamt.h @@ -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