2 * @(#) stdarg.h 1.4 93/06/18 22:29:44
4 * Sample stdarg.h file for use with the unproto filter.
6 * This file serves two purposes.
8 * 1 - On systems that do not have a /usr/include/stdarg.h file, it should be
9 * included by C source files that implement ANSI-style variadic functions.
10 * Ultrix 4.[0-2] comes with stdarg.h but still needs the one that is
11 * provided with the unproto filter.
13 * 2 - To configure the unprototyper itself. If the _VA_ALIST_ macro is
14 * defined, its value will appear in the place of the "..." at the end of
15 * argument lists of variadic function *definitions* (not declarations).
16 * Some compilers (such as Greenhills m88k) have a non-empty va_dcl
17 * definition in the system header file varargs.h. If that is the case,
18 * define "_VA_DCL_" with the same value as va_dcl. If _VA_DCL_ is defined,
19 * the unprototyper will emit its value just before the opening "{".
21 * Compilers that always pass arguments via the stack can use the default code
22 * at the end of this file (this usually applies for the vax, mc68k and
23 * 80*86 architectures).
25 * Special tricks are needed for compilers that pass some or all function
26 * arguments via registers. Examples of the latter are given for the mips
27 * and sparc architectures. Usually the compiler special-cases an argument
28 * declaration such as "va_alist" or "__builtin_va_alist". For inspiration,
29 * see the local /usr/include/varargs.h file.
31 * You can use the varargs.c program provided with the unproto package to
32 * verify that the stdarg.h file has been set up correctly.
35 #ifdef sparc /* tested with SunOS 4.1.1 */
37 #define _VA_ALIST_ "__builtin_va_alist"
38 typedef char *va_list;
39 #define va_start(ap, p) (ap = (char *) &__builtin_va_alist)
40 #define va_arg(ap, type) ((type *) __builtin_va_arg_incr((type *) ap))[0]
44 #ifdef mips /* tested with Ultrix 4.0 and 4.2 */
46 #define _VA_ALIST_ "va_alist"
47 #include "/usr/include/stdarg.h"
50 #ifdef m88k /* Motorola SYSTEM V/88 R32V3 */
52 #define _VA_ALIST_ "va_alist"
53 #define _VA_DCL_ "va_type va_alist;"
54 typedef struct _va_struct {
59 #define va_start(ap, p) \
60 ((ap).va_narg=(int *)&va_alist-va_stkarg, \
61 (ap).va_stkaddr=va_stkarg, \
62 (ap).va_iregs=(int *)va_intreg)
64 #if defined(LittleEndian)
65 #define va_arg(p,mode) \
66 (*(mode *)_gh_va_arg(&p, va_align(mode), va_regtyp(mode), sizeof(mode)))
67 #else /* defined(LittleEndian) */
68 #define va_arg(p,mode) ( \
69 (p).va_narg += ((p).va_narg & (va_align(mode) == 8)) + \
71 ((mode *)((va_regtyp(mode) && (p).va_narg <= 8 ? \
73 (p).va_stkaddr) + (p).va_narg))[-1])
74 #endif /* defined(LittleEndian) */
80 #else /* vax, mc68k, 80*86 */
82 typedef char *va_list;
83 #define va_start(ap, p) (ap = (char *) (&(p)+1))
84 #define va_arg(ap, type) ((type *) (ap += sizeof(type)))[-1]