db: Override cycle multiplier for Colin McRae PAL
[pcsx_rearmed.git] / deps / libretro-common / include / compat / msvc.h
CommitLineData
3719602c
PC
1/* Copyright (C) 2010-2020 The RetroArch team
2 *
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (msvc.h).
5 * ---------------------------------------------------------------------------------------
6 *
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23#ifndef __LIBRETRO_SDK_COMPAT_MSVC_H
24#define __LIBRETRO_SDK_COMPAT_MSVC_H
25
26#ifdef _MSC_VER
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/* Pre-MSVC 2015 compilers don't implement snprintf, vsnprintf in a cross-platform manner. */
33#if _MSC_VER < 1900
34 #include <stdio.h>
35 #include <stdarg.h>
36 #include <stdlib.h>
37
38 #ifndef snprintf
39 #define snprintf c99_snprintf_retro__
40 #endif
41 int c99_snprintf_retro__(char *outBuf, size_t size, const char *format, ...);
42
43 #ifndef vsnprintf
44 #define vsnprintf c99_vsnprintf_retro__
45 #endif
46 int c99_vsnprintf_retro__(char *outBuf, size_t size, const char *format, va_list ap);
47#endif
48
49#ifdef __cplusplus
50}
51#endif
52
53#undef UNICODE /* Do not bother with UNICODE at this time. */
54#include <direct.h>
55#include <stddef.h>
56
57#define _USE_MATH_DEFINES
58#include <math.h>
59
60/* Python headers defines ssize_t and sets HAVE_SSIZE_T.
61 * Cannot duplicate these efforts.
62 */
63#ifndef HAVE_SSIZE_T
64#if defined(_WIN64)
65typedef __int64 ssize_t;
66#elif defined(_WIN32)
67typedef int ssize_t;
68#endif
69#endif
70
71#define mkdir(dirname, unused) _mkdir(dirname)
72#define strtoull _strtoui64
73#undef strcasecmp
74#define strcasecmp _stricmp
75#undef strncasecmp
76#define strncasecmp _strnicmp
77
78/* Disable some of the annoying warnings. */
79#pragma warning(disable : 4800)
80#pragma warning(disable : 4805)
81#pragma warning(disable : 4244)
82#pragma warning(disable : 4305)
83#pragma warning(disable : 4146)
84#pragma warning(disable : 4267)
85#pragma warning(disable : 4723)
86#pragma warning(disable : 4996)
87
88/* roundf and va_copy is available since MSVC 2013 */
89#if _MSC_VER < 1800
90#define roundf(in) (in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f))
91#define va_copy(x, y) ((x) = (y))
92#endif
93
94#if _MSC_VER <= 1310
95 #ifndef __cplusplus
96 /* VC6 math.h doesn't define some functions when in C mode.
97 * Trying to define a prototype gives "undefined reference".
98 * But providing an implementation then gives "function already has body".
99 * So the equivalent of the implementations from math.h are used as
100 * defines here instead, and it seems to work.
101 */
102 #define cosf(x) ((float)cos((double)x))
103 #define powf(x, y) ((float)pow((double)x, (double)y))
104 #define sinf(x) ((float)sin((double)x))
105 #define ceilf(x) ((float)ceil((double)x))
106 #define floorf(x) ((float)floor((double)x))
107 #define sqrtf(x) ((float)sqrt((double)x))
108 #define fabsf(x) ((float)fabs((double)(x)))
109 #endif
110
111 #ifndef _strtoui64
112 #define _strtoui64(x, y, z) (_atoi64(x))
113 #endif
114
115#endif
116
117#ifndef PATH_MAX
118#define PATH_MAX _MAX_PATH
119#endif
120
121#ifndef SIZE_MAX
122#define SIZE_MAX _UI32_MAX
123#endif
124
125#endif
126#endif