BSD 4_4_Lite2 development
[unix-history] / usr / src / contrib / gcc-2.3.3 / gstdarg.h
CommitLineData
619ccb7b
C
1/* stdarg.h for GNU.
2 Note that the type used in va_arg is supposed to match the
3 actual type **after default promotions**.
4 Thus, va_arg (..., short) is not valid. */
5
6#ifndef _STDARG_H
7#ifndef _ANSI_STDARG_H_
8#ifndef __need___va_list
9#define _STDARG_H
10#define _ANSI_STDARG_H_
11#endif /* not __need___va_list */
12#undef __need___va_list
13
14#ifndef __GNUC__
15/* Use the system's macros with the system's compiler.
16 This is relevant only when building GCC with some other compiler. */
17#include <stdarg.h>
18#else
19#ifdef __m88k__
20#include <va-m88k.h>
21#else
22#ifdef __i860__
23#include <va-i860.h>
24#else
25#ifdef __hppa__
26#include <va-pa.h>
27#else
28#ifdef __mips__
29#include <va-mips.h>
30#else
31#ifdef __sparc__
32#include <va-sparc.h>
33#else
34#ifdef __i960__
35#include <va-i960.h>
36#else
37#ifdef __alpha__
38#include <va-alpha.h>
39#else
40
41/* Define __gnuc_va_list. */
42
43#ifndef __GNUC_VA_LIST
44#define __GNUC_VA_LIST
45#if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX)
46typedef char *__gnuc_va_list;
47#else
48typedef void *__gnuc_va_list;
49#endif
50#endif
51
52/* Define the standard macros for the user,
53 if this invocation was from the user program. */
54#ifdef _STDARG_H
55
56/* Amount of space required in an argument list for an arg of type TYPE.
57 TYPE may alternatively be an expression whose type is used. */
58
59#define __va_rounded_size(TYPE) \
60 (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
61
62#define va_start(AP, LASTARG) \
63 (AP = ((__gnuc_va_list) __builtin_next_arg ()))
64
65#undef va_end
66void va_end (__gnuc_va_list); /* Defined in libgcc.a */
67#define va_end(AP)
68
69/* We cast to void * and then to TYPE * because this avoids
70 a warning about increasing the alignment requirement. */
71
72#if defined (__arm__) || defined (__i386__) || defined (__ns32000__) || defined (__vax__)
73/* This is for little-endian machines; small args are padded upward. */
74#define va_arg(AP, TYPE) \
75 (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \
76 *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE))))
77#else /* big-endian */
78/* This is for big-endian machines; small args are padded downward. */
79#define va_arg(AP, TYPE) \
80 (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \
81 *((TYPE *) (void *) ((char *) (AP) - ((sizeof (TYPE) < 4 \
82 ? sizeof (TYPE) \
83 : __va_rounded_size (TYPE))))))
84#endif /* big-endian */
85#endif /* _STDARG_H */
86
87#endif /* not alpha */
88#endif /* not i960 */
89#endif /* not sparc */
90#endif /* not mips */
91#endif /* not hppa */
92#endif /* not i860 */
93#endif /* not m88k */
94
95#ifdef _STDARG_H
96/* Define va_list, if desired, from __gnuc_va_list. */
97/* We deliberately do not define va_list when called from
98 stdio.h, because ANSI C says that stdio.h is not supposed to define
99 va_list. stdio.h needs to have access to that data type,
100 but must not use that name. It should use the name __gnuc_va_list,
101 which is safe because it is reserved for the implementation. */
102
103#ifdef _HIDDEN_VA_LIST /* On OSF1, this means varargs.h is "half-loaded". */
104#undef _VA_LIST
105#endif
106
107#ifdef _BSD_VA_LIST
108#undef _BSD_VA_LIST
109#endif
110
111#ifdef __SVR4_2__
112/* SVR4.2 uses _VA_LIST for an internal alias for va_list,
113 so we must avoid testing it and setting it here. */
114#ifndef _VA_LIST_
115#define _VA_LIST_
116typedef __gnuc_va_list va_list;
117#endif /* _VA_LIST_ */
118#else /* not __SVR4_2__ */
119
120/* The macro _VA_LIST_ is the same thing used by this file in Ultrix.
121 But on BSD NET2 we must not test or define or undef it.
122 (Note that the comments in NET 2's ansi.h
123 are incorrect for _VA_LIST_--see stdio.h!) */
124#if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____)
125/* The macro _VA_LIST is used in SCO Unix 3.2. */
126#ifndef _VA_LIST
127#if !(defined (__BSD_NET2__) || defined (____386BSD____))
128#define _VA_LIST_
129#endif
130#define _VA_LIST
131typedef __gnuc_va_list va_list;
132#endif /* not _VA_LIST */
133#endif /* not _VA_LIST_ */
134
135#endif /* not __SVR4_2__ */
136
137#endif /* _STDARG_H */
138
139#endif /* __GNUC__ */
140#endif /* not _ANSI_STDARG_H_ */
141#endif /* not _STDARG_H */