Debian Codegraph @

regressions/ck_cc/validate/ck_cc.c

raw
1 #include <ck_pr.h>
2 #include <limits.h>
3 #include <stdio.h>
4
5 #include "../../common.h"
6
7 int
8 main(void)
9 {
10 unsigned int x;
11
12 ck_pr_store_uint(&x, 0x10110);
13
14 if (ck_cc_ffs(0) != 0)
15 ck_error("ffs(0) = %d\n", ck_cc_ffs(0));
16 if (ck_cc_ffs(4) != 3)
17 ck_error("ffs(4) = %d\n", ck_cc_ffs(4));
18 if (ck_cc_ffs(UINT_MAX) != 1)
19 ck_error("ffs(UINT_MAX) = %d\n", ck_cc_ffs(UINT_MAX));
20 if (ck_cc_ffs(x) != 5)
21 ck_error("ffs(%u) = %d\n", x, ck_cc_ffs(x));
22
23 if (ck_cc_ffs(x) != ck_cc_ffsl(x) ||
24 ck_cc_ffsl(x) != ck_cc_ffsll(x) ||
25 ck_cc_ffs(x) != ck_cc_ffsll(x)) {
26 ck_error(" ffs = %d, ffsl = %d, ffsll = %d\n",
27 ck_cc_ffs(x), ck_cc_ffsl(x), ck_cc_ffsll(x));
28 }
29
30 if (ck_cc_ctz(x) != 4)
31 ck_error("ctz = %d\n", ck_cc_ctz(x));
32
33 if (ck_cc_popcount(x) != 3)
34 ck_error("popcount = %d\n", ck_cc_popcount(x));
35
36 return 0;
37 }