Mercurial > pub > dyncall > dyncall
annotate test/callback_suite/env.c @ 489:63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
author | Tassilo Philipp |
---|---|
date | Fri, 18 Mar 2022 12:36:49 +0100 |
parents | d8f0e6cecdab |
children |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: test | |
5 File: test/callback_suite/env.c | |
6 Description: | |
7 License: | |
8 | |
281 | 9 Copyright (c) 2011-2018 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 #include <assert.h> | |
487 | 27 #include <stdint.h> |
0 | 28 #include "dyncall_signature.h" |
29 #include "env.h" | |
30 | |
31 DCValueSet ValueMatrix[CONFIG_MAXARGS]; | |
32 | |
489
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
33 static DCValueSet K; |
0 | 34 |
35 void GetReferenceArg(DCValue* output, char ch, int pos) | |
36 { | |
37 output->L = 0xCAFEBABEDEADC0DELL; | |
38 pos = pos + 2; | |
39 switch(ch) { | |
487 | 40 case DC_SIGCHAR_BOOL: output->B = ((pos*K.i) & 1) ? DC_TRUE : DC_FALSE ; break; |
41 case DC_SIGCHAR_CHAR: output->c = pos * K.c; break; | |
42 case DC_SIGCHAR_UCHAR: output->C = pos * K.C; break; | |
43 case DC_SIGCHAR_SHORT: output->s = pos * K.s; break; | |
44 case DC_SIGCHAR_USHORT: output->S = pos * K.S; break; | |
45 case DC_SIGCHAR_INT: output->i = pos * K.i; break; | |
46 case DC_SIGCHAR_UINT: output->I = pos * K.I; break; | |
47 case DC_SIGCHAR_LONG: output->j = pos * K.j; break; | |
48 case DC_SIGCHAR_ULONG: output->J = pos * K.J; break; | |
49 case DC_SIGCHAR_LONGLONG: output->l = pos * K.l; break; | |
50 case DC_SIGCHAR_ULONGLONG:output->L = pos * K.L; break; | |
51 case DC_SIGCHAR_FLOAT: output->f = (float)pos * K.f; break; | |
52 case DC_SIGCHAR_DOUBLE: output->d = (double)pos * K.d; break; | |
53 case DC_SIGCHAR_POINTER: output->p = (DCpointer)(pos * (intptr_t)K.p); break; | |
0 | 54 default: assert(0); |
55 } | |
56 } | |
57 | |
58 void GetReferenceResult(DCValue* output, char ch) | |
59 { | |
60 GetReferenceArg(output, ch, -1); | |
61 } | |
62 | |
63 void InitEnv() | |
64 { | |
65 int pos; | |
489
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
66 |
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
67 K.B = DC_TRUE; |
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
68 K.c = 13; |
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
69 K.C = 19; |
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
70 K.s = -23; |
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
71 K.S = 41; |
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
72 K.i = 134; |
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
73 K.I = 257; |
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
74 K.j = -12357; |
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
75 K.J = 356; |
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
76 K.l = -1234556687721LL; |
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
77 K.L = 23564634576581ULL; |
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
78 K.f = 1.20432545f; |
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
79 K.d = 1.0123456; |
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
80 K.p = (void*)0x1020345; |
63f623bff0b9
- test/callback_suite: reverted designated aggr initialization back to what it was, b/c of MSVCs before 2013 not handling a lot of C99
Tassilo Philipp
parents:
487
diff
changeset
|
81 |
0 | 82 for(pos = 0 ;pos < CONFIG_MAXARGS ;++pos) { |
83 DCValue ref; | |
84 GetReferenceArg( &ref, DC_SIGCHAR_BOOL , pos); ValueMatrix[pos].B = ref.B; | |
85 GetReferenceArg( &ref, DC_SIGCHAR_CHAR , pos); ValueMatrix[pos].c = ref.c; | |
86 GetReferenceArg( &ref, DC_SIGCHAR_UCHAR , pos); ValueMatrix[pos].C = ref.C; | |
87 GetReferenceArg( &ref, DC_SIGCHAR_SHORT , pos); ValueMatrix[pos].s = ref.s; | |
88 GetReferenceArg( &ref, DC_SIGCHAR_USHORT , pos); ValueMatrix[pos].S = ref.S; | |
89 GetReferenceArg( &ref, DC_SIGCHAR_INT , pos); ValueMatrix[pos].i = ref.i; | |
90 GetReferenceArg( &ref, DC_SIGCHAR_UINT , pos); ValueMatrix[pos].I = ref.I; | |
91 GetReferenceArg( &ref, DC_SIGCHAR_LONG , pos); ValueMatrix[pos].j = ref.j; | |
92 GetReferenceArg( &ref, DC_SIGCHAR_ULONG , pos); ValueMatrix[pos].J = ref.J; | |
93 GetReferenceArg( &ref, DC_SIGCHAR_LONGLONG , pos); ValueMatrix[pos].l = ref.l; | |
94 GetReferenceArg( &ref, DC_SIGCHAR_ULONGLONG, pos); ValueMatrix[pos].L = ref.L; | |
95 GetReferenceArg( &ref, DC_SIGCHAR_FLOAT , pos); ValueMatrix[pos].f = ref.f; | |
96 GetReferenceArg( &ref, DC_SIGCHAR_DOUBLE , pos); ValueMatrix[pos].d = ref.d; | |
97 GetReferenceArg( &ref, DC_SIGCHAR_POINTER , pos); ValueMatrix[pos].p = ref.p; | |
98 } | |
99 } | |
100 | |
101 /* Global Options. */ | |
102 int OptionVerbose = 0; | |
103 |