On Mon, Sep 23, 2013 at 5:48 PM, Peter Dimov
Andrey Semashev wrote:
The macros are supposed to provide low level atomic ops on Windows, aren't they? Wouldn't it be better to use gcc atomic intrinsics instead of WinAPI calls in case of MinGW?
No, the macros were supposed to be a portable way of accessing the Interlocked* family of WinAPI calls without having to #include
. That's probably why shared_ptr doesn't have a problem on MingW64 - it uses a g++ specific implementation there. (Interlocked* later mutated into compiler intrinsics.)
Yes, MinGW-w64 defines _Interlocked* functions in terms of gcc intrinsics internally, in intrin.h. This header is only available in MinGW-w64 and not MinGW (the original project). Considering all that I prepared a patch for interlocked.hpp (attached, the patch is against trunk).