Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/psx/mednadisc/emuware/emuware.h
2 views
1
#pragma once
2
3
#include <inttypes.h>
4
#include <stdint.h>
5
#include <cstdlib>
6
7
#ifdef _MSC_VER
8
typedef __int64 s64;
9
typedef __int32 s32;
10
typedef __int16 s16;
11
typedef __int8 s8;
12
typedef unsigned __int64 u64;
13
typedef unsigned __int32 u32;
14
typedef unsigned __int16 u16;
15
typedef unsigned __int8 u8;
16
17
typedef __int64 int64;
18
typedef __int32 int32;
19
typedef __int16 int16;
20
typedef __int8 int8;
21
typedef unsigned __int64 uint64;
22
typedef unsigned __int32 uint32;
23
typedef unsigned __int16 uint16;
24
typedef unsigned __int8 uint8;
25
#else
26
typedef __int64_t s64;
27
typedef __int32_t s32;
28
typedef __int16_t s16;
29
typedef __int8_t s8;
30
typedef __uint64_t u64;
31
typedef __uint32_t u32;
32
typedef __uint16_t u16;
33
typedef __uint8_t u8;
34
35
typedef __int64_t int64;
36
typedef __int32_t int32;
37
typedef __int16_t int16;
38
typedef __int8_t int8;
39
typedef __uint64_t uint64;
40
typedef __uint32_t uint32;
41
typedef __uint16_t uint16;
42
typedef __uint8_t uint8;
43
#endif
44
45
#define final
46
#define noexcept
47
48
#ifdef _MSC_VER
49
#include <intrin.h>
50
//http://stackoverflow.com/questions/355967/how-to-use-msvc-intrinsics-to-get-the-equivalent-of-this-gcc-code
51
//if needed
52
//uint32_t __inline ctz( uint32_t value )
53
//{
54
// DWORD trailing_zero = 0;
55
//
56
// if ( _BitScanForward( &trailing_zero, value ) )
57
// {
58
// return trailing_zero;
59
// }
60
// else
61
// {
62
// // This is undefined, I better choose 32 than 0
63
// return 32;
64
// }
65
//}
66
67
uint32 __inline __builtin_clz( uint32_t value )
68
{
69
unsigned long leading_zero = 0;
70
71
if ( _BitScanReverse( &leading_zero, value ) )
72
{
73
return 31 - leading_zero;
74
}
75
else
76
{
77
// Same remarks as above
78
return 32;
79
}
80
}
81
#endif
82
83
//#if MDFN_GCC_VERSION >= MDFN_MAKE_GCCV(4,7,0)
84
// #define MDFN_ASSUME_ALIGNED(p, align) __builtin_assume_aligned((p), (align))
85
//#else
86
// #define MDFN_ASSUME_ALIGNED(p, align) (p)
87
//#endif
88
#define MDFN_ASSUME_ALIGNED(p, align) (p)
89
90
//#define MDFN_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
91
#define MDFN_WARN_UNUSED_RESULT
92
93
//#define MDFN_COLD __attribute__((cold))
94
#define MDFN_COLD
95
96
//#define NO_INLINE __attribute__((noinline))
97
#define NO_INLINE
98
99
//#define MDFN_UNLIKELY(n) __builtin_expect((n) != 0, 0)
100
//#define MDFN_LIKELY(n) __builtin_expect((n) != 0, 1)
101
#define MDFN_UNLIKELY(n) (n)
102
#define MDFN_LIKELY(n) (n)
103
104
//#define MDFN_NOWARN_UNUSED __attribute__((unused))
105
#define MDFN_NOWARN_UNUSED
106
107
//#define MDFN_FORMATSTR(a,b,c) __attribute__ ((format (a, b, c)))
108
#define MDFN_FORMATSTR(a,b,c)
109
110
#define INLINE inline
111
112
#ifndef UNALIGNED
113
#define UNALIGNED
114
#endif
115
116
#ifdef _MSC_VER
117
#define snprintf _snprintf
118
#define vsnprintf _vsnprintf
119
#define strcasecmp _stricmp
120
#define strncasecmp _strnicmp
121
#endif
122
123
#define TRUE_1 1
124
#define FALSE_0 0
125
126
#ifndef ARRAY_SIZE
127
//taken from winnt.h
128
extern "C++" // templates cannot be declared to have 'C' linkage
129
template <typename T, size_t N>
130
char (*BLAHBLAHBLAH( UNALIGNED T (&)[N] ))[N];
131
132
#define ARRAY_SIZE(A) (sizeof(*BLAHBLAHBLAH(A)))
133
#endif
134
135
//------------alignment macros-------------
136
//dont apply these to types without further testing. it only works portably here on declarations of variables
137
//cant we find a pattern other people use more successfully?
138
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
139
#define EW_VAR_ALIGN(X) __declspec(align(X))
140
#elif defined(__GNUC__)
141
#define EW_VAR_ALIGN(X) __attribute__ ((aligned (X)))
142
#else
143
#error
144
#endif
145
//---------------------------------------------
146
147
#ifdef EW_EXPORT
148
#undef EW_EXPORT
149
#define EW_EXPORT extern "C" __declspec(dllexport)
150
#else
151
#define EW_EXPORT extern "C" __declspec(dllimport)
152
#endif
153
154
155
#define SIZEOF_DOUBLE 8
156
157
#define LSB_FIRST
158
159
//no MSVC support, no use anyway??
160
#define override
161