|
From: Дмитрий Д. <di...@gm...> - 2012-03-24 17:54:41
|
Hello!
i want add new functions -- wcscmp/wcsncmp/wsclen/wscnlen into Memcheck.
And i have questions:
1. Will such addition be accepted? Or there are caveats with WCHAR
functions?
2. Is mc_replace_strmem.c the correct file for such addition?
3. Will it be correct to use 20360 20370 20380 and 20390 for
wcscmp/wscncmp/wsclen/wcsnlen?
Comment in mc_replace_strmem.c say
-- begin --
Assignment of behavioural equivalence class tags: 2NNNP is intended
to be reserved for Memcheck. Current usage:
20010 STRRCHR
...skip...
20350 STRCASESTR
-- end --
Naive implementation for wcscmp() works under Fedora16/x64/gcc-4.6.3 (at
least it looks so :) )
#include <wchar.h>
#define WCSCMP(soname, fnname) \
int VG_REPLACE_FUNCTION_EZU(20360,soname,fnname) \
( const wchar_t* s1, const wchar_t* s2 ); \
int VG_REPLACE_FUNCTION_EZU(20360,soname,fnname) \
( const wchar_t* s1, const wchar_t* s2 ) \
{ \
register wchar_t c1; \
register wchar_t c2; \
while (True) { \
c1 = *(wchar_t *)s1; \
c2 = *(wchar_t *)s2; \
if (c1 != c2) break; \
if (c1 == 0) break; \
s1++; s2++; \
} \
if ((wchar_t)c1 < (wchar_t)c2) return -1; \
if ((wchar_t)c1 > (wchar_t)c2) return 1; \
return 0; \
}
#if defined(VGO_linux)
WCSCMP(VG_Z_LIBC_SONAME, wcscmp)
WCSCMP(VG_Z_LIBC_SONAME, __GI_wcscmp)
#elif defined(VGO_darwin)
// WCSCMP(VG_Z_LIBC_SONAME, wcscmp)
#endif
Thank You
Dmitry
|