| 1 | /* Copyright (C) 2010-2016 The RetroArch team |
| 2 | * |
| 3 | * --------------------------------------------------------------------------------------- |
| 4 | * The following license statement only applies to this file (msvc_compat.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 |
| 29 | extern "C" { |
| 30 | #endif |
| 31 | |
| 32 | /* Pre-MSVC 2015 compilers don't implement snprintf in a cross-platform manner. */ |
| 33 | #if _MSC_VER < 1900 |
| 34 | #include <stdlib.h> |
| 35 | #ifndef snprintf |
| 36 | #define snprintf c99_snprintf_retro__ |
| 37 | #endif |
| 38 | |
| 39 | int c99_snprintf_retro__(char *outBuf, size_t size, const char *format, ...); |
| 40 | #endif |
| 41 | |
| 42 | /* Pre-MSVC 2010 compilers don't implement vsnprintf in a cross-platform manner? Not sure about this one. */ |
| 43 | #if _MSC_VER < 1600 |
| 44 | #include <stdarg.h> |
| 45 | #include <stdlib.h> |
| 46 | #ifndef vsnprintf |
| 47 | #define vsnprintf c99_vsnprintf_retro__ |
| 48 | #endif |
| 49 | int c99_vsnprintf_retro__(char *outBuf, size_t size, const char *format, va_list ap); |
| 50 | #endif |
| 51 | |
| 52 | #ifdef __cplusplus |
| 53 | } |
| 54 | #endif |
| 55 | |
| 56 | #undef UNICODE /* Do not bother with UNICODE at this time. */ |
| 57 | #include <direct.h> |
| 58 | #include <stddef.h> |
| 59 | #include <math.h> |
| 60 | |
| 61 | /* Python headers defines ssize_t and sets HAVE_SSIZE_T. |
| 62 | * Cannot duplicate these efforts. |
| 63 | */ |
| 64 | #ifndef HAVE_SSIZE_T |
| 65 | #if defined(_WIN64) |
| 66 | typedef __int64 ssize_t; |
| 67 | #elif defined(_WIN32) |
| 68 | typedef int ssize_t; |
| 69 | #endif |
| 70 | #endif |
| 71 | |
| 72 | #define mkdir(dirname, unused) _mkdir(dirname) |
| 73 | #define strtoull _strtoui64 |
| 74 | #undef strcasecmp |
| 75 | #define strcasecmp _stricmp |
| 76 | #undef strncasecmp |
| 77 | #define strncasecmp _strnicmp |
| 78 | |
| 79 | /* Disable some of the annoying warnings. */ |
| 80 | #pragma warning(disable : 4800) |
| 81 | #pragma warning(disable : 4805) |
| 82 | #pragma warning(disable : 4244) |
| 83 | #pragma warning(disable : 4305) |
| 84 | #pragma warning(disable : 4146) |
| 85 | #pragma warning(disable : 4267) |
| 86 | #pragma warning(disable : 4723) |
| 87 | #pragma warning(disable : 4996) |
| 88 | |
| 89 | /* roundf is available since MSVC 2013 */ |
| 90 | #if _MSC_VER < 1800 |
| 91 | #define roundf(in) (in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f)) |
| 92 | #endif |
| 93 | |
| 94 | #ifndef PATH_MAX |
| 95 | #define PATH_MAX _MAX_PATH |
| 96 | #endif |
| 97 | |
| 98 | #ifndef SIZE_MAX |
| 99 | #define SIZE_MAX _UI32_MAX |
| 100 | #endif |
| 101 | |
| 102 | #endif |
| 103 | #endif |
| 104 |