Artifact c5584f69c0cb0830edae3a2eb0d885c830c75c4e:


0000: 23 69 66 6e 64 65 66 20 5f 61 76 63 61 6c 6c 5f  #ifndef _avcall_
0010: 69 33 38 36 5f 63 09 09 09 09 2f 2a 2d 2a 2d 20  i386_c..../*-*- 
0020: 43 20 2d 2a 2d 2a 2f 0a 23 64 65 66 69 6e 65 20  C -*-*/.#define 
0030: 5f 61 76 63 61 6c 6c 5f 69 33 38 36 5f 63 0a 2f  _avcall_i386_c./
0040: 2a 2a 0a 20 20 43 6f 70 79 72 69 67 68 74 20 31  **.  Copyright 1
0050: 39 39 33 20 42 69 6c 6c 20 54 72 69 67 67 73 2c  993 Bill Triggs,
0060: 20 3c 42 69 6c 6c 2e 54 72 69 67 67 73 40 69 6e   <Bill.Triggs@in
0070: 72 69 61 6c 70 65 73 2e 66 72 3e 0a 20 20 43 6f  rialpes.fr>.  Co
0080: 70 79 72 69 67 68 74 20 31 39 39 35 2d 31 39 39  pyright 1995-199
0090: 39 20 42 72 75 6e 6f 20 48 61 69 62 6c 65 2c 20  9 Bruno Haible, 
00a0: 3c 62 72 75 6e 6f 40 63 6c 69 73 70 2e 6f 72 67  <bruno@clisp.org
00b0: 3e 0a 0a 20 20 54 68 69 73 20 69 73 20 66 72 65  >..  This is fre
00c0: 65 20 73 6f 66 74 77 61 72 65 20 64 69 73 74 72  e software distr
00d0: 69 62 75 74 65 64 20 75 6e 64 65 72 20 74 68 65  ibuted under the
00e0: 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 50 75 62   GNU General Pub
00f0: 6c 69 63 0a 20 20 4c 69 63 65 6e 63 65 20 64 65  lic.  Licence de
0100: 73 63 72 69 62 65 64 20 69 6e 20 74 68 65 20 66  scribed in the f
0110: 69 6c 65 20 43 4f 50 59 49 4e 47 2e 20 43 6f 6e  ile COPYING. Con
0120: 74 61 63 74 20 74 68 65 20 61 75 74 68 6f 72 20  tact the author 
0130: 69 66 0a 20 20 79 6f 75 20 64 6f 6e 27 74 20 68  if.  you don't h
0140: 61 76 65 20 74 68 69 73 20 6f 72 20 63 61 6e 27  ave this or can'
0150: 74 20 6c 69 76 65 20 77 69 74 68 20 69 74 2e 20  t live with it. 
0160: 54 68 65 72 65 20 69 73 20 41 42 53 4f 4c 55 54  There is ABSOLUT
0170: 45 4c 59 0a 20 20 4e 4f 20 57 41 52 52 41 4e 54  ELY.  NO WARRANT
0180: 59 2c 20 65 78 70 6c 69 63 69 74 20 6f 72 20 69  Y, explicit or i
0190: 6d 70 6c 69 65 64 2c 20 6f 6e 20 74 68 69 73 20  mplied, on this 
01a0: 73 6f 66 74 77 61 72 65 2e 0a 2a 2a 2f 0a 2f 2a  software..**/./*
01b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
01c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
01d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
01e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
01f0: 2d 2d 2d 2d 2d 2d 0a 20 20 21 21 21 20 54 48 49  ------.  !!! THI
0200: 53 20 52 4f 55 54 49 4e 45 20 4d 55 53 54 20 42  S ROUTINE MUST B
0210: 45 20 43 4f 4d 50 49 4c 45 44 20 67 63 63 20 2d  E COMPILED gcc -
0220: 4f 20 2d 66 6e 6f 2d 6f 6d 69 74 2d 66 72 61 6d  O -fno-omit-fram
0230: 65 2d 70 6f 69 6e 74 65 72 20 21 21 21 0a 0a 20  e-pointer !!!.. 
0240: 20 46 6f 72 65 69 67 6e 20 66 75 6e 63 74 69 6f   Foreign functio
0250: 6e 20 69 6e 74 65 72 66 61 63 65 20 66 6f 72 20  n interface for 
0260: 61 20 4c 69 6e 75 78 20 69 33 38 36 2f 34 38 36  a Linux i386/486
0270: 20 77 69 74 68 20 67 63 63 2e 0a 0a 20 20 54 68   with gcc...  Th
0280: 69 73 20 63 61 6c 6c 73 20 61 20 43 20 66 75 6e  is calls a C fun
0290: 63 74 69 6f 6e 20 77 69 74 68 20 61 6e 20 61 72  ction with an ar
02a0: 67 75 6d 65 6e 74 20 6c 69 73 74 20 62 75 69 6c  gument list buil
02b0: 74 20 75 70 20 75 73 69 6e 67 20 6d 61 63 72 6f  t up using macro
02c0: 73 0a 20 20 64 65 66 69 6e 65 64 20 69 6e 20 61  s.  defined in a
02d0: 76 5f 63 61 6c 6c 2e 68 2e 0a 0a 20 20 69 33 38  v_call.h...  i38
02e0: 36 20 41 72 67 75 6d 65 6e 74 20 50 61 73 73 69  6 Argument Passi
02f0: 6e 67 20 43 6f 6e 76 65 6e 74 69 6f 6e 73 3a 0a  ng Conventions:.
0300: 0a 20 20 41 6c 6c 20 61 72 67 75 6d 65 6e 74 73  .  All arguments
0310: 20 61 72 65 20 70 61 73 73 65 64 20 6f 6e 20 74   are passed on t
0320: 68 65 20 73 74 61 63 6b 20 77 69 74 68 20 77 6f  he stack with wo
0330: 72 64 20 61 6c 69 67 6e 6d 65 6e 74 2e 20 44 6f  rd alignment. Do
0340: 75 62 6c 65 73 20 74 61 6b 65 0a 20 20 74 77 6f  ubles take.  two
0350: 20 77 6f 72 64 73 2e 20 53 74 72 75 63 74 75 72   words. Structur
0360: 65 20 61 72 67 73 20 61 72 65 20 70 61 73 73 65  e args are passe
0370: 64 20 61 73 20 74 72 75 65 20 73 74 72 75 63 74  d as true struct
0380: 75 72 65 73 20 65 6d 62 65 64 64 65 64 20 69 6e  ures embedded in
0390: 20 74 68 65 0a 20 20 61 72 67 75 6d 65 6e 74 20   the.  argument 
03a0: 73 74 61 63 6b 2e 20 46 6c 6f 61 74 20 61 6e 64  stack. Float and
03b0: 20 64 6f 75 62 6c 65 20 72 65 74 75 72 6e 73 20   double returns 
03c0: 6f 66 74 65 6e 20 63 6f 6d 65 20 66 72 6f 6d 20  often come from 
03d0: 46 50 55 20 72 65 67 69 73 74 65 72 73 2e 0a 0a  FPU registers...
03e0: 20 20 54 6f 20 72 65 74 75 72 6e 20 61 20 73 74    To return a st
03f0: 72 75 63 74 75 72 65 2c 20 74 68 65 20 63 61 6c  ructure, the cal
0400: 6c 65 64 20 66 75 6e 63 74 69 6f 6e 20 63 6f 70  led function cop
0410: 69 65 73 20 74 68 65 20 76 61 6c 75 65 20 74 6f  ies the value to
0420: 20 73 70 61 63 65 0a 20 20 70 6f 69 6e 74 65 64   space.  pointed
0430: 20 74 6f 20 62 79 20 69 74 73 20 66 69 72 73 74   to by its first
0440: 20 61 72 67 75 6d 65 6e 74 2c 20 61 6e 64 20 61   argument, and a
0450: 6c 6c 20 6f 74 68 65 72 20 61 72 67 75 6d 65 6e  ll other argumen
0460: 74 73 20 61 72 65 20 73 68 69 66 74 65 64 0a 20  ts are shifted. 
0470: 20 64 6f 77 6e 20 62 79 20 6f 6e 65 2e 20 4f 6e   down by one. On
0480: 20 4e 65 58 54 73 74 65 70 2c 20 68 6f 77 65 76   NeXTstep, howev
0490: 65 72 2c 20 74 68 65 20 63 61 6c 6c 65 64 20 66  er, the called f
04a0: 75 6e 63 74 69 6f 6e 20 63 6f 70 69 65 73 20 74  unction copies t
04b0: 68 65 20 72 65 74 75 72 6e 0a 20 20 76 61 6c 75  he return.  valu
04c0: 65 20 74 6f 20 74 68 65 20 61 64 64 72 65 73 73  e to the address
04d0: 20 73 75 70 70 6c 69 65 64 20 69 6e 20 72 65 67   supplied in reg
04e0: 69 73 74 65 72 20 22 25 65 62 78 22 2e 20 47 63  ister "%ebx". Gc
04f0: 63 20 77 69 74 68 6f 75 74 0a 20 20 2d 66 70 63  c without.  -fpc
0500: 63 2d 73 74 72 75 63 74 2d 72 65 74 75 72 6e 20  c-struct-return 
0510: 72 65 74 75 72 6e 73 20 3c 3d 20 34 20 62 79 74  returns <= 4 byt
0520: 65 20 73 74 72 75 63 74 75 72 65 73 20 61 73 20  e structures as 
0530: 69 6e 74 65 67 65 72 73 2e 0a 0a 20 20 43 6f 6d  integers...  Com
0540: 70 69 6c 65 20 74 68 69 73 20 72 6f 75 74 69 6e  pile this routin
0550: 65 20 77 69 74 68 20 67 63 63 20 2d 4f 20 28 6f  e with gcc -O (o
0560: 72 20 2d 4f 32 20 2d 66 6e 6f 2d 6f 6d 69 74 2d  r -O2 -fno-omit-
0570: 66 72 61 6d 65 2d 70 6f 69 6e 74 65 72 20 6f 72  frame-pointer or
0580: 20 2d 67 20 2d 4f 29 0a 20 20 74 6f 20 67 65 74   -g -O).  to get
0590: 20 74 68 65 20 72 69 67 68 74 20 72 65 67 69 73   the right regis
05a0: 74 65 72 20 76 61 72 69 61 62 6c 65 73 2e 20 46  ter variables. F
05b0: 6f 72 20 6f 74 68 65 72 20 63 6f 6d 70 69 6c 65  or other compile
05c0: 72 73 20 75 73 65 20 74 68 65 0a 20 20 70 72 65  rs use the.  pre
05d0: 2d 63 6f 6d 70 69 6c 65 64 20 61 73 73 65 6d 62  -compiled assemb
05e0: 6c 65 72 20 76 65 72 73 69 6f 6e 2e 0a 0a 20 20  ler version...  
05f0: 2d 66 6f 6d 69 74 2d 66 72 61 6d 65 2d 70 6f 69  -fomit-frame-poi
0600: 6e 74 65 72 20 69 73 20 66 6f 72 62 69 64 64 65  nter is forbidde
0610: 6e 20 62 65 63 61 75 73 65 20 77 68 65 6e 20 63  n because when c
0620: 61 6c 6c 69 6e 67 20 73 74 72 75 63 74 75 72 65  alling structure
0630: 20 72 65 74 75 72 6e 69 6e 67 0a 20 20 66 75 6e   returning.  fun
0640: 63 74 69 6f 6e 73 20 28 74 68 65 20 22 69 20 3d  ctions (the "i =
0650: 20 28 2a 6c 2d 3e 66 75 6e 63 29 28 29 3b 22 20   (*l->func)();" 
0660: 6c 69 6e 65 20 62 65 6c 6f 77 29 20 74 68 65 20  line below) the 
0670: 63 61 6c 6c 65 64 20 66 75 6e 63 74 69 6f 6e 73  called functions
0680: 20 70 6f 70 73 0a 20 20 74 68 65 20 72 65 74 75   pops.  the retu
0690: 72 6e 20 76 61 6c 75 65 20 63 6f 6e 74 61 69 6e  rn value contain
06a0: 65 72 20 70 6f 69 6e 74 65 72 20 66 72 6f 6d 20  er pointer from 
06b0: 74 68 65 20 73 74 61 63 6b 3a 20 22 72 65 74 20  the stack: "ret 
06c0: 24 34 22 20 69 6e 73 74 65 61 64 20 6f 66 0a 20  $4" instead of. 
06d0: 20 22 72 65 74 22 2e 20 28 53 65 65 20 67 63 63   "ret". (See gcc
06e0: 2d 32 2e 36 2e 33 20 6d 61 63 72 6f 20 52 45 54  -2.6.3 macro RET
06f0: 55 52 4e 5f 50 4f 50 53 5f 41 52 47 53 2e 29 20  URN_POPS_ARGS.) 
0700: 46 72 6f 6d 20 6f 75 72 20 70 6f 69 6e 74 20 6f  From our point o
0710: 66 20 76 69 65 77 2c 20 25 65 73 70 0a 20 20 67  f view, %esp.  g
0720: 65 74 73 20 6d 61 67 69 63 61 6c 6c 79 20 69 6e  ets magically in
0730: 63 72 65 6d 65 6e 74 65 64 2e 20 41 20 77 6f 72  cremented. A wor
0740: 6b 61 72 6f 75 6e 64 20 77 6f 75 6c 64 20 62 65  karound would be
0750: 20 74 6f 20 70 75 73 68 20 74 68 65 20 72 65 74   to push the ret
0760: 75 72 6e 20 76 61 6c 75 65 0a 20 20 63 6f 6e 74  urn value.  cont
0770: 61 69 6e 65 72 20 70 6f 69 6e 74 65 72 20 75 73  ainer pointer us
0780: 69 6e 67 20 61 6e 20 5f 5f 61 73 6d 5f 5f 28 22  ing an __asm__("
0790: 70 75 73 68 6c 20 25 30 22 20 3a 20 3a 20 3a 20  pushl %0" : : : 
07a0: 2e 2e 2e 29 20 69 6e 73 74 72 75 63 74 69 6f 6e  ...) instruction
07b0: 2e 0a 20 20 53 69 6d 69 6c 61 72 6c 79 2c 20 77  ..  Similarly, w
07c0: 68 65 6e 20 63 61 6c 6c 69 6e 67 20 66 75 6e 63  hen calling func
07d0: 74 69 6f 6e 73 20 77 69 74 68 20 60 73 74 64 63  tions with `stdc
07e0: 61 6c 6c 27 20 6c 69 6e 6b 61 67 65 2c 20 25 65  all' linkage, %e
07f0: 73 70 20 61 6c 73 6f 20 67 65 74 73 0a 20 20 69  sp also gets.  i
0800: 6e 63 72 65 6d 65 6e 74 65 64 3a 20 61 6c 6c 20  ncremented: all 
0810: 61 72 67 75 6d 65 6e 74 73 20 28 69 6e 63 6c 75  arguments (inclu
0820: 64 69 6e 67 20 74 68 65 20 72 65 74 75 72 6e 20  ding the return 
0830: 76 61 6c 75 65 20 63 6f 6e 74 61 69 6e 65 72 20  value container 
0840: 70 6f 69 6e 74 65 72 29 0a 20 20 61 72 65 20 70  pointer).  are p
0850: 6f 70 70 65 64 20 66 72 6f 6d 20 74 68 65 20 73  opped from the s
0860: 74 61 63 6b 2e 0a 20 20 2d 2d 2d 2d 2d 2d 2d 2d  tack..  --------
0870: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0880: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0890: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
08a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2a 2f  --------------*/
08b0: 0a 23 69 6e 63 6c 75 64 65 20 22 61 76 63 61 6c  .#include "avcal
08c0: 6c 2e 68 2e 69 6e 22 0a 0a 23 64 65 66 69 6e 65  l.h.in"..#define
08d0: 20 52 45 54 55 52 4e 28 54 59 50 45 2c 56 41 4c   RETURN(TYPE,VAL
08e0: 29 09 28 2a 28 54 59 50 45 2a 29 6c 2d 3e 72 61  ).(*(TYPE*)l->ra
08f0: 64 64 72 20 3d 20 28 54 59 50 45 29 28 56 41 4c  ddr = (TYPE)(VAL
0900: 29 29 0a 0a 69 6e 74 0a 5f 5f 62 75 69 6c 74 69  ))..int.__builti
0910: 6e 5f 61 76 63 61 6c 6c 28 61 76 5f 61 6c 69 73  n_avcall(av_alis
0920: 74 2a 20 6c 29 0a 7b 0a 20 20 72 65 67 69 73 74  t* l).{.  regist
0930: 65 72 20 5f 5f 61 76 77 6f 72 64 2a 09 73 70 09  er __avword*.sp.
0940: 5f 5f 61 73 6d 5f 5f 28 22 73 70 22 29 3b 09 2f  __asm__("sp");./
0950: 2a 20 43 20 6e 61 6d 65 73 20 66 6f 72 20 72 65  * C names for re
0960: 67 69 73 74 65 72 73 20 2a 2f 0a 2f 2a 72 65 67  gisters */./*reg
0970: 69 73 74 65 72 20 5f 5f 61 76 77 6f 72 64 09 69  ister __avword.i
0980: 72 65 74 09 5f 5f 61 73 6d 5f 5f 28 22 65 61 78  ret.__asm__("eax
0990: 22 29 3b 20 2a 2f 0a 20 20 72 65 67 69 73 74 65  "); */.  registe
09a0: 72 20 5f 5f 61 76 77 6f 72 64 09 69 72 65 74 32  r __avword.iret2
09b0: 09 5f 5f 61 73 6d 5f 5f 28 22 65 64 78 22 29 3b  .__asm__("edx");
09c0: 0a 0a 20 20 5f 5f 61 76 77 6f 72 64 2a 20 61 72  ..  __avword* ar
09d0: 67 66 72 61 6d 65 20 3d 20 28 73 70 20 2d 3d 20  gframe = (sp -= 
09e0: 5f 5f 41 56 5f 41 4c 49 53 54 5f 57 4f 52 44 53  __AV_ALIST_WORDS
09f0: 29 3b 20 2f 2a 20 6d 61 6b 65 20 72 6f 6f 6d 20  ); /* make room 
0a00: 66 6f 72 20 61 72 67 75 6d 65 6e 74 20 6c 69 73  for argument lis
0a10: 74 20 2a 2f 0a 20 20 69 6e 74 20 61 72 67 6c 65  t */.  int argle
0a20: 6e 20 3d 20 6c 2d 3e 61 70 74 72 20 2d 20 6c 2d  n = l->aptr - l-
0a30: 3e 61 72 67 73 3b 0a 20 20 5f 5f 61 76 77 6f 72  >args;.  __avwor
0a40: 64 20 69 3b 0a 0a 20 20 66 6f 72 20 28 69 20 3d  d i;..  for (i =
0a50: 20 30 3b 20 69 20 3c 20 61 72 67 6c 65 6e 3b 20   0; i < arglen; 
0a60: 69 2b 2b 29 09 09 2f 2a 20 70 75 73 68 20 66 75  i++)../* push fu
0a70: 6e 63 74 69 6f 6e 20 61 72 67 73 20 6f 6e 74 6f  nction args onto
0a80: 20 73 74 61 63 6b 20 2a 2f 0a 20 20 20 20 61 72   stack */.    ar
0a90: 67 66 72 61 6d 65 5b 69 5d 20 3d 20 6c 2d 3e 61  gframe[i] = l->a
0aa0: 72 67 73 5b 69 5d 3b 0a 0a 20 20 2f 2a 20 73 74  rgs[i];..  /* st
0ab0: 72 75 63 74 20 72 65 74 75 72 6e 20 61 64 64 72  ruct return addr
0ac0: 65 73 73 20 2a 2f 0a 20 20 69 66 20 28 28 6c 2d  ess */.  if ((l-
0ad0: 3e 66 6c 61 67 73 20 26 20 5f 5f 41 56 5f 4e 45  >flags & __AV_NE
0ae0: 58 54 47 43 43 5f 53 54 52 55 43 54 5f 52 45 54  XTGCC_STRUCT_RET
0af0: 55 52 4e 29 20 26 26 20 28 6c 2d 3e 72 74 79 70  URN) && (l->rtyp
0b00: 65 20 3d 3d 20 5f 5f 41 56 73 74 72 75 63 74 29  e == __AVstruct)
0b10: 29 0a 20 20 20 20 5f 5f 61 73 6d 5f 5f 28 22 6d  ).    __asm__("m
0b20: 6f 76 6c 20 25 30 2c 25 25 65 62 78 22 20 3a 20  ovl %0,%%ebx" : 
0b30: 3a 20 22 67 22 20 28 6c 2d 3e 72 61 64 64 72 29  : "g" (l->raddr)
0b40: 20 3a 20 22 62 78 22 20 2f 2a 20 25 65 62 78 20   : "bx" /* %ebx 
0b50: 2a 2f 29 3b 0a 0a 20 20 2f 2a 20 63 61 6c 6c 20  */);..  /* call 
0b60: 66 75 6e 63 74 69 6f 6e 20 2a 2f 0a 20 20 69 66  function */.  if
0b70: 20 28 6c 2d 3e 72 74 79 70 65 20 3d 3d 20 5f 5f   (l->rtype == __
0b80: 41 56 66 6c 6f 61 74 29 20 7b 0a 20 20 20 20 2a  AVfloat) {.    *
0b90: 28 66 6c 6f 61 74 2a 29 6c 2d 3e 72 61 64 64 72  (float*)l->raddr
0ba0: 20 3d 20 28 2a 28 66 6c 6f 61 74 28 2a 29 28 29   = (*(float(*)()
0bb0: 29 6c 2d 3e 66 75 6e 63 29 28 29 3b 0a 20 20 7d  )l->func)();.  }
0bc0: 20 65 6c 73 65 0a 20 20 69 66 20 28 6c 2d 3e 72   else.  if (l->r
0bd0: 74 79 70 65 20 3d 3d 20 5f 5f 41 56 64 6f 75 62  type == __AVdoub
0be0: 6c 65 29 20 7b 0a 20 20 20 20 2a 28 64 6f 75 62  le) {.    *(doub
0bf0: 6c 65 2a 29 6c 2d 3e 72 61 64 64 72 20 3d 20 28  le*)l->raddr = (
0c00: 2a 28 64 6f 75 62 6c 65 28 2a 29 28 29 29 6c 2d  *(double(*)())l-
0c10: 3e 66 75 6e 63 29 28 29 3b 0a 20 20 7d 20 65 6c  >func)();.  } el
0c20: 73 65 20 7b 0a 20 20 20 20 69 20 3d 20 28 2a 6c  se {.    i = (*l
0c30: 2d 3e 66 75 6e 63 29 28 29 3b 0a 0a 20 20 20 20  ->func)();..    
0c40: 2f 2a 20 73 61 76 65 20 72 65 74 75 72 6e 20 76  /* save return v
0c50: 61 6c 75 65 20 2a 2f 0a 20 20 20 20 69 66 20 28  alue */.    if (
0c60: 6c 2d 3e 72 74 79 70 65 20 3d 3d 20 5f 5f 41 56  l->rtype == __AV
0c70: 76 6f 69 64 29 20 7b 0a 20 20 20 20 7d 20 65 6c  void) {.    } el
0c80: 73 65 0a 20 20 20 20 69 66 20 28 6c 2d 3e 72 74  se.    if (l->rt
0c90: 79 70 65 20 3d 3d 20 5f 5f 41 56 77 6f 72 64 29  ype == __AVword)
0ca0: 20 7b 0a 20 20 20 20 20 20 52 45 54 55 52 4e 28   {.      RETURN(
0cb0: 5f 5f 61 76 77 6f 72 64 2c 20 69 29 3b 0a 20 20  __avword, i);.  
0cc0: 20 20 7d 20 65 6c 73 65 0a 20 20 20 20 69 66 20    } else.    if 
0cd0: 28 6c 2d 3e 72 74 79 70 65 20 3d 3d 20 5f 5f 41  (l->rtype == __A
0ce0: 56 63 68 61 72 29 20 7b 0a 20 20 20 20 20 20 52  Vchar) {.      R
0cf0: 45 54 55 52 4e 28 63 68 61 72 2c 20 69 29 3b 0a  ETURN(char, i);.
0d00: 20 20 20 20 7d 20 65 6c 73 65 0a 20 20 20 20 69      } else.    i
0d10: 66 20 28 6c 2d 3e 72 74 79 70 65 20 3d 3d 20 5f  f (l->rtype == _
0d20: 5f 41 56 73 63 68 61 72 29 20 7b 0a 20 20 20 20  _AVschar) {.    
0d30: 20 20 52 45 54 55 52 4e 28 73 69 67 6e 65 64 20    RETURN(signed 
0d40: 63 68 61 72 2c 20 69 29 3b 0a 20 20 20 20 7d 20  char, i);.    } 
0d50: 65 6c 73 65 0a 20 20 20 20 69 66 20 28 6c 2d 3e  else.    if (l->
0d60: 72 74 79 70 65 20 3d 3d 20 5f 5f 41 56 75 63 68  rtype == __AVuch
0d70: 61 72 29 20 7b 0a 20 20 20 20 20 20 52 45 54 55  ar) {.      RETU
0d80: 52 4e 28 75 6e 73 69 67 6e 65 64 20 63 68 61 72  RN(unsigned char
0d90: 2c 20 69 29 3b 0a 20 20 20 20 7d 20 65 6c 73 65  , i);.    } else
0da0: 0a 20 20 20 20 69 66 20 28 6c 2d 3e 72 74 79 70  .    if (l->rtyp
0db0: 65 20 3d 3d 20 5f 5f 41 56 73 68 6f 72 74 29 20  e == __AVshort) 
0dc0: 7b 0a 20 20 20 20 20 20 52 45 54 55 52 4e 28 73  {.      RETURN(s
0dd0: 68 6f 72 74 2c 20 69 29 3b 0a 20 20 20 20 7d 20  hort, i);.    } 
0de0: 65 6c 73 65 0a 20 20 20 20 69 66 20 28 6c 2d 3e  else.    if (l->
0df0: 72 74 79 70 65 20 3d 3d 20 5f 5f 41 56 75 73 68  rtype == __AVush
0e00: 6f 72 74 29 20 7b 0a 20 20 20 20 20 20 52 45 54  ort) {.      RET
0e10: 55 52 4e 28 75 6e 73 69 67 6e 65 64 20 73 68 6f  URN(unsigned sho
0e20: 72 74 2c 20 69 29 3b 0a 20 20 20 20 7d 20 65 6c  rt, i);.    } el
0e30: 73 65 0a 20 20 20 20 69 66 20 28 6c 2d 3e 72 74  se.    if (l->rt
0e40: 79 70 65 20 3d 3d 20 5f 5f 41 56 69 6e 74 29 20  ype == __AVint) 
0e50: 7b 0a 20 20 20 20 20 20 52 45 54 55 52 4e 28 69  {.      RETURN(i
0e60: 6e 74 2c 20 69 29 3b 0a 20 20 20 20 7d 20 65 6c  nt, i);.    } el
0e70: 73 65 0a 20 20 20 20 69 66 20 28 6c 2d 3e 72 74  se.    if (l->rt
0e80: 79 70 65 20 3d 3d 20 5f 5f 41 56 75 69 6e 74 29  ype == __AVuint)
0e90: 20 7b 0a 20 20 20 20 20 20 52 45 54 55 52 4e 28   {.      RETURN(
0ea0: 75 6e 73 69 67 6e 65 64 20 69 6e 74 2c 20 69 29  unsigned int, i)
0eb0: 3b 0a 20 20 20 20 7d 20 65 6c 73 65 0a 20 20 20  ;.    } else.   
0ec0: 20 69 66 20 28 6c 2d 3e 72 74 79 70 65 20 3d 3d   if (l->rtype ==
0ed0: 20 5f 5f 41 56 6c 6f 6e 67 29 20 7b 0a 20 20 20   __AVlong) {.   
0ee0: 20 20 20 52 45 54 55 52 4e 28 6c 6f 6e 67 2c 20     RETURN(long, 
0ef0: 69 29 3b 0a 20 20 20 20 7d 20 65 6c 73 65 0a 20  i);.    } else. 
0f00: 20 20 20 69 66 20 28 6c 2d 3e 72 74 79 70 65 20     if (l->rtype 
0f10: 3d 3d 20 5f 5f 41 56 75 6c 6f 6e 67 29 20 7b 0a  == __AVulong) {.
0f20: 20 20 20 20 20 20 52 45 54 55 52 4e 28 75 6e 73        RETURN(uns
0f30: 69 67 6e 65 64 20 6c 6f 6e 67 2c 20 69 29 3b 0a  igned long, i);.
0f40: 20 20 20 20 7d 20 65 6c 73 65 0a 20 20 20 20 69      } else.    i
0f50: 66 20 28 6c 2d 3e 72 74 79 70 65 20 3d 3d 20 5f  f (l->rtype == _
0f60: 5f 41 56 6c 6f 6e 67 6c 6f 6e 67 20 7c 7c 20 6c  _AVlonglong || l
0f70: 2d 3e 72 74 79 70 65 20 3d 3d 20 5f 5f 41 56 75  ->rtype == __AVu
0f80: 6c 6f 6e 67 6c 6f 6e 67 29 20 7b 0a 20 20 20 20  longlong) {.    
0f90: 20 20 28 28 5f 5f 61 76 77 6f 72 64 2a 29 6c 2d    ((__avword*)l-
0fa0: 3e 72 61 64 64 72 29 5b 30 5d 20 3d 20 69 3b 0a  >raddr)[0] = i;.
0fb0: 20 20 20 20 20 20 28 28 5f 5f 61 76 77 6f 72 64        ((__avword
0fc0: 2a 29 6c 2d 3e 72 61 64 64 72 29 5b 31 5d 20 3d  *)l->raddr)[1] =
0fd0: 20 69 72 65 74 32 3b 0a 20 20 20 20 7d 20 65 6c   iret2;.    } el
0fe0: 73 65 0a 20 20 2f 2a 20 73 65 65 20 61 62 6f 76  se.  /* see abov
0ff0: 65 0a 20 20 20 20 69 66 20 28 6c 2d 3e 72 74 79  e.    if (l->rty
1000: 70 65 20 3d 3d 20 5f 5f 41 56 66 6c 6f 61 74 29  pe == __AVfloat)
1010: 20 7b 0a 20 20 20 20 7d 20 65 6c 73 65 0a 20 20   {.    } else.  
1020: 20 20 69 66 20 28 6c 2d 3e 72 74 79 70 65 20 3d    if (l->rtype =
1030: 3d 20 5f 5f 41 56 64 6f 75 62 6c 65 29 20 7b 0a  = __AVdouble) {.
1040: 20 20 20 20 7d 20 65 6c 73 65 0a 20 20 2a 2f 0a      } else.  */.
1050: 20 20 20 20 69 66 20 28 6c 2d 3e 72 74 79 70 65      if (l->rtype
1060: 20 3d 3d 20 5f 5f 41 56 76 6f 69 64 70 29 20 7b   == __AVvoidp) {
1070: 0a 20 20 20 20 20 20 52 45 54 55 52 4e 28 76 6f  .      RETURN(vo
1080: 69 64 2a 2c 20 69 29 3b 0a 20 20 20 20 7d 20 65  id*, i);.    } e
1090: 6c 73 65 0a 20 20 20 20 69 66 20 28 6c 2d 3e 72  lse.    if (l->r
10a0: 74 79 70 65 20 3d 3d 20 5f 5f 41 56 73 74 72 75  type == __AVstru
10b0: 63 74 29 20 7b 0a 20 20 20 20 20 20 69 66 20 28  ct) {.      if (
10c0: 6c 2d 3e 66 6c 61 67 73 20 26 20 5f 5f 41 56 5f  l->flags & __AV_
10d0: 50 43 43 5f 53 54 52 55 43 54 5f 52 45 54 55 52  PCC_STRUCT_RETUR
10e0: 4e 29 20 7b 0a 20 20 20 20 20 20 20 20 2f 2a 20  N) {.        /* 
10f0: 70 63 63 20 73 74 72 75 63 74 20 72 65 74 75 72  pcc struct retur
1100: 6e 20 63 6f 6e 76 65 6e 74 69 6f 6e 3a 20 6e 65  n convention: ne
1110: 65 64 20 61 20 20 2a 28 54 59 50 45 2a 29 6c 2d  ed a  *(TYPE*)l-
1120: 3e 72 61 64 64 72 20 3d 20 2a 28 54 59 50 45 2a  >raddr = *(TYPE*
1130: 29 69 3b 20 20 2a 2f 0a 20 20 20 20 20 20 20 20  )i;  */.        
1140: 69 66 20 28 6c 2d 3e 72 73 69 7a 65 20 3d 3d 20  if (l->rsize == 
1150: 73 69 7a 65 6f 66 28 63 68 61 72 29 29 20 7b 0a  sizeof(char)) {.
1160: 20 20 20 20 20 20 20 20 20 20 52 45 54 55 52 4e            RETURN
1170: 28 63 68 61 72 2c 20 2a 28 63 68 61 72 2a 29 69  (char, *(char*)i
1180: 29 3b 0a 20 20 20 20 20 20 20 20 7d 20 65 6c 73  );.        } els
1190: 65 0a 20 20 20 20 20 20 20 20 69 66 20 28 6c 2d  e.        if (l-
11a0: 3e 72 73 69 7a 65 20 3d 3d 20 73 69 7a 65 6f 66  >rsize == sizeof
11b0: 28 73 68 6f 72 74 29 29 20 7b 0a 20 20 20 20 20  (short)) {.     
11c0: 20 20 20 20 20 52 45 54 55 52 4e 28 73 68 6f 72       RETURN(shor
11d0: 74 2c 20 2a 28 73 68 6f 72 74 2a 29 69 29 3b 0a  t, *(short*)i);.
11e0: 20 20 20 20 20 20 20 20 7d 20 65 6c 73 65 0a 20          } else. 
11f0: 20 20 20 20 20 20 20 69 66 20 28 6c 2d 3e 72 73         if (l->rs
1200: 69 7a 65 20 3d 3d 20 73 69 7a 65 6f 66 28 69 6e  ize == sizeof(in
1210: 74 29 29 20 7b 0a 20 20 20 20 20 20 20 20 20 20  t)) {.          
1220: 52 45 54 55 52 4e 28 69 6e 74 2c 20 2a 28 69 6e  RETURN(int, *(in
1230: 74 2a 29 69 29 3b 0a 20 20 20 20 20 20 20 20 7d  t*)i);.        }
1240: 20 65 6c 73 65 0a 20 20 20 20 20 20 20 20 69 66   else.        if
1250: 20 28 6c 2d 3e 72 73 69 7a 65 20 3d 3d 20 73 69   (l->rsize == si
1260: 7a 65 6f 66 28 64 6f 75 62 6c 65 29 29 20 7b 0a  zeof(double)) {.
1270: 20 20 20 20 20 20 20 20 20 20 28 28 69 6e 74 2a            ((int*
1280: 29 6c 2d 3e 72 61 64 64 72 29 5b 30 5d 20 3d 20  )l->raddr)[0] = 
1290: 28 28 69 6e 74 2a 29 69 29 5b 30 5d 3b 0a 20 20  ((int*)i)[0];.  
12a0: 20 20 20 20 20 20 20 20 28 28 69 6e 74 2a 29 6c          ((int*)l
12b0: 2d 3e 72 61 64 64 72 29 5b 31 5d 20 3d 20 28 28  ->raddr)[1] = ((
12c0: 69 6e 74 2a 29 69 29 5b 31 5d 3b 0a 20 20 20 20  int*)i)[1];.    
12d0: 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 20 20 20      } else {.   
12e0: 20 20 20 20 20 20 20 69 6e 74 20 6e 20 3d 20 28         int n = (
12f0: 6c 2d 3e 72 73 69 7a 65 20 2b 20 73 69 7a 65 6f  l->rsize + sizeo
1300: 66 28 5f 5f 61 76 77 6f 72 64 29 2d 31 29 2f 73  f(__avword)-1)/s
1310: 69 7a 65 6f 66 28 5f 5f 61 76 77 6f 72 64 29 3b  izeof(__avword);
1320: 0a 20 20 20 20 20 20 20 20 20 20 77 68 69 6c 65  .          while
1330: 20 28 2d 2d 6e 20 3e 3d 20 30 29 0a 20 20 20 20   (--n >= 0).    
1340: 20 20 20 20 20 20 20 20 28 28 5f 5f 61 76 77 6f          ((__avwo
1350: 72 64 2a 29 6c 2d 3e 72 61 64 64 72 29 5b 6e 5d  rd*)l->raddr)[n]
1360: 20 3d 20 28 28 5f 5f 61 76 77 6f 72 64 2a 29 69   = ((__avword*)i
1370: 29 5b 6e 5d 3b 0a 20 20 20 20 20 20 20 20 7d 0a  )[n];.        }.
1380: 20 20 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 20        } else {. 
1390: 20 20 20 20 20 20 20 2f 2a 20 6e 6f 72 6d 61 6c         /* normal
13a0: 20 73 74 72 75 63 74 20 72 65 74 75 72 6e 20 63   struct return c
13b0: 6f 6e 76 65 6e 74 69 6f 6e 20 2a 2f 0a 20 20 20  onvention */.   
13c0: 20 20 20 20 20 69 66 20 28 6c 2d 3e 66 6c 61 67       if (l->flag
13d0: 73 20 26 20 5f 5f 41 56 5f 52 45 47 49 53 54 45  s & __AV_REGISTE
13e0: 52 5f 53 54 52 55 43 54 5f 52 45 54 55 52 4e 29  R_STRUCT_RETURN)
13f0: 20 7b 0a 20 20 20 20 20 20 20 20 20 20 69 66 20   {.          if 
1400: 28 6c 2d 3e 72 73 69 7a 65 20 3d 3d 20 73 69 7a  (l->rsize == siz
1410: 65 6f 66 28 63 68 61 72 29 29 20 7b 0a 20 20 20  eof(char)) {.   
1420: 20 20 20 20 20 20 20 20 20 52 45 54 55 52 4e 28           RETURN(
1430: 63 68 61 72 2c 20 69 29 3b 0a 20 20 20 20 20 20  char, i);.      
1440: 20 20 20 20 7d 20 65 6c 73 65 0a 20 20 20 20 20      } else.     
1450: 20 20 20 20 20 69 66 20 28 6c 2d 3e 72 73 69 7a       if (l->rsiz
1460: 65 20 3d 3d 20 73 69 7a 65 6f 66 28 73 68 6f 72  e == sizeof(shor
1470: 74 29 29 20 7b 0a 20 20 20 20 20 20 20 20 20 20  t)) {.          
1480: 20 20 52 45 54 55 52 4e 28 73 68 6f 72 74 2c 20    RETURN(short, 
1490: 69 29 3b 0a 20 20 20 20 20 20 20 20 20 20 7d 20  i);.          } 
14a0: 65 6c 73 65 0a 20 20 20 20 20 20 20 20 20 20 69  else.          i
14b0: 66 20 28 6c 2d 3e 72 73 69 7a 65 20 3d 3d 20 73  f (l->rsize == s
14c0: 69 7a 65 6f 66 28 69 6e 74 29 29 20 7b 0a 20 20  izeof(int)) {.  
14d0: 20 20 20 20 20 20 20 20 20 20 52 45 54 55 52 4e            RETURN
14e0: 28 69 6e 74 2c 20 69 29 3b 0a 20 20 20 20 20 20  (int, i);.      
14f0: 20 20 20 20 7d 20 65 6c 73 65 0a 20 20 20 20 20      } else.     
1500: 20 20 20 20 20 69 66 20 28 6c 2d 3e 72 73 69 7a       if (l->rsiz
1510: 65 20 3d 3d 20 32 2a 73 69 7a 65 6f 66 28 5f 5f  e == 2*sizeof(__
1520: 61 76 77 6f 72 64 29 29 20 7b 0a 20 20 20 20 20  avword)) {.     
1530: 20 20 20 20 20 20 20 28 28 5f 5f 61 76 77 6f 72         ((__avwor
1540: 64 2a 29 6c 2d 3e 72 61 64 64 72 29 5b 30 5d 20  d*)l->raddr)[0] 
1550: 3d 20 69 3b 0a 20 20 20 20 20 20 20 20 20 20 20  = i;.           
1560: 20 28 28 5f 5f 61 76 77 6f 72 64 2a 29 6c 2d 3e   ((__avword*)l->
1570: 72 61 64 64 72 29 5b 31 5d 20 3d 20 69 72 65 74  raddr)[1] = iret
1580: 32 3b 0a 20 20 20 20 20 20 20 20 20 20 7d 0a 20  2;.          }. 
1590: 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 7d         }.      }
15a0: 0a 20 20 20 20 7d 0a 20 20 7d 0a 20 20 72 65 74  .    }.  }.  ret
15b0: 75 72 6e 20 30 3b 0a 7d 0a 0a 23 65 6e 64 69 66  urn 0;.}..#endif
15c0: 20 2f 2a 5f 61 76 63 61 6c 6c 5f 69 33 38 36 5f   /*_avcall_i386_
15d0: 63 20 2a 2f 0a                                   c */.