]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/xen/interface/foreign/mkchecker.py
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / xen / interface / foreign / mkchecker.py
1 #!/usr/bin/python
2
3 import sys;
4 from structs import structs;
5
6 # command line arguments
7 arch    = sys.argv[1];
8 outfile = sys.argv[2];
9 archs   = sys.argv[3:];
10
11 f = open(outfile, "w");
12 f.write('''
13 /*
14  * sanity checks for generated foreign headers:
15  *  - verify struct sizes
16  *
17  * generated by %s -- DO NOT EDIT
18  */
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <stddef.h>
22 #include <inttypes.h>
23 #include "../xen.h"
24 ''');
25
26 for a in archs:
27     f.write('#include "%s.h"\n' % a);
28
29 f.write('int main(int argc, char *argv[])\n{\n');
30
31 f.write('\tprintf("\\n");');
32 f.write('printf("%-25s |", "structs");\n');
33 for a in archs:
34     f.write('\tprintf("%%8s", "%s");\n' % a);
35 f.write('\tprintf("\\n");');
36
37 f.write('\tprintf("\\n");');
38 for struct in structs:
39     f.write('\tprintf("%%-25s |", "%s");\n' % struct);
40     for a in archs:
41         if a == arch:
42             s = struct; # native
43         else:
44             s = struct + "_" + a;
45         f.write('#ifdef %s_has_no_%s\n' % (a, struct));
46         f.write('\tprintf("%8s", "-");\n');
47         f.write("#else\n");
48         f.write('\tprintf("%%8zd", sizeof(struct %s));\n' % s);
49         f.write("#endif\n");
50
51     f.write('\tprintf("\\n");\n\n');
52
53 f.write('\tprintf("\\n");\n');
54 f.write('\texit(0);\n');
55 f.write('}\n');
56
57 f.close();
58