From f1da6fb54c259445a8fda17ee32190ea8f3b6ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven=20Dee=20=28J=C5=8Dshin=29?= Date: Mon, 17 Jun 2024 20:17:48 -0700 Subject: [PATCH] Fix c.inc _Atomic define for C++ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit c.inc (AFAICT erroneously) defined _Atomic(t) as `volatile t *`, when it should have just said `volatile t`, when __STDC_VERSION__ was too small. This happens when we’re compiling C++, but in C++11, _Atomic is a define supplied by the STL rather than a keyword supplied by the compiler. Wait though, it gets better: in C++11, _Atomic hooks you into the morass that is stdatomic.h, and ultimately refers everything back to std::atomic. The gory, horrifying details are in libcxx's __atomic/cxx_atomic_impl.h. The tldr is that for our purposes it’s fine to just say volatile and use the normal libc/intrin/atomic.h functions. --- libc/integral/c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/integral/c.inc b/libc/integral/c.inc index 301cca916..1a25488b3 100644 --- a/libc/integral/c.inc +++ b/libc/integral/c.inc @@ -74,7 +74,7 @@ #endif #if __STDC_VERSION__ + 0 < 201112 -#define _Atomic(t) volatile t * +#define _Atomic(t) volatile t #endif #ifdef __llvm__