21#ifndef __WINE_WINE_ASM_H
22#define __WINE_WINE_ASM_H
24#if defined(__APPLE__) || (defined(_WIN32) && defined(__i386__))
25# define __ASM_NAME(name) "_" name
27# define __ASM_NAME(name) name
30#if defined(_WIN32) && defined(__i386__)
31# define __ASM_STDCALL(name,args) __ASM_NAME(name) "@" #args
33# define __ASM_STDCALL(name,args) __ASM_NAME(name)
36#if defined(__GCC_HAVE_DWARF2_CFI_ASM) || defined(__APPLE__)
37# define __ASM_CFI(str) str
39# define __ASM_CFI(str)
43# define __ASM_SEH(str) str
45# define __ASM_SEH(str)
49# define __ASM_FUNC_TYPE(name) ".def " name "; .scl 2; .type 32; .endef"
50#elif defined(__APPLE__)
51# define __ASM_FUNC_TYPE(name) ""
52#elif defined(__arm__) || defined(__arm64__)
53# define __ASM_FUNC_TYPE(name) ".type " name ",%function"
55# define __ASM_FUNC_TYPE(name) ".type " name ",@function"
58#if !defined(__GNUC__) && !defined(__clang__)
59# define __ASM_BLOCK_BEGIN(name) void __asm_dummy_##name(void) {
60# define __ASM_BLOCK_END }
62# define __ASM_BLOCK_BEGIN(name)
63# define __ASM_BLOCK_END
68# define __ASM_DEFINE_FUNC(name,code)
69#elif defined(__GNUC__)
70# define __ASM_DEFINE_FUNC(name,code) \
71 asm(".text\n\t.align 4\n\t.globl " name "\n\t" __ASM_FUNC_TYPE(name) __ASM_SEH("\n\t.seh_proc " name) "\n" name ":\n\t" \
72 __ASM_CFI(".cfi_startproc\n\t") code __ASM_CFI("\n\t.cfi_endproc") __ASM_SEH("\n\t.seh_endproc") );
74# define __ASM_DEFINE_FUNC(name,code) void __asm_dummy_##__LINE__(void) { \
75 asm(".text\n\t.align 4\n\t.globl " name "\n\t" __ASM_FUNC_TYPE(name) __ASM_SEH("\n\t.seh_proc " name) "\n" name ":\n\t" \
76 __ASM_CFI(".cfi_startproc\n\t") code __ASM_CFI("\n\t.cfi_endproc") __ASM_SEH("\n\t.seh_endproc") ); }
79#define __ASM_GLOBAL_FUNC(name,code) __ASM_DEFINE_FUNC(__ASM_NAME(#name),code)
81#define __ASM_STDCALL_FUNC(name,args,code) __ASM_DEFINE_FUNC(__ASM_STDCALL(#name,args),code)
85#if defined(__i386__) && !defined(_WIN32)
87# define DEFINE_FASTCALL1_WRAPPER(func) \
88 __ASM_STDCALL_FUNC( __fastcall_ ## func, 4, \
92 "jmp " __ASM_STDCALL(#func,4) )
93# define DEFINE_FASTCALL_WRAPPER(func,args) \
94 __ASM_STDCALL_FUNC( __fastcall_ ## func, args, \
99 "jmp " __ASM_STDCALL(#func,args) )
103# define DEFINE_FASTCALL1_WRAPPER(func)
104# define DEFINE_FASTCALL_WRAPPER(func,args)
111#define __thiscall __stdcall
114#if defined(__i386__) && !defined(__MINGW32__)
119# define DEFINE_THISCALL_WRAPPER(func,args) \
120 __declspec(naked) void __thiscall_##func(void) \
128# define DEFINE_THISCALL_WRAPPER(func,args) \
129 __declspec(naked) void __thiscall_##func(void) \
138# define DEFINE_THISCALL_WRAPPER(func,args) \
139 extern void __thiscall_ ## func(void); \
140 __ASM_STDCALL_FUNC( __thiscall_ ## func, args, \
144 "jmp " __ASM_STDCALL(#func,args) )
147# define THISCALL(func) (void *)__thiscall_ ## func
148# define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func)
152# define DEFINE_THISCALL_WRAPPER(func,args)
153# define THISCALL(func) func
154# define THISCALL_NAME(func) __ASM_NAME(#func)