New file to figure out if a system has any rounding needs when
[rsync/rsync.git] / mkrounding.c
1 #include "rsync.h"
2
3 struct test1 {
4     union file_extras extras1[1];
5     struct {
6 #       include "mkrounding.h"
7     } file;
8 };
9
10 struct test2 {
11     union file_extras extras2[2];
12     struct {
13 #       include "mkrounding.h"
14     } file;
15 };
16
17 struct test4 {
18     union file_extras extras4[4];
19     struct {
20 #       include "mkrounding.h"
21     } file;
22 };
23
24 #define SIZE_TEST(n) (sizeof (struct test ## n) == EXTRA_LEN * n + sizeof (struct file_struct))
25
26  int main(UNUSED(int argc), UNUSED(char *argv[]))
27 {
28     int cnt;
29     if (SIZE_TEST(1))
30         cnt = 0;
31     else if (SIZE_TEST(2))
32         cnt = 1;
33     else if (SIZE_TEST(4))
34         cnt = 3;
35     else {
36         fprintf(stderr, "Unable to determine required file_extras rounding!\n");
37         cnt = 3;
38     }
39     if (cnt)
40         fprintf(stderr, "Rounding file_extras values in multiples of %d.\n", cnt + 1);
41     else
42         fprintf(stderr, "No rounding needed for file_extras values.\n");
43     printf("#define EXTRA_ROUNDING %d\n", cnt);
44     return 0;
45 }