Mercurial > pub > dyncall > dyncall
annotate dyncallback/dyncall_args_ppc64.c @ 663:127b569978cc default tip
- another tweak handling clang trying to be too smart (see last commit)
author | Tassilo Philipp |
---|---|
date | Sun, 24 Mar 2024 13:52:44 +0100 |
parents | 93ce63d72d59 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncallback | |
5 File: dyncallback/dyncall_args_ppc64.c | |
6 Description: Callback's Arguments VM - Implementation for ppc64 | |
7 License: | |
8 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
83
diff
changeset
|
9 Copyright (c) 2014-2015 Masanori Mitsugi <mitsugi@linux.vnet.ibm.com>, |
661
93ce63d72d59
- dyncallback code cleanup: removed unneeded headers
Tassilo Philipp
parents:
580
diff
changeset
|
10 2022-2024 Tassilo Philipp <tphilipp@potion-studios.com> |
0 | 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 | |
661
93ce63d72d59
- dyncallback code cleanup: removed unneeded headers
Tassilo Philipp
parents:
580
diff
changeset
|
26 #include "dyncall_args.h" |
93ce63d72d59
- dyncallback code cleanup: removed unneeded headers
Tassilo Philipp
parents:
580
diff
changeset
|
27 |
93ce63d72d59
- dyncallback code cleanup: removed unneeded headers
Tassilo Philipp
parents:
580
diff
changeset
|
28 struct DCArgs |
93ce63d72d59
- dyncallback code cleanup: removed unneeded headers
Tassilo Philipp
parents:
580
diff
changeset
|
29 { |
93ce63d72d59
- dyncallback code cleanup: removed unneeded headers
Tassilo Philipp
parents:
580
diff
changeset
|
30 long long ireg_data[8]; |
93ce63d72d59
- dyncallback code cleanup: removed unneeded headers
Tassilo Philipp
parents:
580
diff
changeset
|
31 double freg_data[13]; |
93ce63d72d59
- dyncallback code cleanup: removed unneeded headers
Tassilo Philipp
parents:
580
diff
changeset
|
32 unsigned char* stackptr; |
93ce63d72d59
- dyncallback code cleanup: removed unneeded headers
Tassilo Philipp
parents:
580
diff
changeset
|
33 int ireg_count; |
93ce63d72d59
- dyncallback code cleanup: removed unneeded headers
Tassilo Philipp
parents:
580
diff
changeset
|
34 int freg_count; |
93ce63d72d59
- dyncallback code cleanup: removed unneeded headers
Tassilo Philipp
parents:
580
diff
changeset
|
35 }; |
0 | 36 |
37 DCint dcbArgInt (DCArgs* p) { return (DCint) dcbArgLongLong(p); } | |
38 DCuint dcbArgUInt (DCArgs* p) { return (DCuint) dcbArgLongLong(p); } | |
39 DCulonglong dcbArgULongLong(DCArgs* p) { return (DCulonglong) dcbArgLongLong(p); } | |
40 | |
41 DClonglong dcbArgLongLong(DCArgs* p) | |
42 { | |
43 DClonglong value; | |
44 if (p->ireg_count < 8) { | |
45 value = p->ireg_data[p->ireg_count++]; | |
46 } else { | |
47 value = *( (long long*) p->stackptr ); | |
48 } | |
49 p->stackptr += sizeof(long long); | |
50 return value; | |
51 } | |
52 | |
53 DClong dcbArgLong (DCArgs* p) { return (DClong) dcbArgLongLong(p); } | |
54 DCulong dcbArgULong (DCArgs* p) { return (DCulong) dcbArgLongLong(p); } | |
55 DCchar dcbArgChar (DCArgs* p) { return (DCchar) dcbArgLongLong(p); } | |
56 DCuchar dcbArgUChar (DCArgs* p) { return (DCuchar) dcbArgLongLong(p); } | |
57 DCshort dcbArgShort (DCArgs* p) { return (DCshort) dcbArgLongLong(p); } | |
58 DCushort dcbArgUShort (DCArgs* p) { return (DCushort)dcbArgLongLong(p); } | |
59 DCbool dcbArgBool (DCArgs* p) { return (DCbool) dcbArgLongLong(p); } | |
60 | |
61 DCpointer dcbArgPointer (DCArgs* p) { return (DCpointer)dcbArgLongLong(p); } | |
62 | |
83
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
63 DCdouble dcbArgDouble (DCArgs* p) |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
64 { |
0 | 65 DCdouble result; |
66 | |
67 if (p->freg_count < 13) { | |
68 result = p->freg_data[p->freg_count++]; | |
69 if (p->ireg_count < 8) { | |
70 p->ireg_count++; | |
71 } | |
72 } else { | |
73 result = * ( (double*) p->stackptr ); | |
74 } | |
75 | |
76 p->stackptr += sizeof(double); | |
77 return result; | |
78 } | |
79 | |
83
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
80 DCfloat dcbArgFloat (DCArgs* p) |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
81 { |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
82 DCfloat result; |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
83 |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
84 #if defined(DC__Endian_BIG) |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
85 struct sf { DCfloat f_pad; DCfloat f; } sf; |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
86 #else /* Endian_LITTLE */ |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
87 struct sf { DCfloat f; DCfloat f_pad; } sf; |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
88 #endif |
0 | 89 |
83
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
90 if (p->freg_count < 13) { |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
91 result = (float)p->freg_data[p->freg_count++]; |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
92 if (p->ireg_count < 8) { |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
93 p->ireg_count++; |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
94 } |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
95 } else { |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
96 sf = * ( (struct sf*) p->stackptr ); |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
97 result = sf.f; |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
98 } |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
99 |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
100 p->stackptr += sizeof(double); |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
101 return result; |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
0
diff
changeset
|
102 } |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
83
diff
changeset
|
103 |
580
2562c89d5bb5
- added missing return values for dcbArgAggr() on functions w/o aggregate support
Tassilo Philipp
parents:
544
diff
changeset
|
104 DCpointer dcbArgAggr (DCArgs* p, DCpointer target) { /* @@@AGGR not impl */ return NULL; } |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
83
diff
changeset
|
105 void dcbReturnAggr (DCArgs *args, DCValue *result, DCpointer ret) { /* @@@AGGR not impl */ } |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
83
diff
changeset
|
106 |