0

I have some code that I'm porting and I've tracked down the error to missing the macro _GLIBCXX_ATOMIC_BUILTINS

Do later versions of gcc not define this?

What's the proper way to get around this?

hookenz
  • 36,432
  • 45
  • 177
  • 286

1 Answers1

0

In that version you will also want to check the atomic macros for some particular data type, so you could do:

#if defined(_GLIBCXX_ATOMIC_BUILTINS_4) && !defined(_GLIBCXX_ATOMIC_BUILTINS)
#define _GLIBCXX_ATOMIC_BUILTINS
#endif

or

#if defined(_GLIBCXX_ATOMIC_BUILTINS) || defined(_GLIBCXX_ATOMIC_BUILTINS_4)

The macros are:

/* Define if builtin atomic operations for bool are supported on this host. */
#undef _GLIBCXX_ATOMIC_BUILTINS_1

/* Define if builtin atomic operations for short are supported on this host. */
#undef _GLIBCXX_ATOMIC_BUILTINS_2

/* Define if builtin atomic operations for int are supported on this host. */
#undef _GLIBCXX_ATOMIC_BUILTINS_4

/* Define if builtin atomic operations for long long are supported on this
   host. */
#undef _GLIBCXX_ATOMIC_BUILTINS_8
jspcal
  • 50,847
  • 7
  • 72
  • 76
  • That doesn't seem to work. I had a look at the -dM output and I have defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1, _2, _4 & _8. – hookenz Apr 06 '11 at 03:03
  • if libstdc++ was compiled for i386 it won't have _GLIBCXX_ATOMIC_BUILTINS_N defined in `bits/c++config.h` - that is set at install. it would've needed to be compiled with -march=i686 (or >= 486). it can of course still support atomic ops even if both _GLIBCXX_ATOMIC_BUILTINS_N and _GCC_HAVE_SYNC_COMPARE_AND_SWAP_N aren't defined. The best way to determine if your target supports `__sync_val_compare_and_swap` is to use [autoconf](http://www.gnu.org/software/autoconf/) or the preprocessor conditional here in [atomic_types.h](http://ftp.iptel.org/pub/sems/doc/current/atomic__types_8h_source.html) – jspcal Apr 06 '11 at 04:22