Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 33 additions & 11 deletions libretro/libretro-common/include/compat/msvc.h
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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 <stdio.h>
#include <stdarg.h>
#include <stdlib.h>

#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 <stdarg.h>
#include <stdlib.h>
#ifndef vsnprintf
#define vsnprintf c99_vsnprintf_retro__
#endif
Expand All @@ -56,6 +53,8 @@ extern "C" {
#undef UNICODE /* Do not bother with UNICODE at this time. */
#include <direct.h>
#include <stddef.h>

#define _USE_MATH_DEFINES
#include <math.h>

/* Python headers defines ssize_t and sets HAVE_SSIZE_T.
Expand Down Expand Up @@ -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
Expand All @@ -101,4 +124,3 @@ typedef int ssize_t;

#endif
#endif

11 changes: 6 additions & 5 deletions libretro/libretro-common/include/compat/msvc/stdint.h
Original file line number Diff line number Diff line change
@@ -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
*
Expand All @@ -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.
Expand All @@ -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 <wchar.h>
#ifdef __cplusplus
}
Expand All @@ -63,7 +67,6 @@ extern "C" {
# endif
#endif


/* 7.18.1 Integer types. */

/* 7.18.1.1 Exact-width integer types. */
Expand All @@ -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;
Expand Down Expand Up @@ -251,4 +253,3 @@ typedef uint64_t uintmax_t;
#endif

#endif

2 changes: 1 addition & 1 deletion libretro/libretro-common/include/retro_inline.h
Original file line number Diff line number Diff line change
@@ -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).
Expand Down