~ubuntu-branches/debian/squeeze/ffcall/squeeze

« back to all changes in this revision

Viewing changes to ffcall/callback/vacall_r/vacall-s390.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger
  • Date: 2010-06-26 15:29:30 UTC
  • mfrom: (5.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100626152930-c09y01gk3szcnykn
Tags: 1.10+cvs20100619-2
Ship to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* vacall function for S/390 CPU */
2
 
 
3
 
/*
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>
7
 
 *
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,
11
 
 * on this software.
12
 
 */
13
 
 
14
 
#ifndef REENTRANT
15
 
#include "vacall.h.in"
16
 
#else /* REENTRANT */
17
 
#include "vacall_r.h"
18
 
#endif
19
 
 
20
 
#ifdef REENTRANT
21
 
#define __vacall __vacall_r
22
 
register struct { void (*vacall_function) (void*,va_alist); void* arg; }
23
 
         *              env     __asm__("r0");
24
 
#endif
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");
33
 
 
34
 
void /* the return type is variable, not void! */
35
 
__vacall (__vaword word1, __vaword word2, __vaword word3, __vaword word4,
36
 
          __vaword word5,
37
 
          __vaword firstword)
38
 
{
39
 
  __va_alist list;
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;
47
 
 
48
 
  list.darg[1] = darg2;
49
 
  list.darg[0] = darg1;
50
 
 
51
 
  list.farg[1] = farg2;
52
 
  list.farg[0] = farg1;
53
 
 
54
 
  /* Prepare the va_alist. */
55
 
  list.flags = 0;
56
 
  list.aptr = (long)(&list.regarg[0]);
57
 
  list.saptr = (long)(&firstword);
58
 
  list.onstack = 0;
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. */
64
 
#ifndef REENTRANT
65
 
  (*vacall_function) (&list);
66
 
#else /* REENTRANT */
67
 
  (*env->vacall_function) (env->arg,&list);
68
 
#endif
69
 
  /* Put return value into proper register. */
70
 
  if (list.rtype == __VAvoid) {
71
 
  } else
72
 
  if (list.rtype == __VAchar) {
73
 
    iret = list.tmp._char;
74
 
  } else
75
 
  if (list.rtype == __VAschar) {
76
 
    iret = list.tmp._schar;
77
 
  } else
78
 
  if (list.rtype == __VAuchar) {
79
 
    iret = list.tmp._uchar;
80
 
  } else
81
 
  if (list.rtype == __VAshort) {
82
 
    iret = list.tmp._short;
83
 
  } else
84
 
  if (list.rtype == __VAushort) {
85
 
    iret = list.tmp._ushort;
86
 
  } else
87
 
  if (list.rtype == __VAint) {
88
 
    iret = list.tmp._int;
89
 
  } else
90
 
  if (list.rtype == __VAuint) {
91
 
    iret = list.tmp._uint;
92
 
  } else
93
 
  if (list.rtype == __VAlong) {
94
 
    iret = list.tmp._long;
95
 
  } else
96
 
  if (list.rtype == __VAulong) {
97
 
    iret = list.tmp._ulong;
98
 
  } else
99
 
  if (list.rtype == __VAlonglong || list.rtype == __VAulonglong) {
100
 
    iret  = ((__vaword *) &list.tmp._longlong)[0];
101
 
    iret2 = ((__vaword *) &list.tmp._longlong)[1];
102
 
  } else
103
 
  if (list.rtype == __VAfloat) {
104
 
    fret = list.tmp._float;
105
 
  } else
106
 
  if (list.rtype == __VAdouble) {
107
 
    dret = list.tmp._double;
108
 
  } else
109
 
  if (list.rtype == __VAvoidp) {
110
 
    iret = (long)list.tmp._ptr;
111
 
  } else
112
 
  if (list.rtype == __VAstruct) {
113
 
    if (list.flags & __VA_PCC_STRUCT_RETURN) {
114
 
      /* pcc struct return convention */
115
 
      iret = (long) list.raddr;
116
 
    } else {
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;
121
 
        } else
122
 
        if (list.rsize == sizeof(short)) {
123
 
          iret = *(unsigned short *) list.raddr;
124
 
        } else
125
 
        if (list.rsize == sizeof(int)) {
126
 
          iret = *(unsigned int *) list.raddr;
127
 
        } else
128
 
        if (list.rsize == 2*sizeof(__vaword)) {
129
 
          iret  = ((__vaword *) list.raddr)[0];
130
 
          iret2 = ((__vaword *) list.raddr)[1];
131
 
        }
132
 
      }
133
 
    }
134
 
  }
135
 
}