Mercurial > pub > dyncall > dyncall
annotate test/suite_x86win32fast/case.cc @ 606:85b7a117b807
- more statics in test code (this is partly needed on an experimental freebsd sparc64 build where the elf cleanup code crashes for some reason ... it's probably that experimental build, but a good change to do regardless)
author | Tassilo Philipp |
---|---|
date | Wed, 21 Sep 2022 15:20:58 +0200 |
parents | 90dfdac91b9b |
children |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: test | |
5 File: test/suite_x86win32fast/case.cc | |
6 Description: | |
7 License: | |
8 | |
606
85b7a117b807
- more statics in test code (this is partly needed on an experimental freebsd sparc64 build where the elf cleanup code crashes for some reason ... it's probably that experimental build, but a good change to do regardless)
Tassilo Philipp
parents:
604
diff
changeset
|
9 Copyright (c) 2007-2022 Daniel Adler <dadler@uni-goettingen.de>, |
0 | 10 Tassilo Philipp <tphilipp@potion-studios.com> |
11 | |
12 Permission to use, copy, modify, and distribute this software for any | |
13 purpose with or without fee is hereby granted, provided that the above | |
14 copyright notice and this permission notice appear in all copies. | |
15 | |
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
23 | |
24 */ | |
25 | |
26 | |
27 | |
28 #include "../../dyncall/dyncall.h" | |
29 #include "config.h" | |
30 #include "../../dyncall/dyncall_value.h" | |
31 | |
604
90dfdac91b9b
- cleanups, made some arrays local to TUs, etc.
Tassilo Philipp
parents:
281
diff
changeset
|
32 static DCValue mValue[NARGS]; |
0 | 33 |
34 void clearValues() { for(int i = 0;i<NARGS;++i) mValue[i].L = 0xCAFEBABEDEADC0DEULL; } | |
35 | |
36 template<typename T> void g(T value, int pos); | |
37 | |
604
90dfdac91b9b
- cleanups, made some arrays local to TUs, etc.
Tassilo Philipp
parents:
281
diff
changeset
|
38 template<> void g(DCchar value, int pos) { mValue[pos].c = value; } |
90dfdac91b9b
- cleanups, made some arrays local to TUs, etc.
Tassilo Philipp
parents:
281
diff
changeset
|
39 template<> void g(DCshort value, int pos) { mValue[pos].s = value; } |
90dfdac91b9b
- cleanups, made some arrays local to TUs, etc.
Tassilo Philipp
parents:
281
diff
changeset
|
40 template<> void g(DCint value, int pos) { mValue[pos].i = value; } |
90dfdac91b9b
- cleanups, made some arrays local to TUs, etc.
Tassilo Philipp
parents:
281
diff
changeset
|
41 template<> void g(DClong value, int pos) { mValue[pos].l = value; } |
0 | 42 template<> void g(DClonglong value, int pos) { mValue[pos].L = value; } |
604
90dfdac91b9b
- cleanups, made some arrays local to TUs, etc.
Tassilo Philipp
parents:
281
diff
changeset
|
43 template<> void g(DCfloat value, int pos) { mValue[pos].f = value; } |
90dfdac91b9b
- cleanups, made some arrays local to TUs, etc.
Tassilo Philipp
parents:
281
diff
changeset
|
44 template<> void g(DCdouble value, int pos) { mValue[pos].d = value; } |
90dfdac91b9b
- cleanups, made some arrays local to TUs, etc.
Tassilo Philipp
parents:
281
diff
changeset
|
45 template<> void g(DCpointer value, int pos) { mValue[pos].p = value; } |
0 | 46 |
47 DCValue* getArg(int pos) { return &mValue[pos]; } | |
48 | |
606
85b7a117b807
- more statics in test code (this is partly needed on an experimental freebsd sparc64 build where the elf cleanup code crashes for some reason ... it's probably that experimental build, but a good change to do regardless)
Tassilo Philipp
parents:
604
diff
changeset
|
49 static int gID; |
0 | 50 int getId() { return gID; } |
51 | |
52 #ifdef DC__C_GNU | |
53 #define API __attribute__((fastcall)) | |
54 #else | |
55 #define API __fastcall | |
56 #endif | |
57 | |
58 extern "C" { | |
59 | |
60 #define VF0(id,S) void API S () {gID=id;} | |
61 #define VF1(id,A1,S) void API S (A1 a1) {gID=id;g<A1>(a1,0);} | |
62 #define VF2(id,A1,A2,S) void API S (A1 a1, A2 a2) {gID=id;g<A1>(a1,0);g<A2>(a2,1);} | |
63 #define VF3(id,A1,A2,A3,S) void API S (A1 a1, A2 a2,A3 a3) {gID=id;g<A1>(a1,0);g<A2>(a2,1);g<A3>(a3,2);} | |
64 #define VF4(id,A1,A2,A3,A4,S) void API S (A1 a1, A2 a2,A3 a3,A4 a4) {gID=id;g<A1>(a1,0);g<A2>(a2,1);g<A3>(a3,2);g<A4>(a4,3);} | |
65 #define VF5(id,A1,A2,A3,A4,A5,S) void API S (A1 a1, A2 a2,A3 a3,A4 a4,A5 a5) {gID=id;g<A1>(a1,0);g<A2>(a2,1);g<A3>(a3,2);g<A4>(a4,3);g<A5>(a5,4);} | |
66 #define VF6(id,A1,A2,A3,A4,A5,A6,S) void API S (A1 a1, A2 a2,A3 a3,A4 a4,A5 a5,A6 a6) {gID=id;g<A1>(a1,0);g<A2>(a2,1);g<A3>(a3,2);g<A4>(a4,3);g<A5>(a5,4);g<A6>(a6,5);} | |
67 #define VF7(id,A1,A2,A3,A4,A5,A6,A7,S) void API S (A1 a1, A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7) {gID=id;g<A1>(a1,0);g<A2>(a2,1);g<A3>(a3,2);g<A4>(a4,3);g<A5>(a5,4);g<A6>(a6,5);g<A7>(a7,6);} | |
68 #define VF8(id,A1,A2,A3,A4,A5,A6,A7,A8,S) void API S (A1 a1, A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8) {gID=id;g<A1>(a1,0);g<A2>(a2,1);g<A3>(a3,2);g<A4>(a4,3);g<A5>(a5,4);g<A6>(a6,5);g<A7>(a7,6);g<A8>(a8,7);} | |
69 #define VF9(id,A1,A2,A3,A4,A5,A6,A7,A8,A9,S) void API S (A1 a1, A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9) {gID=id;g<A1>(a1,0);g<A2>(a2,1);g<A3>(a3,2);g<A4>(a4,3);g<A5>(a5,4);g<A6>(a6,5);g<A7>(a7,6);g<A8>(a8,7);g<A9>(a9,8);} | |
70 #define VF10(id,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,S) void API S (A1 a1, A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9,A10 a10) {gID=id;g<A1>(a1,0);g<A2>(a2,1);g<A3>(a3,2);g<A4>(a4,3);g<A5>(a5,4);g<A6>(a6,5);g<A7>(a7,6);g<A8>(a8,7);g<A9>(a9,8);g<A10>(a10,9);} | |
71 | |
72 #include "case.h" | |
73 | |
74 } | |
75 | |
76 #undef VF0 | |
77 #undef VF1 | |
78 #undef VF2 | |
79 #undef VF3 | |
80 #undef VF4 | |
81 #undef VF5 | |
82 #undef VF6 | |
83 #undef VF7 | |
84 #undef VF8 | |
85 #undef VF9 | |
86 #undef VF10 | |
87 | |
88 #define VF0(id,S) reinterpret_cast<void(*)()>(S), | |
89 #define VF1(id,A1,S) reinterpret_cast<void(*)()>(S), | |
90 #define VF2(id,A1,A2,S) reinterpret_cast<void(*)()>(S), | |
91 #define VF3(id,A1,A2,A3,S) reinterpret_cast<void(*)()>(S), | |
92 #define VF4(id,A1,A2,A3,A4,S) reinterpret_cast<void(*)()>(S), | |
93 #define VF5(id,A1,A2,A3,A4,A5,S) reinterpret_cast<void(*)()>(S), | |
94 #define VF6(id,A1,A2,A3,A4,A5,A6,S) reinterpret_cast<void(*)()>(S), | |
95 #define VF7(id,A1,A2,A3,A4,A5,A6,A7,S) reinterpret_cast<void(*)()>(S), | |
96 #define VF8(id,A1,A2,A3,A4,A5,A6,A7,A8,S) reinterpret_cast<void(*)()>(S), | |
97 #define VF9(id,A1,A2,A3,A4,A5,A6,A7,A8,A9,S) reinterpret_cast<void(*)()>(S), | |
98 #define VF10(id,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,S) reinterpret_cast<void(*)()>(S), | |
99 | |
100 typedef void (*fp)(); | |
604
90dfdac91b9b
- cleanups, made some arrays local to TUs, etc.
Tassilo Philipp
parents:
281
diff
changeset
|
101 static fp gFuncTable[] = { |
0 | 102 #include "case.h" |
103 }; | |
104 | |
105 DCpointer getFunc(int x) { | |
106 return (DCpointer) gFuncTable[x]; | |
107 } | |
604
90dfdac91b9b
- cleanups, made some arrays local to TUs, etc.
Tassilo Philipp
parents:
281
diff
changeset
|
108 |