[RFC PATCH 1/2] msvcrt: Split simple string/memory routines to a separate file

Martin Storsjo martin at martin.st
Sun Oct 18 14:20:40 CDT 2015


These are simple functions that don't touch the global CRT state
(not touching errno etc). These are functions that are part of
vcruntime140.dll in the new ucrtbase/vcruntime split.

Signed-off-by: Martin Storsjo <martin at martin.st>
---
I'm not sure if "memory" is the best filename here, other suggestions
are welcome.
---
 dlls/msvcr100/Makefile.in |   1 +
 dlls/msvcr110/Makefile.in |   1 +
 dlls/msvcr120/Makefile.in |   1 +
 dlls/msvcr70/Makefile.in  |   1 +
 dlls/msvcr71/Makefile.in  |   1 +
 dlls/msvcr80/Makefile.in  |   1 +
 dlls/msvcr90/Makefile.in  |   1 +
 dlls/msvcrt/Makefile.in   |   1 +
 dlls/msvcrt/memory.c      | 118 ++++++++++++++++++++++++++++++++++++++++++++++
 dlls/msvcrt/string.c      |  64 -------------------------
 dlls/msvcrt/wcs.c         |  16 -------
 dlls/ucrtbase/Makefile.in |   1 +
 12 files changed, 127 insertions(+), 80 deletions(-)
 create mode 100644 dlls/msvcrt/memory.c

diff --git a/dlls/msvcr100/Makefile.in b/dlls/msvcr100/Makefile.in
index ac9acf4..cfec67e 100644
--- a/dlls/msvcr100/Makefile.in
+++ b/dlls/msvcr100/Makefile.in
@@ -24,6 +24,7 @@ C_SRCS = \
 	main.c \
 	math.c \
 	mbcs.c \
+	memory.c \
 	misc.c \
 	process.c \
 	scanf.c \
diff --git a/dlls/msvcr110/Makefile.in b/dlls/msvcr110/Makefile.in
index ac73a02..5c12dc9 100644
--- a/dlls/msvcr110/Makefile.in
+++ b/dlls/msvcr110/Makefile.in
@@ -24,6 +24,7 @@ C_SRCS = \
 	main.c \
 	math.c \
 	mbcs.c \
+	memory.c \
 	misc.c \
 	process.c \
 	scanf.c \
diff --git a/dlls/msvcr120/Makefile.in b/dlls/msvcr120/Makefile.in
index 5e4a166..0de5b67 100644
--- a/dlls/msvcr120/Makefile.in
+++ b/dlls/msvcr120/Makefile.in
@@ -24,6 +24,7 @@ C_SRCS = \
 	main.c \
 	math.c \
 	mbcs.c \
+	memory.c \
 	misc.c \
 	process.c \
 	scanf.c \
diff --git a/dlls/msvcr70/Makefile.in b/dlls/msvcr70/Makefile.in
index f7b0910..a01be39 100644
--- a/dlls/msvcr70/Makefile.in
+++ b/dlls/msvcr70/Makefile.in
@@ -24,6 +24,7 @@ C_SRCS = \
 	main.c \
 	math.c \
 	mbcs.c \
+	memory.c \
 	misc.c \
 	process.c \
 	scanf.c \
diff --git a/dlls/msvcr71/Makefile.in b/dlls/msvcr71/Makefile.in
index a62630e..c58c41a 100644
--- a/dlls/msvcr71/Makefile.in
+++ b/dlls/msvcr71/Makefile.in
@@ -24,6 +24,7 @@ C_SRCS = \
 	main.c \
 	math.c \
 	mbcs.c \
+	memory.c \
 	misc.c \
 	process.c \
 	scanf.c \
diff --git a/dlls/msvcr80/Makefile.in b/dlls/msvcr80/Makefile.in
index e17b7ac..fbc87a2 100644
--- a/dlls/msvcr80/Makefile.in
+++ b/dlls/msvcr80/Makefile.in
@@ -24,6 +24,7 @@ C_SRCS = \
 	main.c \
 	math.c \
 	mbcs.c \
+	memory.c \
 	misc.c \
 	process.c \
 	scanf.c \
