tools: foreign: add checks for compatible architectures
authorIan Campbell <ian.campbell@citrix.com>
Fri, 19 Jul 2013 11:51:10 +0000 (12:51 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 20 Aug 2013 14:41:25 +0000 (15:41 +0100)
That is architectures whose struct layout must be identical. Use this for arm32
and arm64.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/include/xen-foreign/mkchecker.py
tools/include/xen-foreign/structs.py

index 66c17b19e9f46cc93241a52abe7faad81283cfde..fdad869a912c72f77eb380008950128708fc7bc8 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 
 import sys;
-from structs import structs;
+from structs import structs, compat_arches;
 
 # command line arguments
 outfile = sys.argv[1];
@@ -37,10 +37,27 @@ for struct in structs:
     f.write('\tprintf("%%-25s |", "%s");\n' % struct);
     for a in archs:
         s = struct + "_" + a;
+        if compat_arches.has_key(a):
+            compat = compat_arches[a]
+            c = struct + "_" + compat;
+        else:
+            compat = None
         f.write('#ifdef %s_has_no_%s\n' % (a, struct));
-        f.write('\tprintf("%8s", "-");\n');
+        f.write('\tprintf("%8s",\n');
+        if compat:
+            f.write('# ifndef %s_has_no_%s\n' % (compat, struct));
+            f.write('\t\t"!"\n');
+            f.write('# else\n')
+            f.write('\t\t"-"\n');
+            f.write('# endif\n')
+        else:
+            f.write('\t\t"-"\n');
+        f.write('\t);\n')
         f.write("#else\n");
         f.write('\tprintf("%%8zd", sizeof(struct %s));\n' % s);
+        if compat:
+            f.write('\tif (sizeof(struct %s) != sizeof(struct %s))\n' % (s, c))
+            f.write('\t\tprintf("!");\n')
         f.write("#endif\n");
 
     f.write('\tprintf("\\n");\n\n');
index 476eb85f063876cc49175ff74a0cad4079b9fe46..3d9f2fe956a63893814183bead533e45e9f26ace 100644 (file)
@@ -58,3 +58,8 @@ defines = [ "__arm__",
             "XEN_LEGACY_MAX_VCPUS",
             "MAX_GUEST_CMDLINE" ];
 
+# Architectures which must be compatible, i.e. identical
+compat_arches = {
+    'arm32': 'arm64',
+    'arm64': 'arm32',
+}