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"
60# define __ASM_DEFINE_FUNC(name,code)
61#elif defined(__GNUC__)
62# define __ASM_DEFINE_FUNC(name,code) \
63 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" \
64 __ASM_CFI(".cfi_startproc\n\t") code __ASM_CFI("\n\t.cfi_endproc") __ASM_SEH("\n\t.seh_endproc") );
66# define __ASM_DEFINE_FUNC(name,code) void __asm_dummy_##__LINE__(void) { \
67 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" \
68 __ASM_CFI(".cfi_startproc\n\t") code __ASM_CFI("\n\t.cfi_endproc") __ASM_SEH("\n\t.seh_endproc") ); }
71#define __ASM_GLOBAL_FUNC(name,code) __ASM_DEFINE_FUNC(__ASM_NAME(#name),code)
73#define __ASM_STDCALL_FUNC(name,args,code) __ASM_DEFINE_FUNC(__ASM_STDCALL(#name,args),code)
77#if defined(__i386__) && !defined(_WIN32)
79# define DEFINE_FASTCALL1_WRAPPER(func) \
80 __ASM_STDCALL_FUNC( __fastcall_ ## func, 4, \
84 "jmp " __ASM_STDCALL(#func,4) )
85# define DEFINE_FASTCALL_WRAPPER(func,args) \
86 __ASM_STDCALL_FUNC( __fastcall_ ## func, args, \
91 "jmp " __ASM_STDCALL(#func,args) )
95# define DEFINE_FASTCALL1_WRAPPER(func)
96# define DEFINE_FASTCALL_WRAPPER(func,args)
103#define __thiscall __stdcall
106#if defined(__i386__) && !defined(__MINGW32__)
111# define DEFINE_THISCALL_WRAPPER(func,args) \
112 __declspec(naked) void __thiscall_##func(void) \
120# define DEFINE_THISCALL_WRAPPER(func,args) \
121 __declspec(naked) void __thiscall_##func(void) \
130# define DEFINE_THISCALL_WRAPPER(func,args) \
131 extern void __thiscall_ ## func(void); \
132 __ASM_STDCALL_FUNC( __thiscall_ ## func, args, \
136 "jmp " __ASM_STDCALL(#func,args) )
139# define THISCALL(func) (void *)__thiscall_ ## func
140# define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func)
144# define DEFINE_THISCALL_WRAPPER(func,args)
145# define THISCALL(func) func
146# define THISCALL_NAME(func) __ASM_NAME(#func)