Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/psx/octoshock/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
#define SIZEOF_CHAR sizeof(char)
9
#define SIZEOF_SHORT sizeof(short)
10
#define SIZEOF_INT sizeof(int)
11
#define SIZEOF_LONG sizeof(long)
12
#define SIZEOF_LONG_LONG sizeof(long long)
13
#define SIZEOF_OFF_T sizeof(void*)
14
typedef __int64 s64;
15
typedef __int32 s32;
16
typedef __int16 s16;
17
typedef __int8 s8;
18
typedef unsigned __int64 u64;
19
typedef unsigned __int32 u32;
20
typedef unsigned __int16 u16;
21
typedef unsigned __int8 u8;
22
23
typedef __int64 int64;
24
typedef __int32 int32;
25
typedef __int16 int16;
26
typedef __int8 int8;
27
typedef unsigned __int64 uint64;
28
typedef unsigned __int32 uint32;
29
typedef unsigned __int16 uint16;
30
typedef unsigned __int8 uint8;
31
#else
32
typedef __int64_t s64;
33
typedef __int32_t s32;
34
typedef __int16_t s16;
35
typedef __int8_t s8;
36
typedef __uint64_t u64;
37
typedef __uint32_t u32;
38
typedef __uint16_t u16;
39
typedef __uint8_t u8;
40
41
typedef __int64_t int64;
42
typedef __int32_t int32;
43
typedef __int16_t int16;
44
typedef __int8_t int8;
45
typedef __uint64_t uint64;
46
typedef __uint32_t uint32;
47
typedef __uint16_t uint16;
48
typedef __uint8_t uint8;
49
#endif
50
51
52
//#if MDFN_GCC_VERSION >= MDFN_MAKE_GCCV(4,7,0)
53
// #define MDFN_ASSUME_ALIGNED(p, align) __builtin_assume_aligned((p), (align))
54
//#else
55
// #define MDFN_ASSUME_ALIGNED(p, align) (p)
56
//#endif
57
#define MDFN_ASSUME_ALIGNED(p, align) (p)
58
59
//#define MDFN_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
60
#define MDFN_WARN_UNUSED_RESULT
61
62
//#define MDFN_COLD __attribute__((cold))
63
#define MDFN_COLD
64
65
//#define NO_INLINE __attribute__((noinline))
66
#define NO_INLINE
67
68
//#define MDFN_UNLIKELY(n) __builtin_expect((n) != 0, 0)
69
//#define MDFN_LIKELY(n) __builtin_expect((n) != 0, 1)
70
#define MDFN_UNLIKELY(n) (n)
71
#define MDFN_LIKELY(n) (n)
72
73
//#define MDFN_NOWARN_UNUSED __attribute__((unused))
74
#define MDFN_NOWARN_UNUSED
75
76
//#define MDFN_FORMATSTR(a,b,c) __attribute__ ((format (a, b, c)))
77
#define MDFN_FORMATSTR(a,b,c)
78
79
#define INLINE inline
80
81
#ifndef UNALIGNED
82
#define UNALIGNED
83
#endif
84
85
#if defined(_MSC_VER)
86
#define strncasecmp _strnicmp
87
#define NO_CLONE
88
#endif
89
90
#if defined(_MSC_VER) && _MSC_VER < 1900
91
#define snprintf _snprintf
92
#define vsnprintf _vsnprintf
93
#define strcasecmp _stricmp
94
#define final
95
#define noexcept
96
#endif
97
98
#define TRUE_1 1
99
#define FALSE_0 0
100
101
#ifndef ARRAY_SIZE
102
//taken from winnt.h
103
extern "C++" // templates cannot be declared to have 'C' linkage
104
template <typename T, size_t N>
105
char (*BLAHBLAHBLAH( UNALIGNED T (&)[N] ))[N];
106
107
#define ARRAY_SIZE(A) (sizeof(*BLAHBLAHBLAH(A)))
108
#endif
109
110
//------------alignment macros-------------
111
//dont apply these to types without further testing. it only works portably here on declarations of variables
112
//cant we find a pattern other people use more successfully?
113
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
114
#define EW_VAR_ALIGN(X) __declspec(align(X))
115
#elif defined(__GNUC__)
116
#define EW_VAR_ALIGN(X) __attribute__ ((aligned (X)))
117
#else
118
#error
119
#endif
120
//---------------------------------------------
121
122
#ifdef EW_EXPORT
123
#undef EW_EXPORT
124
#define EW_EXPORT extern "C" __declspec(dllexport)
125
#else
126
#define EW_EXPORT extern "C" __declspec(dllimport)
127
#endif
128
129
//http://stackoverflow.com/questions/1537964/visual-c-equivalent-of-gccs-attribute-packed
130
#ifdef _MSC_VER
131
#define EW_PACKED( ... ) __pragma( pack(push, 1) ) __VA_ARGS__ __pragma( pack(pop) )
132
#else
133
#define EW_PACKED( ... ) __VA_ARGS__ __attribute__((__packed__))
134
#endif
135
136