1
/* vacall function for S/390 CPU */
4
* Copyright 1995-2004 Bruno Haible, <bruno@clisp.org>
5
* Copyright 2000 Adam Fedor, <fedor@gnu.org>
6
* Copyright 2001 Gerhard Tonn, <gt@debian.org>
8
* This is free software distributed under the GNU General Public Licence
9
* described in the file COPYING. Contact the author if you don't have this
10
* or can't live with it. There is ABSOLUTELY NO WARRANTY, explicit or implied,
15
#include "vacall.h.in"
21
#define __vacall __vacall_r
22
register struct { void (*vacall_function) (void*,va_alist); void* arg; }
25
register float farg1 __asm__("f0");
26
register float farg2 __asm__("f2");
27
register double darg1 __asm__("f0");
28
register double darg2 __asm__("f2");
29
register __vaword iret __asm__("%r2");
30
register __vaword iret2 __asm__("%r3");
31
register float fret __asm__("%f0");
32
register double dret __asm__("%f0");
34
void /* the return type is variable, not void! */
35
__vacall (__vaword word1, __vaword word2, __vaword word3, __vaword word4,
40
/* Move the arguments passed in registers to temp storage, since
41
moving them to the stack would mess up the stack */
42
list.regarg[0] = word1;
43
list.regarg[1] = word2;
44
list.regarg[2] = word3;
45
list.regarg[3] = word4;
46
list.regarg[4] = word5;
54
/* Prepare the va_alist. */
56
list.aptr = (long)(&list.regarg[0]);
57
list.saptr = (long)(&firstword);
59
list.raddr = (void*)0;
60
list.rtype = __VAvoid;
61
list.memfargptr = &list.farg[0];
62
list.memdargptr = &list.darg[0];
63
/* Call vacall_function. The macros do all the rest. */
65
(*vacall_function) (&list);
67
(*env->vacall_function) (env->arg,&list);
69
/* Put return value into proper register. */
70
if (list.rtype == __VAvoid) {
72
if (list.rtype == __VAchar) {
73
iret = list.tmp._char;
75
if (list.rtype == __VAschar) {
76
iret = list.tmp._schar;
78
if (list.rtype == __VAuchar) {
79
iret = list.tmp._uchar;
81
if (list.rtype == __VAshort) {
82
iret = list.tmp._short;
84
if (list.rtype == __VAushort) {
85
iret = list.tmp._ushort;
87
if (list.rtype == __VAint) {
90
if (list.rtype == __VAuint) {
91
iret = list.tmp._uint;
93
if (list.rtype == __VAlong) {
94
iret = list.tmp._long;
96
if (list.rtype == __VAulong) {
97
iret = list.tmp._ulong;
99
if (list.rtype == __VAlonglong || list.rtype == __VAulonglong) {
100
iret = ((__vaword *) &list.tmp._longlong)[0];
101
iret2 = ((__vaword *) &list.tmp._longlong)[1];
103
if (list.rtype == __VAfloat) {
104
fret = list.tmp._float;
106
if (list.rtype == __VAdouble) {
107
dret = list.tmp._double;
109
if (list.rtype == __VAvoidp) {
110
iret = (long)list.tmp._ptr;
112
if (list.rtype == __VAstruct) {
113
if (list.flags & __VA_PCC_STRUCT_RETURN) {
114
/* pcc struct return convention */
115
iret = (long) list.raddr;
117
/* normal struct return convention */
118
if (list.flags & __VA_REGISTER_STRUCT_RETURN) {
119
if (list.rsize == sizeof(char)) {
120
iret = *(unsigned char *) list.raddr;
122
if (list.rsize == sizeof(short)) {
123
iret = *(unsigned short *) list.raddr;
125
if (list.rsize == sizeof(int)) {
126
iret = *(unsigned int *) list.raddr;
128
if (list.rsize == 2*sizeof(__vaword)) {
129
iret = ((__vaword *) list.raddr)[0];
130
iret2 = ((__vaword *) list.raddr)[1];