diff options
| author | cadmic <cadmic24@gmail.com> | 2025-01-02 00:35:22 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-02 03:35:22 -0500 |
| commit | 9dafc2f2e4cecff745be05b7003f4e5b2e9f2ba9 (patch) | |
| tree | 0588c180657b7e8a13c98cdbeddc90e5275a72e8 /include/libc/stdarg.h | |
| parent | ffc9f2d4f1fe72a9ac2d803177d612600b5ef22e (diff) | |
[iQue] Build some C files with EGCS (#2396)
Diffstat (limited to 'include/libc/stdarg.h')
| -rw-r--r-- | include/libc/stdarg.h | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/include/libc/stdarg.h b/include/libc/stdarg.h index 35ce4f944..ec57a0c84 100644 --- a/include/libc/stdarg.h +++ b/include/libc/stdarg.h @@ -1,16 +1,16 @@ #ifndef STDARG_H #define STDARG_H -// When building with GCC, use the official vaarg macros to avoid warnings and possibly bad codegen. +// When building with modern GCC, use the official vaarg macros to avoid warnings and possibly bad codegen. -#ifdef __GNUC__ +#if __GNUC__ >= 3 #define va_list __builtin_va_list #define va_start __builtin_va_start #define va_arg __builtin_va_arg #define va_end __builtin_va_end -#else +#elif defined(__sgi) /* IDO */ #ifndef _VA_LIST_ # define _VA_LIST_ @@ -52,6 +52,28 @@ typedef char* va_list; /* No cleanup processing is required for the end of a varargs list: */ #define va_end(__list) -#endif /* __GNUC__ */ +#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 #endif |
