widl: Add separate --win32-align and --win64-align options.
This commit is contained in:
parent
ca18de9512
commit
b524c55021
|
@ -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)
|
unsigned char get_pointer_fc(const type_t *type, const attr_list_t *attrs, int toplevel_param)
|
||||||
{
|
{
|
||||||
const type_t *t;
|
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 falign = 0;
|
||||||
unsigned int fsize = type_memsize(v->type, &falign);
|
unsigned int fsize = type_memsize(v->type, &falign);
|
||||||
if (*align < falign) *align = falign;
|
if (*align < falign) *align = falign;
|
||||||
if (falign > packing) falign = packing;
|
falign = clamp_align(falign);
|
||||||
size = ROUND_SIZE(size, falign);
|
size = ROUND_SIZE(size, falign);
|
||||||
size += fsize;
|
size += fsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
max_align = *align;
|
max_align = clamp_align(*align);
|
||||||
if(max_align > packing) max_align = packing;
|
|
||||||
size = ROUND_SIZE(size, max_align);
|
size = ROUND_SIZE(size, max_align);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
@ -1210,7 +1216,7 @@ int get_padding(const var_list_t *fields)
|
||||||
type_t *ft = f->type;
|
type_t *ft = f->type;
|
||||||
unsigned int align = 0;
|
unsigned int align = 0;
|
||||||
unsigned int size = type_memsize(ft, &align);
|
unsigned int size = type_memsize(ft, &align);
|
||||||
if (align > packing) align = packing;
|
align = clamp_align(align);
|
||||||
if (align > salign) salign = align;
|
if (align > salign) salign = align;
|
||||||
offset = ROUND_SIZE(offset, align);
|
offset = ROUND_SIZE(offset, align);
|
||||||
offset += size;
|
offset += size;
|
||||||
|
@ -2279,7 +2285,7 @@ static void write_struct_members(FILE *file, const type_t *type,
|
||||||
type_t *ft = field->type;
|
type_t *ft = field->type;
|
||||||
unsigned int align = 0;
|
unsigned int align = 0;
|
||||||
unsigned int size = type_memsize(ft, &align);
|
unsigned int size = type_memsize(ft, &align);
|
||||||
if(align > packing) align = packing;
|
align = clamp_align(align);
|
||||||
if (salign < align) salign = align;
|
if (salign < align) salign = align;
|
||||||
|
|
||||||
if (!is_conformant_array(ft) || type_array_is_decl_as_ptr(ft))
|
if (!is_conformant_array(ft) || type_array_is_decl_as_ptr(ft))
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
static const char usage[] =
|
static const char usage[] =
|
||||||
"Usage: widl [options...] infile.idl\n"
|
"Usage: widl [options...] infile.idl\n"
|
||||||
" or: widl [options...] --dlldata-only name1 [name2...]\n"
|
" or: widl [options...] --dlldata-only name1 [name2...]\n"
|
||||||
" -a n Set structure alignment to 'n'\n"
|
|
||||||
" -b arch Set the target architecture\n"
|
" -b arch Set the target architecture\n"
|
||||||
" -c Generate client stub\n"
|
" -c Generate client stub\n"
|
||||||
" -C file Name of client stub file (default is infile_c.c)\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"
|
" -W Enable pedantic warnings\n"
|
||||||
" --win32 Only generate 32-bit code\n"
|
" --win32 Only generate 32-bit code\n"
|
||||||
" --win64 Only generate 64-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"
|
"Debug level 'n' is a bitmask with following meaning:\n"
|
||||||
" * 0x01 Tell which resource is parsed (verbose mode)\n"
|
" * 0x01 Tell which resource is parsed (verbose mode)\n"
|
||||||
" * 0x02 Dump internal structures\n"
|
" * 0x02 Dump internal structures\n"
|
||||||
|
@ -111,7 +112,8 @@ int no_preprocess = 0;
|
||||||
int old_names = 0;
|
int old_names = 0;
|
||||||
int do_win32 = 1;
|
int do_win32 = 1;
|
||||||
int do_win64 = 1;
|
int do_win64 = 1;
|
||||||
int packing = 8;
|
int win32_packing = 8;
|
||||||
|
int win64_packing = 8;
|
||||||
|
|
||||||
char *input_name;
|
char *input_name;
|
||||||
char *header_name;
|
char *header_name;
|
||||||
|
@ -150,11 +152,13 @@ enum {
|
||||||
PREFIX_CLIENT_OPTION,
|
PREFIX_CLIENT_OPTION,
|
||||||
PREFIX_SERVER_OPTION,
|
PREFIX_SERVER_OPTION,
|
||||||
WIN32_OPTION,
|
WIN32_OPTION,
|
||||||
WIN64_OPTION
|
WIN64_OPTION,
|
||||||
|
WIN32_ALIGN_OPTION,
|
||||||
|
WIN64_ALIGN_OPTION
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char short_options[] =
|
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[] = {
|
static const struct option long_options[] = {
|
||||||
{ "dlldata", 1, 0, DLLDATA_OPTION },
|
{ "dlldata", 1, 0, DLLDATA_OPTION },
|
||||||
{ "dlldata-only", 0, 0, DLLDATA_ONLY_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 },
|
{ "prefix-server", 1, 0, PREFIX_SERVER_OPTION },
|
||||||
{ "win32", 0, 0, WIN32_OPTION },
|
{ "win32", 0, 0, WIN32_OPTION },
|
||||||
{ "win64", 0, 0, WIN64_OPTION },
|
{ "win64", 0, 0, WIN64_OPTION },
|
||||||
|
{ "win32-align", 1, 0, WIN32_ALIGN_OPTION },
|
||||||
|
{ "win64-align", 1, 0, WIN64_ALIGN_OPTION },
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -522,9 +528,14 @@ int main(int argc,char *argv[])
|
||||||
do_win32 = 0;
|
do_win32 = 0;
|
||||||
do_win64 = 1;
|
do_win64 = 1;
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case WIN32_ALIGN_OPTION:
|
||||||
packing = strtol(optarg, NULL, 0);
|
win32_packing = strtol(optarg, NULL, 0);
|
||||||
if(packing != 2 && packing != 4 && packing != 8)
|
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");
|
error("Packing must be one of 2, 4 or 8\n");
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
|
|
|
@ -46,7 +46,8 @@ extern int do_dlldata;
|
||||||
extern int old_names;
|
extern int old_names;
|
||||||
extern int do_win32;
|
extern int do_win32;
|
||||||
extern int do_win64;
|
extern int do_win64;
|
||||||
extern int packing;
|
extern int win32_packing;
|
||||||
|
extern int win64_packing;
|
||||||
|
|
||||||
extern char *input_name;
|
extern char *input_name;
|
||||||
extern char *header_name;
|
extern char *header_name;
|
||||||
|
|
Loading…
Reference in New Issue