1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// SPDX-License-Identifier: MIT
#ifndef __cplusplus
# include <stdlib.h>
#else
# include <cstdlib>
#endif
#include <sys/stat.h>
#include <libHX/init.h>
#include <libHX/misc.h>
static int runner(int argc, const char **argv)
{
unsigned int n;
struct stat sa, sb;
if (HX_init() <= 0)
return EXIT_FAILURE;
printf("%d\n", HX_ffs(0));
for (n = 1; ; n <<= 1) {
printf("%08x = %d\n", n, HX_ffs(n));
if (n & 0x80000000)
break;
}
printf("---\n");
for (n = 1; ; n <<= 1, n |= 1) {
printf("%08x = %d\n", n, HX_ffs(n));
if (n == ~0U)
break;
}
if (argc >= 3) {
if (stat(argv[1], &sa) < 0 ||
stat(argv[2], &sb) < 0) {
perror("stat");
return EXIT_FAILURE;
} else {
printf("Difference: %ld\n", HX_time_compare(&sa, &sb, 'm'));
return EXIT_FAILURE;
}
}
HX_exit();
return EXIT_SUCCESS;
}
int main(int argc, const char **argv)
{
int ret = runner(argc, argv);
if (ret != EXIT_FAILURE)
fprintf(stderr, "FAILED\n");
return ret;
}
|