1
2 #include <stdio.h>
3
4 #ifdef __GNUC__
5 #endif
6
7 __declspec(dllimport) int __cdecl CdeclFunc0(void);
8 __declspec(dllimport) int __cdecl CdeclFunc1(char* a1);
9 __declspec(dllimport) int __cdecl CdeclFunc2(char* a1);
10 __declspec(dllimport) int __cdecl CdeclFunc3(char* a1);
11
12 __declspec(dllimport) int __stdcall StdcallFunc0(void);
13 __declspec(dllimport) int __stdcall StdcallFunc1(char* a1);
14 __declspec(dllimport) int __stdcall StdcallFunc2(char* a1);
15 __declspec(dllimport) int __stdcall StdcallFunc3(char* a1);
16 __declspec(dllimport) int __stdcall StdcallFunc4(char* a1);
17 __declspec(dllimport) int __stdcall StdcallFunc5(char* a1);
18
19 __declspec(dllimport) int __stdcall DecoratedStdcallFunc1(char* a1);
20 __declspec(dllimport) int __stdcall DecoratedStdcallFunc2(char* a1);
21 __declspec(dllimport) int __stdcall DecoratedStdcallFunc3(char* a1);
22 __declspec(dllimport) int __stdcall DecoratedStdcallFunc4(char* a1);
23 __declspec(dllimport) int __stdcall DecoratedStdcallFunc5(char* a1);
24
25 __declspec(dllimport) int __fastcall FastcallFunc0(void);
26 __declspec(dllimport) int __fastcall FastcallFunc1(char* a1);
27 __declspec(dllimport) int __fastcall FastcallFunc2(char* a1);
28 __declspec(dllimport) int __fastcall FastcallFunc3(char* a1);
29 __declspec(dllimport) int __fastcall FastcallFunc4(char* a1);
30 __declspec(dllimport) int __fastcall FastcallFunc5(char* a1);
31
32 __declspec(dllimport) int __fastcall DecoratedFastcallFunc1(char* a1);
33 __declspec(dllimport) int __fastcall DecoratedFastcallFunc2(char* a1);
34 __declspec(dllimport) int __fastcall DecoratedFastcallFunc3(char* a1);
35 __declspec(dllimport) int __fastcall DecoratedFastcallFunc4(char* a1);
36 __declspec(dllimport) int __fastcall DecoratedFastcallFunc5(char* a1);
37
38 __declspec(dllimport) extern int DataItem1;
39 __declspec(dllimport) extern int DataItem2;
40 __declspec(dllimport) extern int DataItem3;
41
42 #define ok_int(a, b) \
43 if ((a) != (b)) { printf("wrong result in line %d, expected 0x%x, got 0x%x\n", __LINE__, (b), (a)); }
44
main(int argc,char * argv[])45 int main(int argc, char *argv[])
46 {
47 char* str = "defaultstring";
48
49 if (argc > 2)
50 str = argv[1];
51
52 ok_int(CdeclFunc0(), 0);
53 ok_int(CdeclFunc1(str), 1);
54 ok_int(CdeclFunc2(str), 1);
55 ok_int(CdeclFunc3(str), 0x10001);
56
57 ok_int(StdcallFunc0(), 0x10);
58 ok_int(StdcallFunc1(str), 0x11);
59 ok_int(StdcallFunc2(str), 0x11);
60 ok_int(StdcallFunc3(str), 0x10011);
61 #ifdef _M_IX86
62 ok_int(StdcallFunc4(str), 0x21);
63 #endif
64 ok_int(StdcallFunc5(str), 0x10021);
65
66 #ifdef _M_IX86
67 ok_int(DecoratedStdcallFunc1(str), 0x21);
68 ok_int(DecoratedStdcallFunc2(str), 0x11);
69 //ok_int(DecoratedStdcallFunc3(str), 11);
70 ok_int(DecoratedStdcallFunc4(str), 0x21);
71 ok_int(DecoratedStdcallFunc5(str), 0x10021);
72 #endif
73 ok_int(FastcallFunc0(), 0x30);
74 ok_int(FastcallFunc1(str), 0x31);
75 ok_int(FastcallFunc2(str), 0x31);
76 ok_int(FastcallFunc3(str), 0x10031);
77 #ifdef _M_IX86
78 ok_int(FastcallFunc4(str), 0x42);
79 ok_int(FastcallFunc5(str), 0x10041);
80 #endif
81 #ifdef _M_IX86
82 ok_int(DecoratedFastcallFunc1(str), 0x42);
83 ok_int(DecoratedFastcallFunc2(str), 0x31);
84 //ok_int(DecoratedFastcallFunc3(str), 11);
85 ok_int(DecoratedFastcallFunc4(str), 0x42);
86 ok_int(DecoratedFastcallFunc5(str), 0x10041);
87 #endif
88 ok_int(DataItem1, 0x51);
89 ok_int(DataItem2, 0x51);
90 ok_int(DataItem3, 0x10051);
91
92 printf("done.\n");
93
94 return 0;
95 }
96