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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 /*
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
3 Package: dyncall
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4 Library: dyncallback
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5 File: dyncallback/dyncall_args_ppc64.c
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 Description: Callback's Arguments VM - Implementation for ppc64
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 License:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 Permission to use, copy, modify, and distribute this software for any
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 purpose with or without fee is hereby granted, provided that the above
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 copyright notice and this permission notice appear in all copies.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
24 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
36
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
37 DCint dcbArgInt (DCArgs* p) { return (DCint) dcbArgLongLong(p); }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
38 DCuint dcbArgUInt (DCArgs* p) { return (DCuint) dcbArgLongLong(p); }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
39 DCulonglong dcbArgULongLong(DCArgs* p) { return (DCulonglong) dcbArgLongLong(p); }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
40
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
41 DClonglong dcbArgLongLong(DCArgs* p)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
42 {
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
43 DClonglong value;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
44 if (p->ireg_count < 8) {
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
45 value = p->ireg_data[p->ireg_count++];
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
46 } else {
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
47 value = *( (long long*) p->stackptr );
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
48 }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
49 p->stackptr += sizeof(long long);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
50 return value;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
51 }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
52
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
53 DClong dcbArgLong (DCArgs* p) { return (DClong) dcbArgLongLong(p); }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
54 DCulong dcbArgULong (DCArgs* p) { return (DCulong) dcbArgLongLong(p); }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
55 DCchar dcbArgChar (DCArgs* p) { return (DCchar) dcbArgLongLong(p); }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
56 DCuchar dcbArgUChar (DCArgs* p) { return (DCuchar) dcbArgLongLong(p); }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
57 DCshort dcbArgShort (DCArgs* p) { return (DCshort) dcbArgLongLong(p); }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
58 DCushort dcbArgUShort (DCArgs* p) { return (DCushort)dcbArgLongLong(p); }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
59 DCbool dcbArgBool (DCArgs* p) { return (DCbool) dcbArgLongLong(p); }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
60
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
61 DCpointer dcbArgPointer (DCArgs* p) { return (DCpointer)dcbArgLongLong(p); }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
65 DCdouble result;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
66
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
67 if (p->freg_count < 13) {
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
68 result = p->freg_data[p->freg_count++];
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
69 if (p->ireg_count < 8) {
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
70 p->ireg_count++;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
71 }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
72 } else {
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
73 result = * ( (double*) p->stackptr );
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
74 }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
75
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
76 p->stackptr += sizeof(double);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
77 return result;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
78 }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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