1 #ifndef __MDFN_TYPES 2 #define __MDFN_TYPES 3 4 #include <assert.h> 5 #include <stdint.h> 6 7 typedef int8_t int8; 8 typedef int16_t int16; 9 typedef int32_t int32; 10 typedef int64_t int64; 11 12 typedef uint8_t uint8; 13 typedef uint16_t uint16; 14 typedef uint32_t uint32; 15 typedef uint64_t uint64; 16 17 #ifdef __GNUC__ 18 #define MDFN_UNLIKELY(n) __builtin_expect((n) != 0, 0) 19 #define MDFN_LIKELY(n) __builtin_expect((n) != 0, 1) 20 21 #define INLINE inline __attribute__((always_inline)) 22 23 #if defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386) 24 #define MDFN_FASTCALL __attribute__((fastcall)) 25 #else 26 #define MDFN_FASTCALL 27 #endif 28 29 #define MDFN_ALIGN(n) __attribute__ ((aligned (n))) 30 #define MDFN_FORMATSTR(a,b,c) __attribute__ ((format (a, b, c))); 31 #define MDFN_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) 32 #define MDFN_NOWARN_UNUSED __attribute__((unused)) 33 34 #elif defined(_MSC_VER) 35 36 /* roundf and va_copy is available since MSVC 2013 */ 37 #if _MSC_VER < 1800 38 #define roundf(in) (in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f)) 39 #endif 40 41 #define INLINE inline 42 #define MDFN_LIKELY(n) ((n) != 0) 43 #define MDFN_UNLIKELY(n) ((n) != 0) 44 45 #define MDFN_FASTCALL 46 47 #define MDFN_ALIGN(n) __declspec(align(n)) 48 49 #define MDFN_FORMATSTR(a,b,c) 50 51 #define MDFN_WARN_UNUSED_RESULT 52 #define MDFN_NOWARN_UNUSED 53 54 #else 55 #include <retro_inline.h> 56 #error "Not compiling with GCC nor MSVC" 57 58 #define MDFN_FASTCALL 59 60 #define MDFN_ALIGN(n) // hence the #error. 61 62 #define MDFN_FORMATSTR(a,b,c) 63 64 #define MDFN_WARN_UNUSED_RESULT 65 66 #endif 67 68 typedef uint32 UTF32; /* at least 32 bits */ 69 typedef uint16 UTF16; /* at least 16 bits */ 70 typedef uint8 UTF8; /* typically 8 bits */ 71 typedef unsigned char Boolean; /* 0 or 1 */ 72 73 #ifndef FALSE 74 #define FALSE 0 75 #endif 76 77 #ifndef TRUE 78 #define TRUE 1 79 #endif 80 81 #define MDFN_COLD 82 83 #undef require 84 #define require( expr ) assert( expr ) 85 86 #endif 87