debuggers.hg

view tools/include/xen-foreign/mkchecker.py @ 16957:afa521cf82e6

Move remaining xen/include/public/foreign files to tools/include/xen-foreign
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Sun Jan 27 17:25:56 2008 +0000 (2008-01-27)
parents xen/include/public/foreign/mkchecker.py@f605f35bd6ba
children 5d25187bac94
line source
1 #!/usr/bin/python
3 import sys;
4 from structs import structs;
6 # command line arguments
7 outfile = sys.argv[1];
8 archs = sys.argv[2:];
10 f = open(outfile, "w");
11 f.write('''
12 /*
13 * sanity checks for generated foreign headers:
14 * - verify struct sizes
15 *
16 * generated by %s -- DO NOT EDIT
17 */
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <stddef.h>
21 #include <inttypes.h>
22 ''');
24 for a in archs:
25 f.write('#include "%s.h"\n' % a);
27 f.write('int main(int argc, char *argv[])\n{\n');
29 f.write('\tprintf("\\n");');
30 f.write('printf("%-25s |", "structs");\n');
31 for a in archs:
32 f.write('\tprintf("%%8s", "%s");\n' % a);
33 f.write('\tprintf("\\n");');
35 f.write('\tprintf("\\n");');
36 for struct in structs:
37 f.write('\tprintf("%%-25s |", "%s");\n' % struct);
38 for a in archs:
39 s = struct + "_" + a;
40 f.write('#ifdef %s_has_no_%s\n' % (a, struct));
41 f.write('\tprintf("%8s", "-");\n');
42 f.write("#else\n");
43 f.write('\tprintf("%%8zd", sizeof(struct %s));\n' % s);
44 f.write("#endif\n");
46 f.write('\tprintf("\\n");\n\n');
48 f.write('\tprintf("\\n");\n');
49 f.write('\texit(0);\n');
50 f.write('}\n');
52 f.close();