Artifact
a1cfe5034a45c29cc00bac3d3807bdb31337dd65:
0000: 2f 2a 0a 20 2a 20 43 6f 70 79 72 69 67 68 74 20 /*. * Copyright
0010: 31 39 39 35 2d 31 39 39 39 2c 20 32 30 30 33 2d 1995-1999, 2003-
0020: 32 30 30 35 20 42 72 75 6e 6f 20 48 61 69 62 6c 2005 Bruno Haibl
0030: 65 2c 20 3c 62 72 75 6e 6f 40 63 6c 69 73 70 2e e, <bruno@clisp.
0040: 6f 72 67 3e 0a 20 2a 0a 20 2a 20 54 68 69 73 20 org>. *. * This
0050: 69 73 20 66 72 65 65 20 73 6f 66 74 77 61 72 65 is free software
0060: 20 64 69 73 74 72 69 62 75 74 65 64 20 75 6e 64 distributed und
0070: 65 72 20 74 68 65 20 47 4e 55 20 47 65 6e 65 72 er the GNU Gener
0080: 61 6c 20 50 75 62 6c 69 63 20 4c 69 63 65 6e 63 al Public Licenc
0090: 65 0a 20 2a 20 64 65 73 63 72 69 62 65 64 20 69 e. * described i
00a0: 6e 20 74 68 65 20 66 69 6c 65 20 43 4f 50 59 49 n the file COPYI
00b0: 4e 47 2e 20 43 6f 6e 74 61 63 74 20 74 68 65 20 NG. Contact the
00c0: 61 75 74 68 6f 72 20 69 66 20 79 6f 75 20 64 6f author if you do
00d0: 6e 27 74 20 68 61 76 65 20 74 68 69 73 0a 20 2a n't have this. *
00e0: 20 6f 72 20 63 61 6e 27 74 20 6c 69 76 65 20 77 or can't live w
00f0: 69 74 68 20 69 74 2e 20 54 68 65 72 65 20 69 73 ith it. There is
0100: 20 41 42 53 4f 4c 55 54 45 4c 59 20 4e 4f 20 57 ABSOLUTELY NO W
0110: 41 52 52 41 4e 54 59 2c 20 65 78 70 6c 69 63 69 ARRANTY, explici
0120: 74 20 6f 72 20 69 6d 70 6c 69 65 64 2c 0a 20 2a t or implied,. *
0130: 20 6f 6e 20 74 68 69 73 20 73 6f 66 74 77 61 72 on this softwar
0140: 65 2e 0a 20 2a 2f 0a 0a 23 69 6e 63 6c 75 64 65 e.. */..#include
0150: 20 3c 73 74 64 69 6f 2e 68 3e 0a 23 69 6e 63 6c <stdio.h>.#incl
0160: 75 64 65 20 3c 73 74 64 6c 69 62 2e 68 3e 0a 0a ude <stdlib.h>..
0170: 23 69 66 6e 64 65 66 20 52 45 45 4e 54 52 41 4e #ifndef REENTRAN
0180: 54 0a 23 69 6e 63 6c 75 64 65 20 22 76 61 63 61 T.#include "vaca
0190: 6c 6c 2e 68 22 0a 23 65 6c 73 65 20 2f 2a 20 52 ll.h".#else /* R
01a0: 45 45 4e 54 52 41 4e 54 20 2a 2f 0a 23 69 6e 63 EENTRANT */.#inc
01b0: 6c 75 64 65 20 22 76 61 63 61 6c 6c 5f 72 2e 68 lude "vacall_r.h
01c0: 22 0a 23 65 6e 64 69 66 0a 23 69 6e 63 6c 75 64 ".#endif.#includ
01d0: 65 20 22 63 6f 6e 66 69 67 2e 68 22 0a 0a 23 69 e "config.h"..#i
01e0: 66 6e 64 65 66 20 52 45 45 4e 54 52 41 4e 54 0a fndef REENTRANT.
01f0: 0a 2f 2a 20 54 68 69 73 20 69 73 20 74 68 65 20 ./* This is the
0200: 66 75 6e 63 74 69 6f 6e 20 70 6f 69 6e 74 65 72 function pointer
0210: 20 76 61 63 61 6c 6c 28 29 2e 20 41 20 66 75 6e vacall(). A fun
0220: 63 74 69 6f 6e 20 70 6f 69 6e 74 65 72 20 69 6e ction pointer in
0230: 64 69 72 65 63 74 69 6f 6e 20 69 73 0a 20 20 20 direction is.
0240: 6e 65 65 64 65 64 20 62 65 63 61 75 73 65 20 67 needed because g
0250: 63 63 2d 33 2e 34 20 67 65 6e 65 72 61 74 65 73 cc-3.4 generates
0260: 20 69 6e 76 61 6c 69 64 20 63 6f 64 65 20 77 68 invalid code wh
0270: 65 6e 20 74 68 65 20 61 64 64 72 65 73 73 20 6f en the address o
0280: 66 20 61 20 73 79 6d 62 6f 6c 0a 20 20 20 69 73 f a symbol. is
0290: 20 63 61 73 74 65 64 20 74 6f 20 61 20 66 75 6e casted to a fun
02a0: 63 74 69 6f 6e 20 70 6f 69 6e 74 65 72 20 77 69 ction pointer wi
02b0: 74 68 20 64 69 66 66 65 72 65 6e 74 20 72 65 74 th different ret
02c0: 75 72 6e 20 74 79 70 65 2e 0a 20 20 20 28 68 74 urn type.. (ht
02d0: 74 70 3a 2f 2f 67 63 63 2e 67 6e 75 2e 6f 72 67 tp://gcc.gnu.org
02e0: 2f 6d 6c 2f 67 63 63 2d 70 61 74 63 68 65 73 2f /ml/gcc-patches/
02f0: 32 30 30 33 2d 31 32 2f 6d 73 67 30 31 37 36 37 2003-12/msg01767
0300: 2e 68 74 6d 6c 29 20 2a 2f 0a 23 69 66 64 65 66 .html) */.#ifdef
0310: 20 5f 5f 63 70 6c 75 73 70 6c 75 73 0a 65 78 74 __cplusplus.ext
0320: 65 72 6e 20 22 43 22 20 76 6f 69 64 20 5f 5f 76 ern "C" void __v
0330: 61 63 61 6c 6c 20 28 29 3b 20 2f 2a 20 74 68 65 acall (); /* the
0340: 20 72 65 74 75 72 6e 20 74 79 70 65 20 69 73 20 return type is
0350: 76 61 72 69 61 62 6c 65 2c 20 6e 6f 74 20 76 6f variable, not vo
0360: 69 64 21 20 2a 2f 0a 23 65 6c 73 65 0a 65 78 74 id! */.#else.ext
0370: 65 72 6e 20 76 6f 69 64 20 5f 5f 76 61 63 61 6c ern void __vacal
0380: 6c 20 28 29 3b 20 2f 2a 20 74 68 65 20 72 65 74 l (); /* the ret
0390: 75 72 6e 20 74 79 70 65 20 69 73 20 76 61 72 69 urn type is vari
03a0: 61 62 6c 65 2c 20 6e 6f 74 20 76 6f 69 64 21 20 able, not void!
03b0: 2a 2f 0a 23 65 6e 64 69 66 0a 76 6f 69 64 20 28 */.#endif.void (
03c0: 2a 76 61 63 61 6c 6c 29 20 28 29 20 3d 20 5f 5f *vacall) () = __
03d0: 76 61 63 61 6c 6c 3b 0a 0a 2f 2a 20 54 68 69 73 vacall;../* This
03e0: 20 69 73 20 74 68 65 20 66 75 6e 63 74 69 6f 6e is the function
03f0: 20 63 61 6c 6c 65 64 20 62 79 20 76 61 63 61 6c called by vacal
0400: 6c 28 29 2e 20 2a 2f 0a 76 6f 69 64 20 28 2a 20 l(). */.void (*
0410: 76 61 63 61 6c 6c 5f 66 75 6e 63 74 69 6f 6e 29 vacall_function)
0420: 20 28 76 61 5f 61 6c 69 73 74 29 3b 0a 0a 23 65 (va_alist);..#e
0430: 6e 64 69 66 0a 0a 2f 2a 20 52 6f 6f 6d 20 66 6f ndif../* Room fo
0440: 72 20 72 65 74 75 72 6e 69 6e 67 20 73 74 72 75 r returning stru
0450: 63 74 73 20 61 63 63 6f 72 64 69 6e 67 20 74 6f cts according to
0460: 20 74 68 65 20 70 63 63 20 6e 6f 6e 2d 72 65 65 the pcc non-ree
0470: 6e 74 72 61 6e 74 20 73 74 72 75 63 74 20 72 65 ntrant struct re
0480: 74 75 72 6e 20 63 6f 6e 76 65 6e 74 69 6f 6e 2e turn convention.
0490: 20 2a 2f 0a 5f 5f 76 61 5f 73 74 72 75 63 74 5f */.__va_struct_
04a0: 62 75 66 66 65 72 5f 74 20 5f 5f 76 61 5f 73 74 buffer_t __va_st
04b0: 72 75 63 74 5f 62 75 66 66 65 72 3b 0a 0a 69 6e ruct_buffer;..in
04c0: 74 20 2f 2a 20 6e 6f 20 72 65 74 75 72 6e 20 74 t /* no return t
04d0: 79 70 65 2c 20 73 69 6e 63 65 20 74 68 69 73 20 ype, since this
04e0: 6e 65 76 65 72 20 72 65 74 75 72 6e 73 20 2a 2f never returns */
04f0: 0a 5f 5f 76 61 5f 65 72 72 6f 72 31 20 28 65 6e .__va_error1 (en
0500: 75 6d 20 5f 5f 56 41 74 79 70 65 20 73 74 61 72 um __VAtype star
0510: 74 5f 74 79 70 65 2c 20 65 6e 75 6d 20 5f 5f 56 t_type, enum __V
0520: 41 74 79 70 65 20 72 65 74 75 72 6e 5f 74 79 70 Atype return_typ
0530: 65 29 0a 7b 0a 20 20 2f 2a 20 49 66 20 79 6f 75 e).{. /* If you
0540: 20 73 65 65 20 74 68 69 73 2c 20 66 69 78 20 79 see this, fix y
0550: 6f 75 72 20 63 6f 64 65 2e 20 2a 2f 0a 20 20 66 our code. */. f
0560: 70 72 69 6e 74 66 20 28 73 74 64 65 72 72 2c 20 printf (stderr,
0570: 22 76 61 63 61 6c 6c 3a 20 76 61 5f 73 74 61 72 "vacall: va_star
0580: 74 20 74 79 70 65 20 25 64 20 61 6e 64 20 76 61 t type %d and va
0590: 5f 72 65 74 75 72 6e 20 74 79 70 65 20 25 64 20 _return type %d
05a0: 64 69 73 61 67 72 65 65 2e 5c 6e 22 2c 0a 20 20 disagree.\n",.
05b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
05c0: 20 28 69 6e 74 29 73 74 61 72 74 5f 74 79 70 65 (int)start_type
05d0: 2c 20 28 69 6e 74 29 72 65 74 75 72 6e 5f 74 79 , (int)return_ty
05e0: 70 65 29 3b 0a 20 20 61 62 6f 72 74 28 29 3b 0a pe);. abort();.
05f0: 23 69 66 20 64 65 66 69 6e 65 64 28 5f 5f 63 70 #if defined(__cp
0600: 6c 75 73 70 6c 75 73 29 0a 20 20 72 65 74 75 72 lusplus). retur
0610: 6e 20 30 3b 0a 23 65 6e 64 69 66 0a 7d 0a 0a 69 n 0;.#endif.}..i
0620: 6e 74 20 2f 2a 20 6e 6f 20 72 65 74 75 72 6e 20 nt /* no return
0630: 74 79 70 65 2c 20 73 69 6e 63 65 20 74 68 69 73 type, since this
0640: 20 6e 65 76 65 72 20 72 65 74 75 72 6e 73 20 2a never returns *
0650: 2f 0a 5f 5f 76 61 5f 65 72 72 6f 72 32 20 28 75 /.__va_error2 (u
0660: 6e 73 69 67 6e 65 64 20 69 6e 74 20 73 69 7a 65 nsigned int size
0670: 29 0a 7b 0a 20 20 2f 2a 20 49 66 20 79 6f 75 20 ).{. /* If you
0680: 73 65 65 20 74 68 69 73 2c 20 69 6e 63 72 65 61 see this, increa
0690: 73 65 20 5f 5f 56 41 5f 41 4c 49 53 54 5f 57 4f se __VA_ALIST_WO
06a0: 52 44 53 3a 20 2a 2f 0a 20 20 66 70 72 69 6e 74 RDS: */. fprint
06b0: 66 20 28 73 74 64 65 72 72 2c 20 22 76 61 63 61 f (stderr, "vaca
06c0: 6c 6c 3a 20 73 74 72 75 63 74 20 6f 66 20 73 69 ll: struct of si
06d0: 7a 65 20 25 75 20 74 6f 6f 20 6c 61 72 67 65 20 ze %u too large
06e0: 66 6f 72 20 70 63 63 20 73 74 72 75 63 74 20 72 for pcc struct r
06f0: 65 74 75 72 6e 2e 5c 6e 22 2c 0a 20 20 20 20 20 eturn.\n",.
0700: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 69 si
0710: 7a 65 29 3b 0a 20 20 61 62 6f 72 74 28 29 3b 0a ze);. abort();.
0720: 23 69 66 20 64 65 66 69 6e 65 64 28 5f 5f 63 70 #if defined(__cp
0730: 6c 75 73 70 6c 75 73 29 0a 20 20 72 65 74 75 72 lusplus). retur
0740: 6e 20 30 3b 0a 23 65 6e 64 69 66 0a 7d 0a n 0;.#endif.}.