Mercurial > pub > dyncall > dyncall
annotate dyncallback/dyncall_args_mips.c @ 533:71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
* integration of aggregate-by-value (struct, union) support patch for x64 (win and sysv)
* windows/x64 asm additions to specify how stack unwinds (help for debuggers, exception handling, etc.)
* see Changelog for details
- new calling convention modes for thiscalls (platform agnostic, was specific before)
* new signature character for platform agnostic thiscalls ('*' / DC_SIGCHAR_CC_THISCALL)
- dcCallF(), dcVCallF(), dcArgF() and dcVArgF():
* added support for aggregates-by-value (wasn't part of patch)
* change that those functions don't implicitly call dcReset() anymore, which was unflexible (breaking change)
- added macros to feature test implementation for aggregate-by-value and syscall support
- changed libdyncall_s.lib and libdyncallback_s.lib order in callback test makefiles, as some toolchains are picky about order
- doc:
* man page updates to describe aggregate interface
* manual overview changes to highlight platforms with aggregate-by-value support
- test/plain: replaced tests w/ old/stale sctruct interface with new aggregate one
author | Tassilo Philipp |
---|---|
date | Thu, 21 Apr 2022 13:35:47 +0200 |
parents | f5577f6bf97a |
children | 111236b31c75 |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncallback | |
5 File: dyncallback/dyncall_args_mips.c | |
109 | 6 Description: Callback's Arguments VM - Implementation for non-o32 MIPS |
0 | 7 License: |
8 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
281
diff
changeset
|
9 Copyright (c) 2013-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 #include "dyncall_args_mips.h" | |
28 | |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
29 DCint dcbArgInt(DCArgs* p) |
0 | 30 { |
31 DCint value; | |
109 | 32 if(p->reg_count.i < DCARGS_MIPS_NUM_IREGS) |
33 value = p->ireg_data[p->reg_count.i++]; | |
0 | 34 else { |
109 | 35 value = *((DCint*)p->stackptr); |
36 p->stackptr += sizeof(DCint); | |
0 | 37 } |
38 return value; | |
39 } | |
40 DCuint dcbArgUInt(DCArgs* p) { return (DCuint)dcbArgInt(p); } | |
41 | |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
42 DCulonglong dcbArgULongLong(DCArgs* p) |
0 | 43 { |
44 DCulonglong value; | |
110 | 45 p->reg_count.i += (p->reg_count.i & 1); /* Skip one reg if not aligned. */ |
46 p->stackptr += ((DCulong)p->stackptr & 4) & -4; /* 64bit values are also always aligned on stack */ | |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
47 #if defined(DC__Endian_LITTLE) |
110 | 48 value = dcbArgUInt(p); |
49 value |= ((DCulonglong)dcbArgUInt(p)) << 32; | |
50 #else | |
0 | 51 value = ((DCulonglong)dcbArgUInt(p)) << 32; |
52 value |= dcbArgUInt(p); | |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
53 #endif |
0 | 54 return value; |
55 } | |
56 DClonglong dcbArgLongLong(DCArgs* p) { return (DClonglong)dcbArgULongLong(p); } | |
57 | |
58 DClong dcbArgLong (DCArgs* p) { return (DClong) dcbArgUInt(p); } | |
59 DCulong dcbArgULong (DCArgs* p) { return (DCulong) dcbArgUInt(p); } | |
60 DCchar dcbArgChar (DCArgs* p) { return (DCchar) dcbArgUInt(p); } | |
61 DCuchar dcbArgUChar (DCArgs* p) { return (DCuchar) dcbArgUInt(p); } | |
62 DCshort dcbArgShort (DCArgs* p) { return (DCshort) dcbArgUInt(p); } | |
63 DCushort dcbArgUShort (DCArgs* p) { return (DCushort) dcbArgUInt(p); } | |
64 DCbool dcbArgBool (DCArgs* p) { return (DCbool) dcbArgUInt(p); } | |
65 DCpointer dcbArgPointer(DCArgs* p) { return (DCpointer)dcbArgUInt(p); } | |
66 | |
67 DCfloat dcbArgFloat(DCArgs* p) | |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
68 { |
0 | 69 DCfloat result; |
109 | 70 if(p->reg_count.f < DCARGS_MIPS_NUM_FREGS) |
110 | 71 result = p->freg_data[p->reg_count.f++]; |
0 | 72 else { |
109 | 73 result = *((DCfloat*)p->stackptr); |
74 p->stackptr += sizeof(DCfloat); | |
0 | 75 } |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
76 return result; |
0 | 77 } |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
78 DCdouble dcbArgDouble(DCArgs* p) |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
79 { |
0 | 80 union { |
81 DCdouble result; | |
110 | 82 DCulonglong i; |
0 | 83 } d; |
110 | 84 d.i = dcbArgULongLong(p); /* those are passed via int regs */ |
0 | 85 return d.result; |
86 } | |
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
0
diff
changeset
|
87 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
281
diff
changeset
|
88 void dcbArgAggr (DCArgs* p, DCpointer target) { /* @@@AGGR not impl */ } |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
281
diff
changeset
|
89 void dcbReturnAggr (DCArgs *args, DCValue *result, DCpointer ret) { /* @@@AGGR not impl */ } |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
281
diff
changeset
|
90 |