annotate dyncallback/dyncall_args_mips_o32.c @ 256:7520e2260097

- added to configure some detection on how to compile .s/.S with --noexecstack (or similar), as compilers' defaults are often insane - since no-execstack handling is now in build, remove .note.GNU-stack section markers (were of limites use, anyways, b/c unportable or implemented inconsistently across platforms) - some ToDo, etc. updates
author Tassilo Philipp
date Sat, 20 May 2017 00:02:59 +0200
parents f0437f85091b
children f5577f6bf97a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
118
f0437f85091b - cleanups in comments, etc.
cslag
parents: 110
diff changeset
5 File: dyncallback/dyncall_args_mips_o32.c
109
9e677d4c0b6b - mips comment cleanups
cslag
parents: 104
diff changeset
6 Description: Callback's Arguments VM - Implementation for MIPS o32
102
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;
110
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
32 p->freg_count = 2; /* first int will disable float reg use. */
102
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
33 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
34 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
35 return value;
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
36 }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
37 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
38
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
39 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
40 {
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
41 DCulonglong value;
110
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
42 p->stackptr += ((int)p->stackptr & 4); /* Skip one slot if not aligned. */
102
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
43 #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
44 value = dcbArgUInt(p);
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
45 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
46 #else
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
47 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
48 value |= dcbArgUInt(p);
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
49 #endif
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
50 return value;
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
51 }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
52 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
53
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
63 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
64 {
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
65 DCfloat result;
104
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
66 if(p->freg_count < 2) {
110
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
67 /* Stored float regs (max 2) are always 8b aligned. The way we look them up, */
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
68 /* relative to a diverging p->stackptr, we need consider this. Only works */
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
69 /* with up to two float args, which is all we need. Hacky, but saves us */
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
70 /* from one more variable and more bookkeeping in DCArgs. */
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
71 result = ((DCfloat*)(p->stackptr + ((int)p->stackptr & 4)) - 4) /* '-4' b/c those regs are stored right before the args */
104
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
72 #if defined(DC__Endian_LITTLE)
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
73 [0];
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
74 #else
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
75 [1];
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
76 #endif
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
77 ++p->freg_count;
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
78 } else {
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
79 result = *((DCfloat*)p->stackptr);
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
80 }
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
81 p->stackptr += sizeof(DCfloat);
102
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
82 return result;
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
83 }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
84 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
85 {
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
86 union {
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
87 DCdouble result;
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
88 DCfloat f[2];
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
89 } d;
110
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
90 p->stackptr += ((int)p->stackptr & 4); /* Skip one slot if not aligned. */
104
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
91 if(p->freg_count < 2) {
110
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
92 /*result = *((DCdouble*)p->stackptr-2); this changes the value, slightly*/
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
93 d.f[0] = ((DCfloat*)p->stackptr-4)[0]; /* '-4' b/c those regs are stored right before the args */
104
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
94 d.f[1] = ((DCfloat*)p->stackptr-4)[1];
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
95 ++p->freg_count;
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
96 } else {
110
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
97 /*result = *((DCdouble*)p->stackptr); this changes the value, slightly*/
104
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
98 d.f[0] = ((DCfloat*)p->stackptr)[0];
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
99 d.f[1] = ((DCfloat*)p->stackptr)[1];
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
100 }
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
101 p->stackptr += sizeof(DCdouble);
102
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
102 return d.result;
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
103 }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
104