-
Notifications
You must be signed in to change notification settings - Fork 171
/
nativecall_dyncall.h
108 lines (106 loc) · 5.35 KB
/
nativecall_dyncall.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
MVMint16 MVM_nativecall_get_calling_convention(MVMThreadContext *tc, MVMString *name);
#define MVM_nativecall_load_lib(path) dlLoadLibrary(path)
#define MVM_nativecall_free_lib(lib) dlFreeLibrary(lib)
#define MVM_nativecall_find_sym(lib, name) dlFindSymbol(lib, name)
#ifdef MVM_WCHAR_UNSIGNED
# if MVM_WCHAR_SIZE == 1
# define MVM_WCHAR_DC_SIG_CHAR 'C'
# define MVM_WCHAR_DC_TYPE DCuchar
# define MVM_WCHAR_DC_ARG dcArgChar
# define MVM_WCHAR_DC_CALL(vm, entry_point) (MVMwchar)dcCallChar((vm), (entry_point))
# define MVM_WCHAR_DCB_ARG(cb_args) dcbArgUChar((cb_args))
# elif MVM_WCHAR_SIZE == 2
# define MVM_WCHAR_DC_SIG_CHAR 'S'
# define MVM_WCHAR_DC_TYPE DCushort
# define MVM_WCHAR_DC_ARG dcArgShort
# define MVM_WCHAR_DC_CALL(vm, entry_point) (MVMwchar)dcCallShort((vm), (entry_point))
# define MVM_WCHAR_DCB_ARG(cb_args) dcbArgUShort((cb_args))
# elif MVM_WCHAR_SIZE == 4
# define MVM_WCHAR_DC_SIG_CHAR 'I'
# define MVM_WCHAR_DC_TYPE DCuint
# define MVM_WCHAR_DC_ARG dcArgInt
# define MVM_WCHAR_DC_CALL(vm, entry_point) (MVMwchar)dcCallInt((vm), (entry_point))
# define MVM_WCHAR_DCB_ARG(cb_args) dcbArgUInt((cb_args))
# elif MVM_WCHAR_SIZE == 8
# define MVM_WCHAR_DC_SIG_CHAR 'L'
# define MVM_WCHAR_DC_TYPE DCulonglong
# define MVM_WCHAR_DC_ARG dcArgLongLong
# define MVM_WCHAR_DC_CALL(vm, entry_point) (MVMwchar)dcCallLongLong((vm), (entry_point))
# define MVM_WCHAR_DCB_ARG(cb_args) dcbArgULongLong((cb_args))
# else
# error "Unsupported wchar_t size"
# endif
#else
# if MVM_WCHAR_SIZE == 1
# define MVM_WCHAR_DC_SIG_CHAR 'c'
# define MVM_WCHAR_DC_TYPE DCchar
# define MVM_WCHAR_DC_ARG dcArgChar
# define MVM_WCHAR_DC_CALL(vm, entry_point) (MVMwchar)dcCallChar((vm), (entry_point))
# define MVM_WCHAR_DCB_ARG(cb_args) dcbArgChar((cb_args))
# elif MVM_WCHAR_SIZE == 2
# define MVM_WCHAR_DC_SIG_CHAR 's'
# define MVM_WCHAR_DC_TYPE DCshort
# define MVM_WCHAR_DC_ARG dcArgShort
# define MVM_WCHAR_DC_CALL(vm, entry_point) (MVMwchar)dcCallShort((vm), (entry_point))
# define MVM_WCHAR_DCB_ARG(cb_args) dcbArgShort((cb_args))
# elif MVM_WCHAR_SIZE == 4
# define MVM_WCHAR_DC_SIG_CHAR 'i'
# define MVM_WCHAR_DC_TYPE DCint
# define MVM_WCHAR_DC_ARG dcArgInt
# define MVM_WCHAR_DC_CALL(vm, entry_point) (MVMwchar)dcCallInt((vm), (entry_point))
# define MVM_WCHAR_DCB_ARG(cb_args) dcbArgInt((cb_args))
# elif MVM_WCHAR_SIZE == 8
# define MVM_WCHAR_DC_SIG_CHAR 'l'
# define MVM_WCHAR_DC_TYPE DClonglong
# define MVM_WCHAR_DC_ARG dcArgLongLong
# define MVM_WCHAR_DC_CALL(vm, entry_point) (MVMwchar)dcCallLongLong((vm), (entry_point))
# define MVM_WCHAR_DCB_ARG(cb_args) dcbArgLongLong((cb_args))
# else
# error "Unsupported wchar_t size"
# endif
#endif
#ifdef MVM_WINT_UNSIGNED
# if MVM_WINT_SIZE == 2
# define MVM_WINT_DC_SIG_CHAR 'S'
# define MVM_WINT_DC_TYPE DCushort
# define MVM_WINT_DC_ARG dcArgShort
# define MVM_WINT_DC_CALL(vm, entry_point) (MVMwint)dcCallShort((vm), (entry_point))
# define MVM_WINT_DCB_ARG(cb_args) dcbArgUShort((cb_args))
# elif MVM_WINT_SIZE == 4
# define MVM_WINT_DC_SIG_CHAR 'I'
# define MVM_WINT_DC_TYPE DCuint
# define MVM_WINT_DC_ARG dcArgInt
# define MVM_WINT_DC_CALL(vm, entry_point) (MVMwint)dcCallInt((vm), (entry_point))
# define MVM_WINT_DCB_ARG(cb_args) dcbArgUInt((cb_args))
# elif MVM_WINT_SIZE == 8
# define MVM_WINT_DC_SIG_CHAR 'L'
# define MVM_WINT_DC_TYPE DCulonglong
# define MVM_WINT_DC_ARG dcArgLongLong
# define MVM_WINT_DC_CALL(vm, entry_point) (MVMwint)dcCallLongLong((vm), (entry_point))
# define MVM_WINT_DCB_ARG(cb_args) dcbArgULongLong((cb_args))
# else
# error "Unsupported wint_t size"
# endif
#else
# if MVM_WINT_SIZE == 2
# define MVM_WINT_DC_SIG_CHAR 's'
# define MVM_WINT_DC_TYPE DCshort
# define MVM_WINT_DC_ARG dcArgShort
# define MVM_WINT_DC_CALL(vm, entry_point) (MVMwint)dcCallShort((vm), (entry_point))
# define MVM_WINT_DCB_ARG(cb_args) dcbArgShort((cb_args))
# elif MVM_WINT_SIZE == 4
# define MVM_WINT_DC_SIG_CHAR 'i'
# define MVM_WINT_DC_TYPE DCint
# define MVM_WINT_DC_ARG dcArgInt
# define MVM_WINT_DC_CALL(vm, entry_point) (MVMwint)dcCallInt((vm), (entry_point))
# define MVM_WINT_DCB_ARG(cb_args) dcbArgInt((cb_args))
# elif MVM_WINT_SIZE == 8
# define MVM_WINT_DC_SIG_CHAR 'l'
# define MVM_WINT_DC_TYPE DClonglong
# define MVM_WINT_DC_ARG dcArgLongLong
# define MVM_WINT_DC_CALL(vm, entry_point) (MVMwint)dcCallLongLong((vm), (entry_point))
# define MVM_WINT_DCB_ARG(cb_args) dcbArgLongLong((cb_args))
# else
# error "Unsupported wint_t size"
# endif
#endif