aboutsummaryrefslogtreecommitdiff
path: root/frida_mode/src/seccomp/seccomp_atomic.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2021-09-01 08:41:21 +0200
committerGitHub <noreply@github.com>2021-09-01 08:41:21 +0200
commit773baf9391ff5f1793deb7968366819e7fa07adc (patch)
tree08fcc9ebc0a70f545cbc149385dfb9a4670eada8 /frida_mode/src/seccomp/seccomp_atomic.c
parent353d402aaf9296c7dbd47e66fbbc6e59179c4e44 (diff)
parentd4a8a9df699aa018755f4948e2add508be44b8b2 (diff)
downloadafl++-773baf9391ff5f1793deb7968366819e7fa07adc.tar.gz
Merge pull request #1084 from AFLplusplus/dev
push to stable
Diffstat (limited to 'frida_mode/src/seccomp/seccomp_atomic.c')
-rw-r--r--frida_mode/src/seccomp/seccomp_atomic.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/frida_mode/src/seccomp/seccomp_atomic.c b/frida_mode/src/seccomp/seccomp_atomic.c
new file mode 100644
index 00000000..1720a726
--- /dev/null
+++ b/frida_mode/src/seccomp/seccomp_atomic.c
@@ -0,0 +1,28 @@
+#include <stdbool.h>
+#include <stdio.h>
+
+#include "debug.h"
+
+void seccomp_atomic_set(volatile bool *ptr, bool val) {
+
+ if (!__sync_bool_compare_and_swap(ptr, !val, val)) {
+
+ FATAL("Failed to set event");
+
+ }
+
+}
+
+bool seccomp_atomic_try_set(volatile bool *ptr, bool val) {
+
+ return __sync_bool_compare_and_swap(ptr, !val, val);
+
+}
+
+void seccomp_atomic_wait(volatile bool *ptr, bool val) {
+
+ while (!__sync_bool_compare_and_swap(ptr, val, !val))
+ ;
+
+}
+