[llvm-dev] __c11_atomic builtins' input requirements
Ben Trapani via llvm-dev
llvm-dev at lists.llvm.org
Fri Jan 3 19:59:38 PST 2020
Any update on this? What are your thoughts?
On Sat, Dec 28, 2019 at 8:23 PM Ben Trapani <ben.trapani1995 at gmail.com>
> I have started working on an implementation of atomic_ref. Implementing
> this requires performing atomic operations on arbitrary references. The
> behavior is undefined if a reference is provided that is not aligned per
> the public export required_alignment. What assumptions do the __c11_atomic
> builtins make about destination argument alignment, format, size etc.? Is
> it required that the destination argument be annotated as _Atomic like the
> corresponding standard c11 functions require?
> The following code in libcxx/include/config implies that the c11 atomic
> builtins should be substituted for gcc atomic builtins if present:
> #if __has_feature(cxx_atomic) || __has_extension(c_atomic) ||
> # define _LIBCPP_HAS_C_ATOMIC_IMP
> #elif defined(_LIBCPP_COMPILER_GCC)
> # define _LIBCPP_HAS_GCC_ATOMIC_IMP
> To implement atomic_ref, it might be cleaner to use the gcc builtins. By
> doing so, we avoid depending on the internals of the c11 atomic builtins.
> The required alignment of referenced variables would always be the first
> power of 2 >= max(type_size, type_alignment). Alternatively, we could use
> the c11 atomic builtins when available if it is enough to require that the
> input reference is aligned as the atomic type would be. What are your
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev