#1585 Missing atomic builtins

OTHER
open
nobody
Feature
none
Unknown
False
2014-04-17
2011-10-07
Anonymous
No

Given the same OS (Windows) and the same arch (X86), it's quite weird that
MinGW-W64 GCC or Cygwin GCC does have support for atomic builtins but
MinGW GCC doesnt.

For more details, please see c++config.h for _GLIBCXX_ATOMIC_BUILTINS* macro
definitions.

Test case:

#include <stdint.h>

struct AtomicBuiltins
{
template <class T>
static void check()
{
T value = 0;
__sync_fetch_and_add(&value, 0);
__sync_fetch_and_sub(&value, 0);
__sync_fetch_and_or(&value, 0);
__sync_fetch_and_and(&value, 0);
__sync_fetch_and_xor(&value, 0);
__sync_fetch_and_nand(&value, 0);

__sync_add_and_fetch(&value, 0);
__sync_sub_and_fetch(&value, 0);
__sync_or_and_fetch(&value, 0);
__sync_and_and_fetch(&value, 0);
__sync_xor_and_fetch(&value, 0);
__sync_nand_and_fetch(&value, 0);

__sync_bool_compare_and_swap(&value, 0, 1);
__sync_val_compare_and_swap(&value, 1, 2);

__sync_lock_test_and_set(&value, 1);
__sync_lock_release(&value);
__sync_synchronize();
}
};

int
main()
{
AtomicBuiltins::check<int8_t>();
AtomicBuiltins::check<int16_t>();
AtomicBuiltins::check<int32_t>();
AtomicBuiltins::check<int64_t>();
return 0;
}

Please note that atomic builtins are required for stuffs like std::exception_ptr
or std::atomic.

Discussion

  • Earnie Boyd
    Earnie Boyd
    2013-02-08

    • labels: --> gcc, g++
    • milestone: --> OTHER
    • type: --> Feature
    • resolution: --> none
    • category: --> Unknown
    • patch_attached: --> False
     
  • Earnie Boyd
    Earnie Boyd
    2013-02-08

    Any MinGW developer want to take this on?