FreeBSD regtest: add missing helgrind expecteds
[valgrind.git] / helgrind / tests / tc10_rec_lock.c
blob648305cd7c35600c784fba2b29c5196670db4fa7
2 /* Do simple things with a recursive mutex. */
4 /* Needed for older glibcs (2.3 and older, at least) who don't
5 otherwise "know" about pthread_rwlock_anything or about
6 PTHREAD_MUTEX_RECURSIVE (amongst things). */
7 #define _GNU_SOURCE 1
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <assert.h>
12 #include <pthread.h>
14 void nearly_main ( void )
16 pthread_mutex_t mx1;
17 pthread_mutexattr_t attr;
18 int r;
20 r = pthread_mutexattr_init( &attr );
21 assert(r==0);
22 r = pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE );
23 assert(r==0);
24 r = pthread_mutex_init( &mx1, &attr );
25 assert(r==0);
27 fprintf(stderr, "before lock #1\n");
28 r = pthread_mutex_lock( &mx1 ); assert(r == 0);
29 fprintf(stderr, "before lock #2\n");
30 r = pthread_mutex_lock( &mx1 ); assert(r == 0);
31 fprintf(stderr, "before lock #3\n");
32 r = pthread_mutex_lock( &mx1 ); assert(r == 0);
34 fprintf(stderr, "before unlock #1\n");
35 r = pthread_mutex_unlock( &mx1 ); assert(r == 0);
36 fprintf(stderr, "before unlock #2\n");
37 r = pthread_mutex_unlock( &mx1 ); assert(r == 0);
38 fprintf(stderr, "before unlock #3\n");
39 r = pthread_mutex_unlock( &mx1 ); assert(r == 0);
41 fprintf(stderr, "before unlock #4\n");
42 r = pthread_mutex_unlock( &mx1 ); /* FAILS: assert(r == 0); */
45 int main ( void )
47 nearly_main();
48 return 0;