1 #ifndef __MDFN_TYPES
2 #define __MDFN_TYPES
3 
4 #include <stdint.h>
5 #include <retro_inline.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 NO_INLINE __attribute__((noinline))
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 #if _MSC_VER < 1800
36 #define roundf(in) (in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f))
37 #endif
38 #define NO_INLINE
39 #define MDFN_LIKELY(n) ((n) != 0)
40 #define MDFN_UNLIKELY(n) ((n) != 0)
41 
42   #define MDFN_FASTCALL
43 
44   #define MDFN_ALIGN(n) __declspec(align(n))
45 
46   #define MDFN_FORMATSTR(a,b,c)
47 
48   #define MDFN_WARN_UNUSED_RESULT
49   #define MDFN_NOWARN_UNUSED
50 
51 #else
52   #error "Not compiling with GCC nor MSVC"
53   #define NO_INLINE
54 
55   #define MDFN_FASTCALL
56 
57   #define MDFN_ALIGN(n)	// hence the #error.
58 
59   #define MDFN_FORMATSTR(a,b,c)
60 
61   #define MDFN_WARN_UNUSED_RESULT
62 
63 #endif
64 
65 
66 typedef struct
67 {
68  union
69  {
70   struct
71   {
72    #ifdef MSB_FIRST
73    uint8   High;
74    uint8   Low;
75    #else
76    uint8   Low;
77    uint8   High;
78    #endif
79   } Union8;
80   uint16 Val16;
81  };
82 } Uuint16;
83 
84 typedef struct
85 {
86  union
87  {
88   struct
89   {
90    #ifdef MSB_FIRST
91    Uuint16   High;
92    Uuint16   Low;
93    #else
94    Uuint16   Low;
95    Uuint16   High;
96    #endif
97   } Union16;
98   uint32  Val32;
99  };
100 } Uuint32;
101 
102 typedef uint32   UTF32;  /* at least 32 bits */
103 typedef uint16  UTF16;  /* at least 16 bits */
104 typedef uint8   UTF8;   /* typically 8 bits */
105 typedef unsigned char   Boolean; /* 0 or 1 */
106 
107 #ifndef FALSE
108 #define FALSE 0
109 #endif
110 
111 #ifndef TRUE
112 #define TRUE 1
113 #endif
114 
115 #define MDFN_COLD
116 
117 #undef require
118 #define require( expr ) assert( expr )
119 
120 #endif
121