diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/attributes.h | 16 | ||||
| -rw-r--r-- | include/libc/assert.h | 2 | ||||
| -rw-r--r-- | include/libc/stdarg.h | 30 | ||||
| -rw-r--r-- | include/libc/stddef.h | 2 | ||||
| -rw-r--r-- | include/macros.h | 2 | ||||
| -rw-r--r-- | include/ultra64/libc.h | 2 | ||||
| -rw-r--r-- | include/z64audio.h | 4 |
7 files changed, 45 insertions, 13 deletions
diff --git a/include/attributes.h b/include/attributes.h index c3154cac7..3276c8432 100644 --- a/include/attributes.h +++ b/include/attributes.h @@ -8,12 +8,22 @@ #endif #define UNUSED __attribute__((unused)) -#define FALLTHROUGH __attribute__((fallthrough)) -#define NORETURN __attribute__((noreturn)) #define NO_REORDER __attribute__((no_reorder)) #define SECTION_DATA __attribute__((section(".data"))) -#ifdef __GNUC__ +#if __GNUC__ >= 7 +#define FALLTHROUGH __attribute__((fallthrough)) +#else +#define FALLTHROUGH +#endif + +#if defined(__GNUC__) && defined(NON_MATCHING) +#define NORETURN __attribute__((noreturn)) +#else +#define NORETURN +#endif + +#if defined(__GNUC__) && defined(NON_MATCHING) #define UNREACHABLE() __builtin_unreachable() #else #define UNREACHABLE() 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)) diff --git a/include/macros.h b/include/macros.h index 59360541d..f3fefa96d 100644 --- a/include/macros.h +++ b/include/macros.h @@ -53,6 +53,8 @@ #define PRINTF osSyncPrintf #elif IDO_PRINTF_WORKAROUND #define PRINTF(args) (void)0 +#elif defined(__GNUC__) && __GNUC__ < 3 +#define PRINTF(format, args...) (void)0 #else #define PRINTF(format, ...) (void)0 #endif diff --git a/include/ultra64/libc.h b/include/ultra64/libc.h index e71cb879d..3480f101a 100644 --- a/include/ultra64/libc.h +++ b/include/ultra64/libc.h @@ -5,7 +5,7 @@ void osSyncPrintf(const char* fmt, ...); -#ifdef __GNUC__ +#if defined(__GNUC__) && defined(NON_MATCHING) void bzero(void* __s, unsigned int __n); int bcmp(const void* __sl, const void* __s2, unsigned int __n); void bcopy(const void* __src, void* __dest, unsigned int __n); diff --git a/include/z64audio.h b/include/z64audio.h index 86e2860db..d60a6aaeb 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -201,11 +201,9 @@ typedef struct AdpcmBookHeader { * The procedure used to design the codeBook is based on an adaptive clustering algorithm. * The size of the codeBook is (8 * order * numPredictors) and is 8-byte aligned */ -typedef s16 AdpcmBookData[]; - typedef struct AdpcmBook { /* 0x00 */ AdpcmBookHeader header; - /* 0x08 */ AdpcmBookData book; // size 8 * order * numPredictors. 8-byte aligned + /* 0x08 */ s16 book[1]; // size 8 * order * numPredictors. 8-byte aligned } AdpcmBook; // size >= 0x8 typedef struct Sample { |
