diff --git a/Core/defs.h b/Core/defs.h index 07a07d9..186c893 100644 --- a/Core/defs.h +++ b/Core/defs.h @@ -9,6 +9,15 @@ // "Keyword" definitions #define likely(x) GB_likely(x) #define unlikely(x) GB_unlikely(x) +#define typeof __typeof__ + +#if !defined(MIN) +#define MIN(A, B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __a : __b; }) +#endif + +#if !defined(MAX) +#define MAX(A, B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; }) +#endif #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8) #define __builtin_bswap16(x) ({ typeof(x) _x = (x); _x >> 8 | _x << 8; }) diff --git a/Core/gb.h b/Core/gb.h index 0eef0b8..94a89b1 100644 --- a/Core/gb.h +++ b/Core/gb.h @@ -1,6 +1,5 @@ #ifndef GB_h #define GB_h -#define typeof __typeof__ #include #include #include @@ -251,14 +250,6 @@ typedef enum { #define SGB_NTSC_FREQUENCY (21477272 / 5) #define SGB_PAL_FREQUENCY (21281370 / 5) #define DIV_CYCLES (0x100) - -#if !defined(MIN) -#define MIN(A, B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __a : __b; }) -#endif - -#if !defined(MAX) -#define MAX(A, B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; }) -#endif #endif typedef void (*GB_vblank_callback_t)(GB_gameboy_t *gb, GB_vblank_type_t type); diff --git a/Core/save_state.h b/Core/save_state.h index f9cf4d6..81b5ac3 100644 --- a/Core/save_state.h +++ b/Core/save_state.h @@ -28,7 +28,7 @@ #if __clang_major__ >= 8 || __GNUC__ >= 13 #define GB_ENUM(type, ...) enum : type __VA_ARGS__ #else -#define GB_ENUM(type, ...) typeof((type)((enum __VA_ARGS__)0)) +#define GB_ENUM(type, ...) __typeof__((type)((enum __VA_ARGS__)0)) #endif /* Public calls related to save states */