Try to sort out signedness problems in hg_wordfm.[ch], and do a bunch
of other tidying too.
* All these word-based abstractions (WordFM, WordSet, WordBag) now
operate on unsigned words (UWord), whereas they previously operated
on signed words (Word). This became a problem, when using unboxed
comparisons, with the introduction of HG_(initIterAtFM), which
allows iteration over parts of mappings. Iterating over a mapping in
increasing order of signed Word keys is not what callers expect when
iterating through maps whose keys representing addresses (Addr) since
Addr is unsigned, and causes logical problems and assertion
failures.
* Change various size-of-things types from signed to unsigned, and
make them consistently word sized. For example the return type
of HG_(sizeFM) used to be an Int, which never made any sense
(the size can't be negative, and, on a 64-bit platform, the
map could have more than 2G elements, in which case an Int can't
represent the result). So make the return value a UWord instead.
This should generally help avoid obscure overflow problems on 64-bit
platforms.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7409 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/helgrind/hg_main.c b/helgrind/hg_main.c
index 825b84d..0fe26d5 100644
--- a/helgrind/hg_main.c
+++ b/helgrind/hg_main.c
@@ -2516,7 +2516,7 @@
Char* how = "no error";
Thread* thr;
WordSetID wsA, wsW;
- Word* ls_words;
+ UWord* ls_words;
Word ls_size, i;
Lock* lk;
Segment* seg;
@@ -2676,7 +2676,7 @@
Word smga;
SecMap* sm;
Word i, j, ws_size, n_valid_tags;
- Word* ws_words;
+ UWord* ws_words;
Addr* valid_tags;
HG_(initIterFM)( map_shmem );
// for sm in SecMaps {
@@ -6614,7 +6614,7 @@
}
LAOGLinkExposition;
-static Word cmp_LAOGLinkExposition ( Word llx1W, Word llx2W ) {
+static Word cmp_LAOGLinkExposition ( UWord llx1W, UWord llx2W ) {
/* Compare LAOGLinkExposition*s by (src_ga,dst_ga) field pair. */
LAOGLinkExposition* llx1 = (LAOGLinkExposition*)llx1W;
LAOGLinkExposition* llx2 = (LAOGLinkExposition*)llx2W;
@@ -6631,7 +6631,7 @@
static void laog__show ( Char* who ) {
Word i, ws_size;
- Word* ws_words;
+ UWord* ws_words;
Lock* me;
LAOGLinks* links;
VG_(printf)("laog (requested by %s) {\n", who);
@@ -6791,7 +6791,7 @@
__attribute__((noinline))
static void laog__sanity_check ( Char* who ) {
Word i, ws_size;
- Word* ws_words;
+ UWord* ws_words;
Lock* me;
LAOGLinks* links;
if ( !laog )
@@ -6845,7 +6845,7 @@
Lock* here;
WordSetID succs;
Word succs_size;
- Word* succs_words;
+ UWord* succs_words;
//laog__sanity_check();
/* If the destination set is empty, we can never get there from
@@ -6897,7 +6897,7 @@
Lock* lk
)
{
- Word* ls_words;
+ UWord* ls_words;
Word ls_size, i;
Lock* other;
@@ -6982,7 +6982,7 @@
{
WordSetID preds, succs;
Word preds_size, succs_size, i, j;
- Word *preds_words, *succs_words;
+ UWord *preds_words, *succs_words;
preds = laog__preds( lk );
succs = laog__succs( lk );
@@ -7012,8 +7012,8 @@
WordSetID /* in univ_laog */ locksToDelete
)
{
- Word i, ws_size;
- Word* ws_words;
+ Word i, ws_size;
+ UWord* ws_words;
if (!laog)
laog = HG_(newFM)( hg_zalloc, hg_free, NULL/*unboxedcmp*/ );
@@ -7716,7 +7716,7 @@
/* maps (by value) strings to a copy of them in ARENA_TOOL */
static UWord stats__string_table_queries = 0;
static WordFM* string_table = NULL;
-static Word string_table_cmp ( Word s1, Word s2 ) {
+static Word string_table_cmp ( UWord s1, UWord s2 ) {
return (Word)VG_(strcmp)( (HChar*)s1, (HChar*)s2 );
}
static HChar* string_table_strdup ( HChar* str ) {
@@ -7744,7 +7744,7 @@
/* maps from Lock .unique fields to LockP*s */
static UWord stats__ga_LockN_to_P_queries = 0;
static WordFM* yaWFM = NULL;
-static Word lock_unique_cmp ( Word lk1W, Word lk2W )
+static Word lock_unique_cmp ( UWord lk1W, UWord lk2W )
{
Lock* lk1 = (Lock*)lk1W;
Lock* lk2 = (Lock*)lk2W;
@@ -8084,8 +8084,8 @@
static XArray* /* of Thread* */ get_sorted_thread_set ( WordSetID tset )
{
XArray* xa;
- Word* ts_words;
- Word ts_size, i;
+ UWord* ts_words;
+ UWord ts_size, i;
xa = VG_(newXA)( hg_zalloc, hg_free, sizeof(Thread*) );
tl_assert(xa);
HG_(getPayloadWS)( &ts_words, &ts_size, univ_tsets, tset );