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 65 typedef struct 66 { 67 union 68 { 69 struct 70 { 71 #ifdef MSB_FIRST 72 uint8 High; 73 uint8 Low; 74 #else 75 uint8 Low; 76 uint8 High; 77 #endif 78 } Union8; 79 uint16 Val16; 80 }; 81 } Uuint16; 82 83 typedef struct 84 { 85 union 86 { 87 struct 88 { 89 #ifdef MSB_FIRST 90 Uuint16 High; 91 Uuint16 Low; 92 #else 93 Uuint16 Low; 94 Uuint16 High; 95 #endif 96 } Union16; 97 uint32 Val32; 98 }; 99 } Uuint32; 100 101 #define MDFN_COLD 102 103 #undef require 104 #define require( expr ) assert( expr ) 105 106 #endif 107