diff options
Diffstat (limited to 'recipes-extended/xen/files/xen-tools-update-python-scripts-to-py3.patch')
| -rw-r--r-- | recipes-extended/xen/files/xen-tools-update-python-scripts-to-py3.patch | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/recipes-extended/xen/files/xen-tools-update-python-scripts-to-py3.patch b/recipes-extended/xen/files/xen-tools-update-python-scripts-to-py3.patch new file mode 100644 index 00000000..455072ba --- /dev/null +++ b/recipes-extended/xen/files/xen-tools-update-python-scripts-to-py3.patch | |||
| @@ -0,0 +1,140 @@ | |||
| 1 | From a9047a722ba5de38e7c1d762ffcfb74c36725fe2 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Andrew Cooper <andrew.cooper3@citrix.com> | ||
| 3 | Date: Mon, 11 Mar 2019 19:18:40 +0000 | ||
| 4 | Subject: [PATCH] tools/xen-foreign: Update python scripts to be Py3 compatible | ||
| 5 | |||
| 6 | The issues are: | ||
| 7 | * dict.has_key() was completely removed in Py3 | ||
| 8 | * dict.keys() is an iterable rather than list in Py3, so .sort() doesn't work. | ||
| 9 | * list.sort(cmp=) was deprecated in Py2.4 and removed in Py3. | ||
| 10 | |||
| 11 | The has_key() issue is trivially fixed by switching to using the in keyword. | ||
| 12 | The sorting issue could be trivially fixed, but take the opportunity to | ||
| 13 | improve the code. | ||
| 14 | |||
| 15 | The reason for the sorting is to ensure that "unsigned long" gets replaced | ||
| 16 | before "long", and the only reason sorting is necessary is because | ||
| 17 | inttypes[arch] is needlessly a dictionary. Update inttypes[arch] to be a list | ||
| 18 | of tuples rather than a dictionary, and process them in list order. | ||
| 19 | |||
| 20 | Reported-by: George Dunlap <george.dunlap@eu.citrix.com> | ||
| 21 | Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> | ||
| 22 | Acked-by: Wei Liu <wei.liu2@citrix.com> | ||
| 23 | --- | ||
| 24 | tools/include/xen-foreign/mkchecker.py | 2 +- | ||
| 25 | tools/include/xen-foreign/mkheader.py | 58 +++++++++++++------------- | ||
| 26 | 2 files changed, 29 insertions(+), 31 deletions(-) | ||
| 27 | |||
| 28 | diff --git a/tools/include/xen-foreign/mkchecker.py b/tools/include/xen-foreign/mkchecker.py | ||
| 29 | index fdad869a91..199b0eebbc 100644 | ||
| 30 | --- a/tools/include/xen-foreign/mkchecker.py | ||
| 31 | +++ b/tools/include/xen-foreign/mkchecker.py | ||
| 32 | @@ -37,7 +37,7 @@ for struct in structs: | ||
| 33 | f.write('\tprintf("%%-25s |", "%s");\n' % struct); | ||
| 34 | for a in archs: | ||
| 35 | s = struct + "_" + a; | ||
| 36 | - if compat_arches.has_key(a): | ||
| 37 | + if a in compat_arches: | ||
| 38 | compat = compat_arches[a] | ||
| 39 | c = struct + "_" + compat; | ||
| 40 | else: | ||
| 41 | diff --git a/tools/include/xen-foreign/mkheader.py b/tools/include/xen-foreign/mkheader.py | ||
| 42 | index 97e0c7a984..fb268f0dce 100644 | ||
| 43 | --- a/tools/include/xen-foreign/mkheader.py | ||
| 44 | +++ b/tools/include/xen-foreign/mkheader.py | ||
| 45 | @@ -17,13 +17,13 @@ header = {}; | ||
| 46 | footer = {}; | ||
| 47 | |||
| 48 | #arm | ||
| 49 | -inttypes["arm32"] = { | ||
| 50 | - "unsigned long" : "__danger_unsigned_long_on_arm32", | ||
| 51 | - "long" : "__danger_long_on_arm32", | ||
| 52 | - "xen_pfn_t" : "uint64_t", | ||
| 53 | - "xen_ulong_t" : "uint64_t", | ||
| 54 | - "uint64_t" : "__align8__ uint64_t", | ||
| 55 | -}; | ||
| 56 | +inttypes["arm32"] = [ | ||
| 57 | + ("unsigned long", "__danger_unsigned_long_on_arm32"), | ||
| 58 | + ("long", "__danger_long_on_arm32"), | ||
| 59 | + ("xen_pfn_t", "uint64_t"), | ||
| 60 | + ("xen_ulong_t", "uint64_t"), | ||
| 61 | + ("uint64_t", "__align8__ uint64_t"), | ||
| 62 | +] | ||
| 63 | header["arm32"] = """ | ||
| 64 | #define __arm___ARM32 1 | ||
| 65 | #if defined(__GNUC__) && !defined(__STRICT_ANSI__) | ||
| 66 | @@ -38,13 +38,13 @@ footer["arm32"] = """ | ||
| 67 | #undef __DECL_REG | ||
| 68 | """ | ||
| 69 | |||
| 70 | -inttypes["arm64"] = { | ||
| 71 | - "unsigned long" : "__danger_unsigned_long_on_arm64", | ||
| 72 | - "long" : "__danger_long_on_arm64", | ||
| 73 | - "xen_pfn_t" : "uint64_t", | ||
| 74 | - "xen_ulong_t" : "uint64_t", | ||
| 75 | - "uint64_t" : "__align8__ uint64_t", | ||
| 76 | -}; | ||
| 77 | +inttypes["arm64"] = [ | ||
| 78 | + ("unsigned long", "__danger_unsigned_long_on_arm64"), | ||
| 79 | + ("long", "__danger_long_on_arm64"), | ||
| 80 | + ("xen_pfn_t", "uint64_t"), | ||
| 81 | + ("xen_ulong_t", "uint64_t"), | ||
| 82 | + ("uint64_t", "__align8__ uint64_t"), | ||
| 83 | +] | ||
| 84 | header["arm64"] = """ | ||
| 85 | #define __aarch64___ARM64 1 | ||
| 86 | #if defined(__GNUC__) && !defined(__STRICT_ANSI__) | ||
| 87 | @@ -60,12 +60,12 @@ footer["arm64"] = """ | ||
| 88 | """ | ||
| 89 | |||
| 90 | # x86_32 | ||
| 91 | -inttypes["x86_32"] = { | ||
| 92 | - "unsigned long" : "uint32_t", | ||
| 93 | - "long" : "uint32_t", | ||
| 94 | - "xen_pfn_t" : "uint32_t", | ||
| 95 | - "xen_ulong_t" : "uint32_t", | ||
| 96 | -}; | ||
| 97 | +inttypes["x86_32"] = [ | ||
| 98 | + ("unsigned long", "uint32_t"), | ||
| 99 | + ("long", "uint32_t"), | ||
| 100 | + ("xen_pfn_t", "uint32_t"), | ||
| 101 | + ("xen_ulong_t", "uint32_t"), | ||
| 102 | +] | ||
| 103 | header["x86_32"] = """ | ||
| 104 | #define __DECL_REG_LO8(which) uint32_t e ## which ## x | ||
| 105 | #define __DECL_REG_LO16(name) uint32_t e ## name | ||
| 106 | @@ -79,12 +79,12 @@ footer["x86_32"] = """ | ||
| 107 | """; | ||
| 108 | |||
| 109 | # x86_64 | ||
| 110 | -inttypes["x86_64"] = { | ||
| 111 | - "unsigned long" : "__align8__ uint64_t", | ||
| 112 | - "long" : "__align8__ uint64_t", | ||
| 113 | - "xen_pfn_t" : "__align8__ uint64_t", | ||
| 114 | - "xen_ulong_t" : "__align8__ uint64_t", | ||
| 115 | -}; | ||
| 116 | +inttypes["x86_64"] = [ | ||
| 117 | + ("unsigned long", "__align8__ uint64_t"), | ||
| 118 | + ("long", "__align8__ uint64_t"), | ||
| 119 | + ("xen_pfn_t", "__align8__ uint64_t"), | ||
| 120 | + ("xen_ulong_t", "__align8__ uint64_t"), | ||
| 121 | +] | ||
| 122 | header["x86_64"] = """ | ||
| 123 | #if defined(__GNUC__) && !defined(__STRICT_ANSI__) | ||
| 124 | # define __DECL_REG(name) union { uint64_t r ## name, e ## name; } | ||
| 125 | @@ -205,10 +205,8 @@ for struct in structs: | ||
| 126 | output = re.sub("\\b(%s)_t\\b" % struct, "\\1_%s_t" % arch, output); | ||
| 127 | |||
| 128 | # replace: integer types | ||
| 129 | -integers = inttypes[arch].keys(); | ||
| 130 | -integers.sort(lambda a, b: cmp(len(b),len(a))); | ||
| 131 | -for type in integers: | ||
| 132 | - output = re.sub("\\b%s\\b" % type, inttypes[arch][type], output); | ||
| 133 | +for old, new in inttypes[arch]: | ||
| 134 | + output = re.sub("\\b%s\\b" % old, new, output) | ||
| 135 | |||
| 136 | # print results | ||
| 137 | f = open(outfile, "w"); | ||
| 138 | -- | ||
| 139 | 2.17.1 | ||
| 140 | |||
