-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 15.10.2013 16:34, LRN wrote:
> Testcase is attached. Some invocations of stpcpy work, some don't.
>
expand_builtin_stpcpy() from gcc/builtins.c sheds some light on this
(when return value is ignored, stpcpy() is replaced with strcpy()).
After reading a diff between the asm output (at jon_y's suggestion) i
concluded that builtin stpcpy is not a full implementation. It's there
only to optimize for cases where second argument is known at compile
time. When that is not the case, it just calls system stpcpy. Which
isn't available :(
Here are patches that add stpcpy() to mingw-w64.
- --
O< ascii ribbon - stop html email! - www.asciiribbon.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)
iQEcBAEBAgAGBQJSXVvcAAoJEOs4Jb6SI2Cwn0EIALlQsLoWNuWC8LQMnI7Vk6Ne
7tHTq0OfFJs+wS3dWZMe4H9j2DkpY1qblI6e5sTraa46VNvvp+8Hi0UvfLct0ob4
X6ju+kfLGN0r4yaMAJvxB6F26u41LXHYN701trd5+JmBZM8fbyvF/r9xVJVM4Wj9
tMD91MlZxpUImJyPsPvhVflsQggPcRO6d12g/gRcGT0BbXBkneXZabNUcFB/utaf
6QjF2uSgn0Q1s22P2ZW4eMCl4GBGi1ZpWDOFgkhZFuaVxciGKsN7AKQGX0ib4C54
hgazNyqI5O8plHA6ZdXlmzsJf+SHxx3a/tgPD4NajENXISxRLrb6ln82hz9+L3M=
=A2yc
-----END PGP SIGNATURE-----
From 6e766114a08de78da539ce604c2afd66579fdb1e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?=
=?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <[email protected]>
Date: Tue, 15 Oct 2013 13:21:25 +0000
Subject: [PATCH 1/2] Add stpcpy() implementation
---
mingw-w64-crt/Makefile.am | 2 +-
mingw-w64-crt/misc/stpcpy.c | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
create mode 100755 mingw-w64-crt/misc/stpcpy.c
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index a2f89a6..fe634c7 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -233,7 +233,7 @@ src_libmingwex=\
misc/wcsnlen.c misc/wcstof.c misc/wcstoimax.c
misc/wcstold.c misc/wcstoumax.c \
misc/wctob.c misc/wctrans.c misc/wctype.c
misc/wdirent.c misc/winbs_uint64.c \
misc/winbs_ulong.c misc/winbs_ushort.c misc/wmemchr.c
misc/wmemcmp.c misc/wmemcpy.c \
- misc/wmemmove.c misc/wmempcpy.c misc/wmemset.c
misc/purecall.c \
+ misc/wmemmove.c misc/wmempcpy.c misc/wmemset.c
misc/purecall.c misc/stpcpy.c \
\
stdio/mingw_pformat.h \
stdio/vfscanf2.S stdio/vfwscanf2.S stdio/vscanf2.S
stdio/vsscanf2.S stdio/vswscanf2.S \
diff --git a/mingw-w64-crt/misc/stpcpy.c b/mingw-w64-crt/misc/stpcpy.c
new file mode 100755
index 0000000..71c3a20
--- /dev/null
+++ b/mingw-w64-crt/misc/stpcpy.c
@@ -0,0 +1,10 @@
+#define __CRT__NO_INLINE
+
+char * __cdecl
+stpcpy(char * __restrict__ _Dest,const char * __restrict__ _Source)
+{
+ for (; *_Source; _Source++, _Dest++)
+ *_Dest = *_Source;
+ *_Dest = '\0';
+ return _Dest;
+}
--
1.8.4
From 072881332f00b71764d3219c2f104b2b103c98e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?=
=?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <[email protected]>
Date: Tue, 15 Oct 2013 13:21:36 +0000
Subject: [PATCH 2/2] Add stpcpy() prototype
---
mingw-w64-headers/crt/string.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mingw-w64-headers/crt/string.h b/mingw-w64-headers/crt/string.h
index 972bd54..cb2b44d 100644
--- a/mingw-w64-headers/crt/string.h
+++ b/mingw-w64-headers/crt/string.h
@@ -49,6 +49,9 @@ extern "C" {
char * __cdecl _strset(char *_Str,int _Val)
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
char * __cdecl _strset_l(char *_Str,int _Val,_locale_t _Locale)
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
char * __cdecl strcpy(char * __restrict__ _Dest,const char * __restrict__
_Source);
+#if (defined (_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700) || (defined
(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200809L)
+ char * __cdecl stpcpy(char * __restrict__ _Dest,const char * __restrict__
_Source);
+#endif
char * __cdecl strcat(char * __restrict__ _Dest,const char * __restrict__
_Source);
int __cdecl strcmp(const char *_Str1,const char *_Str2);
size_t __cdecl strlen(const char *_Str);
--
1.8.4
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public