summaryrefslogtreecommitdiff
path: root/sys/src/libsec/port/const.c
diff options
context:
space:
mode:
authormischief <mischief@offblast.org>2015-08-25 02:07:46 -0700
committermischief <mischief@offblast.org>2015-08-25 02:07:46 -0700
commit6b402b83cffc97015345dab1c27c35afe64bb3db (patch)
treeb525f9443564682c46f8c36af6a4d238bd39a756 /sys/src/libsec/port/const.c
parentdbe0a995f03f26ea2b6859d21df3bd67856d672d (diff)
import E script from bell labs
Diffstat (limited to 'sys/src/libsec/port/const.c')
-rw-r--r--sys/src/libsec/port/const.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/sys/src/libsec/port/const.c b/sys/src/libsec/port/const.c
new file mode 100644
index 000000000..0cf400178
--- /dev/null
+++ b/sys/src/libsec/port/const.c
@@ -0,0 +1,18 @@
+#include <u.h>
+
+/*
+ * returns 0 if the the len bytes in x are equal to len bytes in y,
+ * otherwise returns -1.
+ */
+int
+constcmp(uchar *x, uchar *y, int len)
+{
+ uint z;
+ int i;
+
+ for(z = 0, i = 0; i < len; i++) {
+ z |= x[i] ^ y[i];
+ }
+
+ return (1 & ((z - 1) >> 8)) - 1;
+}