mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 02:30:03 +01:00
Signed-off-by: Keir Fraser <keir.fraser@citrix.com> --HG-- rename : xen/include/public/foreign/mkchecker.py => tools/include/xen-foreign/mkchecker.py rename : xen/include/public/foreign/mkheader.py => tools/include/xen-foreign/mkheader.py rename : xen/include/public/foreign/reference.size => tools/include/xen-foreign/reference.size rename : xen/include/public/foreign/structs.py => tools/include/xen-foreign/structs.py
54 lines
1.1 KiB
Python
54 lines
1.1 KiB
Python
#!/usr/bin/python
|
|
|
|
import sys;
|
|
from structs import structs;
|
|
|
|
# command line arguments
|
|
outfile = sys.argv[1];
|
|
archs = sys.argv[2:];
|
|
|
|
f = open(outfile, "w");
|
|
f.write('''
|
|
/*
|
|
* sanity checks for generated foreign headers:
|
|
* - verify struct sizes
|
|
*
|
|
* generated by %s -- DO NOT EDIT
|
|
*/
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stddef.h>
|
|
#include <inttypes.h>
|
|
''');
|
|
|
|
for a in archs:
|
|
f.write('#include "%s.h"\n' % a);
|
|
|
|
f.write('int main(int argc, char *argv[])\n{\n');
|
|
|
|
f.write('\tprintf("\\n");');
|
|
f.write('printf("%-25s |", "structs");\n');
|
|
for a in archs:
|
|
f.write('\tprintf("%%8s", "%s");\n' % a);
|
|
f.write('\tprintf("\\n");');
|
|
|
|
f.write('\tprintf("\\n");');
|
|
for struct in structs:
|
|
f.write('\tprintf("%%-25s |", "%s");\n' % struct);
|
|
for a in archs:
|
|
s = struct + "_" + a;
|
|
f.write('#ifdef %s_has_no_%s\n' % (a, struct));
|
|
f.write('\tprintf("%8s", "-");\n');
|
|
f.write("#else\n");
|
|
f.write('\tprintf("%%8zd", sizeof(struct %s));\n' % s);
|
|
f.write("#endif\n");
|
|
|
|
f.write('\tprintf("\\n");\n\n');
|
|
|
|
f.write('\tprintf("\\n");\n');
|
|
f.write('\texit(0);\n');
|
|
f.write('}\n');
|
|
|
|
f.close();
|
|
|