Added some stub functions for compilers not smart enough to get rid
[rsync/rsync.git] / mkrounding.c
CommitLineData
4f47fec0
WD
1/*
2 * A pre-compilation helper program to aid in the creation of rounding.h.
3 *
4 * Copyright (C) 2007 Wayne Davison
5 *
6 * This program is free software; you can redistribute it and/or modify
8e41b68e
WD
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
4f47fec0
WD
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
4fd842f9 17 * with this program; if not, visit the http://fsf.org website.
4f47fec0
WD
18 */
19
d5833800
WD
20#include "rsync.h"
21
22struct test1 {
23 union file_extras extras1[1];
24 struct {
25# include "mkrounding.h"
26 } file;
27};
28
29struct test2 {
30 union file_extras extras2[2];
31 struct {
32# include "mkrounding.h"
33 } file;
34};
35
36struct test4 {
37 union file_extras extras4[4];
38 struct {
39# include "mkrounding.h"
40 } file;
41};
42
43#define SIZE_TEST(n) (sizeof (struct test ## n) == EXTRA_LEN * n + sizeof (struct file_struct))
44
45 int main(UNUSED(int argc), UNUSED(char *argv[]))
46{
47 int cnt;
48 if (SIZE_TEST(1))
49 cnt = 0;
50 else if (SIZE_TEST(2))
51 cnt = 1;
52 else if (SIZE_TEST(4))
53 cnt = 3;
54 else {
55 fprintf(stderr, "Unable to determine required file_extras rounding!\n");
56 cnt = 3;
57 }
58 if (cnt)
30e50494 59 fprintf(stderr, "Rounding file_extras in multiples of %d", cnt + 1);
d5833800 60 else
30e50494 61 fprintf(stderr, "No rounding needed for file_extras");
5a3e9ff6
WD
62 fprintf(stderr, " (EXTRA_LEN=%d, FILE_STRUCT_LEN=%d)\n",
63 (int)EXTRA_LEN, (int)FILE_STRUCT_LEN);
d5833800
WD
64 printf("#define EXTRA_ROUNDING %d\n", cnt);
65 return 0;
66}
dd4a0395
WD
67
68void *_new_array(UNUSED(unsigned long num), UNUSED(unsigned int size), UNUSED(int use_calloc))
69{
70 out_of_memory("");
71}
72
73void *_realloc_array(UNUSED(void *ptr), UNUSED(unsigned int size), UNUSED(unsigned long num))
74{
75 out_of_memory("");
76}
77
78NORETURN void out_of_memory(UNUSED(const char *str))
79{
80 fprintf(stderr, "ERROR: this function should not be called!\n");
81 exit(1);
82}