2021-09-15 23:24:19 +00:00
|
|
|
#ifndef STDARG_H
|
|
|
|
#define STDARG_H
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2025-01-02 08:35:22 +00:00
|
|
|
// When building with modern GCC, use the official vaarg macros to avoid warnings and possibly bad codegen.
|
2023-10-27 14:06:44 +00:00
|
|
|
|
2025-01-02 08:35:22 +00:00
|
|
|
#if __GNUC__ >= 3
|
2023-10-27 14:06:44 +00:00
|
|
|
|
|
|
|
#define va_list __builtin_va_list
|
2020-03-17 04:31:30 +00:00
|
|
|
#define va_start __builtin_va_start
|
2023-10-27 14:06:44 +00:00
|
|
|
#define va_arg __builtin_va_arg
|
|
|
|
#define va_end __builtin_va_end
|
|
|
|
|
2025-01-02 08:35:22 +00:00
|
|
|
#elif defined(__sgi) /* IDO */
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2023-10-27 14:06:44 +00:00
|
|
|
#ifndef _VA_LIST_
|
|
|
|
# define _VA_LIST_
|
2020-10-03 15:22:44 +00:00
|
|
|
typedef char* va_list;
|
2023-10-27 14:06:44 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define _INT 0
|
|
|
|
#define _FP 1
|
2020-03-17 04:31:30 +00:00
|
|
|
#define _STRUCT 2
|
|
|
|
|
|
|
|
#define _VA_FP_SAVE_AREA 0x10
|
2023-10-27 14:06:44 +00:00
|
|
|
|
|
|
|
#define _VA_ALIGN(p, a) (((unsigned int)(((char*)p) + ((a) > 4 ? (a) : 4) - 1)) & -((a) > 4 ? (a) : 4))
|
|
|
|
|
|
|
|
#define va_start(list, parmN) (list = ((va_list)&parmN + sizeof(parmN)))
|
|
|
|
|
|
|
|
#define __va_stack_arg(list, mode) \
|
|
|
|
( \
|
|
|
|
((list) = (char*)_VA_ALIGN(list, __builtin_alignof(mode)) + \
|
|
|
|
_VA_ALIGN(sizeof(mode), 4)), \
|
|
|
|
(((char*)list) - (_VA_ALIGN(sizeof(mode), 4) - sizeof(mode))) \
|
|
|
|
)
|
|
|
|
|
|
|
|
#define __va_double_arg(list, mode) \
|
|
|
|
( \
|
|
|
|
(((long)list & 0x1) /* 1 byte aligned? */ \
|
|
|
|
? (list = (char*)((long)list + 7), (char*)((long)list - 6 - _VA_FP_SAVE_AREA)) \
|
|
|
|
: (((long)list & 0x2) /* 2 byte aligned? */ \
|
|
|
|
? (list = (char*)((long)list + 10), (char*)((long)list - 24 - _VA_FP_SAVE_AREA)) \
|
|
|
|
: __va_stack_arg(list, mode))) \
|
|
|
|
)
|
|
|
|
|
|
|
|
#define va_arg(list, mode) \
|
|
|
|
((mode*)(((__builtin_classof(mode) == _FP && \
|
|
|
|
__builtin_alignof(mode) == sizeof(double)) \
|
|
|
|
? __va_double_arg(list, mode) \
|
|
|
|
: __va_stack_arg(list, mode))))[-1]
|
|
|
|
|
|
|
|
/* No cleanup processing is required for the end of a varargs list: */
|
2020-03-17 04:31:30 +00:00
|
|
|
#define va_end(__list)
|
|
|
|
|
2025-01-02 08:35:22 +00:00
|
|
|
#else /* EGCS */
|
|
|
|
|
|
|
|
typedef char * __gnuc_va_list;
|
|
|
|
|
|
|
|
#define __va_rounded_size(__TYPE) \
|
|
|
|
(((sizeof (__TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
|
|
|
|
|
|
|
|
#define va_start(__AP, __LASTARG) \
|
|
|
|
(__AP = (__gnuc_va_list) __builtin_next_arg (__LASTARG))
|
|
|
|
|
|
|
|
#define va_end(__AP) ((void)0)
|
|
|
|
|
|
|
|
/* We cast to void * and then to TYPE * because this avoids
|
|
|
|
a warning about increasing the alignment requirement. */
|
|
|
|
#define va_arg(__AP, __type) \
|
|
|
|
((__type *) (void *) (__AP = (char *) ((__alignof__(__type) > 4 \
|
|
|
|
? ((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8 \
|
|
|
|
: ((__PTRDIFF_TYPE__)__AP + 4 - 1) & -4) \
|
|
|
|
+ __va_rounded_size(__type))))[-1]
|
|
|
|
|
|
|
|
typedef __gnuc_va_list va_list;
|
|
|
|
|
|
|
|
#endif
|
2023-10-27 14:06:44 +00:00
|
|
|
|
2020-03-17 04:31:30 +00:00
|
|
|
#endif
|