0000: 2e 54 48 20 41 56 43 41 4c 4c 20 33 20 22 31 34 .TH AVCALL 3 "14
0010: 20 4a 61 6e 75 61 72 79 20 32 30 30 31 22 0a 2e January 2001"..
0020: 53 48 20 4e 41 4d 45 0a 61 76 63 61 6c 6c 20 5c SH NAME.avcall \
0030: 2d 20 62 75 69 6c 64 20 61 20 43 20 61 72 67 75 - build a C argu
0040: 6d 65 6e 74 20 6c 69 73 74 20 69 6e 63 72 65 6d ment list increm
0050: 65 6e 74 61 6c 6c 79 20 61 6e 64 20 63 61 6c 6c entally and call
0060: 20 61 20 43 20 66 75 6e 63 74 69 6f 6e 20 6f 6e a C function on
0070: 20 69 74 2e 0a 2e 53 48 20 53 59 4e 4f 50 53 49 it...SH SYNOPSI
0080: 53 0a 2e 42 20 23 69 6e 63 6c 75 64 65 20 3c 61 S..B #include <a
0090: 76 63 61 6c 6c 2e 68 3e 0a 2e 4c 50 0a 2e 42 49 vcall.h>..LP..BI
00a0: 20 22 61 76 5f 61 6c 69 73 74 20 22 20 61 6c 69 "av_alist " ali
00b0: 73 74 20 22 3b 22 0a 2e 4c 50 0a 2e 42 49 20 61 st ";"..LP..BI a
00c0: 76 5f 73 74 61 72 74 5f 20 74 79 70 65 20 22 28 v_start_ type "(
00d0: 22 20 61 6c 69 73 74 20 22 2c 20 22 20 22 26 66 " alist ", " "&f
00e0: 75 6e 63 22 0a 2e 52 49 20 22 5b 5b 22 5c 63 0a unc"..RI "[["\c.
00f0: 2e 42 49 20 22 2c 20 22 5c 63 0a 2e 49 20 72 65 .BI ", "\c..I re
0100: 74 75 72 6e 5f 74 79 70 65 5c 63 0a 2e 52 42 20 turn_type\c..RB
0110: 22 5d 22 20 22 2c 20 22 5c 63 0a 2e 49 20 22 26 "]" ", "\c..I "&
0120: 72 65 74 75 72 6e 5f 76 61 6c 75 65 22 5c 63 0a return_value"\c.
0130: 2e 52 42 20 22 5d 22 20 22 29 3b 22 0a 2e 4c 50 .RB "]" ");"..LP
0140: 0a 2e 42 49 20 61 76 5f 20 74 79 70 65 20 22 28 ..BI av_ type "(
0150: 22 20 61 6c 69 73 74 20 22 2c 20 22 5c 63 0a 2e " alist ", "\c..
0160: 52 49 20 22 5b 22 5c 63 0a 2e 49 42 20 61 72 67 RI "["\c..IB arg
0170: 5f 74 79 70 65 20 22 2c 22 5c 63 0a 2e 52 49 20 _type ","\c..RI
0180: 22 5d 20 22 5c 63 0a 2e 49 42 20 76 61 6c 75 65 "] "\c..IB value
0190: 20 22 29 3b 22 0a 2e 4c 50 0a 2e 42 49 20 22 61 ");"..LP..BI "a
01a0: 76 5f 63 61 6c 6c 28 22 20 61 6c 69 73 74 20 22 v_call(" alist "
01b0: 29 3b 22 0a 2e 49 58 20 20 22 61 76 5f 61 6c 69 );"..IX "av_ali
01c0: 73 74 22 20 20 22 22 20 20 22 5c 66 4c 61 76 5f st" "" "\fLav_
01d0: 61 6c 69 73 74 5c 66 50 20 5c 28 65 6d 20 61 76 alist\fP \(em av
01e0: 63 61 6c 6c 20 61 72 67 75 6d 65 6e 74 20 6c 69 call argument li
01f0: 73 74 20 64 65 63 6c 61 72 61 74 69 6f 6e 22 0a st declaration".
0200: 2e 49 58 20 20 22 61 76 5f 73 74 61 72 74 5f 74 .IX "av_start_t
0210: 79 70 65 28 29 22 20 20 22 22 20 20 22 5c 66 4c ype()" "" "\fL
0220: 61 76 5f 73 74 61 72 74 5f 74 79 70 65 28 29 5c av_start_type()\
0230: 66 50 20 5c 28 65 6d 20 69 6e 69 74 69 61 6c 69 fP \(em initiali
0240: 7a 65 20 61 76 63 61 6c 6c 20 66 75 6e 63 74 69 ze avcall functi
0250: 6f 6e 22 0a 2e 49 58 20 20 22 61 76 5f 74 79 70 on"..IX "av_typ
0260: 65 28 29 22 20 20 22 22 20 20 22 5c 66 4c 61 76 e()" "" "\fLav
0270: 5f 74 79 70 65 28 29 5c 66 50 20 5c 28 65 6d 20 _type()\fP \(em
0280: 70 75 73 68 20 6e 65 78 74 20 61 72 67 75 6d 65 push next argume
0290: 6e 74 20 69 6e 20 61 76 63 61 6c 6c 20 6c 69 73 nt in avcall lis
02a0: 74 22 0a 2e 49 58 20 20 22 61 76 5f 63 61 6c 6c t"..IX "av_call
02b0: 28 29 22 20 20 22 22 20 20 22 5c 66 4c 61 76 5f ()" "" "\fLav_
02c0: 63 61 6c 6c 28 29 5c 66 50 20 5c 28 65 6d 20 66 call()\fP \(em f
02d0: 69 6e 69 73 68 20 61 76 63 61 6c 6c 20 61 72 67 inish avcall arg
02e0: 75 6d 65 6e 74 20 6c 69 73 74 20 61 6e 64 20 63 ument list and c
02f0: 61 6c 6c 20 66 75 6e 63 74 69 6f 6e 22 0a 2e 53 all function"..S
0300: 48 20 44 45 53 43 52 49 50 54 49 4f 4e 0a 2e 4c H DESCRIPTION..L
0310: 50 0a 54 68 69 73 20 73 65 74 20 6f 66 20 6d 61 P.This set of ma
0320: 63 72 6f 73 20 62 75 69 6c 64 73 20 61 6e 20 61 cros builds an a
0330: 72 67 75 6d 65 6e 74 20 6c 69 73 74 20 66 6f 72 rgument list for
0340: 20 61 20 43 20 66 75 6e 63 74 69 6f 6e 20 61 6e a C function an
0350: 64 20 63 61 6c 6c 73 0a 74 68 65 20 66 75 6e 63 d calls.the func
0360: 74 69 6f 6e 20 6f 6e 20 69 74 2e 20 49 74 20 73 tion on it. It s
0370: 69 67 6e 69 66 69 63 61 6e 74 6c 79 20 72 65 64 ignificantly red
0380: 75 63 65 73 20 74 68 65 20 61 6d 6f 75 6e 74 20 uces the amount
0390: 6f 66 20 60 67 6c 75 65 27 20 63 6f 64 65 0a 72 of `glue' code.r
03a0: 65 71 75 69 72 65 64 20 66 6f 72 20 70 61 72 73 equired for pars
03b0: 65 72 73 2c 20 64 65 62 75 67 67 65 72 73 2c 20 ers, debuggers,
03c0: 69 6d 62 65 64 64 65 64 20 69 6e 74 65 72 70 72 imbedded interpr
03d0: 65 74 65 72 73 2c 20 43 20 65 78 74 65 6e 73 69 eters, C extensi
03e0: 6f 6e 73 20 74 6f 0a 61 70 70 6c 69 63 61 74 69 ons to.applicati
03f0: 6f 6e 20 70 72 6f 67 72 61 6d 73 20 61 6e 64 20 on programs and
0400: 6f 74 68 65 72 20 73 69 74 75 61 74 69 6f 6e 73 other situations
0410: 20 77 68 65 72 65 20 63 6f 6c 6c 65 63 74 69 6f where collectio
0420: 6e 73 20 6f 66 20 66 75 6e 63 74 69 6f 6e 73 0a ns of functions.
0430: 6e 65 65 64 20 74 6f 20 62 65 20 63 61 6c 6c 65 need to be calle
0440: 64 20 6f 6e 20 6c 69 73 74 73 20 6f 66 20 65 78 d on lists of ex
0450: 74 65 72 6e 61 6c 6c 79 2d 73 75 70 70 6c 69 65 ternally-supplie
0460: 64 20 61 72 67 75 6d 65 6e 74 73 2e 0a 0a 46 75 d arguments...Fu
0470: 6e 63 74 69 6f 6e 20 63 61 6c 6c 69 6e 67 20 63 nction calling c
0480: 6f 6e 76 65 6e 74 69 6f 6e 73 20 64 69 66 66 65 onventions diffe
0490: 72 20 63 6f 6e 73 69 64 65 72 61 62 6c 79 20 6f r considerably o
04a0: 6e 20 64 69 66 66 65 72 65 6e 74 0a 6d 61 63 68 n different.mach
04b0: 69 6e 65 73 20 61 6e 64 0a 2e 49 20 61 76 63 61 ines and..I avca
04c0: 6c 6c 0a 61 74 74 65 6d 70 74 73 20 74 6f 20 70 ll.attempts to p
04d0: 72 6f 76 69 64 65 20 73 6f 6d 65 20 64 65 67 72 rovide some degr
04e0: 65 65 20 6f 66 20 69 73 6f 6c 61 74 69 6f 6e 20 ee of isolation
04f0: 66 72 6f 6d 20 73 75 63 68 20 61 72 63 68 69 74 from such archit
0500: 65 63 74 75 72 65 0a 64 65 70 65 6e 64 65 6e 63 ecture.dependenc
0510: 69 65 73 2e 0a 0a 54 68 65 20 69 6e 74 65 72 66 ies...The interf
0520: 61 63 65 20 69 73 20 6c 69 6b 65 20 0a 2e 42 52 ace is like ..BR
0530: 20 73 74 64 61 72 67 20 28 33 29 0a 69 6e 20 72 stdarg (3).in r
0540: 65 76 65 72 73 65 2e 20 41 6c 6c 20 6f 66 20 74 everse. All of t
0550: 68 65 20 6d 61 63 72 6f 73 20 72 65 74 75 72 6e he macros return
0560: 20 30 20 66 6f 72 20 73 75 63 63 65 73 73 2c 20 0 for success,
0570: 3c 20 30 20 66 6f 72 20 66 61 69 6c 75 72 65 20 < 0 for failure
0580: 28 65 2e 67 2e 2c 20 0a 61 72 67 75 6d 65 6e 74 (e.g., .argument
0590: 20 6c 69 73 74 20 6f 76 65 72 66 6c 6f 77 20 6f list overflow o
05a0: 72 20 74 79 70 65 2d 6e 6f 74 2d 73 75 70 70 6f r type-not-suppo
05b0: 72 74 65 64 29 2e 0a 2e 52 53 20 30 0a 2e 54 50 rted)...RS 0..TP
05c0: 0a 28 31 29 0a 2e 42 20 23 69 6e 63 6c 75 64 65 .(1)..B #include
05d0: 20 3c 61 76 63 61 6c 6c 2e 68 3e 0a 2e 6e 66 0a <avcall.h>..nf.
05e0: 61 6e 64 20 64 65 63 6c 61 72 65 20 74 68 65 20 and declare the
05f0: 61 72 67 75 6d 65 6e 74 20 6c 69 73 74 20 73 74 argument list st
0600: 72 75 63 74 75 72 65 0a 2e 42 49 20 22 61 76 5f ructure..BI "av_
0610: 61 6c 69 73 74 20 22 20 61 6c 69 73 74 20 3b 0a alist " alist ;.
0620: 2e 66 69 0a 2e 54 50 0a 28 32 29 0a 53 65 74 20 .fi..TP.(2).Set
0630: 61 6e 79 20 73 70 65 63 69 61 6c 20 66 6c 61 67 any special flag
0640: 73 2e 20 54 68 69 73 20 69 73 20 61 72 63 68 69 s. This is archi
0650: 74 65 63 74 75 72 65 20 61 6e 64 20 63 6f 6d 70 tecture and comp
0660: 69 6c 65 72 20 64 65 70 65 6e 64 65 6e 74 2e 0a iler dependent..
0670: 43 6f 6d 70 69 6c 65 72 20 6f 70 74 69 6f 6e 73 Compiler options
0680: 20 74 68 61 74 20 61 66 66 65 63 74 20 70 61 73 that affect pas
0690: 73 69 6e 67 20 63 6f 6e 76 65 6e 74 69 6f 6e 73 sing conventions
06a0: 20 6d 61 79 20 6e 65 65 64 20 74 6f 20 62 65 20 may need to be
06b0: 66 6c 61 67 67 65 64 0a 62 79 0a 2e 42 52 20 22 flagged.by..BR "
06c0: 23 64 65 66 69 6e 65 22 20 73 0a 62 65 66 6f 72 #define" s.befor
06d0: 65 20 74 68 65 0a 2e 42 20 22 23 69 6e 63 6c 75 e the..B "#inclu
06e0: 64 65 20 3c 61 76 63 61 6c 6c 2e 68 3e 22 0a 73 de <avcall.h>".s
06f0: 74 61 74 65 6d 65 6e 74 2e 20 48 6f 77 65 76 65 tatement. Howeve
0700: 72 2c 20 74 68 65 0a 2e 49 20 63 6f 6e 66 69 67 r, the..I config
0710: 75 72 65 0a 73 63 72 69 70 74 20 73 68 6f 75 6c ure.script shoul
0720: 64 20 68 61 76 65 20 64 65 74 65 72 6d 69 6e 65 d have determine
0730: 64 20 77 68 69 63 68 0a 2e 42 52 20 22 23 64 65 d which..BR "#de
0740: 66 69 6e 65 22 20 73 0a 61 72 65 20 6e 65 65 64 fine" s.are need
0750: 65 64 20 61 6e 64 20 70 75 74 20 74 68 65 6d 0a ed and put them.
0760: 61 74 20 74 68 65 20 74 6f 70 20 6f 66 0a 2e 42 at the top of..B
0770: 52 20 61 76 63 61 6c 6c 2e 68 20 2e 0a 2e 54 50 R avcall.h ...TP
0780: 0a 28 33 29 0a 49 6e 69 74 69 61 6c 69 7a 65 20 .(3).Initialize
0790: 74 68 65 20 61 6c 69 73 74 20 77 69 74 68 20 74 the alist with t
07a0: 68 65 20 66 75 6e 63 74 69 6f 6e 20 61 64 64 72 he function addr
07b0: 65 73 73 20 61 6e 64 20 72 65 74 75 72 6e 20 76 ess and return v
07c0: 61 6c 75 65 0a 70 6f 69 6e 74 65 72 20 28 69 66 alue.pointer (if
07d0: 20 61 6e 79 29 2e 20 54 68 65 72 65 20 69 73 20 any). There is
07e0: 61 20 73 65 70 61 72 61 74 65 20 6d 61 63 72 6f a separate macro
07f0: 20 66 6f 72 20 65 61 63 68 20 73 69 6d 70 6c 65 for each simple
0800: 20 72 65 74 75 72 6e 20 74 79 70 65 0a 28 5b 75 return type.([u
0810: 5d 63 68 61 72 2c 20 5b 75 5d 73 68 6f 72 74 2c ]char, [u]short,
0820: 20 5b 75 5d 69 6e 74 2c 20 5b 75 5d 6c 6f 6e 67 [u]int, [u]long
0830: 2c 20 5b 75 5d 6c 6f 6e 67 6c 6f 6e 67 2c 20 66 , [u]longlong, f
0840: 6c 6f 61 74 2c 20 64 6f 75 62 6c 65 2c 20 77 68 loat, double, wh
0850: 65 72 65 20 60 75 27 0a 69 6e 64 69 63 61 74 65 ere `u'.indicate
0860: 73 20 60 75 6e 73 69 67 6e 65 64 27 29 2e 20 54 s `unsigned'). T
0870: 68 65 20 6d 61 63 72 6f 73 20 66 6f 72 20 66 75 he macros for fu
0880: 6e 63 74 69 6f 6e 73 20 72 65 74 75 72 6e 69 6e nctions returnin
0890: 67 20 73 74 72 75 63 74 75 72 65 73 20 6f 72 0a g structures or.
08a0: 70 6f 69 6e 74 65 72 73 20 72 65 71 75 69 72 65 pointers require
08b0: 20 61 6e 20 65 78 70 6c 69 63 69 74 20 74 79 70 an explicit typ
08c0: 65 20 61 72 67 75 6d 65 6e 74 2e 0a 2e 4c 50 0a e argument...LP.
08d0: 45 2e 67 2e 2c 0a 2e 4c 50 0a 2e 42 49 20 22 61 E.g.,..LP..BI "a
08e0: 76 5f 73 74 61 72 74 5f 69 6e 74 20 28 22 20 61 v_start_int (" a
08f0: 6c 69 73 74 20 22 2c 20 22 20 26 66 75 6e 63 20 list ", " &func
0900: 22 2c 20 22 20 26 69 6e 74 5f 72 65 74 75 72 6e ", " &int_return
0910: 20 29 3b 0a 2e 4c 50 0a 2e 42 49 20 22 61 76 5f );..LP..BI "av_
0920: 73 74 61 72 74 5f 64 6f 75 62 6c 65 20 28 22 20 start_double ("
0930: 61 6c 69 73 74 20 22 2c 20 22 20 26 66 75 6e 63 alist ", " &func
0940: 20 22 2c 20 22 20 26 64 6f 75 62 6c 65 5f 72 65 ", " &double_re
0950: 74 75 72 6e 20 29 3b 0a 2e 4c 50 0a 2e 42 49 20 turn );..LP..BI
0960: 22 61 76 5f 73 74 61 72 74 5f 76 6f 69 64 20 28 "av_start_void (
0970: 22 20 61 6c 69 73 74 20 22 2c 20 22 20 26 66 75 " alist ", " &fu
0980: 6e 63 20 29 3b 0a 2e 4c 50 0a 2e 6e 66 0a 2e 42 nc );..LP..nf..B
0990: 49 20 22 61 76 5f 73 74 61 72 74 5f 73 74 72 75 I "av_start_stru
09a0: 63 74 20 28 22 20 61 6c 69 73 74 20 22 2c 20 22 ct (" alist ", "
09b0: 20 26 66 75 6e 63 20 22 2c 20 22 20 73 74 72 75 &func ", " stru
09c0: 63 74 5f 74 79 70 65 20 22 2c 20 22 20 73 70 6c ct_type ", " spl
09d0: 69 74 74 61 62 6c 65 20 22 2c 20 22 0a 2e 42 49 ittable ", "..BI
09e0: 20 22 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "
09f0: 20 20 20 22 20 26 73 74 72 75 63 74 5f 72 65 74 " &struct_ret
0a00: 75 72 6e 20 29 3b 0a 2e 66 69 0a 2e 4c 50 0a 2e urn );..fi..LP..
0a10: 6e 66 0a 2e 42 49 20 22 61 76 5f 73 74 61 72 74 nf..BI "av_start
0a20: 5f 70 74 72 20 28 22 20 61 6c 69 73 74 20 22 2c _ptr (" alist ",
0a30: 20 22 20 26 66 75 6e 63 20 22 2c 20 22 20 70 6f " &func ", " po
0a40: 69 6e 74 65 72 5f 74 79 70 65 20 22 2c 20 22 0a inter_type ", ".
0a50: 2e 42 49 20 22 20 20 20 20 20 20 20 20 20 20 20 .BI "
0a60: 20 20 20 22 20 26 70 6f 69 6e 74 65 72 5f 72 65 " &pointer_re
0a70: 74 75 72 6e 20 29 3b 0a 2e 66 69 0a 2e 4c 50 0a turn );..fi..LP.
0a80: 54 68 65 0a 2e 49 20 73 70 6c 69 74 74 61 62 6c The..I splittabl
0a90: 65 0a 66 6c 61 67 20 73 70 65 63 69 66 69 65 73 e.flag specifies
0aa0: 20 77 68 65 74 68 65 72 20 74 68 65 0a 2e 49 20 whether the..I
0ab0: 73 74 72 75 63 74 5f 74 79 70 65 0a 63 61 6e 20 struct_type.can
0ac0: 62 65 20 72 65 74 75 72 6e 65 64 20 69 6e 20 72 be returned in r
0ad0: 65 67 69 73 74 65 72 73 20 73 75 63 68 20 74 68 egisters such th
0ae0: 61 74 20 65 76 65 72 79 20 73 74 72 75 63 74 20 at every struct
0af0: 66 69 65 6c 64 20 66 69 74 73 20 65 6e 74 69 72 field fits entir
0b00: 65 6c 79 20 69 6e 0a 61 20 73 69 6e 67 6c 65 20 ely in.a single
0b10: 72 65 67 69 73 74 65 72 2e 20 54 68 69 73 20 6e register. This n
0b20: 65 65 64 73 20 74 6f 20 62 65 20 73 70 65 63 69 eeds to be speci
0b30: 66 69 65 64 20 66 6f 72 20 73 74 72 75 63 74 73 fied for structs
0b40: 20 6f 66 20 73 69 7a 65 0a 32 2a 73 69 7a 65 6f of size.2*sizeo
0b50: 66 28 6c 6f 6e 67 29 2e 20 46 6f 72 20 73 74 72 f(long). For str
0b60: 75 63 74 73 20 6f 66 20 73 69 7a 65 20 3c 3d 20 ucts of size <=
0b70: 73 69 7a 65 6f 66 28 6c 6f 6e 67 29 2c 0a 2e 49 sizeof(long),..I
0b80: 20 73 70 6c 69 74 74 61 62 6c 65 0a 69 73 20 69 splittable.is i
0b90: 67 6e 6f 72 65 64 20 61 6e 64 20 61 73 73 75 6d gnored and assum
0ba0: 65 64 20 74 6f 20 62 65 20 31 2e 20 46 6f 72 20 ed to be 1. For
0bb0: 73 74 72 75 63 74 73 20 6f 66 20 73 69 7a 65 20 structs of size
0bc0: 3e 20 32 2a 73 69 7a 65 6f 66 28 6c 6f 6e 67 29 > 2*sizeof(long)
0bd0: 2c 0a 2e 49 20 73 70 6c 69 74 74 61 62 6c 65 0a ,..I splittable.
0be0: 69 73 20 69 67 6e 6f 72 65 64 20 61 6e 64 20 61 is ignored and a
0bf0: 73 73 75 6d 65 64 20 74 6f 20 62 65 20 30 2e 20 ssumed to be 0.
0c00: 54 68 65 72 65 20 61 72 65 20 73 6f 6d 65 20 68 There are some h
0c10: 61 6e 64 79 20 6d 61 63 72 6f 73 20 66 6f 72 20 andy macros for
0c20: 74 68 69 73 3a 0a 2e 6e 66 0a 2e 42 49 20 22 61 this:..nf..BI "a
0c30: 76 5f 77 6f 72 64 5f 73 70 6c 69 74 74 61 62 6c v_word_splittabl
0c40: 65 5f 31 20 28 22 20 74 79 70 65 31 20 29 0a 2e e_1 (" type1 )..
0c50: 42 49 20 22 61 76 5f 77 6f 72 64 5f 73 70 6c 69 BI "av_word_spli
0c60: 74 74 61 62 6c 65 5f 32 20 28 22 20 74 79 70 65 ttable_2 (" type
0c70: 31 20 22 2c 20 22 20 74 79 70 65 32 20 29 0a 2e 1 ", " type2 )..
0c80: 42 49 20 22 61 76 5f 77 6f 72 64 5f 73 70 6c 69 BI "av_word_spli
0c90: 74 74 61 62 6c 65 5f 33 20 28 22 20 74 79 70 65 ttable_3 (" type
0ca0: 31 20 22 2c 20 22 20 74 79 70 65 32 20 22 2c 20 1 ", " type2 ",
0cb0: 22 20 74 79 70 65 33 20 29 0a 2e 42 49 20 22 61 " type3 )..BI "a
0cc0: 76 5f 77 6f 72 64 5f 73 70 6c 69 74 74 61 62 6c v_word_splittabl
0cd0: 65 5f 34 20 28 22 20 74 79 70 65 31 20 22 2c 20 e_4 (" type1 ",
0ce0: 22 20 74 79 70 65 32 20 22 2c 20 22 20 74 79 70 " type2 ", " typ
0cf0: 65 33 20 22 2c 20 22 20 74 79 70 65 34 20 29 0a e3 ", " type4 ).
0d00: 2e 66 69 0a 46 6f 72 20 61 20 73 74 72 75 63 74 .fi.For a struct
0d10: 20 77 69 74 68 20 74 68 72 65 65 20 73 6c 6f 74 with three slot
0d20: 73 0a 2e 6e 66 0a 2e 42 49 20 22 73 74 72 75 63 s..nf..BI "struc
0d30: 74 20 7b 20 22 20 22 74 79 70 65 31 20 69 64 31 t { " "type1 id1
0d40: 22 20 22 3b 20 22 20 22 74 79 70 65 32 20 69 64 " "; " "type2 id
0d50: 32 22 20 22 3b 20 22 20 22 74 79 70 65 33 20 69 2" "; " "type3 i
0d60: 64 33 22 20 22 3b 20 7d 22 0a 2e 66 69 0a 79 6f d3" "; }"..fi.yo
0d70: 75 20 63 61 6e 20 73 70 65 63 69 66 79 0a 2e 49 u can specify..I
0d80: 20 73 70 6c 69 74 74 61 62 6c 65 0a 61 73 0a 2e splittable.as..
0d90: 42 49 20 22 61 76 5f 77 6f 72 64 5f 73 70 6c 69 BI "av_word_spli
0da0: 74 74 61 62 6c 65 5f 33 20 28 22 20 74 79 70 65 ttable_3 (" type
0db0: 31 20 22 2c 20 22 20 74 79 70 65 32 20 22 2c 20 1 ", " type2 ",
0dc0: 22 20 74 79 70 65 33 20 29 0a 2e 52 42 20 2e 0a " type3 )..RB ..
0dd0: 2e 54 50 0a 28 34 29 0a 50 75 73 68 20 74 68 65 .TP.(4).Push the
0de0: 20 61 72 67 75 6d 65 6e 74 73 20 6f 6e 20 74 6f arguments on to
0df0: 20 74 68 65 20 6c 69 73 74 20 69 6e 20 6f 72 64 the list in ord
0e00: 65 72 2e 20 41 67 61 69 6e 20 74 68 65 72 65 20 er. Again there
0e10: 69 73 20 61 20 6d 61 63 72 6f 0a 66 6f 72 20 65 is a macro.for e
0e20: 61 63 68 20 73 69 6d 70 6c 65 20 62 75 69 6c 74 ach simple built
0e30: 2d 69 6e 20 74 79 70 65 2c 20 61 6e 64 20 74 68 -in type, and th
0e40: 65 20 6d 61 63 72 6f 73 20 66 6f 72 20 73 74 72 e macros for str
0e50: 75 63 74 75 72 65 20 61 6e 64 20 70 6f 69 6e 74 ucture and point
0e60: 65 72 0a 61 72 67 75 6d 65 6e 74 73 20 72 65 71 er.arguments req
0e70: 75 69 72 65 20 61 6e 20 65 78 74 72 61 20 74 79 uire an extra ty
0e80: 70 65 20 61 72 67 75 6d 65 6e 74 3a 0a 2e 4c 50 pe argument:..LP
0e90: 0a 2e 42 49 20 22 61 76 5f 69 6e 74 20 28 22 20 ..BI "av_int ("
0ea0: 61 6c 69 73 74 20 22 2c 20 22 20 69 6e 74 5f 76 alist ", " int_v
0eb0: 61 6c 75 65 20 29 3b 0a 2e 4c 50 0a 2e 42 49 20 alue );..LP..BI
0ec0: 22 61 76 5f 64 6f 75 62 6c 65 20 28 22 20 61 6c "av_double (" al
0ed0: 69 73 74 20 22 2c 20 22 20 64 6f 75 62 6c 65 5f ist ", " double_
0ee0: 76 61 6c 75 65 20 29 3b 0a 2e 4c 50 0a 2e 42 49 value );..LP..BI
0ef0: 20 22 61 76 5f 73 74 72 75 63 74 20 28 22 20 61 "av_struct (" a
0f00: 6c 69 73 74 20 22 2c 20 22 20 73 74 72 75 63 74 list ", " struct
0f10: 5f 6f 72 5f 75 6e 69 6f 6e 5f 74 79 70 65 20 22 _or_union_type "
0f20: 2c 20 22 20 73 74 72 75 63 74 5f 76 61 6c 75 65 , " struct_value
0f30: 20 29 3b 0a 2e 4c 50 0a 2e 42 49 20 22 61 76 5f );..LP..BI "av_
0f40: 70 74 72 20 28 22 20 61 6c 69 73 74 20 22 2c 20 ptr (" alist ",
0f50: 22 20 70 6f 69 6e 74 65 72 5f 74 79 70 65 20 22 " pointer_type "
0f60: 2c 20 22 20 70 6f 69 6e 74 65 72 5f 76 61 6c 75 , " pointer_valu
0f70: 65 20 29 3b 0a 2e 54 50 0a 28 35 29 0a 43 61 6c e );..TP.(5).Cal
0f80: 6c 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 2c 20 l the function,
0f90: 73 65 74 20 74 68 65 20 72 65 74 75 72 6e 20 76 set the return v
0fa0: 61 6c 75 65 2c 20 61 6e 64 20 74 69 64 79 20 75 alue, and tidy u
0fb0: 70 3a 0a 2e 4c 50 0a 2e 42 49 20 22 61 76 5f 63 p:..LP..BI "av_c
0fc0: 61 6c 6c 20 28 22 20 61 6c 69 73 74 20 29 3b 0a all (" alist );.
0fd0: 2e 52 45 0a 0a 2e 53 48 20 4e 4f 54 45 53 0a 0a .RE...SH NOTES..
0fe0: 28 31 29 20 46 75 6e 63 74 69 6f 6e 73 20 77 68 (1) Functions wh
0ff0: 6f 73 65 20 66 69 72 73 74 20 64 65 63 6c 61 72 ose first declar
1000: 61 74 69 6f 6e 20 69 73 20 69 6e 20 4b 65 72 6e ation is in Kern
1010: 69 67 68 61 6e 20 26 20 52 69 74 63 68 69 65 20 ighan & Ritchie
1020: 73 74 79 6c 65 20 28 69 2e 65 2e 2c 0a 77 69 74 style (i.e.,.wit
1030: 68 6f 75 74 20 61 20 74 79 70 65 64 20 61 72 67 hout a typed arg
1040: 75 6d 65 6e 74 20 6c 69 73 74 29 20 4d 55 53 54 ument list) MUST
1050: 20 75 73 65 20 64 65 66 61 75 6c 74 20 4b 26 52 use default K&R
1060: 20 43 20 65 78 70 72 65 73 73 69 6f 6e 20 70 72 C expression pr
1070: 6f 6d 6f 74 69 6f 6e 73 0a 28 63 68 61 72 20 61 omotions.(char a
1080: 6e 64 20 73 68 6f 72 74 20 74 6f 20 69 6e 74 2c nd short to int,
1090: 20 66 6c 6f 61 74 20 74 6f 20 64 6f 75 62 6c 65 float to double
10a0: 29 20 77 68 65 74 68 65 72 20 74 68 65 79 20 61 ) whether they a
10b0: 72 65 20 63 6f 6d 70 69 6c 65 64 20 62 79 20 61 re compiled by a
10c0: 20 4b 26 52 0a 6f 72 20 61 6e 20 41 4e 53 49 20 K&R.or an ANSI
10d0: 63 6f 6d 70 69 6c 65 72 2c 20 62 65 63 61 75 73 compiler, becaus
10e0: 65 20 74 68 65 20 74 72 75 65 20 61 72 67 75 6d e the true argum
10f0: 65 6e 74 20 74 79 70 65 73 20 6d 61 79 20 6e 6f ent types may no
1100: 74 20 62 65 20 6b 6e 6f 77 6e 20 61 74 20 74 68 t be known at th
1110: 65 0a 63 61 6c 6c 20 70 6f 69 6e 74 2e 20 53 75 e.call point. Su
1120: 63 68 20 66 75 6e 63 74 69 6f 6e 73 20 74 79 70 ch functions typ
1130: 69 63 61 6c 6c 79 20 62 61 63 6b 2d 63 6f 6e 76 ically back-conv
1140: 65 72 74 20 74 68 65 69 72 20 61 72 67 75 6d 65 ert their argume
1150: 6e 74 73 20 74 6f 20 74 68 65 20 0a 64 65 63 6c nts to the .decl
1160: 61 72 65 64 20 74 79 70 65 73 20 6f 6e 20 66 75 ared types on fu
1170: 6e 63 74 69 6f 6e 20 65 6e 74 72 79 2e 20 28 49 nction entry. (I
1180: 6e 20 66 61 63 74 2c 20 74 68 65 20 6f 6e 6c 79 n fact, the only
1190: 20 77 61 79 20 74 6f 20 70 61 73 73 20 61 20 74 way to pass a t
11a0: 72 75 65 20 63 68 61 72 2c 0a 73 68 6f 72 74 20 rue char,.short
11b0: 6f 72 20 66 6c 6f 61 74 20 69 6e 20 4b 26 52 20 or float in K&R
11c0: 43 20 69 73 20 62 79 20 61 6e 20 65 78 70 6c 69 C is by an expli
11d0: 63 69 74 20 63 61 73 74 3a 20 0a 2e 42 20 66 75 cit cast: ..B fu
11e0: 6e 63 28 28 63 68 61 72 29 63 2c 28 66 6c 6f 61 nc((char)c,(floa
11f0: 74 29 66 29 0a 29 2e 20 0a 53 69 6d 69 6c 61 72 t)f).). .Similar
1200: 6c 79 2c 20 73 6f 6d 65 20 4b 26 52 20 63 6f 6d ly, some K&R com
1210: 70 69 6c 65 72 73 20 28 73 75 63 68 20 61 73 20 pilers (such as
1220: 53 75 6e 20 63 63 20 6f 6e 20 74 68 65 20 73 70 Sun cc on the sp
1230: 61 72 63 29 20 61 63 74 75 61 6c 6c 79 0a 72 65 arc) actually.re
1240: 74 75 72 6e 20 61 20 66 6c 6f 61 74 20 61 73 20 turn a float as
1250: 61 20 64 6f 75 62 6c 65 2e 0a 0a 48 65 6e 63 65 a double...Hence
1260: 2c 20 66 6f 72 20 61 72 67 75 6d 65 6e 74 73 20 , for arguments
1270: 6f 66 20 66 75 6e 63 74 69 6f 6e 73 20 64 65 63 of functions dec
1280: 6c 61 72 65 64 20 69 6e 20 4b 26 52 20 73 74 79 lared in K&R sty
1290: 6c 65 20 79 6f 75 20 73 68 6f 75 6c 64 20 75 73 le you should us
12a0: 65 0a 2e 42 20 61 76 5f 69 6e 74 28 5c 7c 29 0a e..B av_int(\|).
12b0: 61 6e 64 0a 2e 42 20 61 76 5f 64 6f 75 62 6c 65 and..B av_double
12c0: 28 5c 7c 29 0a 72 61 74 68 65 72 20 74 68 61 6e (\|).rather than
12d0: 20 0a 2e 42 20 61 76 5f 63 68 61 72 28 5c 7c 29 ..B av_char(\|)
12e0: 2c 0a 2e 42 20 61 76 5f 73 68 6f 72 74 28 5c 7c ,..B av_short(\|
12f0: 29 0a 6f 72 0a 2e 42 20 61 76 5f 66 6c 6f 61 74 ).or..B av_float
1300: 28 5c 7c 29 2e 0a 49 66 20 79 6f 75 20 75 73 65 (\|)..If you use
1310: 20 61 20 4b 26 52 20 63 6f 6d 70 69 6c 65 72 2c a K&R compiler,
1320: 20 74 68 65 20 61 76 63 61 6c 6c 20 68 65 61 64 the avcall head
1330: 65 72 20 66 69 6c 65 73 20 6d 61 79 20 62 65 20 er files may be
1340: 61 62 6c 65 20 74 6f 0a 64 65 74 65 63 74 20 74 able to.detect t
1350: 68 69 73 20 61 6e 64 20 64 65 66 69 6e 65 20 0a his and define .
1360: 2e 42 20 61 76 5f 66 6c 6f 61 74 28 5c 7c 29 2c .B av_float(\|),
1370: 0a 65 74 63 2c 20 61 70 70 72 6f 70 72 69 61 74 .etc, appropriat
1380: 65 6c 79 2c 20 62 75 74 20 77 69 74 68 20 61 6e ely, but with an
1390: 20 41 4e 53 49 20 63 6f 6d 70 69 6c 65 72 20 74 ANSI compiler t
13a0: 68 65 72 65 20 69 73 20 6e 6f 20 77 61 79 20 0a here is no way .
13b0: 2e 49 20 61 76 63 61 6c 6c 0a 63 61 6e 20 6b 6e .I avcall.can kn
13c0: 6f 77 20 68 6f 77 20 61 20 66 75 6e 63 74 69 6f ow how a functio
13d0: 6e 20 77 61 73 20 64 65 63 6c 61 72 65 64 2c 20 n was declared,
13e0: 73 6f 20 79 6f 75 20 68 61 76 65 20 74 6f 20 63 so you have to c
13f0: 6f 72 72 65 63 74 20 74 68 65 0a 61 72 67 75 6d orrect the.argum
1400: 65 6e 74 20 74 79 70 65 73 20 79 6f 75 72 73 65 ent types yourse
1410: 6c 66 2e 0a 0a 28 32 29 20 54 68 65 20 65 78 70 lf...(2) The exp
1420: 6c 69 63 69 74 20 74 79 70 65 20 61 72 67 75 6d licit type argum
1430: 65 6e 74 73 20 6f 66 20 74 68 65 20 0a 2e 42 20 ents of the ..B
1440: 61 76 5f 73 74 72 75 63 74 28 5c 7c 29 20 0a 61 av_struct(\|) .a
1450: 6e 64 20 0a 2e 42 20 61 76 5f 70 74 72 28 5c 7c nd ..B av_ptr(\|
1460: 29 20 0a 6d 61 63 72 6f 73 20 61 72 65 20 74 79 ) .macros are ty
1470: 70 69 63 61 6c 6c 79 20 75 73 65 64 20 74 6f 20 pically used to
1480: 63 61 6c 63 75 6c 61 74 65 20 73 69 7a 65 2c 20 calculate size,
1490: 61 6c 69 67 6e 6d 65 6e 74 2c 20 61 6e 64 20 70 alignment, and p
14a0: 61 73 73 69 6e 67 0a 63 6f 6e 76 65 6e 74 69 6f assing.conventio
14b0: 6e 73 2e 20 20 54 68 69 73 20 6d 61 79 20 6e 6f ns. This may no
14c0: 74 20 62 65 20 73 75 66 66 69 63 69 65 6e 74 20 t be sufficient
14d0: 66 6f 72 20 73 6f 6d 65 20 6d 61 63 68 69 6e 65 for some machine
14e0: 73 20 77 69 74 68 20 75 6e 75 73 75 61 6c 0a 73 s with unusual.s
14f0: 74 72 75 63 74 75 72 65 20 61 6e 64 20 70 6f 69 tructure and poi
1500: 6e 74 65 72 20 68 61 6e 64 6c 69 6e 67 3a 20 69 nter handling: i
1510: 6e 20 74 68 69 73 20 63 61 73 65 20 61 64 64 69 n this case addi
1520: 74 69 6f 6e 61 6c 20 0a 2e 42 20 61 76 5f 73 74 tional ..B av_st
1530: 61 72 74 5f 5c 63 0a 2e 49 20 74 79 70 65 5c 63 art_\c..I type\c
1540: 0a 2e 42 20 28 5c 7c 29 0a 61 6e 64 20 0a 2e 42 ..B (\|).and ..B
1550: 20 61 76 5f 5c 63 0a 2e 49 20 74 79 70 65 5c 63 av_\c..I type\c
1560: 0a 2e 42 20 28 5c 7c 29 0a 6d 61 63 72 6f 73 20 ..B (\|).macros
1570: 6d 61 79 20 62 65 20 64 65 66 69 6e 65 64 2e 0a may be defined..
1580: 0a 28 33 29 20 54 68 65 20 6d 61 63 72 6f 73 0a .(3) The macros.
1590: 2e 42 52 20 61 76 5f 73 74 61 72 74 5f 6c 6f 6e .BR av_start_lon
15a0: 67 6c 6f 6e 67 28 5c 7c 29 20 2c 0a 2e 42 52 20 glong(\|) ,..BR
15b0: 61 76 5f 73 74 61 72 74 5f 75 6c 6f 6e 67 6c 6f av_start_ulonglo
15c0: 6e 67 28 5c 7c 29 20 2c 0a 2e 42 20 61 76 5f 6c ng(\|) ,..B av_l
15d0: 6f 6e 67 6c 6f 6e 67 28 5c 7c 29 0a 61 6e 64 0a onglong(\|).and.
15e0: 2e 42 20 61 76 5f 75 6c 6f 6e 67 6c 6f 6e 67 28 .B av_ulonglong(
15f0: 5c 7c 29 0a 77 6f 72 6b 20 6f 6e 6c 79 20 69 66 \|).work only if
1600: 20 74 68 65 20 43 20 63 6f 6d 70 69 6c 65 72 20 the C compiler
1610: 68 61 73 20 61 20 77 6f 72 6b 69 6e 67 0a 2e 42 has a working..B
1620: 20 6c 6f 6e 67 20 6c 6f 6e 67 0a 36 34 2d 62 69 long long.64-bi
1630: 74 20 69 6e 74 65 67 65 72 20 74 79 70 65 2e 0a t integer type..
1640: 0a 28 34 29 20 54 68 65 20 73 74 72 75 63 74 20 .(4) The struct
1650: 74 79 70 65 73 20 75 73 65 64 20 69 6e 0a 2e 42 types used in..B
1660: 20 61 76 5f 73 74 61 72 74 5f 73 74 72 75 63 74 av_start_struct
1670: 28 5c 7c 29 0a 61 6e 64 0a 2e 42 20 61 76 5f 73 (\|).and..B av_s
1680: 74 72 75 63 74 28 5c 7c 29 0a 6d 75 73 74 20 6f truct(\|).must o
1690: 6e 6c 79 20 63 6f 6e 74 61 69 6e 20 28 73 69 67 nly contain (sig
16a0: 6e 65 64 20 6f 72 20 75 6e 73 69 67 6e 65 64 29 ned or unsigned)
16b0: 20 69 6e 74 2c 20 6c 6f 6e 67 2c 20 6c 6f 6e 67 int, long, long
16c0: 20 6c 6f 6e 67 20 6f 72 20 70 6f 69 6e 74 65 72 long or pointer
16d0: 20 66 69 65 6c 64 73 2e 0a 53 74 72 75 63 74 20 fields..Struct
16e0: 74 79 70 65 73 20 63 6f 6e 74 61 69 6e 69 6e 67 types containing
16f0: 20 28 73 69 67 6e 65 64 20 6f 72 20 75 6e 73 69 (signed or unsi
1700: 67 6e 65 64 29 20 63 68 61 72 2c 20 73 68 6f 72 gned) char, shor
1710: 74 2c 20 66 6c 6f 61 74 2c 20 64 6f 75 62 6c 65 t, float, double
1720: 20 6f 72 0a 6f 74 68 65 72 20 73 74 72 75 63 74 or.other struct
1730: 73 20 61 72 65 20 6e 6f 74 20 73 75 70 70 6f 72 s are not suppor
1740: 74 65 64 2e 0a 0a 2e 53 48 20 53 45 45 20 41 4c ted....SH SEE AL
1750: 53 4f 0a 2e 42 52 20 73 74 64 61 72 67 20 28 33 SO..BR stdarg (3
1760: 29 2c 0a 2e 42 52 20 76 61 72 61 72 67 73 20 28 ),..BR varargs (
1770: 33 29 2e 0a 0a 2e 53 48 20 42 55 47 53 0a 0a 54 3)....SH BUGS..T
1780: 68 65 20 63 75 72 72 65 6e 74 20 69 6d 70 6c 65 he current imple
1790: 6d 65 6e 74 61 74 69 6f 6e 73 20 68 61 76 65 20 mentations have
17a0: 62 65 65 6e 20 74 65 73 74 65 64 20 6f 6e 20 61 been tested on a
17b0: 20 73 65 6c 65 63 74 69 6f 6e 20 6f 66 20 63 6f selection of co
17c0: 6d 6d 6f 6e 0a 63 61 73 65 73 20 62 75 74 20 74 mmon.cases but t
17d0: 68 65 72 65 20 61 72 65 20 70 72 6f 62 61 62 6c here are probabl
17e0: 79 20 73 74 69 6c 6c 20 6d 61 6e 79 20 62 75 67 y still many bug
17f0: 73 2e 0a 0a 54 68 65 72 65 20 61 72 65 20 74 79 s...There are ty
1800: 70 69 63 61 6c 6c 79 20 62 75 69 6c 74 2d 69 6e pically built-in
1810: 20 6c 69 6d 69 74 73 20 6f 6e 20 74 68 65 20 73 limits on the s
1820: 69 7a 65 20 6f 66 20 74 68 65 20 61 72 67 75 6d ize of the argum
1830: 65 6e 74 2d 6c 69 73 74 2c 0a 77 68 69 63 68 20 ent-list,.which
1840: 6d 61 79 20 61 6c 73 6f 20 69 6e 63 6c 75 64 65 may also include
1850: 20 74 68 65 20 73 69 7a 65 20 6f 66 20 61 6e 79 the size of any
1860: 20 73 74 72 75 63 74 75 72 65 20 61 72 67 75 6d structure argum
1870: 65 6e 74 73 2e 0a 0a 54 68 65 20 64 65 63 69 73 ents...The decis
1880: 69 6f 6e 20 77 68 65 74 68 65 72 20 61 20 73 74 ion whether a st
1890: 72 75 63 74 20 69 73 20 74 6f 20 62 65 20 72 65 ruct is to be re
18a0: 74 75 72 6e 65 64 20 69 6e 20 72 65 67 69 73 74 turned in regist
18b0: 65 72 73 20 6f 72 20 69 6e 20 6d 65 6d 6f 72 79 ers or in memory
18c0: 0a 63 6f 6e 73 69 64 65 72 73 20 6f 6e 6c 79 20 .considers only
18d0: 74 68 65 20 73 74 72 75 63 74 27 73 20 73 69 7a the struct's siz
18e0: 65 20 61 6e 64 20 61 6c 69 67 6e 6d 65 6e 74 2e e and alignment.
18f0: 20 54 68 69 73 20 69 73 20 69 6e 61 63 63 75 72 This is inaccur
1900: 61 74 65 3a 20 66 6f 72 0a 65 78 61 6d 70 6c 65 ate: for.example
1910: 2c 20 67 63 63 20 6f 6e 20 6d 36 38 6b 2d 6e 65 , gcc on m68k-ne
1920: 78 74 20 72 65 74 75 72 6e 73 0a 2e 42 20 22 73 xt returns..B "s
1930: 74 72 75 63 74 20 7b 20 63 68 61 72 20 61 2c 62 truct { char a,b
1940: 2c 63 3b 20 7d 22 0a 69 6e 20 72 65 67 69 73 74 ,c; }".in regist
1950: 65 72 73 20 61 6e 64 0a 2e 42 20 22 73 74 72 75 ers and..B "stru
1960: 63 74 20 7b 20 63 68 61 72 20 61 5b 33 5d 3b 20 ct { char a[3];
1970: 7d 22 0a 69 6e 20 6d 65 6d 6f 72 79 2c 20 61 6c }".in memory, al
1980: 74 68 6f 75 67 68 20 62 6f 74 68 20 74 79 70 65 though both type
1990: 73 20 68 61 76 65 20 74 68 65 20 73 61 6d 65 20 s have the same
19a0: 73 69 7a 65 20 61 6e 64 20 74 68 65 20 73 61 6d size and the sam
19b0: 65 20 61 6c 69 67 6e 6d 65 6e 74 2e 0a 0a 2e 53 e alignment....S
19c0: 48 20 4e 4f 4e 2d 42 55 47 53 0a 0a 41 6c 6c 20 H NON-BUGS..All
19d0: 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 69 73 20 70 information is p
19e0: 61 73 73 65 64 20 69 6e 20 43 50 55 20 72 65 67 assed in CPU reg
19f0: 69 73 74 65 72 73 20 61 6e 64 20 74 68 65 20 73 isters and the s
1a00: 74 61 63 6b 2e 20 54 68 65 0a 2e 42 20 61 76 63 tack. The..B avc
1a10: 61 6c 6c 0a 70 61 63 6b 61 67 65 20 69 73 20 74 all.package is t
1a20: 68 65 72 65 66 6f 72 65 20 6d 75 6c 74 69 74 68 herefore multith
1a30: 72 65 61 64 2d 73 61 66 65 2e 0a 0a 2e 53 48 20 read-safe....SH
1a40: 50 4f 52 54 49 4e 47 20 41 56 43 41 4c 4c 0a 0a PORTING AVCALL..
1a50: 50 6f 72 74 73 2c 20 62 75 67 2d 66 69 78 65 73 Ports, bug-fixes
1a60: 2c 20 61 6e 64 20 73 75 67 67 65 73 74 69 6f 6e , and suggestion
1a70: 73 20 61 72 65 20 6d 6f 73 74 20 77 65 6c 63 6f s are most welco
1a80: 6d 65 2e 20 54 68 65 20 6d 61 63 72 6f 73 20 72 me. The macros r
1a90: 65 71 75 69 72 65 64 0a 66 6f 72 20 61 72 67 75 equired.for argu
1aa0: 6d 65 6e 74 20 70 75 73 68 69 6e 67 20 61 72 65 ment pushing are
1ab0: 20 70 72 65 74 74 79 20 67 72 75 6e 67 79 2c 20 pretty grungy,
1ac0: 62 75 74 20 69 74 20 64 6f 65 73 20 73 65 65 6d but it does seem
1ad0: 20 74 6f 20 62 65 20 70 6f 73 73 69 62 6c 65 0a to be possible.
1ae0: 74 6f 20 70 6f 72 74 20 61 76 63 61 6c 6c 20 74 to port avcall t
1af0: 6f 20 61 20 72 61 6e 67 65 20 6f 66 20 6d 61 63 o a range of mac
1b00: 68 69 6e 65 73 2e 20 50 6f 72 74 73 20 74 6f 20 hines. Ports to
1b10: 6e 6f 6e 2d 73 74 61 6e 64 61 72 64 20 6f 72 0a non-standard or.
1b20: 6e 6f 6e 2d 33 32 2d 62 69 74 20 6d 61 63 68 69 non-32-bit machi
1b30: 6e 65 73 20 61 72 65 20 65 73 70 65 63 69 61 6c nes are especial
1b40: 6c 79 20 77 65 6c 63 6f 6d 65 20 73 6f 20 77 65 ly welcome so we
1b50: 20 63 61 6e 20 73 6f 72 74 20 74 68 65 20 69 6e can sort the in
1b60: 74 65 72 66 61 63 65 0a 6f 75 74 20 62 65 66 6f terface.out befo
1b70: 72 65 20 69 74 27 73 20 74 6f 6f 20 6c 61 74 65 re it's too late
1b80: 2e 0a 0a 4b 6e 6f 77 6c 65 64 67 65 20 61 62 6f ...Knowledge abo
1b90: 75 74 20 61 72 67 75 6d 65 6e 74 20 70 61 73 73 ut argument pass
1ba0: 69 6e 67 20 63 6f 6e 76 65 6e 74 69 6f 6e 73 20 ing conventions
1bb0: 63 61 6e 20 62 65 20 66 6f 75 6e 64 20 69 6e 20 can be found in
1bc0: 74 68 65 20 67 63 63 0a 73 6f 75 72 63 65 2c 20 the gcc.source,
1bd0: 66 69 6c 65 0a 2e 52 49 20 67 63 63 2d 32 2e 36 file..RI gcc-2.6
1be0: 2e 33 2f 63 6f 6e 66 69 67 2f 20 63 70 75 20 2f .3/config/ cpu /
1bf0: 20 63 70 75 20 2e 68 2c 0a 73 65 63 74 69 6f 6e cpu .h,.section
1c00: 20 22 53 74 61 63 6b 20 6c 61 79 6f 75 74 3b 20 "Stack layout;
1c10: 66 75 6e 63 74 69 6f 6e 20 65 6e 74 72 79 2c 20 function entry,
1c20: 65 78 69 74 20 61 6e 64 20 63 61 6c 6c 69 6e 67 exit and calling
1c30: 2e 22 0a 0a 53 6f 6d 65 20 6f 66 20 74 68 65 20 ."..Some of the
1c40: 67 72 75 6e 67 65 20 69 73 20 75 73 75 61 6c 6c grunge is usuall
1c50: 79 20 68 61 6e 64 6c 65 64 20 62 79 20 61 20 43 y handled by a C
1c60: 20 6f 72 20 61 73 73 65 6d 62 6c 79 20 6c 65 76 or assembly lev
1c70: 65 6c 20 67 6c 75 65 0a 72 6f 75 74 69 6e 65 20 el glue.routine
1c80: 74 68 61 74 20 61 63 74 75 61 6c 6c 79 20 70 75 that actually pu
1c90: 73 68 65 73 20 74 68 65 20 61 72 67 75 6d 65 6e shes the argumen
1ca0: 74 73 2c 20 63 61 6c 6c 73 20 74 68 65 20 66 75 ts, calls the fu
1cb0: 6e 63 74 69 6f 6e 20 61 6e 64 0a 75 6e 70 61 63 nction and.unpac
1cc0: 6b 73 20 61 6e 79 20 72 65 74 75 72 6e 20 76 61 ks any return va
1cd0: 6c 75 65 2e 0a 54 68 69 73 20 69 73 20 63 61 6c lue..This is cal
1ce0: 6c 65 64 20 5f 5f 62 75 69 6c 74 69 6e 5f 61 76 led __builtin_av
1cf0: 63 61 6c 6c 28 5c 7c 29 2e 20 41 20 70 72 65 63 call(\|). A prec
1d00: 6f 6d 70 69 6c 65 64 20 61 73 73 65 6d 62 6c 65 ompiled assemble
1d10: 72 20 76 65 72 73 69 6f 6e 20 66 6f 72 0a 70 65 r version for.pe
1d20: 6f 70 6c 65 20 77 69 74 68 6f 75 74 20 67 63 63 ople without gcc
1d30: 20 69 73 20 61 6c 73 6f 20 6d 61 64 65 20 61 76 is also made av
1d40: 61 69 6c 61 62 6c 65 2e 20 54 68 65 20 72 6f 75 ailable. The rou
1d50: 74 69 6e 65 20 73 68 6f 75 6c 64 20 69 64 65 61 tine should idea
1d60: 6c 6c 79 0a 68 61 76 65 20 66 6c 61 67 73 20 66 lly.have flags f
1d70: 6f 72 20 74 68 65 20 70 61 73 73 69 6e 67 20 63 or the passing c
1d80: 6f 6e 76 65 6e 74 69 6f 6e 73 20 6f 66 20 6f 74 onventions of ot
1d90: 68 65 72 20 63 6f 6d 70 69 6c 65 72 73 2e 0a 0a her compilers...
1da0: 4d 61 6e 79 20 6f 66 20 74 68 65 20 63 75 72 72 Many of the curr
1db0: 65 6e 74 20 72 6f 75 74 69 6e 65 73 20 77 61 73 ent routines was
1dc0: 74 65 20 61 20 6c 6f 74 20 6f 66 20 73 74 61 63 te a lot of stac
1dd0: 6b 20 73 70 61 63 65 20 61 6e 64 20 67 65 6e 65 k space and gene
1de0: 72 61 6c 6c 79 20 64 6f 0a 68 61 69 72 79 20 74 rally do.hairy t
1df0: 68 69 6e 67 73 20 74 6f 20 73 74 61 63 6b 20 66 hings to stack f
1e00: 72 61 6d 65 73 20 2d 20 61 20 62 69 74 20 6d 6f rames - a bit mo
1e10: 72 65 20 61 73 73 65 6d 62 6c 79 20 63 6f 64 65 re assembly code
1e20: 20 77 6f 75 6c 64 20 70 72 6f 62 61 62 6c 79 0a would probably.
1e30: 68 65 6c 70 20 74 68 69 6e 67 73 20 61 6c 6f 6e help things alon
1e40: 67 20 71 75 69 74 65 20 61 20 62 69 74 20 68 65 g quite a bit he
1e50: 72 65 2e 0a 0a 2e 53 48 20 41 55 54 48 4f 52 0a re....SH AUTHOR.
1e60: 0a 42 69 6c 6c 20 54 72 69 67 67 73 20 3c 42 69 .Bill Triggs <Bi
1e70: 6c 6c 2e 54 72 69 67 67 73 40 69 6e 72 69 61 6c ll.Triggs@inrial
1e80: 70 65 73 2e 66 72 3e 2e 20 0a 0a 2e 53 48 20 41 pes.fr>. ...SH A
1e90: 43 4b 4e 4f 57 4c 45 44 47 45 4d 45 4e 54 53 0a CKNOWLEDGEMENTS.
1ea0: 0a 53 6f 6d 65 20 69 6e 69 74 69 61 6c 20 69 64 .Some initial id
1eb0: 65 61 73 20 77 65 72 65 20 73 74 6f 6c 65 6e 20 eas were stolen
1ec0: 66 72 6f 6d 20 74 68 65 20 43 20 69 6e 74 65 72 from the C inter
1ed0: 66 61 63 65 20 74 6f 20 74 68 65 20 5a 65 6c 6b face to the Zelk
1ee0: 0a 65 78 74 65 6e 73 69 6f 6e 73 20 74 6f 20 4f .extensions to O
1ef0: 6c 69 76 65 72 20 4c 61 75 6d 61 6e 6e 27 73 20 liver Laumann's
1f00: 45 6c 6b 20 73 63 68 65 6d 65 20 69 6e 74 65 72 Elk scheme inter
1f10: 70 72 65 74 65 72 20 62 79 20 4a 2e 50 2e 4c 65 preter by J.P.Le
1f20: 77 69 73 2c 20 4e 45 43 0a 43 26 43 20 52 65 73 wis, NEC.C&C Res
1f30: 65 61 72 63 68 2c 20 3c 7a 69 6c 6c 61 40 63 63 earch, <zilla@cc
1f40: 72 6c 2e 6e 6a 2e 6e 65 63 2e 63 6f 6d 3e 20 28 rl.nj.nec.com> (
1f50: 66 6f 72 20 53 75 6e 34 20 26 20 53 47 49 29 2c for Sun4 & SGI),
1f60: 20 61 6e 64 20 52 6f 79 0a 46 65 61 74 68 65 72 and Roy.Feather
1f70: 73 74 6f 6e 65 27 73 20 3c 72 6f 79 40 72 6f 62 stone's <roy@rob
1f80: 6f 74 73 2e 6f 78 66 6f 72 64 2e 61 63 2e 75 6b ots.oxford.ac.uk
1f90: 3e 20 70 65 72 73 6f 6e 61 6c 20 43 20 69 6e 74 > personal C int
1fa0: 65 72 66 61 63 65 20 6c 69 62 72 61 72 79 0a 66 erface library.f
1fb0: 6f 72 20 53 75 6e 5b 33 34 5d 20 26 20 53 47 49 or Sun[34] & SGI
1fc0: 2e 20 20 49 20 61 6c 73 6f 20 6c 6f 6f 6b 65 64 . I also looked
1fd0: 20 61 74 20 74 68 65 20 6d 61 63 68 69 6e 65 2d at the machine-
1fe0: 64 65 70 65 6e 64 65 6e 74 20 70 61 72 74 73 20 dependent parts
1ff0: 6f 66 20 74 68 65 0a 47 43 43 20 61 6e 64 20 47 of the.GCC and G
2000: 44 42 20 64 69 73 74 72 69 62 75 74 69 6f 6e 73 DB distributions
2010: 2c 20 61 6e 64 20 70 75 74 20 74 68 65 20 67 63 , and put the gc
2020: 63 20 61 73 6d 28 5c 7c 29 20 65 78 74 65 6e 73 c asm(\|) extens
2030: 69 6f 6e 73 20 74 6f 20 67 6f 6f 64 0a 75 73 65 ions to good.use
2040: 2e 20 54 68 61 6e 6b 73 20 67 75 79 73 21 0a 0a . Thanks guys!..
2050: 54 68 69 73 20 77 6f 72 6b 20 77 61 73 20 70 61 This work was pa
2060: 72 74 6c 79 20 73 75 70 70 6f 72 74 65 64 20 62 rtly supported b
2070: 79 20 45 43 2d 45 53 50 52 49 54 20 42 61 73 69 y EC-ESPRIT Basi
2080: 63 20 52 65 73 65 61 72 63 68 20 41 63 74 69 6f c Research Actio
2090: 6e 20 53 45 43 4f 4e 44 2e 0a 0a n SECOND...