浏览代码

Fixed building without HAVE_LIBC on Windows

Fixes https://github.com/libsdl-org/SDL/issues/9064
Sam Lantinga 1 年之前
父节点
当前提交
ff01d0b568
共有 3 个文件被更改,包括 22 次插入4 次删除
  1. 2 2
      src/stdlib/SDL_memcpy.c
  2. 18 0
      src/stdlib/SDL_memmove.c
  3. 2 2
      src/stdlib/SDL_memset.c

+ 2 - 2
src/stdlib/SDL_memcpy.c

@@ -81,7 +81,7 @@ void *SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void
 
 /* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls.
    We will provide our own implementation if we're not building with a C runtime. */
-#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(_MT)
+#ifndef HAVE_LIBC
 /* NOLINTNEXTLINE(readability-redundant-declaration) */
 extern void *memcpy(void *dst, const void *src, size_t len);
 #ifndef __INTEL_LLVM_COMPILER
@@ -96,4 +96,4 @@ void *memcpy(void *dst, const void *src, size_t len)
 {
     return SDL_memcpy(dst, src, len);
 }
-#endif /* (_MSC_VER >= 1400) && !defined(_MT) */
+#endif /* !HAVE_LIBC */

+ 18 - 0
src/stdlib/SDL_memmove.c

@@ -53,3 +53,21 @@ void *SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void
 #endif /* HAVE_MEMMOVE */
 }
 
+
+#ifndef HAVE_LIBC
+/* NOLINTNEXTLINE(readability-redundant-declaration) */
+extern void *memmove(void *dst, const void *src, size_t len);
+#ifndef __INTEL_LLVM_COMPILER
+#pragma intrinsic(memmove)
+#endif
+
+#ifndef __clang__
+#pragma function(memmove)
+#endif
+/* NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) */
+void *memmove(void *dst, const void *src, size_t len)
+{
+    return SDL_memmove(dst, src, len);
+}
+#endif /* !HAVE_LIBC */
+

+ 2 - 2
src/stdlib/SDL_memset.c

@@ -118,7 +118,7 @@ void *SDL_memset4(void *dst, Uint32 val, size_t dwords)
 
 /* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls.
    We will provide our own implementation if we're not building with a C runtime. */
-#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(_MT)
+#ifndef HAVE_LIBC
 /* NOLINTNEXTLINE(readability-redundant-declaration) */
 extern void *memset(void *dst, int c, size_t len);
 #ifndef __INTEL_LLVM_COMPILER
@@ -133,5 +133,5 @@ void *memset(void *dst, int c, size_t len)
 {
     return SDL_memset(dst, c, len);
 }
-#endif /* (_MSC_VER >= 1400) && !defined(_MT) */
+#endif /* !HAVE_LIBC */