It is not exported from the DLL.

The implementation was copied and modified from wmemcmp.c in libmingwex.

v4: fix sign again, move to libntoskrnl
---
 mingw-w64-crt/Makefile.am     |  6 ++++++
 mingw-w64-crt/libsrc/memcmp.c | 26 ++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100644 mingw-w64-crt/libsrc/memcmp.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 10f3b04c..c38816e6 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -111,6 +111,7 @@ src_libsapi=libsrc/sapi.c
 src_libsensorsapi=libsrc/sensorsapi.c
 src_libportabledeviceguids=libsrc/portabledeviceguids.c
 src_libtaskschd=libsrc/taskschd.c
+src_libntoskrnl=libsrc/memcmp.c
 
 src_libmingw32=include/oscalls.h include/internal.h include/sect_attribs.h \
   crt/crt0_c.c        crt/dll_argv.c  crt/gccmain.c     crt/natstart.c  
crt/pseudo-reloc-list.c  crt/wildcard.c \
@@ -632,6 +633,11 @@ lib32_LIBRARIES += lib32/libtaskschd.a
 lib32_libtaskschd_a_SOURCES = $(src_libtaskschd)
 lib32_libtaskschd_a_CPPFLAGS=$(CPPFLAGS32) $(sysincludes)
 
+lib32_LIBRARIES += lib32/libntoskrnl.a
+lib32_libntoskrnl_a_SOURCES = $(src_libntoskrnl)
+lib32_libntoskrnl_a_CPPFLAGS=$(CPPFLAGS32) $(sysincludes)
+lib32_libntoskrnl_a_AR = $(DTLIB32) && $(AR) $(ARFLAGS)
+
 if !W32API
 lib32_LIBRARIES += lib32/libdelayimp.a
 lib32_libdelayimp_a_SOURCES =
diff --git a/mingw-w64-crt/libsrc/memcmp.c b/mingw-w64-crt/libsrc/memcmp.c
new file mode 100644
index 00000000..11f5f9c9
--- /dev/null
+++ b/mingw-w64-crt/libsrc/memcmp.c
@@ -0,0 +1,26 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#define __CRT__NO_INLINE
+#include <stddef.h>
+
+int __cdecl memcmp(const void *_S1, const void *_S2, size_t _N)
+{
+    const unsigned char *s1 = _S1, *s2 = _S2;
+
+    if (_N == 0 || s1 == s2)
+       return 0;       /* even for NULL pointers */
+
+    if ((s1 != NULL) != (s2 != NULL))
+       return s2 == NULL ? 1 : -1;     /* robust */
+
+    for ( ; 0 < _N; ++s1, ++s2, --_N)
+       if (*s1 != *s2)
+           return (*s1 < *s2 ? -1 : +1);
+
+    return 0;
+}
+
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to