This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++17 is_always_lock_free implementation

Hello GCC / libstdc++ folks,

I implemented C++17's is_always_lock_free [0] in clang / libc++
and am wondering if GCC and libstdc++ are interested in following
a similar API as the one I propose in the clang patch [1].

What I propose is:

  * Extend the __GCC_ATOMIC_##TYPE##_LOCK_FREE macros to FLOAT,
    DOUBLE, LDOUBLE. This doesn't add corresponding C macros.

  * Add a __LLVM_LOCK_FREE_IS_SIZE_BASED macro with value 1 if
    all the lock-free-ness is based purely on the type's
    size. For LLVM this is currently the case for all ISAs.

  * Add macros __LLVM_ATOMIC_##BYTES##_BYTES_LOCK_FREE for sizes
    1, 2, 4, 8, 16. We could go further, but I don't think any
    ISA has 32-byte and up lock-free (and the C++ library can
    just #if defined() on wider types).

I then use these in libc++ [2].

It may be worth standardizing equivalent macros in C, but we'll
need these built-in macros anyways. I also think C macros aren't
as useful as the C++ template-based constexpr magic.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]