Skip to content
Permalink
Browse files

win32, stdlib: use _strtoi64() and _strtoui64() when available

  • Loading branch information
sezero committed Mar 24, 2018
1 parent 460d095 commit a66cc7fe801066e05d3b4c86c63d120e21c954aa
Showing with 30 additions and 10 deletions.
  1. +10 −0 configure.in
  2. +2 −0 include/SDL_config.h.in
  3. +4 −0 include/SDL_config_win32.h
  4. +12 −8 include/SDL_stdinc.h
  5. +2 −2 src/stdlib/SDL_string.c
@@ -2123,6 +2123,16 @@ CheckWIN32()
])
fi

save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS -Werror-implicit-function-declaration"
AC_TRY_LINK([#include <stdlib.h>],
[return (int) _strtoi64 (NULL,NULL,0);],
AC_DEFINE(HAVE__STRTOI64))
AC_TRY_LINK([#include <stdlib.h>],
[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]]]),
@@ -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
@@ -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
@@ -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
@@ -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;

0 comments on commit a66cc7f

Please sign in to comment.