From a66cc7fe801066e05d3b4c86c63d120e21c954aa Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Sat, 24 Mar 2018 23:04:03 +0300 Subject: [PATCH] win32, stdlib: use _strtoi64() and _strtoui64() when available --- configure.in | 10 ++++++++++ include/SDL_config.h.in | 2 ++ include/SDL_config_win32.h | 4 ++++ include/SDL_stdinc.h | 20 ++++++++++++-------- src/stdlib/SDL_string.c | 4 ++-- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/configure.in b/configure.in index 9c5094fd7..d195576cd 100644 --- a/configure.in +++ b/configure.in @@ -2123,6 +2123,16 @@ CheckWIN32() ]) fi + save_CFLAGS="$CFLAGS" + CFLAGS="$save_CFLAGS -Werror-implicit-function-declaration" + AC_TRY_LINK([#include ], + [return (int) _strtoi64 (NULL,NULL,0);], + AC_DEFINE(HAVE__STRTOI64)) + AC_TRY_LINK([#include ], + [return (int) _strtoui64(NULL,NULL,0);], + AC_DEFINE(HAVE__STRTOUI64)) + CFLAGS="$save_CFLAGS" + dnl See if the user wants to redirect standard output to files AC_ARG_ENABLE(stdio-redirect, AC_HELP_STRING([--enable-stdio-redirect], [Redirect STDIO to files on Win32 [[default=yes]]]), diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 7b94ea52b..df4fa4dad 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -117,6 +117,8 @@ #undef HAVE__UI64TOA #undef HAVE_STRTOLL #undef HAVE_STRTOULL +#undef HAVE__STRTOI64 +#undef HAVE__STRTOUI64 #undef HAVE_STRTOD #undef HAVE_ATOI #undef HAVE_ATOF diff --git a/include/SDL_config_win32.h b/include/SDL_config_win32.h index 9b0b9bf6e..6d2ae2d67 100644 --- a/include/SDL_config_win32.h +++ b/include/SDL_config_win32.h @@ -114,6 +114,10 @@ typedef unsigned int uintptr_t; #define HAVE_STRTOLL 1 #define HAVE_STRTOULL 1 #endif +#if defined(__WATCOMC__) || (defined(_MSC_VER) && (_MSC_VER >= 1300)) || defined(_WIN64) +#define HAVE__STRTOI64 1 +#define HAVE__STRTOUI64 1 +#endif #define HAVE_STRTOD 1 #define HAVE_ATOI 1 #define HAVE_ATOF 1 diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index 35a4fdde5..fb3b6a3c9 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -505,13 +505,17 @@ extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix); extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix); #endif -#ifdef HAVE_STRTOLL +#ifdef HAVE__STRTOI64 +#define SDL_strtoll _strtoi64 +#elif defined(HAVE_STRTOLL) #define SDL_strtoll strtoll #else extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base); #endif -#ifdef HAVE_STRTOULL +#ifdef HAVE__STRTOUI64 +#define SDL_strtoull _strtoui64 +#elif defined(HAVE_STRTOULL) #define SDL_strtoull strtoull #else extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp, int base); @@ -549,18 +553,18 @@ extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); #endif -#ifdef HAVE_STRCASECMP -#define SDL_strcasecmp strcasecmp -#elif defined(HAVE__STRICMP) +#if defined(HAVE__STRICMP) #define SDL_strcasecmp _stricmp +#elif defined(HAVE_STRCASECMP) +#define SDL_strcasecmp strcasecmp #else extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); #endif -#ifdef HAVE_STRNCASECMP -#define SDL_strncasecmp strncasecmp -#elif defined(HAVE__STRNICMP) +#if defined(HAVE__STRNICMP) #define SDL_strncasecmp _strnicmp +#elif defined(HAVE_STRNCASECMP) +#define SDL_strncasecmp strncasecmp #else extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen); #endif diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index 550a623a9..4927a4eff 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -603,7 +603,7 @@ char *SDL_ulltoa(Uint64 value, char *string, int radix) } #endif -#ifndef HAVE_STRTOLL +#if !defined(HAVE_STRTOLL) && !defined(HAVE__STRTOI64) Sint64 SDL_strtoll(const char *string, char **endp, int base) { size_t len; @@ -625,7 +625,7 @@ Sint64 SDL_strtoll(const char *string, char **endp, int base) } #endif -#ifndef HAVE_STRTOULL +#if !defined(HAVE_STRTOULL) && !defined(HAVE__STRTOUI64) Uint64 SDL_strtoull(const char *string, char **endp, int base) { size_t len;