From 7aee90762a50cf6412ef44438f6dba0e3a7f3dbc Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 18 Oct 2002 00:29:32 +0000 Subject: [PATCH] Merged wine_call_to_16_long and wine_call_to_16_short into a single function. --- dlls/kernel/kernel32.spec | 3 +- dlls/kernel/wowthunk.c | 2 +- if1632/relay.c | 12 ++------ include/wine/winbase16.h | 3 +- scheduler/thread.c | 2 +- tools/winebuild/relay.c | 59 ++++++++++++++------------------------- tools/winebuild/spec16.c | 6 ++-- 7 files changed, 29 insertions(+), 58 deletions(-) diff --git a/dlls/kernel/kernel32.spec b/dlls/kernel/kernel32.spec index bf12387128b..57aa909075b 100644 --- a/dlls/kernel/kernel32.spec +++ b/dlls/kernel/kernel32.spec @@ -1026,8 +1026,7 @@ init MAIN_KernelInit @ varargs __wine_call_from_16_word() __wine_call_from_16_word @ varargs __wine_call_from_16_long() __wine_call_from_16_long @ varargs __wine_call_from_16_regs() __wine_call_from_16_regs -@ stdcall wine_call_to_16_word(ptr long) wine_call_to_16_word -@ stdcall wine_call_to_16_long(ptr long) wine_call_to_16_long +@ stdcall wine_call_to_16(ptr long) wine_call_to_16 @ stdcall wine_call_to_16_regs_short(ptr long) wine_call_to_16_regs_short @ stdcall wine_call_to_16_regs_long (ptr long) wine_call_to_16_regs_long diff --git a/dlls/kernel/wowthunk.c b/dlls/kernel/wowthunk.c index 0c967061933..80b106eed81 100644 --- a/dlls/kernel/wowthunk.c +++ b/dlls/kernel/wowthunk.c @@ -285,7 +285,7 @@ BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags, * stack pointer is always reset to the position it had before. */ - ret = wine_call_to_16_long( (FARPROC16)vpfn16, cbArgs ); + ret = wine_call_to_16( (FARPROC16)vpfn16, cbArgs ); if ( pdwRetCode ) *pdwRetCode = ret; diff --git a/if1632/relay.c b/if1632/relay.c index 2da0d29c065..d94ec7a67f7 100644 --- a/if1632/relay.c +++ b/if1632/relay.c @@ -80,17 +80,9 @@ BOOL RELAY_Init(void) */ #ifndef __i386__ /*********************************************************************** - * wine_call_to_16_word (KERNEL32.@) + * wine_call_to_16 (KERNEL32.@) */ -WORD WINAPI wine_call_to_16_word( FARPROC16 target, INT nArgs ) -{ - assert( FALSE ); -} - -/*********************************************************************** - * wine_call_to_16_long (KERNEL32.@) - */ -LONG WINAPI wine_call_to_16_long( FARPROC16 target, INT nArgs ) +LONG WINAPI wine_call_to_16( FARPROC16 target, INT nArgs ) { assert( FALSE ); } diff --git a/include/wine/winbase16.h b/include/wine/winbase16.h index 1eb9d91628c..7398679033e 100644 --- a/include/wine/winbase16.h +++ b/include/wine/winbase16.h @@ -380,8 +380,7 @@ BOOL16 WINAPI WritePrivateProfileStruct16(LPCSTR,LPCSTR,LPVOID,UINT16,LPCST BOOL16 WINAPI WriteProfileSection16(LPCSTR,LPCSTR); /* Wine-specific functions */ -WORD WINAPI wine_call_to_16_word( FARPROC16 target, INT nArgs ); -LONG WINAPI wine_call_to_16_long( FARPROC16 target, INT nArgs ); +LONG WINAPI wine_call_to_16( FARPROC16 target, INT nArgs ); void WINAPI wine_call_to_16_regs_short( CONTEXT86 *context, INT nArgs ); void WINAPI wine_call_to_16_regs_long ( CONTEXT86 *context, INT nArgs ); diff --git a/scheduler/thread.c b/scheduler/thread.c index 09b9288f89e..ab26e710dc6 100644 --- a/scheduler/thread.c +++ b/scheduler/thread.c @@ -337,7 +337,7 @@ static DWORD CALLBACK THREAD_StartThread16( LPVOID threadArgs ) HeapFree( GetProcessHeap(), 0, threadArgs ); ((LPDWORD)CURRENT_STACK16)[-1] = param; - return wine_call_to_16_long( start, sizeof(DWORD) ); + return wine_call_to_16( start, sizeof(DWORD) ); } HANDLE WINAPI CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack, FARPROC16 start, SEGPTR param, diff --git a/tools/winebuild/relay.c b/tools/winebuild/relay.c index f9e48c8c363..a014df4c947 100644 --- a/tools/winebuild/relay.c +++ b/tools/winebuild/relay.c @@ -447,8 +447,7 @@ static void BuildCallFrom16Core( FILE *outfile, int reg_func, int thunk, int sho * * This routine builds the core routines used in 32->16 thunks: * - * extern void WINAPI wine_call_to_16_word( SEGPTR target, int nb_args ); - * extern void WINAPI wine_call_to_16_long( SEGPTR target, int nb_args ); + * extern LONG WINAPI wine_call_to_16( SEGPTR target, int nb_args ); * extern void WINAPI wine_call_to_16_regs_short( const CONTEXT86 *context, int nb_args ); * extern void WINAPI wine_call_to_16_regs_long ( const CONTEXT86 *context, int nb_args ); * @@ -469,17 +468,14 @@ static void BuildCallFrom16Core( FILE *outfile, int reg_func, int thunk, int sho * core routine. * */ -static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func ) +static void BuildCallTo16Core( FILE *outfile, int reg_func ) { - char *name = reg_func == 2 ? "regs_long" : - reg_func == 1 ? "regs_short" : - short_ret? "word" : "long"; + const char *name = reg_func == 2 ? "wine_call_to_16_regs_long" : + reg_func == 1 ? "wine_call_to_16_regs_short" : + "wine_call_to_16"; /* Function header */ - if (reg_func == 2) function_header( outfile, "wine_call_to_16_regs_long" ); - else if (reg_func == 1) function_header( outfile, "wine_call_to_16_regs_short" ); - else if (short_ret) function_header( outfile, "wine_call_to_16_word" ); - else function_header( outfile, "wine_call_to_16_long" ); + function_header( outfile, name ); /* Function entry sequence */ fprintf( outfile, "\tpushl %%ebp\n" ); @@ -495,10 +491,10 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func ) if ( UsePIC ) { /* Get Global Offset Table into %ebx */ - fprintf( outfile, "\tcall .Lwine_call_to_16_%s.getgot1\n", name ); - fprintf( outfile, ".Lwine_call_to_16_%s.getgot1:\n", name ); + fprintf( outfile, "\tcall .L%s.getgot1\n", name ); + fprintf( outfile, ".L%s.getgot1:\n", name ); fprintf( outfile, "\tpopl %%ebx\n" ); - fprintf( outfile, "\taddl $_GLOBAL_OFFSET_TABLE_+[.-.Lwine_call_to_16_%s.getgot1], %%ebx\n", name ); + fprintf( outfile, "\taddl $_GLOBAL_OFFSET_TABLE_+[.-.L%s.getgot1], %%ebx\n", name ); } /* Print debugging info */ @@ -543,7 +539,7 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func ) /* Call the actual CallTo16 routine (simulate a lcall) */ fprintf( outfile, "\tpushl %%cs\n" ); - fprintf( outfile, "\tcall .Lwine_call_to_16_%s\n", reg_func ? name : "long" ); + fprintf( outfile, "\tcall .L%s\n", name ); /* Remove exception frame */ fprintf( outfile, "\t.byte 0x64\n\tpopl (%d)\n", STRUCTOFFSET(TEB,except) ); @@ -553,17 +549,9 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func ) if ( !reg_func ) { /* Convert and push return value */ - if ( short_ret ) - { - fprintf( outfile, "\tmovzwl %%ax, %%eax\n" ); - fprintf( outfile, "\tpushl %%eax\n" ); - } - else - { - fprintf( outfile, "\tshll $16,%%edx\n" ); - fprintf( outfile, "\tmovw %%ax,%%dx\n" ); - fprintf( outfile, "\tpushl %%edx\n" ); - } + fprintf( outfile, "\tshll $16,%%edx\n" ); + fprintf( outfile, "\tmovw %%ax,%%dx\n" ); + fprintf( outfile, "\tpushl %%edx\n" ); } else { @@ -594,10 +582,10 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func ) if ( UsePIC ) { /* Get Global Offset Table into %ebx (might have been overwritten) */ - fprintf( outfile, "\tcall .Lwine_call_to_16_%s.getgot2\n", name ); - fprintf( outfile, ".Lwine_call_to_16_%s.getgot2:\n", name ); + fprintf( outfile, "\tcall .L%s.getgot2\n", name ); + fprintf( outfile, ".L%s.getgot2:\n", name ); fprintf( outfile, "\tpopl %%ebx\n" ); - fprintf( outfile, "\taddl $_GLOBAL_OFFSET_TABLE_+[.-.Lwine_call_to_16_%s.getgot2], %%ebx\n", name ); + fprintf( outfile, "\taddl $_GLOBAL_OFFSET_TABLE_+[.-.L%s.getgot2], %%ebx\n", name ); } /* Leave Win16 Mutex */ @@ -636,9 +624,7 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func ) /* Start of the actual CallTo16 routine */ - if (!reg_func && short_ret) return; /* call_to_16_word uses call_to_16_long backend routine */ - - fprintf( outfile, ".Lwine_call_to_16_%s:\n", name ); + fprintf( outfile, ".L%s:\n", name ); /* Switch to the 16-bit stack */ fprintf( outfile, "\tmovl %%esp,%%edx\n" ); @@ -1200,17 +1186,14 @@ void BuildRelays16( FILE *outfile ) /* C16ThkSL CallFrom16 routine */ BuildCallFrom16Core( outfile, FALSE, TRUE, FALSE ); - /* Standard CallTo16 routine (WORD return) */ - BuildCallTo16Core( outfile, TRUE, FALSE ); - - /* Standard CallTo16 routine (DWORD return) */ - BuildCallTo16Core( outfile, FALSE, FALSE ); + /* Standard CallTo16 routine */ + BuildCallTo16Core( outfile, 0 ); /* Register CallTo16 routine (16:16 retf) */ - BuildCallTo16Core( outfile, FALSE, 1 ); + BuildCallTo16Core( outfile, 1 ); /* Register CallTo16 routine (16:32 retf) */ - BuildCallTo16Core( outfile, FALSE, 2 ); + BuildCallTo16Core( outfile, 2 ); /* CBClientThunkSL routine */ BuildCallTo32CBClient( outfile, FALSE ); diff --git a/tools/winebuild/spec16.c b/tools/winebuild/spec16.c index 80720cac053..54da5cd6581 100644 --- a/tools/winebuild/spec16.c +++ b/tools/winebuild/spec16.c @@ -505,8 +505,7 @@ static void BuildCallTo16Func( FILE *outfile, const char *profile, const char *p fprintf( outfile, " *)args = arg%d;\n", i+1 ); } - fprintf( outfile, " return wine_call_to_16_%s( proc, %d );\n}\n\n", - short_ret? "word" : "long", argsize ); + fprintf( outfile, " return wine_call_to_16( proc, %d );\n}\n\n", argsize ); #else /* __i386__ */ fprintf( outfile, " assert(0);\n}\n\n" ); #endif /* __i386__ */ @@ -914,8 +913,7 @@ void BuildGlue( FILE *outfile, const char *srcdir, char **argv ) output_file_header( outfile ); #ifdef __i386__ - fprintf( outfile, "extern unsigned short __stdcall wine_call_to_16_word( void (*target)(), int args );\n" ); - fprintf( outfile, "extern unsigned int __stdcall wine_call_to_16_long( void (*target)(), int args );\n\n" ); + fprintf( outfile, "extern unsigned int __stdcall wine_call_to_16( void (*target)(), int args );\n\n" ); #else fprintf( outfile, "#include \n\n" ); #endif