aboutsummaryrefslogtreecommitdiff
path: root/liblow
diff options
context:
space:
mode:
authorGravatar Andres Erbsen <andreser@mit.edu>2017-07-02 17:09:09 -0400
committerGravatar Andres Erbsen <andreser@mit.edu>2017-07-02 17:09:09 -0400
commitd7ad9528319596298b80e450e5a2eb87610d2fcf (patch)
tree517a2de4683a867a706af0e3ee1e5f8ed164002c /liblow
parent448af3b44af491738b83a6084161e414d6522cdf (diff)
automate P256 integration
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);