~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to tools/include/xen-foreign/mkchecker.py

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import sys;
 
4
from structs import structs;
 
5
 
 
6
# command line arguments
 
7
outfile = sys.argv[1];
 
8
archs   = sys.argv[2:];
 
9
 
 
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
''');
 
23
 
 
24
for a in archs:
 
25
    f.write('#include "%s.h"\n' % a);
 
26
 
 
27
f.write('int main(int argc, char *argv[])\n{\n');
 
28
 
 
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");');
 
34
 
 
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");
 
45
 
 
46
    f.write('\tprintf("\\n");\n\n');
 
47
 
 
48
f.write('\tprintf("\\n");\n');
 
49
f.write('\texit(0);\n');
 
50
f.write('}\n');
 
51
 
 
52
f.close();
 
53