diff --git a/dlls/msvcr90/Makefile.in b/dlls/msvcr90/Makefile.in
index d409039..3f38e48 100644
--- a/dlls/msvcr90/Makefile.in
+++ b/dlls/msvcr90/Makefile.in
@@ -24,6 +24,7 @@ C_SRCS = \
 	main.c \
 	math.c \
 	mbcs.c \
+	memory.c \
 	misc.c \
 	process.c \
 	scanf.c \
diff --git a/dlls/msvcrt/Makefile.in b/dlls/msvcrt/Makefile.in
index 1632c6b..a298282 100644
--- a/dlls/msvcrt/Makefile.in
+++ b/dlls/msvcrt/Makefile.in
@@ -23,6 +23,7 @@ C_SRCS = \
 	main.c \
 	math.c \
 	mbcs.c \
+	memory.c \
 	misc.c \
 	process.c \
 	scanf.c \
diff --git a/dlls/msvcrt/memory.c b/dlls/msvcrt/memory.c
new file mode 100644
index 0000000..b2becc7
--- /dev/null
+++ b/dlls/msvcrt/memory.c
@@ -0,0 +1,118 @@
+/*
+ * MSVCRT memory functions
+ *
+ * Copyright 1996,1998 Marcus Meissner
+ * Copyright 1996 Jukka Iivonen
+ * Copyright 1997,2000 Uwe Bonnes
+ * Copyright 2000 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define _ISOC99_SOURCE
+#include "config.h"
+#include "wine/port.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <limits.h>
+#include <errno.h>
+#include "msvcrt.h"
+#include "winnls.h"
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+
+/*********************************************************************
+ *                  memcmp (MSVCRT.@)
+ */
+int __cdecl MSVCRT_memcmp(const void *ptr1, const void *ptr2, MSVCRT_size_t n)
+{
+    return memcmp(ptr1, ptr2, n);
+}
+
+/*********************************************************************
+ *                  memcpy   (MSVCRT.@)
+ */
+void * __cdecl MSVCRT_memcpy(void *dst, const void *src, MSVCRT_size_t n)
+{
+    return memmove(dst, src, n);
+}
+
+/*********************************************************************
+ *                  memmove (MSVCRT.@)
+ */
+void * __cdecl MSVCRT_memmove(void *dst, const void *src, MSVCRT_size_t n)
+{
+    return memmove(dst, src, n);
+}
+
+/*********************************************************************
+ *		    memset (MSVCRT.@)
+ */
+void* __cdecl MSVCRT_memset(void *dst, int c, MSVCRT_size_t n)
+{
+    return memset(dst, c, n);
+}
+
+/*********************************************************************
+ *		    strchr (MSVCRT.@)
+ */
+char* __cdecl MSVCRT_strchr(const char *str, int c)
+{
+    return strchr(str, c);
+}
+
+/*********************************************************************
+ *                  strrchr (MSVCRT.@)
+ */
+char* __cdecl MSVCRT_strrchr(const char *str, int c)
+{
+    return strrchr(str, c);
+}
+
+/*********************************************************************
+ *                  memchr   (MSVCRT.@)
+ */
+void* __cdecl MSVCRT_memchr(const void *ptr, int c, MSVCRT_size_t n)
+{
+    return memchr(ptr, c, n);
+}
+
+/*********************************************************************
+ *                  strstr   (MSVCRT.@)
+ */
+char* __cdecl MSVCRT_strstr(const char *haystack, const char *needle)
+{
+    return strstr(haystack, needle);
+}
+
+/*********************************************************************
+ *              wcschr (MSVCRT.@)
+ */
+MSVCRT_wchar_t* CDECL MSVCRT_wcschr(const MSVCRT_wchar_t *str, MSVCRT_wchar_t ch)
+{
+    return strchrW(str, ch);
+}
+
+/*********************************************************************
+ *              wcsstr (MSVCRT.@)
+ */
+MSVCRT_wchar_t* CDECL MSVCRT_wcsstr(const MSVCRT_wchar_t *str, const MSVCRT_wchar_t *sub)
+{
+    return strstrW(str, sub);
+}
diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c
index dde95ac..da9d17f 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -1753,62 +1753,6 @@ int CDECL MSVCRT_I10_OUTPUT(MSVCRT__LDOUBLE ld80, int prec, int flag, struct _I1
 #undef I10_OUTPUT_MAX_PREC
 
 /*********************************************************************
- *                  memcmp (MSVCRT.@)
- */
-int __cdecl MSVCRT_memcmp(const void *ptr1, const void *ptr2, MSVCRT_size_t n)
-{
-    return memcmp(ptr1, ptr2, n);
-}
-
-/*********************************************************************
- *                  memcpy   (MSVCRT.@)
- */
-void * __cdecl MSVCRT_memcpy(void *dst, const void *src, MSVCRT_size_t n)
-{
-    return memmove(dst, src, n);
-}
-
-/*********************************************************************
- *                  memmove (MSVCRT.@)
- */
-void * __cdecl MSVCRT_memmove(void *dst, const void *src, MSVCRT_size_t n)
-{
-    return memmove(dst, src, n);
-}
-
-/*********************************************************************
- *		    memset (MSVCRT.@)
- */
-void* __cdecl MSVCRT_memset(void *dst, int c, MSVCRT_size_t n)
-{
-    return memset(dst, c, n);
-}
-
-/*********************************************************************
- *		    strchr (MSVCRT.@)
- */
-char* __cdecl MSVCRT_strchr(const char *str, int c)
-{
-    return strchr(str, c);
-}
-
-/*********************************************************************
- *                  strrchr (MSVCRT.@)
- */
-char* __cdecl MSVCRT_strrchr(const char *str, int c)
-{
-    return strrchr(str, c);
-}
-
-/*********************************************************************
- *                  memchr   (MSVCRT.@)
- */
-void* __cdecl MSVCRT_memchr(const void *ptr, int c, MSVCRT_size_t n)
-{
-    return memchr(ptr, c, n);
-}
-
-/*********************************************************************
  *                  strcmp (MSVCRT.@)
  */
 int __cdecl MSVCRT_strcmp(const char *str1, const char *str2)
@@ -1878,11 +1822,3 @@ int __cdecl MSVCRT__stricmp(const char *s1, const char *s2)
 {
     return MSVCRT__strnicmp_l(s1, s2, -1, NULL);
 }
-
-/*********************************************************************
- *                  strstr   (MSVCRT.@)
- */
-char* __cdecl MSVCRT_strstr(const char *haystack, const char *needle)
-{
-    return strstr(haystack, needle);
-}
diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c
index 913b0a7..87a57ef 100644
--- a/dlls/msvcrt/wcs.c
+++ b/dlls/msvcrt/wcs.c
@@ -2098,14 +2098,6 @@ int CDECL MSVCRT_towlower(MSVCRT_wint_t c)
     return MSVCRT__towlower_l(c, NULL);
 }
 
