Differences From Artifact [afde7bf522]:

To Artifact [2500b5af01]:


1
2
3
4
5
6
7
8
9
10
11
12
#ifndef _avcall_sparc_c				/*-*- C -*-*/
#define _avcall_sparc_c
/**
  Copyright 1993 Bill Triggs, <Bill.Triggs@inrialpes.fr>
  Copyright 1995-1999 Bruno Haible, <bruno@clisp.org>

  This is free software distributed under the GNU General Public
  Licence described in the file COPYING. Contact the author if
  you don't have this or can't live with it. There is ABSOLUTELY
  NO WARRANTY, explicit or implied, on this software.
**/
/*----------------------------------------------------------------------




|







1
2
3
4
5
6
7
8
9
10
11
12
#ifndef _avcall_sparc_c				/*-*- C -*-*/
#define _avcall_sparc_c
/**
  Copyright 1993 Bill Triggs, <Bill.Triggs@inrialpes.fr>
  Copyright 1995-1999, 2005 Bruno Haible, <bruno@clisp.org>

  This is free software distributed under the GNU General Public
  Licence described in the file COPYING. Contact the author if
  you don't have this or can't live with it. There is ABSOLUTELY
  NO WARRANTY, explicit or implied, on this software.
**/
/*----------------------------------------------------------------------
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

  __avword trampoline[6];		/* room for a trampoline */
  __avword space[__AV_ALIST_WORDS];	/* space for callee's stack frame */
  __avword *argframe = sp + 17;		/* stack offset for argument list */
  int arglen = l->aptr - l->args;
  __avword i;

  if ((l->rtype == __AVstruct) && !(l->flags & __AV_SUNCC_STRUCT_RETURN))
    argframe[-1] = (__avword)l->raddr;	/* push struct return address */

  {
    int i;
    for (i = 6; i < arglen; i++)	/* push excess function args */
      argframe[i] = l->args[i];
  }







|







73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

  __avword trampoline[6];		/* room for a trampoline */
  __avword space[__AV_ALIST_WORDS];	/* space for callee's stack frame */
  __avword *argframe = sp + 17;		/* stack offset for argument list */
  int arglen = l->aptr - l->args;
  __avword i;

  if (l->rtype == __AVstruct)
    argframe[-1] = (__avword)l->raddr;	/* push struct return address */

  {
    int i;
    for (i = 6; i < arglen; i++)	/* push excess function args */
      argframe[i] = l->args[i];
  }
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
      o0 = l->args[0]; o1 = l->args[1]; o2 = l->args[2];
      o3 = l->args[3]; o4 = l->args[4]; o5 = l->args[5];
      callee = l->func;
      goto *(void*)trampoline;
    }

					/* call function with 1st 6 args */
  i = ({ __avword iret;	/* %o0 */
         iret = (*l->func)(l->args[0], l->args[1], l->args[2],
			   l->args[3], l->args[4], l->args[5]);
         asm ("nop");	/* struct returning functions skip this instruction */
         iret;
       });

  /* save return value */







|







