Etterna 0.74.4
Loading...
Searching...
No Matches
arch_setup.h
1#ifndef ARCH_SETUP_WINDOWS_H
2#define ARCH_SETUP_WINDOWS_H
3
4#if defined(_MSC_VER)
5#define HAVE_FFMPEG
6#endif
7
8#define SUPPORT_OPENGL
9#if defined(_MSC_VER)
10#define SUPPORT_D3D
11#endif
12
13#if defined(__MINGW32__)
14#if !defined(_WIN32)
15#define _WINDOWS // This isn't defined under all versions of MinGW
16#endif
17#define NEED_CSTDLIB_WORKAROUND // Needed for llabs() in MinGW
18#endif
19
20#if defined(_MSC_VER)
21
22#if _MSC_VER == 1400 // VC8 specific warnings
23#pragma warning(disable : 4005) // macro redefinitions (ARRAYSIZE)
24#endif
25
26/*
27The following warnings are disabled in all builds.
28Enable them in the project file at your peril (or if you feel like
29learning of many pedantic style warnings and want to fix them).
30
31C2475: non dll-interface class 'stdext::exception' used as base for
32dll-interface class 'std::bad_cast', bug in VC <exception> when exceptions
33disabled C4100: unreferenced formal parameter Many functions are like this,
34including virtual functions: unsure if it can be justified. "case 'aaa' is not a
35valid value for switch of enum 'bbb' Actually, this is a valid warning, but we
36do it all over the place, eg. with ScreenMessages. Those should be fixed, but
37later. XXX C4127: conditional expression is constant.
38
39C4201: nonstandard extension used : nameless struct/union (Windows headers do
40this) C4786: turn off broken debugger warning C4512: assignment operator could
41not be generated (so?) "unreachable code". This warning crops up in incorrect
42places (end of do ... while(0) blocks, try/catch blocks), and I've never found
43it to be useful. C4702: assignment operator could not be generated (so?)
44// "unreferenced formal parameter"; we *want* that in many cases
45
46C4063:
47C4786: VC6: identifier was truncated to '255' characters in the debug
48information C4505: removed unferenced local function from integer.cpp &
49algebra.h C4244: converting of data = possible data loss. (This pragma should
50eventually go away) C4355: 'this' : used in base member initializer list
51
52*/
53// Fix VC breakage.
54#define PATH_MAX _MAX_PATH
55
56// Disable false deprecation warnings in VC2005.
57#define _CRT_SECURE_NO_DEPRECATE
58#define _SCL_SECURE_NO_DEPRECATE
59
60// Disable false deprecation warnings in VC2008.
61#define _CRT_NONSTDC_NO_WARNINGS
62
63// Don't include windows.h everywhere; when we do eventually include it, use
64// these:
65#define WIN32_LEAN_AND_MEAN
66#define VC_EXTRALEAN
67
68/* Pull in NT-only definitions. Note that we support Win98 and WinME; you can
69 * make NT calls, but be sure to fall back on 9x if they're not supported. */
70#ifndef _WIN32_WINNT
71#define _WIN32_WINNT 0x0601
72#endif
73#ifndef _WIN32_IE
74#define _WIN32_IE 0x0400
75#endif
76
77// If this isn't defined to 0, VC fails to define things like stat and alloca.
78#define __STDC__ 0
79
80#endif
81
82#include <cwchar> // needs to be included before our fixes below
83
84#define lstat stat
85#define fsync _commit
86
87typedef time_t time_t;
88struct tm;
89auto
90my_localtime_r(const time_t* timep, struct tm* result) -> struct tm*;
91#define localtime_r my_localtime_r
92auto
93my_gmtime_r(const time_t* timep, struct tm* result) -> struct tm*;
94#define gmtime_r my_gmtime_r
95#if defined(_MSC_VER)
96void
97my_usleep(unsigned long usec);
98#define usleep my_usleep
99#endif
100
101// Missing stdint types:
102#if !defined(__MINGW32__) // MinGW headers define these for us
103using int8_t = signed char;
104using int16_t = short;
105using int32_t = int;
106using int64_t = long long;
107using uint8_t = unsigned char;
108using int16_t = short;
109using uint16_t = unsigned short;
110using int32_t = int;
111using uint32_t = unsigned int;
112using int64_t = long long;
113using uint64_t = unsigned long long;
114#if defined(_MSC_VER)
115#if _MSC_VER < 1700 // 1700 = VC++ 2011
116#define INT64_C(i) i##i64
117#ifndef UINT64_C
118#define UINT64_C(i) i##ui64
119#endif
120#endif // #if _MSC_VER < 1700
121#if (_MSC_VER >= 1400) && (_MSC_VER < 1800) // 1800 = VC++ 2013
122#define llabs(i) _abs64(i)
123#endif // #if (_MSC_VER >= 1400) && (_MSC_VER < 1800)
124#if _MSC_VER < 1400 // 1400 = VC++ 2005
125int64_t
126llabs(int64_t i)
127{
128 return i >= 0 ? i : -i;
129}
130#endif // #if _MSC_VER < 1400
131#endif // #if defined(_MSC_VER)
132#endif // #if !defined(__MINGW32__)
133
134#undef min
135#undef max
136#define NOMINMAX // make sure Windows doesn't try to define this
137
138/* We implement the crash handler interface (though that interface isn't
139 * completely uniform across platforms yet). */
140#if !defined(SMPACKAGE)
141#define CRASH_HANDLER
142#endif
143
144#if defined(__GNUC__) // It might be MinGW or Cygwin(?)
145#include "archutils/Common/gcc_byte_swaps.h"
146#elif defined(_MSC_VER) && (_MSC_VER >= 1310) // Byte swap functions were first
147 // implemented in Visual Studio
148 // .NET 2003
149#define ArchSwap32(n) _byteswap_ulong(n)
150#define ArchSwap24(n) _byteswap_ulong(n) >> 8
151#define ArchSwap16(n) _byteswap_ushort(n)
152#else
153#define HAVE_BYTE_SWAPS
154
155inline uint32_t
156ArchSwap32(uint32_t n)
157{
158 __asm
159 {
160 mov eax, n
161 xchg al, ah
162 ror eax, 16
163 xchg al, ah
164 mov n, eax
165 }
166 ;
167 return n;
168}
169
170inline uint32_t
171ArchSwap24(uint32_t n)
172{
173 __asm
174 {
175 mov eax, n
176 xchg al, ah
177 ror eax, 16
178 xchg al, ah
179 ror eax, 8
180 mov n, eax
181 }
182 ;
183 return n;
184}
185
186inline uint16_t
187ArchSwap16(uint16_t n)
188{
189 __asm
190 {
191 mov ax, n
192 xchg al, ah
193 mov n, ax
194 }
195 ;
196 return n;
197}
198#endif
199
200#endif