Add missing zstd.h to coregrind Makefile.am noinst_HEADERS
[valgrind.git] / memcheck / tests / freebsd / timing_safe.c
blobabc1b42dd7e366f00190a95a7a291edc825a0027
1 #include <string.h>
2 #include <assert.h>
3 #include <stdlib.h>
5 int main(void)
7 char* s1 = "the the the";
8 char* s2 = "the cat zat";
9 char* d1;
10 double undef1;
11 double undef2;
12 int res;
14 res = timingsafe_bcmp(s1, s2, 3);
15 assert(res == 0);
16 res = timingsafe_bcmp(s1, s2, 5);
17 assert(res != 0);
18 res = timingsafe_bcmp(s1, s1+4, 3);
19 assert(res == 0);
21 res = timingsafe_memcmp(s1, s2, 3);
22 assert(res == 0);
23 res = timingsafe_memcmp(s1, s2, 5);
24 assert(res > 0);
25 res = timingsafe_memcmp(s1+8, s2+8, 3);
26 assert(res < 0);
27 res = timingsafe_memcmp(s1, s1+4, 3);
28 assert(res == 0);
30 timingsafe_bcmp(&undef1, &undef2, 8);
31 timingsafe_memcmp(&undef1, &undef2, 8);
33 d1 = strdup(s1);
35 timingsafe_bcmp(s1, d1, 13);
36 timingsafe_memcmp(s1, d1, 13);
38 free(d1);
40 timingsafe_bcmp(s1, d1, 10);
41 timingsafe_memcmp(s1, d1, 10);