1
/* vacall function for m88k CPU */
4
* Copyright 1995-2004 Bruno Haible, <bruno@clisp.org>
6
* This is free software distributed under the GNU General Public Licence
7
* described in the file COPYING. Contact the author if you don't have this
8
* or can't live with it. There is ABSOLUTELY NO WARRANTY, explicit or implied,
13
#include "vacall.h.in"
15
#include "vacall_r.h.in"
19
#define __vacall __vacall_r
20
register struct { void (*vacall_function) (void*,va_alist); void* arg; }
23
register __vaword* sret __asm__("r12");
24
register int iret __asm__("r2");
25
register int iret2 __asm__("r3");
26
register float fret __asm__("r2");
27
register double dret __asm__("r2");
29
void /* the return type is variable, not void! */
30
__vacall (__vaword word1, __vaword word2, __vaword word3, __vaword word4,
31
__vaword word5, __vaword word6, __vaword word7, __vaword word8,
35
/* gcc-2.6.3 source says: When a parameter is passed in a register,
36
* stack space is still allocated for it.
38
/* Move the arguments passed in registers to their stack locations. */
40
* Is this correct?? I think struct arguments among the first 8 words
41
* are passed on the stack, not in registers, and we shouldn't overwrite
44
(&firstword)[-8] = word1;
45
(&firstword)[-7] = word2;
46
(&firstword)[-6] = word3;
47
(&firstword)[-5] = word4;
48
(&firstword)[-4] = word5;
49
(&firstword)[-3] = word6;
50
(&firstword)[-2] = word7;
51
(&firstword)[-1] = word8;
52
/* Prepare the va_alist. */
54
list.aptr = (long)&firstword;
55
list.raddr = (void*)0;
56
list.rtype = __VAvoid;
57
list.structraddr = sret;
58
/* Call vacall_function. The macros do all the rest. */
60
(*vacall_function) (&list);
62
(*env->vacall_function) (env->arg,&list);
64
/* Put return value into proper register. */
65
if (list.rtype == __VAvoid) {
67
if (list.rtype == __VAchar) {
68
iret = list.tmp._char;
70
if (list.rtype == __VAschar) {
71
iret = list.tmp._schar;
73
if (list.rtype == __VAuchar) {
74
iret = list.tmp._uchar;
76
if (list.rtype == __VAshort) {
77
iret = list.tmp._short;
79
if (list.rtype == __VAushort) {
80
iret = list.tmp._ushort;
82
if (list.rtype == __VAint) {
85
if (list.rtype == __VAuint) {
86
iret = list.tmp._uint;
88
if (list.rtype == __VAlong) {
89
iret = list.tmp._long;
91
if (list.rtype == __VAulong) {
92
iret = list.tmp._ulong;
94
if (list.rtype == __VAlonglong || list.rtype == __VAulonglong) {
95
iret = ((__vaword *) &list.tmp._longlong)[0];
96
iret2 = ((__vaword *) &list.tmp._longlong)[1];
98
if (list.rtype == __VAfloat) {
99
fret = list.tmp._float;
101
if (list.rtype == __VAdouble) {
102
dret = list.tmp._double;
104
if (list.rtype == __VAvoidp) {
105
iret = (long)list.tmp._ptr;
107
if (list.rtype == __VAstruct) {
108
if (list.flags & __VA_PCC_STRUCT_RETURN) {
109
/* pcc struct return convention */
110
iret = (long) list.raddr;
112
/* normal struct return convention */
113
if (list.flags & __VA_SMALL_STRUCT_RETURN) {
114
if (list.rsize == sizeof(char)) {
115
iret = *(unsigned char *) list.raddr;
117
if (list.rsize == sizeof(short)) {
118
iret = *(unsigned short *) list.raddr;
120
if (list.rsize == sizeof(int)) {
121
iret = *(unsigned int *) list.raddr;