diff --git a/libretro/libretro-common/include/compat/msvc.h b/libretro/libretro-common/include/compat/msvc.h index 57ca291bc..a4c93a59a 100644 --- a/libretro/libretro-common/include/compat/msvc.h +++ b/libretro/libretro-common/include/compat/msvc.h @@ -1,7 +1,7 @@ -/* Copyright (C) 2010-2016 The RetroArch team +/* Copyright (C) 2010-2020 The RetroArch team * * --------------------------------------------------------------------------------------- - * The following license statement only applies to this file (msvc_compat.h). + * The following license statement only applies to this file (msvc.h). * --------------------------------------------------------------------------------------- * * Permission is hereby granted, free of charge, @@ -29,20 +29,17 @@ extern "C" { #endif -/* Pre-MSVC 2015 compilers don't implement snprintf in a cross-platform manner. */ +/* Pre-MSVC 2015 compilers don't implement snprintf, vsnprintf in a cross-platform manner. */ #if _MSC_VER < 1900 + #include + #include #include + #ifndef snprintf #define snprintf c99_snprintf_retro__ #endif - int c99_snprintf_retro__(char *outBuf, size_t size, const char *format, ...); -#endif -/* Pre-MSVC 2010 compilers don't implement vsnprintf in a cross-platform manner? Not sure about this one. */ -#if _MSC_VER < 1600 - #include - #include #ifndef vsnprintf #define vsnprintf c99_vsnprintf_retro__ #endif @@ -56,6 +53,8 @@ extern "C" { #undef UNICODE /* Do not bother with UNICODE at this time. */ #include #include + +#define _USE_MATH_DEFINES #include /* Python headers defines ssize_t and sets HAVE_SSIZE_T. @@ -86,9 +85,33 @@ typedef int ssize_t; #pragma warning(disable : 4723) #pragma warning(disable : 4996) -/* roundf is available since MSVC 2013 */ +/* roundf and va_copy is available since MSVC 2013 */ #if _MSC_VER < 1800 #define roundf(in) (in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f)) +#define va_copy(x, y) ((x) = (y)) +#endif + +#if _MSC_VER <= 1310 + #ifndef __cplusplus + /* VC6 math.h doesn't define some functions when in C mode. + * Trying to define a prototype gives "undefined reference". + * But providing an implementation then gives "function already has body". + * So the equivalent of the implementations from math.h are used as + * defines here instead, and it seems to work. + */ + #define cosf(x) ((float)cos((double)x)) + #define powf(x, y) ((float)pow((double)x, (double)y)) + #define sinf(x) ((float)sin((double)x)) + #define ceilf(x) ((float)ceil((double)x)) + #define floorf(x) ((float)floor((double)x)) + #define sqrtf(x) ((float)sqrt((double)x)) + #define fabsf(x) ((float)fabs((double)(x))) + #endif + + #ifndef _strtoui64 + #define _strtoui64(x, y, z) (_atoi64(x)) + #endif + #endif #ifndef PATH_MAX @@ -101,4 +124,3 @@ typedef int ssize_t; #endif #endif - diff --git a/libretro/libretro-common/include/compat/msvc/stdint.h b/libretro/libretro-common/include/compat/msvc/stdint.h index 403e1f73d..7c91a6851 100644 --- a/libretro/libretro-common/include/compat/msvc/stdint.h +++ b/libretro/libretro-common/include/compat/msvc/stdint.h @@ -1,5 +1,5 @@ /* ISO C9x compliant stdint.h for Microsoft Visual Studio - * Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 + * Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 * * Copyright (c) 2006-2008 Alexander Chemeris * @@ -22,7 +22,7 @@ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @@ -47,8 +47,12 @@ * error C2733: second C linkage of overloaded function 'wmemchr' not allowed */ #ifdef __cplusplus +#if _MSC_VER <= 1200 +extern "C++" { +#else extern "C" { #endif +#endif # include #ifdef __cplusplus } @@ -63,7 +67,6 @@ extern "C" { # endif #endif - /* 7.18.1 Integer types. */ /* 7.18.1.1 Exact-width integer types. */ @@ -90,7 +93,6 @@ extern "C" { typedef signed __int64 int64_t; typedef unsigned __int64 uint64_t; - /* 7.18.1.2 Minimum-width integer types. */ typedef int8_t int_least8_t; typedef int16_t int_least16_t; @@ -251,4 +253,3 @@ typedef uint64_t uintmax_t; #endif #endif - diff --git a/libretro/libretro-common/include/retro_inline.h b/libretro/libretro-common/include/retro_inline.h index e4a21f6c4..b27d6dd6d 100644 --- a/libretro/libretro-common/include/retro_inline.h +++ b/libretro/libretro-common/include/retro_inline.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2018 The RetroArch team +/* Copyright (C) 2010-2020 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (retro_inline.h).