aboutsummaryrefslogtreecommitdiff
path: root/liblow
diff options
context:
space:
mode:
Diffstat (limited to 'liblow')
-rw-r--r--liblow/cmovznz.c10
-rw-r--r--liblow/liblow.h2
2 files changed, 12 insertions, 0 deletions
diff --git a/liblow/cmovznz.c b/liblow/cmovznz.c
new file mode 100644
index 000000000..8533ade99
--- /dev/null
+++ b/liblow/cmovznz.c
@@ -0,0 +1,10 @@
+#include <stdint.h>
+#include "liblow.h"
+uint64_t cmovznz(uint64_t t, uint64_t z, uint64_t nz) {
+ asm ("testq %1, %1;" "\n"
+ "\t" "cmovnzq %3, %0;"
+ :"=r"(z)
+ :"r"(t), "0"(z), "r"(nz)
+ );
+ return z;
+}
diff --git a/liblow/liblow.h b/liblow/liblow.h
new file mode 100644
index 000000000..a8af0f52f
--- /dev/null
+++ b/liblow/liblow.h
@@ -0,0 +1,2 @@
+#include <stdint.h>
+uint64_t cmovznz(uint64_t t, uint64_t z, uint64_t nz);