summaryrefslogtreecommitdiff
path: root/src/stdatomic/atomic_compare_exchange_strong.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2022-04-21 19:11:41 -0400
committerJakob Kaivo <jkk@ung.org>2022-04-21 19:11:41 -0400
commit1ae71a66576028eddf532c574c77e12c193eeebc (patch)
treeeb1e580a8528c3179f3e41a964807875717a4a10 /src/stdatomic/atomic_compare_exchange_strong.c
parent5a2f0c03d2a9cf1a463abe81ac26455e243dc6f3 (diff)
add prototypes for stdatomic
Diffstat (limited to 'src/stdatomic/atomic_compare_exchange_strong.c')
-rw-r--r--src/stdatomic/atomic_compare_exchange_strong.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/stdatomic/atomic_compare_exchange_strong.c b/src/stdatomic/atomic_compare_exchange_strong.c
new file mode 100644
index 00000000..43877395
--- /dev/null
+++ b/src/stdatomic/atomic_compare_exchange_strong.c
@@ -0,0 +1,13 @@
+#include <stdatomic.h>
+#include <stdbool.h>
+
+_Bool atomic_compare_exchange_strong(volatile __TYPE *object, __BASE *expected, __BASE desired)
+{
+ if (memcmp(object, expected, sizeof(*object)) == 0) {
+ memcpy(object, &desired, sizeof(*object));
+ return true;
+ }
+
+ memcpy(expected, object, sizeof(*object));
+ return false;
+}