From c468fd7e6228f2820ef8f4ede7432313354730f0 Mon Sep 17 00:00:00 2001 From: Marcin Cieslak Date: Sat, 13 Sep 2014 18:35:52 +0000 Subject: [PATCH 07/10] clang: sizeof(type) must not have __attribute__(aligned) Signed-off-by: Marcin Cieslak --- tools/include/xen-foreign/mkheader.py | 41 ++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/tools/include/xen-foreign/mkheader.py b/tools/include/xen-foreign/mkheader.py index 0504cb8..80a8404 100644 --- a/tools/include/xen-foreign/mkheader.py +++ b/tools/include/xen-foreign/mkheader.py @@ -16,13 +16,23 @@ inttypes = {}; header = {}; footer = {}; +def convertint(arch, t, aligned=False): + nt = inttypes[arch][t] + attr = "" + if type(nt) is type(()): + (attr, nt) = nt + if not aligned: + attr = "" + print >>sys.stderr, "%s(%d) -> %s %s" % (t, aligned, attr, nt) + return "%s %s" % (nt, attr) # Order is important due to re.sub done twice + #arm inttypes["arm32"] = { "unsigned long" : "__danger_unsigned_long_on_arm32", "long" : "__danger_long_on_arm32", - "xen_pfn_t" : "__align8__ uint64_t", - "xen_ulong_t" : "__align8__ uint64_t", - "uint64_t" : "__align8__ uint64_t", + "xen_pfn_t" : ("__align8__", "uint64_t"), + "xen_ulong_t" : ("__align8__", "uint64_t"), + "uint64_t" : ("__align8__", "uint64_t"), }; header["arm32"] = """ #define __arm___ARM32 1 @@ -41,10 +51,10 @@ footer["arm32"] = """ inttypes["arm64"] = { "unsigned long" : "__danger_unsigned_long_on_arm64", "long" : "__danger_long_on_arm64", - "xen_pfn_t" : "__align8__ uint64_t", - "xen_ulong_t" : "__align8__ uint64_t", - "uint64_t" : "__align8__ uint64_t", -}; + "xen_pfn_t" : ("__align8__", "uint64_t"), + "xen_ulong_t" : ("__align8__", "uint64_t"), + "uint64_t" : ("__align8__", "uint64_t"), +} header["arm64"] = """ #define __aarch64___ARM64 1 #if defined(__GNUC__) && !defined(__STRICT_ANSI__) @@ -65,7 +75,7 @@ inttypes["x86_32"] = { "long" : "uint32_t", "xen_pfn_t" : "uint32_t", "xen_ulong_t" : "uint32_t", -}; +} header["x86_32"] = """ #define __i386___X86_32 1 #pragma pack(4) @@ -76,11 +86,11 @@ footer["x86_32"] = """ # x86_64 inttypes["x86_64"] = { - "unsigned long" : "__align8__ uint64_t", - "long" : "__align8__ uint64_t", - "xen_pfn_t" : "__align8__ uint64_t", - "xen_ulong_t" : "__align8__ uint64_t", -}; + "unsigned long" : ("__align8__", "uint64_t"), + "long" : ("__align8__", "uint64_t"), + "xen_pfn_t" : ("__align8__", "uint64_t"), + "xen_ulong_t" : ("__align8__", "uint64_t"), +} header["x86_64"] = """ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) # define __DECL_REG(name) union { uint64_t r ## name, e ## name; } @@ -195,8 +205,9 @@ for struct in structs: # replace: integer types integers = inttypes[arch].keys(); integers.sort(lambda a, b: cmp(len(b),len(a))); -for type in integers: - output = re.sub("\\b%s\\b" % type, inttypes[arch][type], output); +for typename in integers: + output = re.sub("\\b(?