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

« back to all changes in this revision

Viewing changes to callback/vacall_r/vacall-powerpc64.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 powerpc64 CPU */
 
2
 
 
3
/*
 
4
 * Copyright 1995-2006 Bruno Haible, <bruno@clisp.org>
 
5
 * Copyright 2000 Adam Fedor, <fedor@gnu.org>
 
6
 * Copyright 2004 Paul Guyot, <pguyot@kallisys.net>
 
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.in"
 
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__("r11");
 
24
#endif
 
25
register double         farg1   __asm__("fr1");
 
26
register double         farg2   __asm__("fr2");
 
27
register double         farg3   __asm__("fr3");
 
28
register double         farg4   __asm__("fr4");
 
29
register double         farg5   __asm__("fr5");
 
30
register double         farg6   __asm__("fr6");
 
31
register double         farg7   __asm__("fr7");
 
32
register double         farg8   __asm__("fr8");
 
33
register double         farg9   __asm__("fr9");
 
34
register double         farg10  __asm__("fr10");
 
35
register double         farg11  __asm__("fr11");
 
36
register double         farg12  __asm__("fr12");
 
37
register double         farg13  __asm__("fr13");
 
38
register __vaword       iret    __asm__("r3");
 
39
register float          fret    __asm__("fr1");
 
40
register double         dret    __asm__("fr1");
 
41
 
 
42
void /* the return type is variable, not void! */
 
43
__vacall (__vaword word1, __vaword word2, __vaword word3, __vaword word4,
 
44
          __vaword word5, __vaword word6, __vaword word7, __vaword word8,
 
45
          __vaword firstword)
 
46
{
 
47
  __va_alist list;
 
48
  /* When a parameter is passed in a register,
 
49
   * stack space is still allocated for it.
 
50
   */
 
51
  /* Move the arguments passed in registers to their stack locations. */
 
52
  (&firstword)[-8] = word1;
 
53
  (&firstword)[-7] = word2;
 
54
  (&firstword)[-6] = word3;
 
55
  (&firstword)[-5] = word4;
 
56
  (&firstword)[-4] = word5;
 
57
  (&firstword)[-3] = word6;
 
58
  (&firstword)[-2] = word7;
 
59
  (&firstword)[-1] = word8;
 
60
  list.farg[0] = farg1;
 
61
  list.farg[1] = farg2;
 
62
  list.farg[2] = farg3;
 
63
  list.farg[3] = farg4;
 
64
  list.farg[4] = farg5;
 
65
  list.farg[5] = farg6;
 
66
  list.farg[6] = farg7;
 
67
  list.farg[7] = farg8;
 
68
  list.farg[8] = farg9;
 
69
  list.farg[9] = farg10;
 
70
  list.farg[10] = farg11;
 
71
  list.farg[11] = farg12;
 
72
  list.farg[12] = farg13;
 
73
  /* Prepare the va_alist. */
 
74
  list.flags = 0;
 
75
  list.aptr = (long)(&firstword - 8);
 
76
  list.raddr = (void*)0;
 
77
  list.rtype = __VAvoid;
 
78
  list.memfargptr = &list.farg[0];
 
79
  /* Call vacall_function. The macros do all the rest. */
 
80
#ifndef REENTRANT
 
81
  (*vacall_function) (&list);
 
82
#else /* REENTRANT */
 
83
  (*env->vacall_function) (env->arg,&list);
 
84
#endif
 
85
  /* Put return value into proper register. */
 
86
  if (list.rtype == __VAvoid) {
 
87
  } else
 
88
  if (list.rtype == __VAchar) {
 
89
    iret = list.tmp._char;
 
90
  } else
 
91
  if (list.rtype == __VAschar) {
 
92
    iret = list.tmp._schar;
 
93
  } else
 
94
  if (list.rtype == __VAuchar) {
 
95
    iret = list.tmp._uchar;
 
96
  } else
 
97
  if (list.rtype == __VAshort) {
 
98
    iret = list.tmp._short;
 
99
  } else
 
100
  if (list.rtype == __VAushort) {
 
101
    iret = list.tmp._ushort;
 
102
  } else
 
103
  if (list.rtype == __VAint) {
 
104
    iret = list.tmp._int;
 
105
  } else
 
106
  if (list.rtype == __VAuint) {
 
107
    iret = list.tmp._uint;
 
108
  } else
 
109
  if (list.rtype == __VAlong) {
 
110
    iret = list.tmp._long;
 
111
  } else
 
112
  if (list.rtype == __VAulong) {
 
113
    iret = list.tmp._ulong;
 
114
  } else
 
115
  if (list.rtype == __VAlonglong) {
 
116
    iret = list.tmp._long;
 
117
  } else
 
118
  if (list.rtype == __VAulonglong) {
 
119
    iret = list.tmp._ulong;
 
120
  } else
 
121
  if (list.rtype == __VAfloat) {
 
122
    fret = list.tmp._float;
 
123
  } else
 
124
  if (list.rtype == __VAdouble) {
 
125
    dret = list.tmp._double;
 
126
  } else
 
127
  if (list.rtype == __VAvoidp) {
 
128
    iret = (long)list.tmp._ptr;
 
129
  } else
 
130
  if (list.rtype == __VAstruct) {
 
131
    /* __VA_PCC_STRUCT_RETURN and __VA_REGISTER_STRUCT_RETURN are ignored */
 
132
  }
 
133
}