These should be in defs.h

This commit is contained in:
Lior Halphon 2023-06-03 21:54:01 +03:00
parent ee9b6c1444
commit d62132be38
3 changed files with 10 additions and 10 deletions

View File

@ -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; })

View File

@ -1,6 +1,5 @@
#ifndef GB_h
#define GB_h
#define typeof __typeof__
#include <stdbool.h>
#include <stdint.h>
#include <stdalign.h>
@ -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);

View File

@ -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 */