|
From: <sv...@va...> - 2012-08-24 14:44:35
|
sewardj 2012-08-24 15:44:27 +0100 (Fri, 24 Aug 2012)
New Revision: 12893
Log:
Implement a wrapper for wcslen on Linux, assuming that
sizeof(wchar_t) == 4, which I believe to be true on both Linux
and MacOSX. Fixes #298281.
Modified files:
trunk/memcheck/mc_replace_strmem.c
Modified: trunk/memcheck/mc_replace_strmem.c (+27 -0)
===================================================================
--- trunk/memcheck/mc_replace_strmem.c 2012-08-24 15:38:56 +01:00 (rev 12892)
+++ trunk/memcheck/mc_replace_strmem.c 2012-08-24 15:44:27 +01:00 (rev 12893)
@@ -96,6 +96,7 @@
20340 STRSPN
20350 STRCASESTR
20360 MEMRCHR
+ 20370 WCSLEN
*/
@@ -1543,6 +1544,32 @@
#endif
+/*---------------------- wcslen ----------------------*/
+
+// This is a wchar_t equivalent to strlen. Unfortunately
+// we don't have wchar_t available here, but it looks like
+// a 32 bit int on Linux. I don't know if that is also
+// valid on MacOSX.
+
+#define WCSLEN(soname, fnname) \
+ SizeT VG_REPLACE_FUNCTION_EZU(20370,soname,fnname) \
+ ( const UInt* str ); \
+ SizeT VG_REPLACE_FUNCTION_EZU(20370,soname,fnname) \
+ ( const UInt* str ) \
+ { \
+ SizeT i = 0; \
+ while (str[i] != 0) i++; \
+ return i; \
+ }
+
+#if defined(VGO_linux)
+ WCSLEN(VG_Z_LIBC_SONAME, wcslen)
+
+#elif defined(VGO_darwin)
+
+#endif
+
+
/*------------------------------------------------------------*/
/*--- Improve definedness checking of process environment ---*/
/*------------------------------------------------------------*/
|
|
From: Bart V. A. <bva...@ac...> - 2012-08-24 15:41:15
|
On 08/24/12 14:44, sv...@va... wrote: > sewardj 2012-08-24 15:44:27 +0100 (Fri, 24 Aug 2012) > > New Revision: 12893 > > Log: > Implement a wrapper for wcslen on Linux, assuming that > sizeof(wchar_t) == 4, which I believe to be true on both Linux > and MacOSX. Fixes #298281. >From http://gcc.gnu.org/onlinedocs/gcc-4.5.4/gcc/Code-Gen-Options.html: -fshort-wchar Override the underlying type for `wchar_t' to be `short unsigned int' instead of the default for the target. This option is useful for building programs to run under WINE. Warning: the -fshort-wchar switch causes GCC to generate code that is not binary compatible with code generated without that switch. Use it to conform to a non-default application binary interface. Bart. |
|
From: Julian S. <js...@ac...> - 2012-08-24 16:51:04
|
On Friday, August 24, 2012, Bart Van Assche wrote: > On 08/24/12 14:44, sv...@va... wrote: > > sewardj 2012-08-24 15:44:27 +0100 (Fri, 24 Aug 2012) > > > > New Revision: 12893 > > > > Log: > > Implement a wrapper for wcslen on Linux, assuming that > > sizeof(wchar_t) == 4, which I believe to be true on both Linux > > and MacOSX. Fixes #298281. > > > >From http://gcc.gnu.org/onlinedocs/gcc-4.5.4/gcc/Code-Gen-Options.html: > -fshort-wchar Yes, a good point. But in this case we're intercepting wcslen only in glibc, so it seems to me to be unlikely that glibc itself would be built for 16-bit wchar_t. (Would it? Maybe I assume wrong.) So it _seems_ safe to me. J |