| 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 in multiples of %d", cnt + 1); |
| 41 | else |
| 42 | fprintf(stderr, "No rounding needed for file_extras"); |
| 43 | fprintf(stderr, " (EXTRA_LEN=%d, FILE_STRUCT_LEN=%d)\n", |
| 44 | (int)EXTRA_LEN, (int)FILE_STRUCT_LEN); |
| 45 | printf("#define EXTRA_ROUNDING %d\n", cnt); |
| 46 | return 0; |
| 47 | } |