|
From: <sv...@va...> - 2005-05-14 21:28:47
|
Author: njn
Date: 2005-05-14 22:28:43 +0100 (Sat, 14 May 2005)
New Revision: 3710
Added:
trunk/coregrind/m_hashtable.c
trunk/coregrind/pub_core_hashtable.h
trunk/include/pub_tool_hashtable.h
Removed:
trunk/coregrind/vg_hashtable.c
Modified:
trunk/cachegrind/cg_main.c
trunk/coregrind/Makefile.am
trunk/helgrind/hg_main.c
trunk/include/Makefile.am
trunk/include/tool.h
trunk/massif/ms_main.c
trunk/memcheck/mac_shared.h
Log:
Modularised vg_hashtable.c as m_hashtable.
Modified: trunk/cachegrind/cg_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/cachegrind/cg_main.c 2005-05-14 18:42:26 UTC (rev 3709)
+++ trunk/cachegrind/cg_main.c 2005-05-14 21:28:43 UTC (rev 3710)
@@ -30,6 +30,7 @@
*/
=20
#include "tool.h"
+#include "pub_tool_hashtable.h"
#include "pub_tool_mallocfree.h"
#include "pub_tool_tooliface.h"
=20
Modified: trunk/coregrind/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/Makefile.am 2005-05-14 18:42:26 UTC (rev 3709)
+++ trunk/coregrind/Makefile.am 2005-05-14 21:28:43 UTC (rev 3710)
@@ -45,6 +45,7 @@
pub_core_dispatch_asm.h \
pub_core_errormgr.h \
pub_core_execontext.h \
+ pub_core_hashtable.h \
pub_core_mallocfree.h \
pub_core_replacemalloc.h\
pub_core_sigframe.h \
@@ -76,6 +77,7 @@
m_debuglog.c \
m_errormgr.c \
m_execontext.c \
+ m_hashtable.c \
m_mallocfree.c \
m_skiplist.c \
m_stacktrace.c \
@@ -85,7 +87,6 @@
ume.c \
\
vg_scheduler.c \
- vg_hashtable.c \
vg_main.c \
vg_messages.c \
vg_mylibc.c \
Copied: trunk/coregrind/m_hashtable.c (from rev 3701, trunk/coregrind/vg_=
hashtable.c)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/vg_hashtable.c 2005-05-13 23:14:40 UTC (rev 3701)
+++ trunk/coregrind/m_hashtable.c 2005-05-14 21:28:43 UTC (rev 3710)
@@ -0,0 +1,181 @@
+
+/*--------------------------------------------------------------------*/
+/*--- A separately chained hash table. m_hashtable.c ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward=20
+ js...@ac...
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#include "core.h"
+#include "pub_core_hashtable.h"
+
+/*--------------------------------------------------------------------*/
+/*--- Declarations ---*/
+/*--------------------------------------------------------------------*/
+
+/* Holds malloc'd but not freed blocks. Static, so zero-inited by defau=
lt. */
+
+#define VG_N_CHAINS 4999 /* a prime number */
+
+#define VG_CHAIN_NO(aa) (((UWord)(aa)) % VG_N_CHAINS)
+
+/*--------------------------------------------------------------------*/
+/*--- Functions ---*/
+/*--------------------------------------------------------------------*/
+
+VgHashTable VG_(HT_construct)(void)
+{
+ /* Initialises to zero, ie. all entries NULL */
+ return VG_(calloc)(VG_N_CHAINS, sizeof(VgHashNode*));
+}
+
+Int VG_(HT_count_nodes) ( VgHashTable table )
+{
+ VgHashNode* node;
+ UInt chain;
+ Int n =3D 0;
+
+ for (chain =3D 0; chain < VG_N_CHAINS; chain++)
+ for (node =3D table[chain]; node !=3D NULL; node =3D node->next)
+ n++;
+ return n;
+}
+
+/* Puts a new, heap allocated VgHashNode, into the malloclist. */
+void VG_(HT_add_node) ( VgHashTable table, VgHashNode* node )
+{
+ UInt chain =3D VG_CHAIN_NO(node->key);
+ node->next =3D table[chain];
+ table[chain] =3D node;
+}
+
+/* Looks up a VgHashNode in the table. Also returns the address of
+ the previous node's `next' pointer which allows it to be removed from=
the
+ list later without having to look it up again. */
+VgHashNode* VG_(HT_get_node) ( VgHashTable table, UWord key,
+ /*OUT*/VgHashNode*** next_ptr )
+{
+ VgHashNode *prev, *curr;
+ Int chain;
+
+ chain =3D VG_CHAIN_NO(key);
+
+ prev =3D NULL;
+ curr =3D table[chain];
+ while (True) {
+ if (curr =3D=3D NULL)
+ break;
+ if (key =3D=3D curr->key)
+ break;
+ prev =3D curr;
+ curr =3D curr->next;
+ }
+
+ if (NULL =3D=3D prev)
+ *next_ptr =3D & table[chain];
+ else
+ *next_ptr =3D & prev->next;
+
+ return curr;
+}
+
+/* Allocates a suitably-sized array, copies all the malloc'd block
+ shadows into it, then returns both the array and the size of it. Thi=
s is
+ used by the memory-leak detector.
+*/
+VgHashNode** VG_(HT_to_array) ( VgHashTable table, /*OUT*/ UInt* n_shado=
ws )
+{
+ UInt i, j;
+ VgHashNode** arr;
+ VgHashNode* node;
+
+ *n_shadows =3D 0;
+ for (i =3D 0; i < VG_N_CHAINS; i++) {
+ for (node =3D table[i]; node !=3D NULL; node =3D node->next) {
+ (*n_shadows)++;
+ }
+ }
+ if (*n_shadows =3D=3D 0)=20
+ return NULL;
+
+ arr =3D VG_(malloc)( *n_shadows * sizeof(VgHashNode*) );
+
+ j =3D 0;
+ for (i =3D 0; i < VG_N_CHAINS; i++) {
+ for (node =3D table[i]; node !=3D NULL; node =3D node->next) {
+ arr[j++] =3D node;
+ }
+ }
+ vg_assert(j =3D=3D *n_shadows);
+
+ return arr;
+}
+
+/* Return the first VgHashNode satisfying the predicate p. */
+VgHashNode* VG_(HT_first_match) ( VgHashTable table,
+ Bool (*p) ( VgHashNode*, void* ),
+ void* d )
+{
+ UInt i;
+ VgHashNode* node;
+
+ for (i =3D 0; i < VG_N_CHAINS; i++)
+ for (node =3D table[i]; node !=3D NULL; node =3D node->next)
+ if ( p(node, d) )
+ return node;
+
+ return NULL;
+}
+
+void VG_(HT_apply_to_all_nodes)( VgHashTable table,
+ void (*f)(VgHashNode*, void*),
+ void* d )
+{
+ UInt i;
+ VgHashNode* node;
+
+ for (i =3D 0; i < VG_N_CHAINS; i++) {
+ for (node =3D table[i]; node !=3D NULL; node =3D node->next) {
+ f(node, d);
+ }
+ }
+}
+
+void VG_(HT_destruct)(VgHashTable table)
+{
+ UInt i;
+ VgHashNode* node;
+ =20
+ for (i =3D 0; i < VG_N_CHAINS; i++) {
+ for (node =3D table[i]; node !=3D NULL; node =3D node->next) {
+ VG_(free)(node);
+ }
+ }
+ VG_(free)(table);
+}
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
Added: trunk/coregrind/pub_core_hashtable.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/pub_core_hashtable.h 2005-05-14 18:42:26 UTC (rev 370=
9)
+++ trunk/coregrind/pub_core_hashtable.h 2005-05-14 21:28:43 UTC (rev 371=
0)
@@ -0,0 +1,48 @@
+
+/*--------------------------------------------------------------------*/
+/*--- A separately-chained hash table. pub_core_hashtable.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward
+ js...@ac...
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __PUB_CORE_HASHTABLE_H
+#define __PUB_CORE_HASHTABLE_H
+
+//--------------------------------------------------------------------
+// PURPOSE: A generic data structure with fairly fast lookup for not to=
o
+// many elements, eg. up to a few thousand.
+//--------------------------------------------------------------------
+
+#include "pub_tool_hashtable.h"
+
+// No core-only exports; everything in this module is visible to both
+// the core and tools.
+
+#endif // __PUB_CORE_HASHTABLE_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
Deleted: trunk/coregrind/vg_hashtable.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/vg_hashtable.c 2005-05-14 18:42:26 UTC (rev 3709)
+++ trunk/coregrind/vg_hashtable.c 2005-05-14 21:28:43 UTC (rev 3710)
@@ -1,180 +0,0 @@
-
-/*--------------------------------------------------------------------*/
-/*--- A separately chained hash table. vg_hashtable.c ---*/
-/*--------------------------------------------------------------------*/
-
-/*
- This file is part of Valgrind, a dynamic binary instrumentation
- framework.
-
- Copyright (C) 2000-2005 Julian Seward=20
- js...@ac...
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307, USA.
-
- The GNU General Public License is contained in the file COPYING.
-*/
-
-#include "core.h"
-
-/*--------------------------------------------------------------------*/
-/*--- Declarations ---*/
-/*--------------------------------------------------------------------*/
-
-/* Holds malloc'd but not freed blocks. Static, so zero-inited by defau=
lt. */
-
-#define VG_N_CHAINS 4999 /* a prime number */
-
-#define VG_CHAIN_NO(aa) (((UWord)(aa)) % VG_N_CHAINS)
-
-/*--------------------------------------------------------------------*/
-/*--- Functions ---*/
-/*--------------------------------------------------------------------*/
-
-VgHashTable VG_(HT_construct)(void)
-{
- /* Initialises to zero, ie. all entries NULL */
- return VG_(calloc)(VG_N_CHAINS, sizeof(VgHashNode*));
-}
-
-Int VG_(HT_count_nodes) ( VgHashTable table )
-{
- VgHashNode* node;
- UInt chain;
- Int n =3D 0;
-
- for (chain =3D 0; chain < VG_N_CHAINS; chain++)
- for (node =3D table[chain]; node !=3D NULL; node =3D node->next)
- n++;
- return n;
-}
-
-/* Puts a new, heap allocated VgHashNode, into the malloclist. */
-void VG_(HT_add_node) ( VgHashTable table, VgHashNode* node )
-{
- UInt chain =3D VG_CHAIN_NO(node->key);
- node->next =3D table[chain];
- table[chain] =3D node;
-}
-
-/* Looks up a VgHashNode in the table. Also returns the address of
- the previous node's `next' pointer which allows it to be removed from=
the
- list later without having to look it up again. */
-VgHashNode* VG_(HT_get_node) ( VgHashTable table, UWord key,
- /*OUT*/VgHashNode*** next_ptr )
-{
- VgHashNode *prev, *curr;
- Int chain;
-
- chain =3D VG_CHAIN_NO(key);
-
- prev =3D NULL;
- curr =3D table[chain];
- while (True) {
- if (curr =3D=3D NULL)
- break;
- if (key =3D=3D curr->key)
- break;
- prev =3D curr;
- curr =3D curr->next;
- }
-
- if (NULL =3D=3D prev)
- *next_ptr =3D & table[chain];
- else
- *next_ptr =3D & prev->next;
-
- return curr;
-}
-
-/* Allocates a suitably-sized array, copies all the malloc'd block
- shadows into it, then returns both the array and the size of it. Thi=
s is
- used by the memory-leak detector.
-*/
-VgHashNode** VG_(HT_to_array) ( VgHashTable table, /*OUT*/ UInt* n_shado=
ws )
-{
- UInt i, j;
- VgHashNode** arr;
- VgHashNode* node;
-
- *n_shadows =3D 0;
- for (i =3D 0; i < VG_N_CHAINS; i++) {
- for (node =3D table[i]; node !=3D NULL; node =3D node->next) {
- (*n_shadows)++;
- }
- }
- if (*n_shadows =3D=3D 0)=20
- return NULL;
-
- arr =3D VG_(malloc)( *n_shadows * sizeof(VgHashNode*) );
-
- j =3D 0;
- for (i =3D 0; i < VG_N_CHAINS; i++) {
- for (node =3D table[i]; node !=3D NULL; node =3D node->next) {
- arr[j++] =3D node;
- }
- }
- vg_assert(j =3D=3D *n_shadows);
-
- return arr;
-}
-
-/* Return the first VgHashNode satisfying the predicate p. */
-VgHashNode* VG_(HT_first_match) ( VgHashTable table,
- Bool (*p) ( VgHashNode*, void* ),
- void* d )
-{
- UInt i;
- VgHashNode* node;
-
- for (i =3D 0; i < VG_N_CHAINS; i++)
- for (node =3D table[i]; node !=3D NULL; node =3D node->next)
- if ( p(node, d) )
- return node;
-
- return NULL;
-}
-
-void VG_(HT_apply_to_all_nodes)( VgHashTable table,
- void (*f)(VgHashNode*, void*),
- void* d )
-{
- UInt i;
- VgHashNode* node;
-
- for (i =3D 0; i < VG_N_CHAINS; i++) {
- for (node =3D table[i]; node !=3D NULL; node =3D node->next) {
- f(node, d);
- }
- }
-}
-
-void VG_(HT_destruct)(VgHashTable table)
-{
- UInt i;
- VgHashNode* node;
- =20
- for (i =3D 0; i < VG_N_CHAINS; i++) {
- for (node =3D table[i]; node !=3D NULL; node =3D node->next) {
- VG_(free)(node);
- }
- }
- VG_(free)(table);
-}
-
-/*--------------------------------------------------------------------*/
-/*--- end vg_hashtable.c ---*/
-/*--------------------------------------------------------------------*/
Modified: trunk/helgrind/hg_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/helgrind/hg_main.c 2005-05-14 18:42:26 UTC (rev 3709)
+++ trunk/helgrind/hg_main.c 2005-05-14 21:28:43 UTC (rev 3710)
@@ -30,6 +30,7 @@
*/
=20
#include "tool.h"
+#include "pub_tool_hashtable.h"
#include "pub_tool_mallocfree.h"
#include "pub_tool_replacemalloc.h"
#include "pub_tool_tooliface.h"
Modified: trunk/include/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/include/Makefile.am 2005-05-14 18:42:26 UTC (rev 3709)
+++ trunk/include/Makefile.am 2005-05-14 21:28:43 UTC (rev 3710)
@@ -14,6 +14,7 @@
tool_asm.h \
pub_tool_errormgr.h \
pub_tool_execontext.h \
+ pub_tool_hashtable.h \
pub_tool_mallocfree.h \
pub_tool_replacemalloc.h\
pub_tool_skiplist.h \
Added: trunk/include/pub_tool_hashtable.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/include/pub_tool_hashtable.h 2005-05-14 18:42:26 UTC (rev 3709)
+++ trunk/include/pub_tool_hashtable.h 2005-05-14 21:28:43 UTC (rev 3710)
@@ -0,0 +1,98 @@
+
+/*--------------------------------------------------------------------*/
+/*--- A hash table implementation. pub_tool_hashtable.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward
+ js...@ac...
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __PUB_TOOL_HASHTABLE_H
+#define __PUB_TOOL_HASHTABLE_H
+
+/* Generic type for a separately-chained hash table. Via a kind of dodg=
y
+ C-as-C++ style inheritance, tools can extend the VgHashNode type, so =
long
+ as the first two fields match the sizes of these two fields. Require=
s
+ a bit of casting by the tool. */
+
+// Problems with this type:
+// - Table is fixed-size. =20
+// - Separate chaining gives bad cache behaviour. Hash tables with line=
ar
+// probing give better cache behaviour.
+// - It's not very abstract, eg. deleting nodes exposes more internals t=
han
+// I'd like.
+
+typedef
+ struct _VgHashNode {
+ struct _VgHashNode * next;
+ UWord key;
+ }
+ VgHashNode;
+
+typedef
+ VgHashNode**
+ VgHashTable;
+
+/* Make a new table. Allocates the memory with VG_(calloc)(), so can be=
freed
+ * with VG_(free)(). */
+extern VgHashTable VG_(HT_construct) ( void );
+
+/* Count the number of nodes in a table. */
+extern Int VG_(HT_count_nodes) ( VgHashTable table );
+
+/* Add a node to the table. */
+extern void VG_(HT_add_node) ( VgHashTable t, VgHashNode* node );
+
+/* Looks up a node in the hash table. Also returns the address of the
+ previous node's `next' pointer which allows it to be removed from the
+ list later without having to look it up again. */
+extern VgHashNode* VG_(HT_get_node) ( VgHashTable t, UWord key,
+ /*OUT*/VgHashNode*** next_ptr );
+
+/* Allocates an array of pointers to all the shadow chunks of malloc'd
+ blocks. Must be freed with VG_(free)(). */
+extern VgHashNode** VG_(HT_to_array) ( VgHashTable t, /*OUT*/ UInt* n_sh=
adows );
+
+/* Returns first node that matches predicate `p', or NULL if none do.
+ Extra arguments can be implicitly passed to `p' using `d' which is an
+ opaque pointer passed to `p' each time it is called. */
+extern VgHashNode* VG_(HT_first_match) ( VgHashTable t,
+ Bool (*p)(VgHashNode*, void*),
+ void* d );
+
+/* Applies a function f() once to each node. Again, `d' can be used
+ to pass extra information to the function. */
+extern void VG_(HT_apply_to_all_nodes)( VgHashTable t,
+ void (*f)(VgHashNode*, void*),
+ void* d );
+
+/* Destroy a table. */
+extern void VG_(HT_destruct) ( VgHashTable t );
+
+
+#endif // __PUB_TOOL_HASHTABLE_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
Modified: trunk/include/tool.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/include/tool.h 2005-05-14 18:42:26 UTC (rev 3709)
+++ trunk/include/tool.h 2005-05-14 21:28:43 UTC (rev 3710)
@@ -579,62 +579,6 @@
extern VgSectKind VG_(seg_sect_kind)(Addr);
=20
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-/*=3D=3D=3D Generic hash table =
=3D=3D=3D*/
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-
-/* Generic type for a separately-chained hash table. Via a kind of dodg=
y
- C-as-C++ style inheritance, tools can extend the VgHashNode type, so =
long
- as the first two fields match the sizes of these two fields. Require=
s
- a bit of casting by the tool. */
-typedef
- struct _VgHashNode {
- struct _VgHashNode * next;
- UWord key;
- }
- VgHashNode;
-
-typedef
- VgHashNode**
- VgHashTable;
-
-/* Make a new table. Allocates the memory with VG_(calloc)(), so can be=
freed
- * with VG_(free)(). */
-extern VgHashTable VG_(HT_construct) ( void );
-
-/* Count the number of nodes in a table. */
-extern Int VG_(HT_count_nodes) ( VgHashTable table );
-
-/* Add a node to the table. */
-extern void VG_(HT_add_node) ( VgHashTable t, VgHashNode* node );
-
-/* Looks up a node in the hash table. Also returns the address of the
- previous node's `next' pointer which allows it to be removed from the
- list later without having to look it up again. */
-extern VgHashNode* VG_(HT_get_node) ( VgHashTable t, UWord key,
- /*OUT*/VgHashNode*** next_ptr );
-
-/* Allocates an array of pointers to all the shadow chunks of malloc'd
- blocks. Must be freed with VG_(free)(). */
-extern VgHashNode** VG_(HT_to_array) ( VgHashTable t, /*OUT*/ UInt* n_sh=
adows );
-
-/* Returns first node that matches predicate `p', or NULL if none do.
- Extra arguments can be implicitly passed to `p' using `d' which is an
- opaque pointer passed to `p' each time it is called. */
-extern VgHashNode* VG_(HT_first_match) ( VgHashTable t,
- Bool (*p)(VgHashNode*, void*),
- void* d );
-
-/* Applies a function f() once to each node. Again, `d' can be used
- to pass extra information to the function. */
-extern void VG_(HT_apply_to_all_nodes)( VgHashTable t,
- void (*f)(VgHashNode*, void*),
- void* d );
-
-/* Destroy a table. */
-extern void VG_(HT_destruct) ( VgHashTable t );
-
-
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
/*=3D=3D=3D Functions for shadow registers =
=3D=3D=3D*/
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
=20
Modified: trunk/massif/ms_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/massif/ms_main.c 2005-05-14 18:42:26 UTC (rev 3709)
+++ trunk/massif/ms_main.c 2005-05-14 21:28:43 UTC (rev 3710)
@@ -35,6 +35,7 @@
// structures below for more info on how things work.
=20
#include "tool.h"
+#include "pub_tool_hashtable.h"
#include "pub_tool_mallocfree.h"
#include "pub_tool_replacemalloc.h"
#include "pub_tool_stacktrace.h"
Modified: trunk/memcheck/mac_shared.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/memcheck/mac_shared.h 2005-05-14 18:42:26 UTC (rev 3709)
+++ trunk/memcheck/mac_shared.h 2005-05-14 21:28:43 UTC (rev 3710)
@@ -37,6 +37,7 @@
#define __MAC_SHARED_H
=20
#include "tool.h"
+#include "pub_tool_hashtable.h"
#include "pub_tool_mallocfree.h"
#include "pub_tool_replacemalloc.h"
#include "pub_tool_tooliface.h"
|