include: Add asm helper macros to define import variables.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-11-24 11:42:29 +01:00
parent 79d8ed4849
commit d2452b572c
2 changed files with 24 additions and 6 deletions

View File

@ -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)

View File

@ -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)