Mercurial > pub > dyncall > dyncall
comparison dyncallback/dyncall_args_mips.c @ 0:3e629dc19168
initial from svn dyncall-1745
author | Daniel Adler |
---|---|
date | Thu, 19 Mar 2015 22:24:28 +0100 |
parents | |
children | b7a9b524f0c3 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3e629dc19168 |
---|---|
1 /* | |
2 | |
3 Package: dyncall | |
4 Library: dyncallback | |
5 File: dyncallback/dyncall_args_mips.c | |
6 Description: Callback's Arguments VM - Implementation for MIPS | |
7 License: | |
8 | |
9 Copyright (c) 2013-2015 Daniel Adler <dadler@uni-goettingen.de>, | |
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 | |
29 DCint dcbArgInt(DCArgs* p) | |
30 { | |
31 DCint value; | |
32 if(p->ireg_count < 8) | |
33 value = p->ireg_data[p->ireg_count++]; | |
34 else { | |
35 value = *((int*)p->stackptr); | |
36 p->stackptr += sizeof(int); | |
37 } | |
38 return value; | |
39 } | |
40 DCuint dcbArgUInt(DCArgs* p) { return (DCuint)dcbArgInt(p); } | |
41 | |
42 DCulonglong dcbArgULongLong(DCArgs* p) | |
43 { | |
44 DCulonglong value; | |
45 p->ireg_count += (p->ireg_count & 1); // Skip one reg if not aligned. | |
46 value = ((DCulonglong)dcbArgUInt(p)) << 32; | |
47 value |= dcbArgUInt(p); | |
48 return value; | |
49 } | |
50 DClonglong dcbArgLongLong(DCArgs* p) { return (DClonglong)dcbArgULongLong(p); } | |
51 | |
52 DClong dcbArgLong (DCArgs* p) { return (DClong) dcbArgUInt(p); } | |
53 DCulong dcbArgULong (DCArgs* p) { return (DCulong) dcbArgUInt(p); } | |
54 DCchar dcbArgChar (DCArgs* p) { return (DCchar) dcbArgUInt(p); } | |
55 DCuchar dcbArgUChar (DCArgs* p) { return (DCuchar) dcbArgUInt(p); } | |
56 DCshort dcbArgShort (DCArgs* p) { return (DCshort) dcbArgUInt(p); } | |
57 DCushort dcbArgUShort (DCArgs* p) { return (DCushort) dcbArgUInt(p); } | |
58 DCbool dcbArgBool (DCArgs* p) { return (DCbool) dcbArgUInt(p); } | |
59 DCpointer dcbArgPointer(DCArgs* p) { return (DCpointer)dcbArgUInt(p); } | |
60 | |
61 DCfloat dcbArgFloat(DCArgs* p) | |
62 { | |
63 DCfloat result; | |
64 if(p->freg_count < 8) | |
65 result = (DCfloat)p->freg_data[p->freg_count++]; | |
66 else { | |
67 result = *((float*)p->stackptr); | |
68 p->stackptr += sizeof(float); | |
69 } | |
70 return result; | |
71 } | |
72 DCdouble dcbArgDouble(DCArgs* p) | |
73 { | |
74 union { | |
75 DCdouble result; | |
76 DCfloat f[2]; | |
77 } d; | |
78 p->freg_count += (p->freg_count & 1); // Skip one reg if not aligned. | |
79 d.f[0] = dcbArgFloat(p); | |
80 d.f[1] = dcbArgFloat(p); | |
81 return d.result; | |
82 } |