| 1 | #ifndef __MDFN_TYPES |
| 2 | #define __MDFN_TYPES |
| 3 | |
| 4 | #include <stdint.h> |
| 5 | |
| 6 | typedef int8_t int8; |
| 7 | typedef int16_t int16; |
| 8 | typedef int32_t int32; |
| 9 | typedef int64_t int64; |
| 10 | |
| 11 | typedef uint8_t uint8; |
| 12 | typedef uint16_t uint16; |
| 13 | typedef uint32_t uint32; |
| 14 | typedef uint64_t uint64; |
| 15 | |
| 16 | #ifdef __GNUC__ |
| 17 | #define MDFN_UNLIKELY(n) __builtin_expect((n) != 0, 0) |
| 18 | #define MDFN_LIKELY(n) __builtin_expect((n) != 0, 1) |
| 19 | |
| 20 | #define NO_INLINE __attribute__((noinline)) |
| 21 | |
| 22 | #if defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386) |
| 23 | #define MDFN_FASTCALL __attribute__((fastcall)) |
| 24 | #else |
| 25 | #define MDFN_FASTCALL |
| 26 | #endif |
| 27 | |
| 28 | #define MDFN_ALIGN(n) __attribute__ ((aligned (n))) |
| 29 | #define MDFN_FORMATSTR(a,b,c) __attribute__ ((format (a, b, c))); |
| 30 | #define MDFN_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) |
| 31 | #define MDFN_NOWARN_UNUSED __attribute__((unused)) |
| 32 | |
| 33 | #elif defined(_MSC_VER) |
| 34 | #if _MSC_VER < 1800 |
| 35 | #define roundf(in) (in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f)) |
| 36 | #endif |
| 37 | #define NO_INLINE |
| 38 | #define MDFN_LIKELY(n) ((n) != 0) |
| 39 | #define MDFN_UNLIKELY(n) ((n) != 0) |
| 40 | |
| 41 | #define MDFN_FASTCALL |
| 42 | |
| 43 | #define MDFN_ALIGN(n) __declspec(align(n)) |
| 44 | |
| 45 | #define MDFN_FORMATSTR(a,b,c) |
| 46 | |
| 47 | #define MDFN_WARN_UNUSED_RESULT |
| 48 | #define MDFN_NOWARN_UNUSED |
| 49 | |
| 50 | #else |
| 51 | #error "Not compiling with GCC nor MSVC" |
| 52 | #define NO_INLINE |
| 53 | |
| 54 | #define MDFN_FASTCALL |
| 55 | |
| 56 | #define MDFN_ALIGN(n) // hence the #error. |
| 57 | |
| 58 | #define MDFN_FORMATSTR(a,b,c) |
| 59 | |
| 60 | #define MDFN_WARN_UNUSED_RESULT |
| 61 | |
| 62 | #endif |
| 63 | |
| 64 | #endif |