diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index 9e517c07833..d3d8f75dfc2 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -174,8 +174,7 @@ extern char *get_temp_file_name( const char *prefix, const char *suffix ); extern void output_standard_file_header( FILE *outfile ); extern FILE *open_input_file( const char *srcdir, const char *name ); extern void close_input_file( FILE *file ); -extern void dump_bytes( FILE *outfile, const unsigned char *data, int len, - const char *label, int constant ); +extern void dump_bytes( FILE *outfile, const void *buffer, unsigned int size ); extern int remove_stdcall_decoration( char *name ); extern void assemble_file( const char *src_file, const char *obj_file ); extern DLLSPEC *alloc_dll_spec(void); @@ -187,12 +186,12 @@ extern unsigned int get_page_size(void); extern unsigned int get_ptr_size(void); extern const char *asm_name( const char *func ); extern const char *func_declaration( const char *func ); -extern const char *func_size( const char *func ); extern const char *asm_globl( const char *func ); extern const char *get_asm_ptr_keyword(void); extern const char *get_asm_string_keyword(void); extern const char *get_asm_short_keyword(void); extern const char *get_asm_string_section(void); +extern void output_function_size( FILE *outfile, const char *name ); extern void add_import_dll( const char *name, const char *filename ); extern void add_delayed_import( const char *name ); diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index 61fa30daf3d..adf1387b9ff 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -205,12 +205,6 @@ inline static ORDDEF *find_export( const char *name, ORDDEF **table, int size ) return res ? *res : NULL; } -inline static void output_function_size( FILE *outfile, const char *name ) -{ - const char *size = func_size( name ); - if (size[0]) fprintf( outfile, "\t%s\n", size ); -} - /* free an import structure */ static void free_imports( struct import *imp ) { @@ -1220,7 +1214,7 @@ void output_stubs( FILE *outfile, DLLSPEC *spec ) fprintf( outfile, "\tpushl $.L__wine_spec_file_name\n" ); } fprintf( outfile, "\tcall %s\n", asm_name("__wine_spec_unimplemented_stub") ); - fprintf( outfile, "\t%s\n", func_size(name) ); + output_function_size( outfile, name ); } if (pos) diff --git a/tools/winebuild/relay.c b/tools/winebuild/relay.c index b07c909d73e..92061f999c3 100644 --- a/tools/winebuild/relay.c +++ b/tools/winebuild/relay.c @@ -40,12 +40,6 @@ static void function_header( FILE *outfile, const char *name ) } -static void function_footer( FILE *outfile, const char *name ) -{ - const char *size = func_size( name ); - if (size[0]) fprintf( outfile, "\t%s\n", size ); -} - static inline const char *data16_prefix(void) { return (target_platform == PLATFORM_SVR4) ? "\tdata16\n" : ""; @@ -350,9 +344,9 @@ static void BuildCallFrom16Core( FILE *outfile, int reg_func, int thunk ) /* Return to return stub which will return to caller */ fprintf( outfile, "\tlret $12\n" ); } - if (thunk) function_footer( outfile, "__wine_call_from_16_thunk" ); - else if (reg_func) function_footer( outfile, "__wine_call_from_16_regs" ); - else function_footer( outfile, "__wine_call_from_16" ); + if (thunk) output_function_size( outfile, "__wine_call_from_16_thunk" ); + else if (reg_func) output_function_size( outfile, "__wine_call_from_16_regs" ); + else output_function_size( outfile, "__wine_call_from_16" ); } @@ -513,7 +507,7 @@ static void BuildCallTo16Core( FILE *outfile, int reg_func ) fprintf( outfile, "\tlret\n" ); /* Function footer */ - function_footer( outfile, name ); + output_function_size( outfile, name ); } @@ -549,7 +543,7 @@ static void BuildRet16Func( FILE *outfile ) /* Return to caller */ fprintf( outfile, "\tlret\n" ); - function_footer( outfile, "__wine_call_to_16_ret" ); + output_function_size( outfile, "__wine_call_to_16_ret" ); } @@ -695,7 +689,7 @@ static void BuildCallTo32CBClient( FILE *outfile, BOOL isEx ) fprintf( outfile, "\tpopl %%edi\n" ); fprintf( outfile, "\tpopl %%ebp\n" ); fprintf( outfile, "\tret\n" ); - function_footer( outfile, isEx ? "CALL32_CBClientEx" : "CALL32_CBClient" ); + output_function_size( outfile, isEx ? "CALL32_CBClientEx" : "CALL32_CBClient" ); /* '16-bit' return stub */ @@ -713,7 +707,7 @@ static void BuildCallTo32CBClient( FILE *outfile, BOOL isEx ) fprintf( outfile, "\tlssl %%ss:-12(%%ebx), %%esp\n" ); } fprintf( outfile, "\tlret\n" ); - function_footer( outfile, isEx ? "CALL32_CBClientEx_Ret" : "CALL32_CBClient_Ret" ); + output_function_size( outfile, isEx ? "CALL32_CBClientEx_Ret" : "CALL32_CBClient_Ret" ); } @@ -842,12 +836,12 @@ static void BuildCallFrom32Regs( FILE *outfile ) fprintf( outfile, "\tpopl %%ds\n" ); fprintf( outfile, "\tiret\n" ); - function_footer( outfile, "__wine_call_from_32_regs" ); + output_function_size( outfile, "__wine_call_from_32_regs" ); function_header( outfile, "__wine_call_from_32_restore_regs" ); fprintf( outfile, "\tleal 4(%%esp),%%ecx\n" ); fprintf( outfile, "\tjmp 2b\n" ); - function_footer( outfile, "__wine_call_from_32_restore_regs" ); + output_function_size( outfile, "__wine_call_from_32_restore_regs" ); } @@ -898,7 +892,7 @@ static void BuildPendingEventCheck( FILE *outfile ) fprintf( outfile, "%s\n", asm_globl("DPMI_PendingEventCheck_Return") ); fprintf( outfile, "\tiret\n" ); - function_footer( outfile, "DPMI_PendingEventCheck" ); + output_function_size( outfile, "DPMI_PendingEventCheck" ); } @@ -952,7 +946,7 @@ void BuildRelays16( FILE *outfile ) BuildPendingEventCheck( outfile ); fprintf( outfile, "%s\n", asm_globl("__wine_call16_end") ); - function_footer( outfile, "__wine_spec_thunk_text_16" ); + output_function_size( outfile, "__wine_spec_thunk_text_16" ); /* Declare the return address and data selector variables */ fprintf( outfile, "\n\t.data\n\t.align %d\n", get_alignment(4) ); @@ -983,5 +977,5 @@ void BuildRelays32( FILE *outfile ) /* 32-bit register entry point */ BuildCallFrom32Regs( outfile ); - function_footer( outfile, "__wine_spec_thunk_text_32" ); + output_function_size( outfile, "__wine_spec_thunk_text_32" ); } diff --git a/tools/winebuild/res32.c b/tools/winebuild/res32.c index cd882cd9cbd..eb365a92672 100644 --- a/tools/winebuild/res32.c +++ b/tools/winebuild/res32.c @@ -340,7 +340,7 @@ static inline void output_res_dir( FILE *outfile, unsigned int nb_names, unsigne /* output the resource definitions */ void output_resources( FILE *outfile, DLLSPEC *spec ) { - int j, k, nb_id_types; + int k, nb_id_types; unsigned int i, n, offset, data_offset; struct res_tree *tree; struct res_type *type; @@ -453,16 +453,9 @@ void output_resources( FILE *outfile, DLLSPEC *spec ) for (i = 0, res = spec->resources; i < spec->nb_resources; i++, res++) { - const unsigned char *p = res->data; fprintf( outfile, "\n\t.align %d\n", get_alignment(get_ptr_size()) ); fprintf( outfile, ".L__wine_spec_res_%d:\n", i ); - fprintf( outfile, "\t.byte " ); - for (j = 0; j < res->data_size - 1; j++, p++) - { - if ((j % 16) == 15) fprintf( outfile, "0x%02x\n\t.byte ", *p ); - else fprintf( outfile, "0x%02x,", *p ); - } - fprintf( outfile, "0x%02x\n", *p ); + dump_bytes( outfile, res->data, res->data_size ); } fprintf( outfile, ".L__wine_spec_resources_end:\n" ); fprintf( outfile, "\t.byte 0\n" ); diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index 358514f2078..6e6dc00bea6 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -205,20 +205,19 @@ void output_standard_file_header( FILE *outfile ) } /* dump a byte stream into the assembly code */ -void dump_bytes( FILE *outfile, const unsigned char *data, int len, - const char *label, int constant ) +void dump_bytes( FILE *outfile, const void *buffer, unsigned int size ) { - int i; + unsigned int i; + const unsigned char *ptr = buffer; - fprintf( outfile, "\nstatic %sunsigned char %s[%d] = {", - constant ? "const " : "", label, len ); - for (i = 0; i < len; i++) + if (!size) return; + fprintf( outfile, "\t.byte " ); + for (i = 0; i < size - 1; i++, ptr++) { - if (!(i & 7)) fprintf( outfile, "\n " ); - fprintf( outfile, "0x%02x", *data++ ); - if (i < len - 1) fprintf( outfile, "," ); + if ((i % 16) == 15) fprintf( outfile, "0x%02x\n\t.byte ", *ptr ); + else fprintf( outfile, "0x%02x,", *ptr ); } - fprintf( outfile, "\n};\n" ); + fprintf( outfile, "0x%02x\n", *ptr ); } @@ -523,19 +522,17 @@ const char *func_declaration( const char *func ) return buffer; } -/* return a size declaration for an assembly function */ -const char *func_size( const char *func ) +/* output a size declaration for an assembly function */ +void output_function_size( FILE *outfile, const char *name ) { - static char buffer[256]; - switch (target_platform) { case PLATFORM_APPLE: case PLATFORM_WINDOWS: - return ""; + break; default: - sprintf( buffer, ".size %s, .-%s", func, func ); - return buffer; + fprintf( outfile, "\t.size %s, .-%s\n", name, name ); + break; } }