Mercurial > pub > dyncall > dyncall
comparison dyncallback/dyncall_args_mips.c @ 102:b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
author | cslag |
---|---|
date | Tue, 07 Jun 2016 09:05:34 +0200 |
parents | 3e629dc19168 |
children | 9e677d4c0b6b |
comparison
equal
deleted
inserted
replaced
101:1ce60358fbad | 102:b7a9b524f0c3 |
---|---|
24 */ | 24 */ |
25 | 25 |
26 | 26 |
27 #include "dyncall_args_mips.h" | 27 #include "dyncall_args_mips.h" |
28 | 28 |
29 DCint dcbArgInt(DCArgs* p) | 29 DCint dcbArgInt(DCArgs* p) |
30 { | 30 { |
31 DCint value; | 31 DCint value; |
32 if(p->ireg_count < 8) | 32 if(p->reg_count.i < DCARGS_MIPS_PARAM_REGS) |
33 value = p->ireg_data[p->ireg_count++]; | 33 value = p->reg_data.i[p->reg_count.i++]; |
34 else { | 34 else { |
35 value = *((int*)p->stackptr); | 35 value = *((int*)p->stackptr); |
36 p->stackptr += sizeof(int); | 36 p->stackptr += sizeof(int); |
37 } | 37 } |
38 return value; | 38 return value; |
39 } | 39 } |
40 DCuint dcbArgUInt(DCArgs* p) { return (DCuint)dcbArgInt(p); } | 40 DCuint dcbArgUInt(DCArgs* p) { return (DCuint)dcbArgInt(p); } |
41 | 41 |
42 DCulonglong dcbArgULongLong(DCArgs* p) | 42 DCulonglong dcbArgULongLong(DCArgs* p) |
43 { | 43 { |
44 DCulonglong value; | 44 DCulonglong value; |
45 p->ireg_count += (p->ireg_count & 1); // Skip one reg if not aligned. | 45 p->reg_count.i += (p->reg_count.i & 1); // Skip one reg if not aligned. |
46 #if defined(DC__Endian_LITTLE) | |
46 value = ((DCulonglong)dcbArgUInt(p)) << 32; | 47 value = ((DCulonglong)dcbArgUInt(p)) << 32; |
47 value |= dcbArgUInt(p); | 48 value |= dcbArgUInt(p); |
49 #else | |
50 value = dcbArgUInt(p); | |
51 value |= ((DCulonglong)dcbArgUInt(p)) << 32; | |
52 #endif | |
48 return value; | 53 return value; |
49 } | 54 } |
50 DClonglong dcbArgLongLong(DCArgs* p) { return (DClonglong)dcbArgULongLong(p); } | 55 DClonglong dcbArgLongLong(DCArgs* p) { return (DClonglong)dcbArgULongLong(p); } |
51 | 56 |
52 DClong dcbArgLong (DCArgs* p) { return (DClong) dcbArgUInt(p); } | 57 DClong dcbArgLong (DCArgs* p) { return (DClong) dcbArgUInt(p); } |
57 DCushort dcbArgUShort (DCArgs* p) { return (DCushort) dcbArgUInt(p); } | 62 DCushort dcbArgUShort (DCArgs* p) { return (DCushort) dcbArgUInt(p); } |
58 DCbool dcbArgBool (DCArgs* p) { return (DCbool) dcbArgUInt(p); } | 63 DCbool dcbArgBool (DCArgs* p) { return (DCbool) dcbArgUInt(p); } |
59 DCpointer dcbArgPointer(DCArgs* p) { return (DCpointer)dcbArgUInt(p); } | 64 DCpointer dcbArgPointer(DCArgs* p) { return (DCpointer)dcbArgUInt(p); } |
60 | 65 |
61 DCfloat dcbArgFloat(DCArgs* p) | 66 DCfloat dcbArgFloat(DCArgs* p) |
62 { | 67 { |
63 DCfloat result; | 68 DCfloat result; |
64 if(p->freg_count < 8) | 69 if(p->reg_count.f < DCARGS_MIPS_PARAM_REGS) |
65 result = (DCfloat)p->freg_data[p->freg_count++]; | 70 result = (DCfloat)p->reg_data.f[p->reg_count.f++]; |
66 else { | 71 else { |
67 result = *((float*)p->stackptr); | 72 result = *((float*)p->stackptr); |
68 p->stackptr += sizeof(float); | 73 p->stackptr += sizeof(float); |
69 } | 74 } |
70 return result; | 75 return result; |
71 } | 76 } |
72 DCdouble dcbArgDouble(DCArgs* p) | 77 DCdouble dcbArgDouble(DCArgs* p) |
73 { | 78 { |
74 union { | 79 union { |
75 DCdouble result; | 80 DCdouble result; |
76 DCfloat f[2]; | 81 DCfloat f[2]; |
77 } d; | 82 } d; |
78 p->freg_count += (p->freg_count & 1); // Skip one reg if not aligned. | 83 p->reg_count.f += (p->reg_count.f & 1); // Skip one reg if not aligned. |
84 #if defined(DC__Endian_LITTLE) | |
79 d.f[0] = dcbArgFloat(p); | 85 d.f[0] = dcbArgFloat(p); |
80 d.f[1] = dcbArgFloat(p); | 86 d.f[1] = dcbArgFloat(p); |
87 #else | |
88 d.f[1] = dcbArgFloat(p); | |
89 d.f[0] = dcbArgFloat(p); | |
90 #endif | |
81 return d.result; | 91 return d.result; |
82 } | 92 } |
93 |