|
From: <sv...@va...> - 2005-12-24 03:11:21
|
Author: njn
Date: 2005-12-24 03:10:56 +0000 (Sat, 24 Dec 2005)
New Revision: 5427
Log:
Fix a nasty 64-bit-uncleanness bug in OSet spotted by Julian -- for fast
comparisons it was only considering the bottom 32-bits of the key.
Modified:
trunk/cachegrind/cg_main.c
trunk/coregrind/m_oset.c
trunk/include/pub_tool_oset.h
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-12-23 23:46:31 UTC (rev 5426)
+++ trunk/cachegrind/cg_main.c 2005-12-24 03:10:56 UTC (rev 5427)
@@ -92,9 +92,9 @@
};
=20
// First compare file, then fn, then line.
-static Int cmp_CodeLoc_LineCC(void *vloc, void *vcc)
+static Word cmp_CodeLoc_LineCC(void *vloc, void *vcc)
{
- Int res;
+ Word res;
CodeLoc* a =3D (CodeLoc*)vloc;
CodeLoc* b =3D &(((LineCC*)vcc)->loc);
=20
@@ -162,7 +162,7 @@
/*--- String table operations ---*/
/*------------------------------------------------------------*/
=20
-static Int stringCmp( void* key, void* elem )
+static Word stringCmp( void* key, void* elem )
{
return VG_(strcmp)(*(Char**)key, *(Char**)elem);
}
Modified: trunk/coregrind/m_oset.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/m_oset.c 2005-12-23 23:46:31 UTC (rev 5426)
+++ trunk/coregrind/m_oset.c 2005-12-24 03:10:56 UTC (rev 5427)
@@ -171,13 +171,13 @@
}
=20
// Compare the first word of each element. Inlining is *crucial*.
-static inline Int fast_cmp(void* k, AvlNode* n)
+static inline Word fast_cmp(void* k, AvlNode* n)
{
- return ( *(Int*)k - *(Int*)elem_of_node(n) );
+ return ( *(Word*)k - *(Word*)elem_of_node(n) );
}
=20
// Compare a key and an element. Inlining is *crucial*.
-static inline Int slow_cmp(AvlTree* t, void* k, AvlNode* n)
+static inline Word slow_cmp(AvlTree* t, void* k, AvlNode* n)
{
return t->cmp(k, elem_of_node(n));
}
@@ -349,7 +349,7 @@
/*--- Insertion ---*/
/*--------------------------------------------------------------------*/
=20
-static inline Int cmp_key_root(AvlTree* t, AvlNode* n)
+static inline Word cmp_key_root(AvlTree* t, AvlNode* n)
{
return t->cmp
? slow_cmp(t, slow_key_of_node(t, n), t->root)
@@ -360,7 +360,7 @@
// Returns True if the depth of the tree has grown.
static Bool avl_insert(AvlTree* t, AvlNode* n)
{
- Int cmpres =3D cmp_key_root(t, n);
+ Word cmpres =3D cmp_key_root(t, n);
=20
if (cmpres < 0) {
// Insert into the left subtree.
@@ -464,7 +464,7 @@
// Find the *node* in t matching k, or NULL if not found.
static AvlNode* avl_lookup(AvlTree* t, void* k)
{
- Int cmpres;
+ Word cmpres;
AvlNode* curr =3D t->root;
=20
if (t->cmp) {
@@ -481,10 +481,10 @@
// elem_of_node because it saves about 10% on lookup time. This
// shouldn't be very dangerous because each node will have been
// checked on insertion.
- Int kk =3D *(Int*)k;
+ Word kk =3D *(Word*)k;
while (True) {
if (curr =3D=3D NULL) return NULL;
- cmpres =3D kk - *(Int*)elem_of_node_no_check(curr);
+ cmpres =3D kk - *(Word*)elem_of_node_no_check(curr);
if (cmpres < 0) curr =3D curr->left; else
if (cmpres > 0) curr =3D curr->right; else
return curr;
@@ -533,7 +533,7 @@
static Bool avl_remove(AvlTree* t, AvlNode* n)
{
Bool ch;
- Int cmpres =3D cmp_key_root(t, n);
+ Word cmpres =3D cmp_key_root(t, n);
=20
if (cmpres < 0) {
AvlTree left_subtree;
@@ -616,7 +616,7 @@
// Returns True if the depth of the tree has shrunk.
static Bool avl_removeroot(AvlTree* t)
{
- Int ch;
+ Bool ch;
AvlNode* n;
=20
if (!t->root->left) {
Modified: trunk/include/pub_tool_oset.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_oset.h 2005-12-23 23:46:31 UTC (rev 5426)
+++ trunk/include/pub_tool_oset.h 2005-12-24 03:10:56 UTC (rev 5427)
@@ -65,7 +65,7 @@
typedef struct _OSet OSet;
typedef struct _OSetNode OSetNode;
=20
-typedef Int (*OSetCmp_t) ( void* key, void* elem );
+typedef Word (*OSetCmp_t) ( void* key, void* elem );
typedef void* (*OSetAlloc_t) ( SizeT szB );
typedef void (*OSetFree_t) ( void* p );
typedef void (*OSetNodeDestroy_t) ( void* elem );
|