[libc-commits] [libc] [libc] fix and explicit atomic difference from c++ (PR #119715)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Thu Dec 12 09:14:12 PST 2024


================
@@ -62,6 +62,18 @@ template <typename T> struct Atomic {
     return static_cast<int>(mem_scope);
   }
 
+  LIBC_INLINE static T *addressof(T &ref) { return __builtin_addressof(ref); }
+
+  // require types that are 1, 2, 4, 8, or 16 bytes in length to be aligned to
+  // at least their size to be potentially
+  // used lock-free
+  LIBC_INLINE_VAR static constexpr size_t MIN_ALIGNMENT =
+      (sizeof(T) & (sizeof(T) - 1)) || (sizeof(T) > 16) ? 0 : sizeof(T);
----------------
nickdesaulniers wrote:

Is this expression re-used from libc++?

https://github.com/llvm/llvm-project/pull/119715


More information about the libc-commits mailing list