Commit b524c550 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

widl: Add separate --win32-align and --win64-align options.

parent ca18de95
......@@ -144,6 +144,13 @@ unsigned char get_basic_fc(const type_t *type)
}
}
static inline unsigned int clamp_align(unsigned int align)
{
unsigned int packing = (pointer_size == 4) ? win32_packing : win64_packing;
if(align > packing) align = packing;
return align;
}
unsigned char get_pointer_fc(const type_t *type, const attr_list_t *attrs, int toplevel_param)
{
const type_t *t;
......@@ -1164,13 +1171,12 @@ static unsigned int fields_memsize(const var_list_t *fields, unsigned int *align
unsigned int falign = 0;
unsigned int fsize = type_memsize(v->type, &falign);
if (*align < falign) *align = falign;
if (falign > packing) falign = packing;
falign = clamp_align(falign);
size = ROUND_SIZE(size, falign);
size += fsize;
}
max_align = *align;
if(max_align > packing) max_align = packing;
max_align = clamp_align(*align);
size = ROUND_SIZE(size, max_align);
return size;
......@@ -1210,7 +1216,7 @@ int get_padding(const var_list_t *fields)
type_t *ft = f->type;
unsigned int align = 0;
unsigned int size = type_memsize(ft, &align);
if (align > packing) align = packing;
align = clamp_align(align);
if (align > salign) salign = align;
offset = ROUND_SIZE(offset, align);
offset += size;
......@@ -2279,7 +2285,7 @@ static void write_struct_members(FILE *file, const type_t *type,
type_t *ft = field->type;
unsigned int align = 0;
unsigned int size = type_memsize(ft, &align);
if(align > packing) align = packing;
align = clamp_align(align);
if (salign < align) salign = align;
if (!is_conformant_array(ft) || type_array_is_decl_as_ptr(ft))
......
......@@ -52,7 +52,6 @@
static const char usage[] =
"Usage: widl [options...] infile.idl\n"
" or: widl [options...] --dlldata-only name1 [name2...]\n"
" -a n Set structure alignment to 'n'\n"
" -b arch Set the target architecture\n"
" -c Generate client stub\n"
" -C file Name of client stub file (default is infile_c.c)\n"
......@@ -82,6 +81,8 @@ static const char usage[] =
" -W Enable pedantic warnings\n"
" --win32 Only generate 32-bit code\n"
" --win64 Only generate 64-bit code\n"
" --win32-align n Set win32 structure alignment to 'n'\n"
" --win64-align n Set win64 structure alignment to 'n'\n"
"Debug level 'n' is a bitmask with following meaning:\n"
" * 0x01 Tell which resource is parsed (verbose mode)\n"
" * 0x02 Dump internal structures\n"
......@@ -111,7 +112,8 @@ int no_preprocess = 0;
int old_names = 0;
int do_win32 = 1;
int do_win64 = 1;
int packing = 8;
int win32_packing = 8;
int win64_packing = 8;
char *input_name;
char *header_name;
......@@ -150,11 +152,13 @@ enum {
PREFIX_CLIENT_OPTION,
PREFIX_SERVER_OPTION,
WIN32_OPTION,
WIN64_OPTION
WIN64_OPTION,
WIN32_ALIGN_OPTION,
WIN64_ALIGN_OPTION
};
static const char short_options[] =
"a:b:cC:d:D:EhH:I:m:NpP:sS:tT:uU:VW";
"b:cC:d:D:EhH:I:m:NpP:sS:tT:uU:VW";
static const struct option long_options[] = {
{ "dlldata", 1, 0, DLLDATA_OPTION },
{ "dlldata-only", 0, 0, DLLDATA_ONLY_OPTION },
......@@ -165,6 +169,8 @@ static const struct option long_options[] = {
{ "prefix-server", 1, 0, PREFIX_SERVER_OPTION },
{ "win32", 0, 0, WIN32_OPTION },
{ "win64", 0, 0, WIN64_OPTION },
{ "win32-align", 1, 0, WIN32_ALIGN_OPTION },
{ "win64-align", 1, 0, WIN64_ALIGN_OPTION },
{ 0, 0, 0, 0 }
};
......@@ -522,9 +528,14 @@ int main(int argc,char *argv[])
do_win32 = 0;
do_win64 = 1;
break;
case 'a':
packing = strtol(optarg, NULL, 0);
if(packing != 2 && packing != 4 && packing != 8)
case WIN32_ALIGN_OPTION:
win32_packing = strtol(optarg, NULL, 0);
if(win32_packing != 2 && win32_packing != 4 && win32_packing != 8)
error("Packing must be one of 2, 4 or 8\n");
break;
case WIN64_ALIGN_OPTION:
win64_packing = strtol(optarg, NULL, 0);
if(win64_packing != 2 && win64_packing != 4 && win64_packing != 8)
error("Packing must be one of 2, 4 or 8\n");
break;
case 'b':
......
......@@ -46,7 +46,8 @@ extern int do_dlldata;
extern int old_names;
extern int do_win32;
extern int do_win64;
extern int packing;
extern int win32_packing;
extern int win64_packing;
extern char *input_name;
extern char *header_name;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment