Mercurial > pub > dyncall > dyncall
comparison dyncallback/dyncall_args_mips64.c @ 122:f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
author | cslag |
---|---|
date | Mon, 04 Jul 2016 01:11:08 +0200 |
parents | |
children | be08b699dca5 |
comparison
equal
deleted
inserted
replaced
121:f00b1f3da52e | 122:f63467916f98 |
---|---|
1 /* | |
2 | |
3 Package: dyncall | |
4 Library: dyncallback | |
5 File: dyncallback/dyncall_args_mips64.c | |
6 Description: Callback's Arguments VM - Implementation for MIPS64 n32&n64 | |
7 License: | |
8 | |
9 Copyright (c) 2016 Tassilo Philipp <tphilipp@potion-studios.com> | |
10 | |
11 Permission to use, copy, modify, and distribute this software for any | |
12 purpose with or without fee is hereby granted, provided that the above | |
13 copyright notice and this permission notice appear in all copies. | |
14 | |
15 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
16 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
17 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
18 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
21 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
22 | |
23 */ | |
24 | |
25 | |
26 #include "dyncall_args_mips.h" | |
27 | |
28 /* @@@ test and add n32 code here, also, if needed */ | |
29 | |
30 DClonglong dcbArgLongLong(DCArgs* p) | |
31 { | |
32 DClonglong value; | |
33 if(p->reg_count < DCARGS_MIPS_NUM_IREGS) | |
34 value = p->ireg_data[p->reg_count++]; | |
35 else { | |
36 value = *((DClonglong*)p->stackptr); | |
37 p->stackptr += sizeof(DClonglong); | |
38 } | |
39 return value; | |
40 } | |
41 DCulonglong dcbArgULongLong(DCArgs* p) { return (DCulonglong)dcbArgLongLong(p); } | |
42 | |
43 DCint dcbArgInt (DCArgs* p) { return (DCint) dcbArgLongLong(p); } | |
44 DCuint dcbArgUInt (DCArgs* p) { return (DCuint) dcbArgLongLong(p); } | |
45 DClong dcbArgLong (DCArgs* p) { return (DClong) dcbArgLongLong(p); } | |
46 DCulong dcbArgULong (DCArgs* p) { return (DCulong) dcbArgLongLong(p); } | |
47 DCchar dcbArgChar (DCArgs* p) { return (DCchar) dcbArgLongLong(p); } | |
48 DCuchar dcbArgUChar (DCArgs* p) { return (DCuchar) dcbArgLongLong(p); } | |
49 DCshort dcbArgShort (DCArgs* p) { return (DCshort) dcbArgLongLong(p); } | |
50 DCushort dcbArgUShort (DCArgs* p) { return (DCushort) dcbArgLongLong(p); } | |
51 DCbool dcbArgBool (DCArgs* p) { return (DCbool) dcbArgLongLong(p); } | |
52 DCpointer dcbArgPointer(DCArgs* p) { return (DCpointer)dcbArgLongLong(p); } | |
53 | |
54 DCdouble dcbArgDouble(DCArgs* p) | |
55 { | |
56 DCdouble result; | |
57 if(p->reg_count < DCARGS_MIPS_NUM_FREGS) | |
58 result = p->freg_data[p->reg_count++]; | |
59 else { | |
60 result = *((DCdouble*)p->stackptr); | |
61 p->stackptr += sizeof(DCdouble); | |
62 } | |
63 return result; | |
64 } | |
65 DCfloat dcbArgFloat(DCArgs* p) { | |
66 DCdouble d = dcbArgDouble(p); | |
67 return ((DCfloat*)&d) // single precision are stored in double slots, but not promoted | |
68 #if defined(DC__Endian_LITTLE) | |
69 [0]; | |
70 #else | |
71 [1]; | |
72 #endif | |
73 } | |
74 |