Add DRD suppression patterns for races triggered by std::ostream
[valgrind.git] / helgrind / tests / tc12_rwl_trivial.c
bloba84428e018e5fbd56b841f11dbfb259466a98ebe
2 /* Needed for older glibcs (2.3 and older, at least) who don't
3 otherwise "know" about pthread_rwlock_anything or about
4 PTHREAD_MUTEX_RECURSIVE (amongst things). */
5 #define _GNU_SOURCE 1
7 #include <stdio.h>
8 #include "safe-pthread.h"
9 #include <assert.h>
11 /* Do trivial stuff with a reader-writer lock. */
13 int main ( void )
15 int r;
16 pthread_rwlock_t rwl;
18 r = pthread_rwlock_init( &rwl, NULL ); assert(r == 0);
20 r = pthread_rwlock_wrlock( &rwl ); assert(r == 0);
21 r = pthread_rwlock_unlock( &rwl ); assert(r == 0);
23 r = pthread_rwlock_rdlock( &rwl ); assert(r == 0);
24 r = pthread_rwlock_rdlock( &rwl ); assert(r == 0);
25 r = pthread_rwlock_unlock( &rwl ); assert(r == 0);
26 r = pthread_rwlock_unlock( &rwl ); assert(r == 0);
28 /* this should fail - lock is unowned now */
29 r = pthread_rwlock_unlock( &rwl );
30 #if defined(VGO_darwin) || defined(VGO_solaris)
31 assert(r != 0);
32 #else
33 assert(r == 0);
34 #endif
36 r = pthread_rwlock_destroy( &rwl ); assert(r == 0);
38 return 0;