diff options
Diffstat (limited to 'helgrind/tests/tc20_verifywrap.c')
-rw-r--r-- | helgrind/tests/tc20_verifywrap.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/helgrind/tests/tc20_verifywrap.c b/helgrind/tests/tc20_verifywrap.c index 8718d0bba..f71c7f8d4 100644 --- a/helgrind/tests/tc20_verifywrap.c +++ b/helgrind/tests/tc20_verifywrap.c @@ -15,14 +15,19 @@ #include <string.h> #include <assert.h> #include <unistd.h> -#include <pthread.h> -#include <semaphore.h> +#include "safe-pthread.h" +#include "safe-semaphore.h" #if !defined(__APPLE__) +#if defined(__sun__) +/* Fake __GLIBC_PREREQ on Solaris. Pretend glibc >= 2.4. */ +# define __GLIBC_PREREQ +#else #if !defined(__GLIBC_PREREQ) # error "This program needs __GLIBC_PREREQ (in /usr/include/features.h)" #endif +#endif /* __sun__ */ short unprotected = 0; @@ -88,7 +93,12 @@ int main ( void ) "\n---------------- pthread_mutex_lock et al ----------------\n\n"); /* make pthread_mutex_init fail */ +#if defined(__sun__) + pthread_mutexattr_init( &mxa ); + memset( mxa.__pthread_mutexattrp, 0xFF, 5 * sizeof(int) ); +#else memset( &mxa, 0xFF, sizeof(mxa) ); +#endif r= pthread_mutex_init( &mx, &mxa ); # if __GLIBC_PREREQ(2,4) assert(r); /* glibc >= 2.4: the call should fail */ @@ -193,7 +203,12 @@ int main ( void ) r= pthread_rwlock_unlock( &rwl2 ); assert(!r); /* unlock it again, get an error */ fprintf(stderr, "(3) ERROR on next line\n"); - r= pthread_rwlock_unlock( &rwl2 ); assert(!r); + r= pthread_rwlock_unlock( &rwl2 ); +#if defined(__sun__) + assert(r); +#else + assert(!r); +#endif /* same game with r-locks */ r= pthread_rwlock_init( &rwl2, NULL ); assert(!r); @@ -209,7 +224,12 @@ int main ( void ) r= pthread_rwlock_unlock( &rwl2 ); assert(!r); /* unlock it again, get an error */ fprintf(stderr, "(8) ERROR on next line\n"); - r= pthread_rwlock_unlock( &rwl2 ); assert(!r); + r= pthread_rwlock_unlock( &rwl2 ); +#if defined(__sun__) + assert(r); +#else + assert(!r); +#endif /* Lock rwl3 so the locked-lock-at-dealloc check can complain about it. */ |