From: Julian Seward Date: Sun, 9 Nov 2008 23:31:19 +0000 (+0000) Subject: Move the conflicting accesses in each thread earlier, so that pure h-b X-Git-Tag: svn/VALGRIND_3_4_0~143 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb5e457e3e4b396a9d77da155dbb1612121a98cb;p=thirdparty%2Fvalgrind.git Move the conflicting accesses in each thread earlier, so that pure h-b is not fooled by the locking on non-conflicted parts of the arrays. (Not really sure what's going on here, but DRD and Helgrind behave identically, so I'm not too concerned.) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8751 --- diff --git a/helgrind/tests/tc19_shadowmem.c b/helgrind/tests/tc19_shadowmem.c index a56cec3bbf..ec05061f85 100644 --- a/helgrind/tests/tc19_shadowmem.c +++ b/helgrind/tests/tc19_shadowmem.c @@ -29,14 +29,14 @@ void* child8 ( void* infoV ) arr = info->arr; assert( sizeof(char) == 1 ); assert( info->child == &child8 ); + { char* ptr = (char*)&arr[skipoff]; + *ptr = 0; } for (i = firstoff; i <= lastoff; i += 1) { char* ptr = (char*)&arr[i]; - if (i == skipoff) { - *ptr = 0; - } else { - r= pthread_mutex_lock( &mx ); assert(!r); - *ptr = 0; - r= pthread_mutex_unlock( &mx ); assert(!r); + if (i != skipoff) { + r= pthread_mutex_lock( &mx ); assert(!r); + *ptr = 0; + r= pthread_mutex_unlock( &mx ); assert(!r); } } return NULL; @@ -53,14 +53,14 @@ void* child16 ( void* infoV ) arr = info->arr; assert( sizeof(short) == 2 ); assert( info->child == &child16 ); + { short* ptr = (short*)&arr[skipoff]; + *ptr = 0; } for (i = firstoff; i <= lastoff; i += 2) { short* ptr = (short*)&arr[i]; - if (i == skipoff) { - *ptr = 0; - } else { - r= pthread_mutex_lock( &mx ); assert(!r); - *ptr = 0; - r= pthread_mutex_unlock( &mx ); assert(!r); + if (i != skipoff) { + r= pthread_mutex_lock( &mx ); assert(!r); + *ptr = 0; + r= pthread_mutex_unlock( &mx ); assert(!r); } } return NULL; @@ -77,14 +77,14 @@ void* child32 ( void* infoV ) arr = info->arr; assert( sizeof(int) == 4 ); assert( info->child == &child32 ); + { int* ptr = (int*)&arr[skipoff]; + *ptr = 0; } for (i = firstoff; i <= lastoff; i += 4) { int* ptr = (int*)&arr[i]; - if (i == skipoff) { - *ptr = 0; - } else { - r= pthread_mutex_lock( &mx ); assert(!r); - *ptr = 0; - r= pthread_mutex_unlock( &mx ); assert(!r); + if (i != skipoff) { + r= pthread_mutex_lock( &mx ); assert(!r); + *ptr = 0; + r= pthread_mutex_unlock( &mx ); assert(!r); } } return NULL; @@ -101,14 +101,14 @@ void* child64 ( void* infoV ) arr = info->arr; assert( sizeof(double) == 8 ); assert( info->child == &child64 ); + { double* ptr = (double*)&arr[skipoff]; + *ptr = 0.0; } for (i = firstoff; i <= lastoff; i += 8) { double* ptr = (double*)&arr[i]; - if (i == skipoff) { - *ptr = 0; - } else { - r= pthread_mutex_lock( &mx ); assert(!r); - *ptr = 0; - r= pthread_mutex_unlock( &mx ); assert(!r); + if (i != skipoff) { + r= pthread_mutex_lock( &mx ); assert(!r); + *ptr = 0.0; + r= pthread_mutex_unlock( &mx ); assert(!r); } } return NULL;