Module: wine Branch: master Commit: d2452b572c045582bc7168c3f54081921d30376e URL: https://source.winehq.org/git/wine.git/?a=commit;h=d2452b572c045582bc7168c3f...
Author: Alexandre Julliard julliard@winehq.org Date: Tue Nov 24 11:42:29 2020 +0100
include: Add asm helper macros to define import variables.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/msvcrt/iob.c | 8 ++------ include/wine/asm.h | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/dlls/msvcrt/iob.c b/dlls/msvcrt/iob.c index a499f19309e..4d8456867a8 100644 --- a/dlls/msvcrt/iob.c +++ b/dlls/msvcrt/iob.c @@ -24,6 +24,7 @@ #endif
#include <stdio.h> +#include <wine/asm.h>
#undef __iob_func extern FILE * __cdecl __iob_func(void); @@ -35,9 +36,4 @@ FILE * __cdecl __acrt_iob_func(unsigned idx) { return __iob_func() + idx; } - -#ifdef __i386__ -void *_imp____acrt_iob_func = __acrt_iob_func; -#else -void *__imp___acrt_iob_func = __acrt_iob_func; -#endif +__ASM_GLOBAL_IMPORT(__acrt_iob_func) diff --git a/include/wine/asm.h b/include/wine/asm.h index 2d1607ca772..b4b6fb50eb8 100644 --- a/include/wine/asm.h +++ b/include/wine/asm.h @@ -83,6 +83,28 @@ #define __ASM_STDCALL_FUNC(name,args,code) __ASM_DEFINE_FUNC(__ASM_STDCALL(#name,args),code) #define __ASM_FASTCALL_FUNC(name,args,code) __ASM_DEFINE_FUNC(__ASM_FASTCALL(#name,args),code)
+/* import variables */ + +#ifdef _WIN64 +#define __ASM_DEFINE_IMPORT(name) \ + __ASM_BLOCK_BEGIN(__LINE__) \ + asm(".data\n\t.balign 8\n\t.globl __imp_" name "\n__imp_" name ":\n\t.quad " name "\n\t.text"); \ + __ASM_BLOCK_END +#else +#define __ASM_DEFINE_IMPORT(name) \ + __ASM_BLOCK_BEGIN(__LINE__) \ + asm(".data\n\t.balign 4\n\t.globl __imp_" name "\n__imp_" name ":\n\t.long " name "\n\t.text"); \ + __ASM_BLOCK_END +#endif + +#ifdef _WIN32 +#define __ASM_GLOBAL_IMPORT(name) __ASM_DEFINE_IMPORT(__ASM_NAME(#name)) +#define __ASM_STDCALL_IMPORT(name,args) __ASM_DEFINE_IMPORT(__ASM_STDCALL(#name,args)) +#else +#define __ASM_GLOBAL_IMPORT(name) /* nothing */ +#define __ASM_STDCALL_IMPORT(name,args) /* nothing */ +#endif + /* fastcall support */
#if defined(__i386__) && !defined(_WIN32)