^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include <stdint.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) volatile uint64_t x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) int main(int argc, char *argv[])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) uint64_t old, new = argc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) (void)argv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) old = __sync_val_compare_and_swap(&x, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) } while (!__sync_bool_compare_and_swap(&x, old, new));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) return old == new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) }