Mercurial > pub > dyncall > dyncall
annotate dyncallback/dyncall_args_mips_o32.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 | |
children | dbca6763f2be |
rev | line source |
---|---|
102
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
1 /* |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
2 |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
3 Package: dyncall |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
4 Library: dyncallback |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
5 File: dyncallback/dyncall_args_mips.c |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
6 Description: Callback's Arguments VM - Implementation for MIPS |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
7 License: |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
8 |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
9 Copyright (c) 2013-2015 Daniel Adler <dadler@uni-goettingen.de>, |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
10 Tassilo Philipp <tphilipp@potion-studios.com> |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
11 |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
12 Permission to use, copy, modify, and distribute this software for any |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
13 purpose with or without fee is hereby granted, provided that the above |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
14 copyright notice and this permission notice appear in all copies. |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
15 |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
23 |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
24 */ |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
25 |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
26 |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
27 #include "dyncall_args_mips.h" |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
28 |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
29 DCint dcbArgInt(DCArgs* p) |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
30 { |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
31 DCint value; |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
32 value = *((int*)p->stackptr); |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
33 p->stackptr += sizeof(int); |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
34 return value; |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
35 } |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
36 DCuint dcbArgUInt(DCArgs* p) { return (DCuint)dcbArgInt(p); } |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
37 |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
38 DCulonglong dcbArgULongLong(DCArgs* p) |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
39 { |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
40 DCulonglong value; |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
41 p->stackptr += ((int)p->stackptr & 4); // Skip one slot if not aligned. |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
42 #if defined(DC__Endian_LITTLE) |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
43 value = dcbArgUInt(p); |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
44 value |= ((DCulonglong)dcbArgUInt(p)) << 32; |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
45 #else |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
46 value = ((DCulonglong)dcbArgUInt(p)) << 32; |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
47 value |= dcbArgUInt(p); |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
48 #endif |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
49 return value; |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
50 } |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
51 DClonglong dcbArgLongLong(DCArgs* p) { return (DClonglong)dcbArgULongLong(p); } |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
52 |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
53 DClong dcbArgLong (DCArgs* p) { return (DClong) dcbArgUInt(p); } |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
54 DCulong dcbArgULong (DCArgs* p) { return (DCulong) dcbArgUInt(p); } |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
55 DCchar dcbArgChar (DCArgs* p) { return (DCchar) dcbArgUInt(p); } |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
56 DCuchar dcbArgUChar (DCArgs* p) { return (DCuchar) dcbArgUInt(p); } |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
57 DCshort dcbArgShort (DCArgs* p) { return (DCshort) dcbArgUInt(p); } |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
58 DCushort dcbArgUShort (DCArgs* p) { return (DCushort) dcbArgUInt(p); } |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
59 DCbool dcbArgBool (DCArgs* p) { return (DCbool) dcbArgUInt(p); } |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
60 DCpointer dcbArgPointer(DCArgs* p) { return (DCpointer)dcbArgUInt(p); } |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
61 |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
62 DCfloat dcbArgFloat(DCArgs* p) |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
63 { |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
64 DCfloat result; |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
65 result = *((float*)p->stackptr); |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
66 p->stackptr += sizeof(float); |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
67 return result; |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
68 } |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
69 DCdouble dcbArgDouble(DCArgs* p) |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
70 { |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
71 union { |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
72 DCdouble result; |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
73 DCfloat f[2]; |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
74 } d; |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
75 p->stackptr += ((int)p->stackptr & 4); // Skip one slot if not aligned. |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
76 #if defined(DC__Endian_LITTLE) |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
77 d.f[0] = dcbArgFloat(p); |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
78 d.f[1] = dcbArgFloat(p); |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
79 #else |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
80 d.f[1] = dcbArgFloat(p); |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
81 d.f[0] = dcbArgFloat(p); |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
82 #endif |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
83 return d.result; |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
84 } |
b7a9b524f0c3
- mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff
changeset
|
85 |