Skip to content

Commit

Permalink
Fixed bug 5112 - CMake won't compile in VS2019
Browse files Browse the repository at this point in the history
dark_sylinc

Trying to build SDL with VS2019 using CMake will encounter a linking error

More specifically:

    1>SDL_string.obj : error LNK2019: unresolved external symbol memset referenced in function SDL_vsnprintf_REAL
  • Loading branch information
slouken committed May 2, 2020
1 parent 05a60c2 commit 8b60d39
Showing 1 changed file with 12 additions and 32 deletions.
44 changes: 12 additions & 32 deletions src/stdlib/SDL_stdlib.c
Expand Up @@ -486,42 +486,22 @@ int SDL_tolower(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) :
__declspec(selectany) int _fltused = 1;
#endif

/* The optimizer on Visual Studio 2005 and later generates memcpy() calls */
#if (_MSC_VER >= 1400) && defined(_WIN64) && !defined(_DEBUG) && !(_MSC_VER >= 1900 && defined(_MT))
#include <intrin.h>

/* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls */
#if _MSC_VER >= 1400
#pragma function(memcpy)
void * memcpy ( void * destination, const void * source, size_t num )
void *
memcpy(void *dst, const void *src, size_t len)
{
const Uint8 *src = (const Uint8 *)source;
Uint8 *dst = (Uint8 *)destination;
size_t i;

/* All WIN64 architectures have SSE, right? */
if (!((uintptr_t) src & 15) && !((uintptr_t) dst & 15)) {
__m128 values[4];
for (i = num / 64; i--;) {
_mm_prefetch(src, _MM_HINT_NTA);
values[0] = *(__m128 *) (src + 0);
values[1] = *(__m128 *) (src + 16);
values[2] = *(__m128 *) (src + 32);
values[3] = *(__m128 *) (src + 48);
_mm_stream_ps((float *) (dst + 0), values[0]);
_mm_stream_ps((float *) (dst + 16), values[1]);
_mm_stream_ps((float *) (dst + 32), values[2]);
_mm_stream_ps((float *) (dst + 48), values[3]);
src += 64;
dst += 64;
}
num &= 63;
}
return SDL_memcpy(dst, src, len);
}

while (num--) {
*dst++ = *src++;
}
return destination;
#pragma function(memset)
void *
memset(void *dst, int c, size_t len)
{
return SDL_memset(dst, c, len);
}
#endif /* _MSC_VER == 1600 && defined(_WIN64) && !defined(_DEBUG) */
#endif

#ifdef _M_IX86

Expand Down

0 comments on commit 8b60d39

Please sign in to comment.