diff options
Diffstat (limited to 'sys/src/libsec/port/const.c')
-rw-r--r-- | sys/src/libsec/port/const.c | 18 |
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; +} |