[PATCH 1/4] widl: Generate correct alignment for encapsulated union tags.

Zebediah Figura z.figura12 at gmail.com
Tue Apr 10 20:30:26 CDT 2018


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 tools/widl/typegen.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index e63600c..27855cc 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -3276,6 +3276,7 @@ static unsigned int write_union_tfs(FILE *file, const attr_list_t *attrs,
     {
         const var_t *sv = type_union_get_switch_value(type);
         const type_t *st = sv->type;
+        unsigned int align = 0;
         unsigned char fc;
 
         if (type_get_type(st) == TYPE_BASIC)
@@ -3303,9 +3304,16 @@ static unsigned int write_union_tfs(FILE *file, const attr_list_t *attrs,
         else
             error("union switch type must be an integer, char, or enum\n");
 
+        type_memsize_and_alignment(st, &align);
+        if (fields) LIST_FOR_EACH_ENTRY(f, fields, var_t, entry)
+        {
+            if (f->type)
+                type_memsize_and_alignment(f->type, &align);
+        }
+
         print_file(file, 2, "0x%x,\t/* FC_ENCAPSULATED_UNION */\n", RPC_FC_ENCAPSULATED_UNION);
         print_file(file, 2, "0x%x,\t/* Switch type= %s */\n",
-                   0x40 | fc, string_of_type(fc));
+                   (align << 4) | fc, string_of_type(fc));
         *tfsoff += 2;
     }
     else if (is_attr(type->attrs, ATTR_SWITCHTYPE))
-- 
2.7.4




More information about the wine-devel mailing list