2 * JNPR: stdarg.h,v 1.3 2006/09/15 12:52:34 katta
6 #ifndef _MACHINE_STDARG_H_
7 #define _MACHINE_STDARG_H_
9 #include <sys/_types.h>
14 #ifndef _VA_LIST_DECLARED
15 #define _VA_LIST_DECLARED
16 typedef __va_list va_list;
18 #define va_start(v,l) __builtin_va_start((v),l)
19 #define va_end __builtin_va_end
20 #define va_arg __builtin_va_arg
21 #define va_copy __builtin_va_copy
26 /* ---------------------------------------- */
27 /* VARARGS for MIPS/GNU CC */
28 /* ---------------------------------------- */
30 #include <machine/endian.h>
32 /* These macros implement varargs for GNU C--either traditional or ANSI. */
34 /* Define __gnuc_va_list. */
36 #ifndef __GNUC_VA_LIST
37 #define __GNUC_VA_LIST
39 typedef char * __gnuc_va_list;
40 typedef __gnuc_va_list va_list;
42 #endif /* ! __GNUC_VA_LIST */
44 /* If this is for internal libc use, don't define anything but
47 #ifndef _VA_MIPS_H_ENUM
48 #define _VA_MIPS_H_ENUM
54 __enumeral_type_class,
57 __reference_type_class,
61 __function_type_class,
73 /* In GCC version 2, we want an ellipsis at the end of the declaration
74 of the argument list. GCC version 1 can't parse it. */
77 #define __va_ellipsis ...
83 #define va_start(__AP, __LASTARG) \
84 (__AP = (__gnuc_va_list) __builtin_next_arg (__LASTARG))
86 #define va_end(__AP) ((void)0)
89 /* We cast to void * and then to TYPE * because this avoids
90 a warning about increasing the alignment requirement. */
91 /* The __mips64 cases are reversed from the 32 bit cases, because the standard
92 32 bit calling convention left-aligns all parameters smaller than a word,
93 whereas the __mips64 calling convention does not (and hence they are
98 #define __va_rounded_size(__TYPE) (((sizeof (__TYPE) + 8 - 1) / 8) * 8)
100 #define __va_reg_size 8
102 #if defined(__MIPSEB__) || (BYTE_ORDER == BIG_ENDIAN)
103 #define va_arg(__AP, __type) \
104 ((__type *) (void *) (__AP = (char *) \
105 ((((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8) \
106 + __va_rounded_size (__type))))[-1]
107 #else /* ! __MIPSEB__ && !BYTE_ORDER == BIG_ENDIAN */
108 #define va_arg(__AP, __type) \
109 ((__AP = (char *) ((((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8) \
110 + __va_rounded_size (__type))), \
111 *(__type *) (void *) (__AP - __va_rounded_size (__type)))
112 #endif /* ! __MIPSEB__ && !BYTE_ORDER == BIG_ENDIAN */
114 #else /* ! __mips64 */
116 #define __va_rounded_size(__TYPE) \
117 (((sizeof (__TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
119 #define __va_reg_size 4
121 #if defined(__MIPSEB__) || (BYTE_ORDER == BIG_ENDIAN)
122 /* For big-endian machines. */
123 #define va_arg(__AP, __type) \
124 ((__AP = (char *) ((__alignof__ (__type) > 4 \
125 ? ((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8 \
126 : ((__PTRDIFF_TYPE__)__AP + 4 - 1) & -4) \
127 + __va_rounded_size (__type))), \
128 *(__type *) (void *) (__AP - __va_rounded_size (__type)))
129 #else /* ! __MIPSEB__ && !BYTE_ORDER == BIG_ENDIAN */
130 /* For little-endian machines. */
131 #define va_arg(__AP, __type) \
132 ((__type *) (void *) (__AP = (char *) ((__alignof__(__type) > 4 \
133 ? ((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8 \
134 : ((__PTRDIFF_TYPE__)__AP + 4 - 1) & -4) \
135 + __va_rounded_size(__type))))[-1]
136 #endif /* ! __MIPSEB__ && !BYTE_ORDER == BIG_ENDIAN */
137 #endif /* ! __mips64 */
139 /* Copy __gnuc_va_list into another variable of this type. */
140 #define __va_copy(dest, src) (dest) = (src)
141 #define va_copy(dest, src) (dest) = (src)
143 #endif /* __GNUC__ */
144 #endif /* _MACHINE_STDARG_H_ */