]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fundamental: replace __sync with __atomic in ONCE macro
authormatoro <matoro@users.noreply.github.com>
Sun, 10 Jul 2022 03:44:00 +0000 (23:44 -0400)
committermatoro <matoro@users.noreply.github.com>
Thu, 14 Jul 2022 21:34:15 +0000 (17:34 -0400)
For this one, we can actually just use __atomic_exchange_n since we
don't need the "compare" part of __atomic_compare_exchange_n.

src/fundamental/macro-fundamental.h

index a738b1f50e8151302493270c1f2f1f8faf52a33a..7cc34b6f1ac3fb458aa6c585b0e99a73e9d39a51 100644 (file)
  * on this macro will run concurrently to all other code conditionalized
  * the same way, there's no ordering or completion enforced. */
 #define ONCE __ONCE(UNIQ_T(_once_, UNIQ))
-#define __ONCE(o)                                                \
-        ({                                                       \
-                static bool (o) = false;                         \
-                __sync_bool_compare_and_swap(&(o), false, true); \
+#define __ONCE(o)                                                  \
+        ({                                                         \
+                static bool (o) = false;                           \
+                __atomic_exchange_n(&(o), true, __ATOMIC_SEQ_CST); \
         })
 
 #undef MAX