-/*********************************************************************
- *              wcschr (MSVCRT.@)
- */
-MSVCRT_wchar_t* CDECL MSVCRT_wcschr(const MSVCRT_wchar_t *str, MSVCRT_wchar_t ch)
-{
-    return strchrW(str, ch);
-}
-
 /***********************************************************************
  *              wcslen (MSVCRT.@)
  */
@@ -2115,14 +2107,6 @@ int CDECL MSVCRT_wcslen(const MSVCRT_wchar_t *str)
 }
 
 /*********************************************************************
- *              wcsstr (MSVCRT.@)
- */
-MSVCRT_wchar_t* CDECL MSVCRT_wcsstr(const MSVCRT_wchar_t *str, const MSVCRT_wchar_t *sub)
-{
-    return strstrW(str, sub);
-}
-
-/*********************************************************************
  *              _wtoi64_l (MSVCRT.@)
  */
 __int64 CDECL MSVCRT__wtoi64_l(const MSVCRT_wchar_t *str, MSVCRT__locale_t locale)
diff --git a/dlls/ucrtbase/Makefile.in b/dlls/ucrtbase/Makefile.in
index 9e672f3..38635ac 100644
--- a/dlls/ucrtbase/Makefile.in
+++ b/dlls/ucrtbase/Makefile.in
@@ -23,6 +23,7 @@ C_SRCS = \
 	main.c \
 	math.c \
 	mbcs.c \
+	memory.c \
 	misc.c \
 	process.c \
 	string.c \
-- 
1.8.1.2




More information about the wine-patches mailing list