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 | |
| parent | ffc9f2d4f1fe72a9ac2d803177d612600b5ef22e (diff) | |
[iQue] Build some C files with EGCS (#2396)
Diffstat (limited to 'include/libc')
| -rw-r--r-- | include/libc/assert.h | 2 | ||||
| -rw-r--r-- | include/libc/stdarg.h | 30 | ||||
| -rw-r--r-- | include/libc/stddef.h | 2 |
3 files changed, 28 insertions, 6 deletions
diff --git a/include/libc/assert.h b/include/libc/assert.h index dae8aeb65..de54b8a79 100644 --- a/include/libc/assert.h +++ b/include/libc/assert.h @@ -29,7 +29,7 @@ __attribute__((noreturn)) void __assert(const char* assertion, const char* file, // Static/compile-time assertions -#if !defined(__sgi) && (defined(__GNUC__) || (__STDC_VERSION__ >= 201112L)) +#if !defined(__sgi) && (__GNUC__ >= 5 || __STDC_VERSION__ >= 201112L) # define static_assert(cond, msg) _Static_assert(cond, msg) #else # ifndef GLUE 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 diff --git a/include/libc/stddef.h b/include/libc/stddef.h index 45620895e..0c0926ba6 100644 --- a/include/libc/stddef.h +++ b/include/libc/stddef.h @@ -15,7 +15,7 @@ typedef unsigned long size_t; #endif -#ifdef __GNUC__ +#if __GNUC__ >= 4 #define offsetof(structure, member) __builtin_offsetof (structure, member) #else #define offsetof(structure, member) ((size_t)&(((structure*)0)->member)) |
