Home | History | Annotate | Download | only in tests
      1 /* Test program that triggers mutex reinitialization. */
      2 
      3 
      4 #define _GNU_SOURCE
      5 
      6 #include <assert.h>
      7 #include <pthread.h>
      8 #include <stdio.h>
      9 #include <stdlib.h>
     10 
     11 
     12 int main(int argc, char** argv)
     13 {
     14   pthread_mutex_t m;
     15   pthread_mutexattr_t attr;
     16 
     17   pthread_mutexattr_init(&attr);
     18   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
     19   pthread_mutex_init(&m, &attr);
     20   pthread_mutexattr_destroy(&attr);
     21   pthread_mutex_lock(&m);
     22   pthread_mutex_unlock(&m);
     23 
     24   pthread_mutexattr_init(&attr);
     25   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
     26   pthread_mutex_init(&m, &attr);
     27   pthread_mutexattr_destroy(&attr);
     28   pthread_mutex_lock(&m);
     29   pthread_mutex_unlock(&m);
     30 
     31   pthread_mutex_destroy(&m);
     32 
     33   fprintf(stderr, "Done.\n");
     34 
     35   return 0;
     36 }
     37