104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
      o0 = l->args[0]; o1 = l->args[1]; o2 = l->args[2];
      o3 = l->args[3]; o4 = l->args[4]; o5 = l->args[5];
      callee = l->func;
      goto *(void*)trampoline;
    }

					/* call function with 1st 6 args */
  i = ({ register __avword iret __asm__("%o0");
         iret = (*l->func)(l->args[0], l->args[1], l->args[2],
			   l->args[3], l->args[4], l->args[5]);
         asm ("nop");	/* struct returning functions skip this instruction */
         iret;
       });

  /* save return value */
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
  if (l->rtype == __AVdouble) {
    RETURN(double, dret);
  } else
  if (l->rtype == __AVvoidp) {
    RETURN(void*, i);
  } else
  if (l->rtype == __AVstruct) {
    /* This is a kludge for old Sun cc and is probably fragile. */
    if (l->flags & __AV_SUNCC_STRUCT_RETURN) {
      /* Sun cc struct return convention */
      if (l->rsize == sizeof(char)) {
        RETURN(char, ((char*)sp)[-1]);
      } else
      if (l->rsize == sizeof(short)) {
        RETURN(short, ((short*)sp)[-1]);
      } else
      if (l->rsize == sizeof(int)) {
        RETURN(int, ((int*)sp)[-1]);
      } else
      if (l->rsize == sizeof(double)) {
        ((int*)l->raddr)[0] = ((int*)sp)[-2];
        ((int*)l->raddr)[1] = ((int*)sp)[-1];
      } else
      if (l->rsize % 4) {
        char* dstaddr = (char*)l->raddr;
        char* srcaddr = (char*)((long)sp - l->rsize);
        unsigned int count = l->rsize;
        if (count > 4)
          srcaddr = (char*)((long)srcaddr & -4);
        while (count > 0) {
          *dstaddr++ = *srcaddr++;
          count--;
        }
      } else {
        __avword* dstaddr = (__avword*)l->raddr;
        __avword* srcaddr = (__avword*)((long)sp - l->rsize);
        while (srcaddr < sp)
          *dstaddr++ = *srcaddr++;
      }
    } else {
      if (l->flags & __AV_PCC_STRUCT_RETURN) {
        /* pcc struct return convention: need a  *(TYPE*)l->raddr = *(TYPE*)i;  */
        if (l->rsize == sizeof(char)) {
          RETURN(char, *(char*)i);
        } else
        if (l->rsize == sizeof(short)) {
          RETURN(short, *(short*)i);
        } else
        if (l->rsize == sizeof(int)) {
          RETURN(int, *(int*)i);
        } else
        if (l->rsize == sizeof(double)) {
          ((int*)l->raddr)[0] = ((int*)i)[0];
          ((int*)l->raddr)[1] = ((int*)i)[1];
        } else {
          int n = (l->rsize + sizeof(__avword)-1)/sizeof(__avword);
          while (--n >= 0)
            ((__avword*)l->raddr)[n] = ((__avword*)i)[n];
        }
      } else {
        /* normal struct return convention */
        if (l->flags & __AV_SMALL_STRUCT_RETURN) {
          if (l->rsize == sizeof(char)) {
            RETURN(char, i);
          } else
          if (l->rsize == sizeof(short)) {
            RETURN(short, i);
          } else
          if (l->rsize == sizeof(int)) {
            RETURN(int, i);
          }
        }
      }
    }
  }
  return 0;
}

#endif /*_avcall_sparc_c */







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<








163
164
165
166
167
168
169

































170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199

200
201
202
203
204
205
206
207
  if (l->rtype == __AVdouble) {
    RETURN(double, dret);
  } else
  if (l->rtype == __AVvoidp) {
    RETURN(void*, i);
  } else
  if (l->rtype == __AVstruct) {

































    if (l->flags & __AV_PCC_STRUCT_RETURN) {
      /* pcc struct return convention: need a  *(TYPE*)l->raddr = *(TYPE*)i;  */
      if (l->rsize == sizeof(char)) {
        RETURN(char, *(char*)i);
      } else
      if (l->rsize == sizeof(short)) {
        RETURN(short, *(short*)i);
      } else
      if (l->rsize == sizeof(int)) {
        RETURN(int, *(int*)i);
      } else
      if (l->rsize == sizeof(double)) {
        ((int*)l->raddr)[0] = ((int*)i)[0];
        ((int*)l->raddr)[1] = ((int*)i)[1];
      } else {
        int n = (l->rsize + sizeof(__avword)-1)/sizeof(__avword);
        while (--n >= 0)
          ((__avword*)l->raddr)[n] = ((__avword*)i)[n];
      }
    } else {
      /* normal struct return convention */
      if (l->flags & __AV_SMALL_STRUCT_RETURN) {
        if (l->rsize == sizeof(char)) {
          RETURN(char, i);
        } else
        if (l->rsize == sizeof(short)) {
          RETURN(short, i);
        } else
        if (l->rsize == sizeof(int)) {
          RETURN(int, i);

        }
      }
    }
  }
  return 0;
}

#endif /*_avcall_sparc_c */