]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add replacements for wmemchr() and wcsnlen() on Linux.
authorNick Alcock <nix@esperi.org.uk>
Wed, 28 Feb 2018 15:20:11 +0000 (15:20 +0000)
committerIvo Raisr <ivosh@ivosh.net>
Fri, 2 Mar 2018 15:24:26 +0000 (16:24 +0100)
These have gained ifunc support in recent glibc releases,
so need replacement.
Fixes BZ#388862

Patch by: Nix <nix@esperi.org.uk>

NEWS
shared/vg_replace_strmem.c

diff --git a/NEWS b/NEWS
index 3a180e91ff9d12cec06fda5f9d4a984dac200374..5b33424a04a9ce8689fc87343d57982c0b11b999 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -89,6 +89,7 @@ where XXXXXX is the bug number as listed below.
 387410  MIPSr6 support
 387712  s390x cgijnl reports Conditional jump depends on uninitialised value
 387773  .gnu_debugaltlink paths resolve relative to .debug file, not symlink
+388862  Add replacements for wmemchr and wcsnlen on Linux
 389065  valgrind meets gcc flag -Wlogical-op
 390723  make xtree dump files world wide readable, similar to log files
 
index 6c946ce44fefa1917dd76627b29f0dfbbb96f7a6..215ab7f5ce2b3d4037e21e6b6b47441a15f1f329 100644 (file)
    20400 WCSCHR
    20410 WCSRCHR
    20420 STPNCPY
+   20430 WMEMCHR
+   20440 WCSNLEN
 */
 
 #if defined(VGO_solaris)
@@ -1843,9 +1845,9 @@ static inline void my_exit ( int x )
 
 #define WCSLEN(soname, fnname) \
    SizeT VG_REPLACE_FUNCTION_EZU(20370,soname,fnname) \
-      ( const UInt* str ); \
+      ( const Int* str ); \
    SizeT VG_REPLACE_FUNCTION_EZU(20370,soname,fnname) \
-      ( const UInt* str )  \
+      ( const Int* str )  \
    { \
       SizeT i = 0; \
       while (str[i] != 0) i++; \
@@ -1862,6 +1864,28 @@ static inline void my_exit ( int x )
 
 #endif
 
+/*---------------------- wcsnlen ----------------------*/
+
+#define WCSNLEN(soname, fnname) \
+   SizeT VG_REPLACE_FUNCTION_EZU(20440,soname,fnname) \
+            ( const Int *s, SizeT n ); \
+   SizeT VG_REPLACE_FUNCTION_EZU(20440,soname,fnname) \
+            ( const Int *s, SizeT n ) \
+   {                                     \
+      SizeT i = 0;                       \
+      const Int* p = s;                  \
+      while (i < n && *p != 0) {         \
+         i++;                            \
+         p++;                            \
+      }                                  \
+      return i;                          \
+   }
+
+#if defined(VGO_linux)
+ WCSNLEN(VG_Z_LIBC_SONAME, wcsnlen)
+ WCSNLEN(VG_Z_LIBC_SONAME, __GI_wcsnlen)
+#endif
+
 /*---------------------- wcscmp ----------------------*/
 
 // This is a wchar_t equivalent to strcmp.  We don't
@@ -1971,6 +1995,32 @@ static inline void my_exit ( int x )
  WCSRCHR(VG_Z_LIBC_SONAME, wcsrchr)
 #endif
 
+ /*---------------------- wmemchr ----------------------*/
+
+// This is a wchar_t equivalent to memchr.  We don't
+// have wchar_t available here, but in the GNU C Library
+// wchar_t is always 32 bits wide.
+
+#define WMEMCHR(soname, fnname)                        \
+   Int* VG_REPLACE_FUNCTION_EZU(20430,soname,fnname) \
+            (const Int *s, Int c, SizeT n); \
+   Int* VG_REPLACE_FUNCTION_EZU(20430,soname,fnname) \
+            (const Int *s, Int c, SizeT n) \
+   { \
+      SizeT i; \
+      const Int* p = s; \
+      for (i = 0; i < n; i++) {                   \
+         if (*p == c) return CONST_CAST(Int *,p); \
+         p++;                                     \
+      }                                           \
+      return NULL; \
+   }
+
+#if defined(VGO_linux)
+ WMEMCHR(VG_Z_LIBC_SONAME, wmemchr)
+ WMEMCHR(VG_Z_LIBC_SONAME, __GI_wmemchr)
+#endif
+
 /*------------------------------------------------------------*/
 /*--- Improve definedness checking of process environment  ---*/
 /*------------------------------------------------------------*/