1 /* ---------------------------------------- */
2 /* VARARGS for MIPS/GNU CC */
7 /* ---------------------------------------- */
10 /* These macros implement varargs for GNU C--either traditional or ANSI. */
12 /* Define __gnuc_va_list. */
14 #ifndef __GNUC_VA_LIST
15 #define __GNUC_VA_LIST
16 typedef char * __gnuc_va_list;
17 #endif /* not __GNUC_VA_LIST */
19 /* If this is for internal libc use, don't define anything but
21 #if defined (_STDARG_H) || defined (_VARARGS_H)
23 /* In GCC version 2, we want an ellipsis at the end of the declaration
24 of the argument list. GCC version 1 can't parse it. */
27 #define __va_ellipsis ...
33 #define __va_rounded_size(__TYPE) \
34 (((sizeof (__TYPE) + 8 - 1) / 8) * 8)
36 #define __va_rounded_size(__TYPE) \
37 (((sizeof (__TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
40 /* Get definitions for _MIPS_SIM_ABI64 etc. */
46 #define va_start(__AP, __LASTARG) \
47 (__AP = (__gnuc_va_list) __builtin_next_arg (__LASTARG))
50 #define va_alist __builtin_va_alist
52 /* This assumes that `long long int' is always a 64 bit type. */
53 #define va_dcl long long int __builtin_va_alist; __va_ellipsis
55 #define va_dcl int __builtin_va_alist; __va_ellipsis
57 /* Need alternate code for _MIPS_SIM_ABI64. */
58 #if defined(_MIPS_SIM) && (_MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32)
59 #define va_start(__AP) \
60 (__AP = (__gnuc_va_list) __builtin_next_arg () \
61 + (__builtin_args_info (2) >= 8 ? -8 : 0))
63 #define va_start(__AP) __AP = (char *) &__builtin_va_alist
68 void va_end (__gnuc_va_list); /* Defined in libgcc.a */
70 #define va_end(__AP) ((void)0)
72 /* We cast to void * and then to TYPE * because this avoids
73 a warning about increasing the alignment requirement. */
74 /* The __mips64 cases are reversed from the 32 bit cases, because the standard
75 32 bit calling convention left-aligns all parameters smaller than a word,
76 whereas the __mips64 calling convention does not (and hence they are
80 #define va_arg(__AP, __type) \
81 ((__type *) (void *) (__AP = (char *) ((((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8) \
82 + __va_rounded_size (__type))))[-1]
84 #define va_arg(__AP, __type) \
85 ((__AP = (char *) ((((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8) \
86 + __va_rounded_size (__type))), \
87 *(__type *) (void *) (__AP - __va_rounded_size (__type)))
90 #else /* not __mips64 */
93 /* For big-endian machines. */
94 #define va_arg(__AP, __type) \
95 ((__AP = (char *) ((__alignof__ (__type) > 4 \
96 ? ((int)__AP + 8 - 1) & -8 \
97 : ((int)__AP + 4 - 1) & -4) \
98 + __va_rounded_size (__type))), \
99 *(__type *) (void *) (__AP - __va_rounded_size (__type)))
101 /* For little-endian machines. */
102 #define va_arg(__AP, __type) \
103 ((__type *) (void *) (__AP = (char *) ((__alignof__(__type) > 4 \
104 ? ((int)__AP + 8 - 1) & -8 \
105 : ((int)__AP + 4 - 1) & -4) \
106 + __va_rounded_size(__type))))[-1]
110 #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */