1 /* -*- mode: C; c-basic-offset: 3; indent-tabs-mode: nil; -*- */
3 /*--------------------------------------------------------------------*/
4 /*--- Replacements for strlen() and strnlen(), which run on the ---*/
5 /*--- simulated CPU. ---*/
6 /*--------------------------------------------------------------------*/
9 This file is part of DRD, a heavyweight Valgrind tool for
10 detecting threading errors. The code below has been extracted
11 from memchec/mc_replace_strmem.c, which has the following copyright
14 Copyright (C) 2000-2010 Julian Seward
17 This program is free software; you can redistribute it and/or
18 modify it under the terms of the GNU General Public License as
19 published by the Free Software Foundation; either version 2 of the
20 License, or (at your option) any later version.
22 This program is distributed in the hope that it will be useful, but
23 WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 General Public License for more details.
27 You should have received a copy of the GNU General Public License
28 along with this program; if not, write to the Free Software
29 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
32 The GNU General Public License is contained in the file COPYING.
35 #include "pub_tool_basics.h"
36 #include "pub_tool_hashtable.h"
37 #include "pub_tool_redir.h"
38 #include "pub_tool_tooliface.h"
42 #define STRNLEN(soname, fnname) \
43 SizeT VG_REPLACE_FUNCTION_ZU(soname,fnname) ( const char* str, SizeT n ); \
44 SizeT VG_REPLACE_FUNCTION_ZU(soname,fnname) ( const char* str, SizeT n ) \
47 while (i < n && str[i] != 0) i++; \
51 STRNLEN(VG_Z_LIBC_SONAME, strnlen)
54 // Note that this replacement often doesn't get used because gcc inlines
55 // calls to strlen() with its own built-in version. This can be very
56 // confusing if you aren't expecting it. Other small functions in this file
57 // may also be inline by gcc.
58 #define STRLEN(soname, fnname) \
59 SizeT VG_REPLACE_FUNCTION_ZU(soname,fnname)( const char* str ); \
60 SizeT VG_REPLACE_FUNCTION_ZU(soname,fnname)( const char* str ) \
63 while (str[i] != 0) i++; \
67 STRLEN(VG_Z_LIBC_SONAME, strlen)
68 #if defined(VGO_linux)
69 STRLEN(VG_Z_LD_LINUX_SO_2, strlen)
70 STRLEN(VG_Z_LD_LINUX_X86_64_SO_2, strlen)
73 /*--------------------------------------------------------------------*/
75 /*--------------------------------------------------------------------*/