Mark __libc_resp with attribute_tls_model_ie for consistency with __resp
[glibc/nacl-glibc.git] / nptl / tst-robust9.c
blob1d6ba179be9ebf0d4b9ff1c6327a91909d10c473
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <errno.h>
4 #include <pthread.h>
5 #include <unistd.h>
6 #include <sys/time.h>
9 static pthread_mutex_t m;
11 static void *
12 tf (void *data)
14 int err = pthread_mutex_lock (&m);
15 if (err == EOWNERDEAD)
17 err = pthread_mutex_consistent_np (&m);
18 if (err)
20 puts ("pthread_mutex_consistent_np");
21 exit (1);
24 else if (err)
26 puts ("pthread_mutex_lock");
27 exit (1);
29 printf ("thread%ld got the lock.\n", (long int) data);
30 sleep (1);
31 /* exit without unlock */
32 return NULL;
35 static int
36 do_test (void)
38 int err, i;
39 pthread_t t[3];
40 pthread_mutexattr_t ma;
42 pthread_mutexattr_init (&ma);
43 err = pthread_mutexattr_setrobust_np (&ma, PTHREAD_MUTEX_ROBUST_NP);
44 if (err)
46 puts ("pthread_mutexattr_setrobust_np");
47 return 1;
49 #ifdef ENABLE_PI
50 if (pthread_mutexattr_setprotocol (&ma, PTHREAD_PRIO_INHERIT) != 0)
52 puts ("pthread_mutexattr_setprotocol failed");
53 return 1;
55 #endif
56 err = pthread_mutex_init (&m, &ma);
57 #ifdef ENABLE_PI
58 if (err == ENOTSUP)
60 puts ("PI robust mutexes not supported");
61 return 0;
63 #endif
64 if (err)
66 puts ("pthread_mutex_init");
67 return 1;
70 for (i = 0; i < sizeof (t) / sizeof (t[0]); i++)
72 err = pthread_create (&t[i], NULL, tf, (void *) (long int) i);
73 if (err)
75 puts ("pthread_create");
76 return 1;
80 for (i = 0; i < sizeof (t) / sizeof (t[0]); i++)
82 err = pthread_join (t[i], NULL);
83 if (err)
85 puts ("pthread_join");
86 return 1;
89 return 0;
92 #define TIMEOUT 5
93 #define TEST_FUNCTION do_test ()
94 #include "../test-skeleton.c"