|
From: <sv...@va...> - 2008-09-21 09:31:30
|
Author: sewardj
Date: 2008-09-21 10:31:15 +0100 (Sun, 21 Sep 2008)
New Revision: 8629
Log:
libhb_core.c: call HG_(malloc), HG_(free) and shmem__bigchunk_alloc
directly, instead of via function pointers supplied at startup. Tidy
up accordingly.
Modified:
branches/YARD/helgrind/hg_basics.c
branches/YARD/helgrind/hg_basics.h
branches/YARD/helgrind/hg_main.c
branches/YARD/helgrind/libhb.h
branches/YARD/helgrind/libhb_core.c
branches/YARD/include/pub_tool_libcbase.h
Modified: branches/YARD/helgrind/hg_basics.c
===================================================================
--- branches/YARD/helgrind/hg_basics.c 2008-09-21 00:58:00 UTC (rev 8628)
+++ branches/YARD/helgrind/hg_basics.c 2008-09-21 09:31:15 UTC (rev 8629)
@@ -29,7 +29,31 @@
The GNU General Public License is contained in the file COPYING.
*/
+#include "pub_tool_basics.h"
+#include "pub_tool_libcbase.h"
+#include "pub_tool_libcassert.h"
+#include "pub_tool_mallocfree.h"
+#include "hg_basics.h" /* self */
+
+
+void* HG_(zalloc) ( HChar* cc, SizeT n )
+{
+ void* p;
+ tl_assert(n > 0);
+ p = VG_(malloc)( cc, n );
+ tl_assert(p);
+ VG_(memset)(p, 0, n);
+ return p;
+}
+
+void HG_(free) ( void* p )
+{
+ tl_assert(p);
+ VG_(free)(p);
+}
+
+
/*--------------------------------------------------------------------*/
/*--- end hg_basics.c ---*/
/*--------------------------------------------------------------------*/
Modified: branches/YARD/helgrind/hg_basics.h
===================================================================
--- branches/YARD/helgrind/hg_basics.h 2008-09-21 00:58:00 UTC (rev 8628)
+++ branches/YARD/helgrind/hg_basics.h 2008-09-21 09:31:15 UTC (rev 8629)
@@ -32,8 +32,13 @@
#ifndef __HG_BASICS_H
#define __HG_BASICS_H
+
#define HG_(str) VGAPPEND(vgHelgrind_,str)
+void* HG_(zalloc) ( HChar* cc, SizeT n );
+void HG_(free) ( void* p );
+
+
#endif /* ! __HG_BASICS_H */
/*--------------------------------------------------------------------*/
Modified: branches/YARD/helgrind/hg_main.c
===================================================================
--- branches/YARD/helgrind/hg_main.c 2008-09-21 00:58:00 UTC (rev 8628)
+++ branches/YARD/helgrind/hg_main.c 2008-09-21 09:31:15 UTC (rev 8629)
@@ -35,7 +35,6 @@
*/
#include "pub_tool_basics.h"
-#include "pub_tool_aspacemgr.h"
#include "pub_tool_libcassert.h"
#include "pub_tool_libcbase.h"
#include "pub_tool_libcprint.h"
@@ -195,29 +194,6 @@
*/
/*----------------------------------------------------------------*/
-/*--- Some very basic stuff ---*/
-/*----------------------------------------------------------------*/
-
-static void* hg_zalloc ( HChar* cc, SizeT n ) {
- void* p;
- tl_assert(n > 0);
- p = VG_(malloc)( cc, n );
- tl_assert(p);
- VG_(memset)(p, 0, n);
- return p;
-}
-static void hg_free ( void* p ) {
- tl_assert(p);
- VG_(free)(p);
-}
-
-/* Round a up to the next multiple of N. N must be a power of 2 */
-#define ROUNDUP(a, N) ((a + N - 1) & ~(N-1))
-/* Round a down to the next multiple of N. N must be a power of 2 */
-#define ROUNDDN(a, N) ((a) & ~(N-1))
-
-
-/*----------------------------------------------------------------*/
/*--- Primary data definitions ---*/
/*----------------------------------------------------------------*/
@@ -357,7 +333,7 @@
static Thread* mk_Thread ( Thr* hbthr ) {
static Int indx = 1;
- Thread* thread = hg_zalloc( "hg.mk_Thread.1", sizeof(Thread) );
+ Thread* thread = HG_(zalloc)( "hg.mk_Thread.1", sizeof(Thread) );
thread->locksetA = HG_(emptyWS)( univ_lsets );
thread->locksetW = HG_(emptyWS)( univ_lsets );
thread->magic = Thread_MAGIC;
@@ -373,7 +349,7 @@
// Make a new lock which is unlocked (hence ownerless)
static Lock* mk_LockN ( LockKind kind, Addr guestaddr ) {
static ULong unique = 0;
- Lock* lock = hg_zalloc( "hg.mk_Lock.1", sizeof(Lock) );
+ Lock* lock = HG_(zalloc)( "hg.mk_Lock.1", sizeof(Lock) );
lock->admin = admin_locks;
lock->unique = unique++;
lock->magic = LockN_MAGIC;
@@ -467,7 +443,7 @@
if (lk->heldBy)
VG_(deleteBag)( lk->heldBy );
VG_(memset)(lk, 0xAA, sizeof(*lk));
- hg_free(lk);
+ HG_(free)(lk);
}
/* Update 'lk' to reflect that 'thr' now has a write-acquisition of
@@ -500,7 +476,7 @@
tl_assert(lk->heldBy == NULL); /* can't w-lock recursively */
tl_assert(!lk->heldW);
lk->heldW = True;
- lk->heldBy = VG_(newBag)( hg_zalloc, "hg.lNaw.1", hg_free );
+ lk->heldBy = VG_(newBag)( HG_(zalloc), "hg.lNaw.1", HG_(free) );
VG_(addToBag)( lk->heldBy, (Word)thr );
break;
case LK_mbRec:
@@ -554,7 +530,7 @@
VG_(addToBag)(lk->heldBy, (Word)thr);
} else {
lk->heldW = False;
- lk->heldBy = VG_(newBag)( hg_zalloc, "hg.lNar.1", hg_free );
+ lk->heldBy = VG_(newBag)( HG_(zalloc), "hg.lNar.1", HG_(free) );
VG_(addToBag)( lk->heldBy, (Word)thr );
}
tl_assert(!lk->heldW);
@@ -801,12 +777,12 @@
tl_assert(sizeof(Addr) == sizeof(Word));
tl_assert(map_threads == NULL);
- map_threads = hg_zalloc( "hg.ids.1", VG_N_THREADS * sizeof(Thread*) );
+ map_threads = HG_(zalloc)( "hg.ids.1", VG_N_THREADS * sizeof(Thread*) );
tl_assert(map_threads != NULL);
tl_assert(sizeof(Addr) == sizeof(Word));
tl_assert(map_locks == NULL);
- map_locks = VG_(newFM)( hg_zalloc, "hg.ids.2", hg_free,
+ map_locks = VG_(newFM)( HG_(zalloc), "hg.ids.2", HG_(free),
NULL/*unboxed Word cmp*/);
tl_assert(map_locks != NULL);
@@ -815,18 +791,18 @@
VG_(addToFM)( map_locks, (Word)&__bus_lock, (Word)__bus_lock_Lock );
tl_assert(univ_tsets == NULL);
- univ_tsets = HG_(newWordSetU)( hg_zalloc, "hg.ids.3", hg_free,
+ univ_tsets = HG_(newWordSetU)( HG_(zalloc), "hg.ids.3", HG_(free),
8/*cacheSize*/ );
tl_assert(univ_tsets != NULL);
tl_assert(univ_lsets == NULL);
- univ_lsets = HG_(newWordSetU)( hg_zalloc, "hg.ids.4", hg_free,
+ univ_lsets = HG_(newWordSetU)( HG_(zalloc), "hg.ids.4", HG_(free),
8/*cacheSize*/ );
tl_assert(univ_lsets != NULL);
tl_assert(univ_laog == NULL);
- univ_laog = HG_(newWordSetU)( hg_zalloc, "hg.ids.5 (univ_laog)",
- hg_free, 24/*cacheSize*/ );
+ univ_laog = HG_(newWordSetU)( HG_(zalloc), "hg.ids.5 (univ_laog)",
+ HG_(free), 24/*cacheSize*/ );
tl_assert(univ_laog != NULL);
/* Set up entries for the root thread */
@@ -969,39 +945,6 @@
/*----------------------------------------------------------------*/
-/*--- map_shmem :: WordFM Addr SecMap ---*/
-/*--- shadow memory (low level handlers) (shmem__* fns) ---*/
-/*----------------------------------------------------------------*/
-
-/*--------------- SecMap allocation --------------- */
-
-static HChar* shmem__bigchunk_next = NULL;
-static HChar* shmem__bigchunk_end1 = NULL;
-
-static void* shmem__bigchunk_alloc ( SizeT n )
-{
- const SizeT sHMEM__BIGCHUNK_SIZE = 4096 * 256 * 4;
- tl_assert(n > 0);
- n = ROUNDUP(n, 16);
- tl_assert(shmem__bigchunk_next <= shmem__bigchunk_end1);
- tl_assert(shmem__bigchunk_end1 - shmem__bigchunk_next
- <= (SSizeT)sHMEM__BIGCHUNK_SIZE);
- if (shmem__bigchunk_next + n > shmem__bigchunk_end1) {
- if (0)
- VG_(printf)("XXXXX bigchunk: abandoning %d bytes\n",
- (Int)(shmem__bigchunk_end1 - shmem__bigchunk_next));
- shmem__bigchunk_next = VG_(am_shadow_alloc)( sHMEM__BIGCHUNK_SIZE );
- shmem__bigchunk_end1 = shmem__bigchunk_next + sHMEM__BIGCHUNK_SIZE;
- }
- tl_assert(shmem__bigchunk_next);
- tl_assert( 0 == (((Addr)shmem__bigchunk_next) & (16-1)) );
- tl_assert(shmem__bigchunk_next + n <= shmem__bigchunk_end1);
- shmem__bigchunk_next += n;
- return shmem__bigchunk_next - n;
-}
-
-
-/*----------------------------------------------------------------*/
/*--- Sanity checking the data structures ---*/
/*----------------------------------------------------------------*/
@@ -1326,7 +1269,7 @@
HG_(cardinalityWS)( univ_lsets, lset_old), lk );
if (lk->appeared_at) {
if (ga_to_lastlock == NULL)
- ga_to_lastlock = VG_(newFM)( hg_zalloc, "hg.rlll.1", hg_free, NULL );
+ ga_to_lastlock = VG_(newFM)( HG_(zalloc), "hg.rlll.1", HG_(free), NULL );
VG_(addToFM)( ga_to_lastlock, ga_of_access, (Word)lk->appeared_at );
stats__ga_LL_adds++;
}
@@ -2343,7 +2286,7 @@
static void map_cond_to_SO_INIT ( void ) {
if (UNLIKELY(map_cond_to_SO == NULL)) {
- map_cond_to_SO = VG_(newFM)( hg_zalloc, "hg.mctSI.1", hg_free, NULL );
+ map_cond_to_SO = VG_(newFM)( HG_(zalloc), "hg.mctSI.1", HG_(free), NULL );
tl_assert(map_cond_to_SO != NULL);
}
}
@@ -2676,8 +2619,8 @@
static void map_sem_to_SO_stack_INIT ( void ) {
if (map_sem_to_SO_stack == NULL) {
- map_sem_to_SO_stack = VG_(newFM)( hg_zalloc, "hg.mstSs.1",
- hg_free, NULL );
+ map_sem_to_SO_stack = VG_(newFM)( HG_(zalloc), "hg.mstSs.1",
+ HG_(free), NULL );
tl_assert(map_sem_to_SO_stack != NULL);
}
}
@@ -2693,7 +2636,7 @@
tl_assert(xa);
VG_(addToXA)( xa, &so );
} else {
- xa = VG_(newXA)( hg_zalloc, "hg.pSfs.1", hg_free, sizeof(SO*) );
+ xa = VG_(newXA)( HG_(zalloc), "hg.pSfs.1", HG_(free), sizeof(SO*) );
VG_(addToXA)( xa, &so );
VG_(addToFM)( map_sem_to_SO_stack, (Word)sem, (Word)xa );
}
@@ -2983,7 +2926,7 @@
presentF = outs_new == links->outs;
links->outs = outs_new;
} else {
- links = hg_zalloc("hg.lae.1", sizeof(LAOGLinks));
+ links = HG_(zalloc)("hg.lae.1", sizeof(LAOGLinks));
links->inns = HG_(emptyWS)( univ_laog );
links->outs = HG_(singletonWS)( univ_laog, (Word)dst );
VG_(addToFM)( laog, (Word)src, (Word)links );
@@ -2999,7 +2942,7 @@
presentR = inns_new == links->inns;
links->inns = inns_new;
} else {
- links = hg_zalloc("hg.lae.2", sizeof(LAOGLinks));
+ links = HG_(zalloc)("hg.lae.2", sizeof(LAOGLinks));
links->inns = HG_(singletonWS)( univ_laog, (Word)src );
links->outs = HG_(emptyWS)( univ_laog );
VG_(addToFM)( laog, (Word)dst, (Word)links );
@@ -3024,7 +2967,7 @@
if (VG_(lookupFM)( laog_exposition, NULL, NULL, (Word)&expo )) {
/* we already have it; do nothing */
} else {
- LAOGLinkExposition* expo2 = hg_zalloc("hg.lae.3",
+ LAOGLinkExposition* expo2 = HG_(zalloc)("hg.lae.3",
sizeof(LAOGLinkExposition));
expo2->src_ga = src->guestaddr;
expo2->dst_ga = dst->guestaddr;
@@ -3154,8 +3097,8 @@
return NULL;
ret = NULL;
- stack = VG_(newXA)( hg_zalloc, "hg.lddft.1", hg_free, sizeof(Lock*) );
- visited = VG_(newFM)( hg_zalloc, "hg.lddft.2", hg_free, NULL/*unboxedcmp*/ );
+ stack = VG_(newXA)( HG_(zalloc), "hg.lddft.1", HG_(free), sizeof(Lock*) );
+ visited = VG_(newFM)( HG_(zalloc), "hg.lddft.2", HG_(free), NULL/*unboxedcmp*/ );
(void) VG_(addToXA)( stack, &src );
@@ -3208,10 +3151,10 @@
return;
if (!laog)
- laog = VG_(newFM)( hg_zalloc, "hg.lptal.1",
- hg_free, NULL/*unboxedcmp*/ );
+ laog = VG_(newFM)( HG_(zalloc), "hg.lptal.1",
+ HG_(free), NULL/*unboxedcmp*/ );
if (!laog_exposition)
- laog_exposition = VG_(newFM)( hg_zalloc, "hg.lptal.2", hg_free,
+ laog_exposition = VG_(newFM)( HG_(zalloc), "hg.lptal.2", HG_(free),
cmp_LAOGLinkExposition );
/* First, the check. Complain if there is any path in laog from lk
@@ -3317,9 +3260,9 @@
UWord* ws_words;
if (!laog)
- laog = VG_(newFM)( hg_zalloc, "hg.lhld.1", hg_free, NULL/*unboxedcmp*/ );
+ laog = VG_(newFM)( HG_(zalloc), "hg.lhld.1", HG_(free), NULL/*unboxedcmp*/ );
if (!laog_exposition)
- laog_exposition = VG_(newFM)( hg_zalloc, "hg.lhld.2", hg_free,
+ laog_exposition = VG_(newFM)( HG_(zalloc), "hg.lhld.2", HG_(free),
cmp_LAOGLinkExposition );
HG_(getPayloadWS)( &ws_words, &ws_size, univ_lsets, locksToDelete );
@@ -3351,12 +3294,12 @@
static MallocMeta* new_MallocMeta ( void ) {
- MallocMeta* md = hg_zalloc( "hg.new_MallocMeta.1", sizeof(MallocMeta) );
+ MallocMeta* md = HG_(zalloc)( "hg.new_MallocMeta.1", sizeof(MallocMeta) );
tl_assert(md);
return md;
}
static void delete_MallocMeta ( MallocMeta* md ) {
- hg_free(md);
+ HG_(free)(md);
}
@@ -3813,8 +3756,8 @@
static void map_pthread_t_to_Thread_INIT ( void ) {
if (UNLIKELY(map_pthread_t_to_Thread == NULL)) {
- map_pthread_t_to_Thread = VG_(newFM)( hg_zalloc, "hg.mpttT.1",
- hg_free, NULL );
+ map_pthread_t_to_Thread = VG_(newFM)( HG_(zalloc), "hg.mpttT.1",
+ HG_(free), NULL );
tl_assert(map_pthread_t_to_Thread != NULL);
}
}
@@ -4059,8 +4002,8 @@
if (!str)
str = "(null)";
if (!string_table) {
- string_table = VG_(newFM)( hg_zalloc, "hg.sts.1",
- hg_free, string_table_cmp );
+ string_table = VG_(newFM)( HG_(zalloc), "hg.sts.1",
+ HG_(free), string_table_cmp );
tl_assert(string_table);
}
if (VG_(lookupFM)( string_table,
@@ -4095,11 +4038,11 @@
stats__ga_LockN_to_P_queries++;
tl_assert( is_sane_LockN(lkn) );
if (!yaWFM) {
- yaWFM = VG_(newFM)( hg_zalloc, "hg.mLPfLN.1", hg_free, lock_unique_cmp );
+ yaWFM = VG_(newFM)( HG_(zalloc), "hg.mLPfLN.1", HG_(free), lock_unique_cmp );
tl_assert(yaWFM);
}
if (!VG_(lookupFM)( yaWFM, NULL, (Word*)&lkp, (Word)lkn)) {
- lkp = hg_zalloc( "hg.mLPfLN.2", sizeof(Lock) );
+ lkp = HG_(zalloc)( "hg.mLPfLN.2", sizeof(Lock) );
*lkp = *lkn;
lkp->admin = NULL;
lkp->magic = LockP_MAGIC;
@@ -4454,7 +4397,7 @@
errmsg_index fields. This is for printing out thread sets in
repeatable orders, which is important for for repeatable regression
testing. The returned XArray* is dynamically allocated (of course)
- and so must be hg_freed by the caller. */
+ and so must be HG_(free)d by the caller. */
static Int cmp_Thread_by_errmsg_index ( void* thr1V, void* thr2V ) {
Thread* thr1 = *(Thread**)thr1V;
Thread* thr2 = *(Thread**)thr2V;
@@ -4467,7 +4410,7 @@
XArray* xa;
UWord* ts_words;
UWord ts_size, i;
- xa = VG_(newXA)( hg_zalloc, "hg.cTbei.1", hg_free, sizeof(Thread*) );
+ xa = VG_(newXA)( HG_(zalloc), "hg.cTbei.1", HG_(free), sizeof(Thread*) );
tl_assert(xa);
HG_(getPayloadWS)( &ts_words, &ts_size, univ_tsets, tset );
tl_assert(ts_words);
@@ -5083,8 +5026,7 @@
VG_(track_stop_client_code)( evh__stop_client_code );
/////////////////////////////////////////////
- hbthr_root = libhb_init( hg_zalloc, hg_free, shmem__bigchunk_alloc,
- for_libhb__get_stacktrace,
+ hbthr_root = libhb_init( for_libhb__get_stacktrace,
for_libhb__stacktrace_to_EC,
for_libhb__get_EC );
/////////////////////////////////////////////
Modified: branches/YARD/helgrind/libhb.h
===================================================================
--- branches/YARD/helgrind/libhb.h 2008-09-21 00:58:00 UTC (rev 8628)
+++ branches/YARD/helgrind/libhb.h 2008-09-21 09:31:15 UTC (rev 8629)
@@ -48,13 +48,10 @@
Thr* thrp; struct EC_* wherep; }
RaceInfo;
-/* Initialise library; returns Thr* for root thread. 'alloc' and
- 'shadow_alloc' should never return NULL, instead they should simply
- not return if they encounter an out-of-memory condition. */
+/* Initialise library; returns Thr* for root thread. 'shadow_alloc'
+ should never return NULL, instead it should simply not return if
+ they encounter an out-of-memory condition. */
Thr* libhb_init (
- void* (*zalloc)( HChar*, SizeT ),
- void (*dealloc)( void* ),
- void* (*shadow_alloc)( SizeT ),
void (*get_stacktrace)( Thr*, Addr*, UWord ),
struct EC_* (*stacktrace_to_EC)( Addr*, UWord ),
struct EC_* (*get_EC)( Thr* )
Modified: branches/YARD/helgrind/libhb_core.c
===================================================================
--- branches/YARD/helgrind/libhb_core.c 2008-09-21 00:58:00 UTC (rev 8628)
+++ branches/YARD/helgrind/libhb_core.c 2008-09-21 09:31:15 UTC (rev 8629)
@@ -40,6 +40,7 @@
#include "pub_tool_wordfm.h"
#include "pub_tool_xarray.h"
#include "pub_tool_oset.h"
+#include "pub_tool_aspacemgr.h"
#include "hg_basics.h"
#include "libhb.h"
@@ -48,9 +49,6 @@
/* fwds for
Globals needed by other parts of the library. These are set
once at startup and then never changed. */
-static void* (*main_zalloc)( HChar*, SizeT ) = NULL;
-static void (*main_dealloc)( void* ) = NULL;
-static void* (*main_shadow_alloc)( SizeT ) = NULL;
static void (*main_get_stacktrace)( Thr*, Addr*, UWord ) = NULL;
static struct EC_* (*main_stacktrace_to_EC)( Addr*, UWord ) = NULL;
static struct EC_* (*main_get_EC)( Thr* ) = NULL;
@@ -335,12 +333,42 @@
}
+/*----------------------------------------------------------------*/
+/*--- map_shmem :: WordFM Addr SecMap ---*/
+/*--- shadow memory (low level handlers) (shmem__* fns) ---*/
+/*----------------------------------------------------------------*/
+
/*--------------- SecMap allocation --------------- */
+static HChar* shmem__bigchunk_next = NULL;
+static HChar* shmem__bigchunk_end1 = NULL;
+
+static void* shmem__bigchunk_alloc ( SizeT n )
+{
+ const SizeT sHMEM__BIGCHUNK_SIZE = 4096 * 256 * 4;
+ tl_assert(n > 0);
+ n = VG_ROUNDUP(n, 16);
+ tl_assert(shmem__bigchunk_next <= shmem__bigchunk_end1);
+ tl_assert(shmem__bigchunk_end1 - shmem__bigchunk_next
+ <= (SSizeT)sHMEM__BIGCHUNK_SIZE);
+ if (shmem__bigchunk_next + n > shmem__bigchunk_end1) {
+ if (0)
+ VG_(printf)("XXXXX bigchunk: abandoning %d bytes\n",
+ (Int)(shmem__bigchunk_end1 - shmem__bigchunk_next));
+ shmem__bigchunk_next = VG_(am_shadow_alloc)( sHMEM__BIGCHUNK_SIZE );
+ shmem__bigchunk_end1 = shmem__bigchunk_next + sHMEM__BIGCHUNK_SIZE;
+ }
+ tl_assert(shmem__bigchunk_next);
+ tl_assert( 0 == (((Addr)shmem__bigchunk_next) & (16-1)) );
+ tl_assert(shmem__bigchunk_next + n <= shmem__bigchunk_end1);
+ shmem__bigchunk_next += n;
+ return shmem__bigchunk_next - n;
+}
+
static SecMap* shmem__alloc_SecMap ( void )
{
Word i, j;
- SecMap* sm = main_shadow_alloc( sizeof(SecMap) );
+ SecMap* sm = shmem__bigchunk_alloc( sizeof(SecMap) );
if (0) VG_(printf)("alloc_SecMap %p\n",sm);
tl_assert(sm);
sm->magic = SecMap_MAGIC;
@@ -560,7 +588,7 @@
/* No free F line found. Expand existing array and try again. */
new_size = sm->linesF_size==0 ? 1 : 2 * sm->linesF_size;
- nyu = main_zalloc( "libhb.aFfw.1 (LineF storage)",
+ nyu = HG_(zalloc)( "libhb.aFfw.1 (LineF storage)",
new_size * sizeof(LineF) );
tl_assert(nyu);
@@ -581,7 +609,7 @@
nyu[i] = sm->linesF[i];
}
VG_(memset)(sm->linesF, 0, sm->linesF_size * sizeof(LineF) );
- main_dealloc(sm->linesF);
+ HG_(free)(sm->linesF);
}
sm->linesF = nyu;
@@ -2023,8 +2051,8 @@
rcdec = p_rcdec;
tl_assert(map_shmem == NULL);
- map_shmem = VG_(newFM)( main_zalloc, "libhb.zsm_init.1 (map_shmem)",
- main_dealloc,
+ map_shmem = VG_(newFM)( HG_(zalloc), "libhb.zsm_init.1 (map_shmem)",
+ HG_(free),
NULL/*unboxed UWord cmp*/);
tl_assert(map_shmem != NULL);
shmem__invalidate_scache();
@@ -2148,11 +2176,11 @@
VTS* VTS__new ( void )
{
VTS* vts;
- vts = main_zalloc( "libhb.VTS__new.1", sizeof(VTS) );
+ vts = HG_(zalloc)( "libhb.VTS__new.1", sizeof(VTS) );
tl_assert(vts);
vts->id = VtsID_INVALID;
- vts->ts = VG_(newXA)( main_zalloc, "libhb.VTS__new.2",
- main_dealloc, sizeof(ScalarTS) );
+ vts->ts = VG_(newXA)( HG_(zalloc), "libhb.VTS__new.2",
+ HG_(free), sizeof(ScalarTS) );
tl_assert(vts->ts);
return vts;
}
@@ -2165,7 +2193,7 @@
tl_assert(vts);
tl_assert(vts->ts);
VG_(deleteXA)( vts->ts );
- main_dealloc(vts);
+ HG_(free)(vts);
}
@@ -2564,8 +2592,8 @@
static void vts_set_init ( void )
{
tl_assert(!vts_set);
- vts_set = VG_(newFM)( main_zalloc, "libhb.vts_set_init.1",
- main_dealloc,
+ vts_set = VG_(newFM)( HG_(zalloc), "libhb.vts_set_init.1",
+ HG_(free),
(Word(*)(UWord,UWord))VTS__cmp_structural );
tl_assert(vts_set);
}
@@ -2639,8 +2667,8 @@
static void vts_tab_init ( void )
{
vts_tab
- = VG_(newXA)( main_zalloc, "libhb.vts_tab_init.1",
- main_dealloc, sizeof(VtsTE) );
+ = VG_(newXA)( HG_(zalloc), "libhb.vts_tab_init.1",
+ HG_(free), sizeof(VtsTE) );
vts_tab_freelist
= VtsID_INVALID;
tl_assert(vts_tab);
@@ -3020,7 +3048,7 @@
};
static Thr* Thr__new ( void ) {
- Thr* thr = main_zalloc( "libhb.Thr__new.1", sizeof(Thr) );
+ Thr* thr = HG_(zalloc)( "libhb.Thr__new.1", sizeof(Thr) );
thr->viR = VtsID_INVALID;
thr->viW = VtsID_INVALID;
return thr;
@@ -3406,8 +3434,8 @@
contextTree = VG_(OSetGen_Create)(
0,
(Word(*)(const void *, const void*))RCEC__cmp_by_frames,
- main_zalloc, "libhb.event_map_init.1 (context tree)",
- main_dealloc
+ HG_(zalloc), "libhb.event_map_init.1 (context tree)",
+ HG_(free)
);
tl_assert(contextTree);
@@ -3415,8 +3443,8 @@
oldrefTree = VG_(OSetGen_Create)(
0,
(Word(*)(const void *, const void*))OldRef__cmp_by_EA,
- main_zalloc, "libhb.event_map_init.2 (oldref tree)",
- main_dealloc
+ HG_(zalloc), "libhb.event_map_init.2 (oldref tree)",
+ HG_(free)
);
tl_assert(oldrefTree);
@@ -3481,8 +3509,8 @@
/* Compute the distribution of generation values in the ref tree */
/* genMap :: generation-number -> count-of-nodes-with-that-number */
- genMap = VG_(newFM)( main_zalloc, "libhb.emmG.1",
- main_dealloc, NULL );
+ genMap = VG_(newFM)( HG_(zalloc), "libhb.emmG.1",
+ HG_(free), NULL );
VG_(OSetGen_ResetIter)( oldrefTree );
while ( (oldref = VG_(OSetGen_Next)( oldrefTree )) ) {
@@ -3532,8 +3560,8 @@
delete. We can't simultaneously traverse the tree and delete
stuff from it, so first we need to copy them off somewhere
else. (sigh) */
- refs2del = VG_(newXA)( main_zalloc, "libhb.emmG.1",
- main_dealloc, sizeof(OldRef*) );
+ refs2del = VG_(newXA)( HG_(zalloc), "libhb.emmG.1",
+ HG_(free), sizeof(OldRef*) );
VG_(OSetGen_ResetIter)( oldrefTree );
while ( (oldref = VG_(OSetGen_Next)( oldrefTree )) ) {
@@ -3788,7 +3816,7 @@
};
static SO* SO__Alloc ( void ) {
- SO* so = main_zalloc( "libhb.SO__Alloc.1", sizeof(SO) );
+ SO* so = HG_(zalloc)( "libhb.SO__Alloc.1", sizeof(SO) );
so->viR = VtsID_INVALID;
so->viW = VtsID_INVALID;
so->magic = SO_MAGIC;
@@ -3805,7 +3833,7 @@
VtsID__rcdec(so->viW);
}
so->magic = 0;
- main_dealloc( so );
+ HG_(free)( so );
}
@@ -3833,9 +3861,6 @@
Thr* libhb_init (
- void* (*zalloc)( HChar*, SizeT ),
- void (*dealloc)( void* ),
- void* (*shadow_alloc)( SizeT ),
void (*get_stacktrace)( Thr*, Addr*, UWord ),
struct EC_* (*stacktrace_to_EC)( Addr*, UWord ),
struct EC_* (*get_EC)( Thr* )
@@ -3843,15 +3868,9 @@
{
Thr* thr;
VtsID vi;
- tl_assert(zalloc);
- tl_assert(dealloc);
- tl_assert(shadow_alloc);
tl_assert(get_stacktrace);
tl_assert(stacktrace_to_EC);
tl_assert(get_EC);
- main_zalloc = zalloc;
- main_dealloc = dealloc;
- main_shadow_alloc = shadow_alloc;
main_get_stacktrace = get_stacktrace;
main_stacktrace_to_EC = stacktrace_to_EC;
main_get_EC = get_EC;
Modified: branches/YARD/include/pub_tool_libcbase.h
===================================================================
--- branches/YARD/include/pub_tool_libcbase.h 2008-09-21 00:58:00 UTC (rev 8628)
+++ branches/YARD/include/pub_tool_libcbase.h 2008-09-21 09:31:15 UTC (rev 8629)
@@ -72,8 +72,9 @@
------------------------------------------------------------------ */
/* Use this for normal null-termination-style string comparison */
-#define VG_STREQ(s1,s2) ( (s1 != NULL && s2 != NULL \
- && VG_(strcmp)((s1),(s2))==0) ? True : False )
+#define VG_STREQ(_s1,_s2) \
+ ( ((_s1) != NULL && (_s2) != NULL \
+ && VG_(strcmp)((_s1),(_s2))==0) ? True : False )
extern Int VG_(strlen) ( const Char* str );
extern Char* VG_(strcat) ( Char* dest, const Char* src );
@@ -122,10 +123,10 @@
// 'a' -- the alignment -- must be a power of 2.
// The latter two require the vki-*.h header to be imported also.
-#define VG_ROUNDDN(p, a) ((Addr)(p) & ~((Addr)(a)-1))
-#define VG_ROUNDUP(p, a) VG_ROUNDDN((p)+(a)-1, (a))
-#define VG_PGROUNDDN(p) VG_ROUNDDN(p, VKI_PAGE_SIZE)
-#define VG_PGROUNDUP(p) VG_ROUNDUP(p, VKI_PAGE_SIZE)
+#define VG_ROUNDDN(_p, _a) ((Addr)(_p) & ~((Addr)(_a)-1))
+#define VG_ROUNDUP(_p, _a) VG_ROUNDDN((_p)+(_a)-1, (_a))
+#define VG_PGROUNDDN(_p) VG_ROUNDDN((_p), VKI_PAGE_SIZE)
+#define VG_PGROUNDUP(_p) VG_ROUNDUP((_p), VKI_PAGE_SIZE)
/* ---------------------------------------------------------------------
Misc useful functions
|