Skip to content

Commit 01d86ef

Browse files
mjcarrollDavid-LP99
authored andcommitted
Remove the bundled gcc stdatomic compatibility header (ros2#589)
This header is a copy of the FreeBSD stdatomic.h, added so that rcutils could build on compilers that predated a working <stdatomic.h>. Its own banner records the intent: "so that it will work with gcc 4.7+ and Clang 3.1+". The include guards select it only for GCC 4.9 and older, or for Clang that does not report the c_atomic feature, which means Clang older than 3.1. Neither has been a supported platform for years, so on every compiler Rolling targets these branches are dead and <stdatomic.h> is used already. Dropping it removes 400 lines of vendored code and collapses the include selection to a single choice between the native header and the win32 shim. The win32 shim is untouched, and is still required: MSVC 14.51 provides <stdatomic.h> but refuses to compile it without /experimental:c11atomics. Verified both remaining paths build clean at /W4 /WX with MSVC 14.51, the native one by forcing the non-Windows branch. Signed-off-by: Michael Carroll <mjcarroll.oss@gmail.com>
1 parent 4e1f3fa commit 01d86ef

2 files changed

Lines changed: 8 additions & 423 deletions

File tree

‎include/rcutils/stdatomic_helper.h‎

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,16 @@
2929

3030
#if !defined(_WIN32) || defined(__MINGW64__)
3131

32-
// The my__has_feature avoids a preprocessor error when you check for it and
33-
// use it on the same line below.
34-
#if defined(__has_feature)
35-
#define my__has_feature __has_feature
36-
#else
37-
#define my__has_feature(x) 0
38-
#endif
39-
40-
#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ <= 4 && __GNUC_MINOR__ <= 9
41-
// If GCC and below GCC-4.9, use the compatability header.
42-
# include "stdatomic_helper/gcc/stdatomic.h"
43-
#else // !defined(__clang__) && defined(__GNUC__) && __GNUC__ <= 4 && __GNUC_MINOR__ <= 9
44-
# if __cplusplus
32+
// Every compiler we support provides a working <stdatomic.h>; the bundled gcc
33+
// compatibility header was only ever needed for GCC before 4.9 and Clang
34+
// before 3.1.
35+
#if __cplusplus
4536
// NOLINTNEXTLINE
46-
# error "cannot be used with C++ due to a conflict with the C++ <atomic> header, see: p0943r1"
37+
# error "cannot be used with C++ due to a conflict with the C++ <atomic> header, see: p0943r1"
4738
// See: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0943r1.html"
48-
# else
49-
# if defined(__has_feature) && !my__has_feature(c_atomic)
50-
// If Clang and no c_atomics (true for some older versions), use the compatability header.
51-
# include "stdatomic_helper/gcc/stdatomic.h"
52-
# else
53-
# include <stdatomic.h>
54-
# endif
55-
# endif
56-
#endif // !defined(__clang__) && defined(__GNUC__) && __GNUC__ <= 4 && __GNUC_MINOR__ <= 9
39+
#else
40+
# include <stdatomic.h>
41+
#endif
5742

5843
#define rcutils_atomic_load(object, out) (out) = atomic_load(object)
5944

0 commit comments

Comments
 (0)