1 // commit: e5dd18319bbd47c89aac5e1571771958a43e067d 2011-03-08
2 // pthread_rwlock_try* should fail with EBUSY
8 #define T(f) if ((r=(f))) t_error(#f " failed: %s\n", strerror(r))
10 static void *tryrdlock(void *arg
)
12 int r
= pthread_rwlock_tryrdlock(arg
);
14 t_error("tryrdlock for wrlocked lock returned %s, want EBUSY\n", strerror(r
));
18 static void *trywrlock(void *arg
)
20 int r
= pthread_rwlock_trywrlock(arg
);
22 t_error("trywrlock for rdlocked lock returned %s, want EBUSY\n", strerror(r
));
29 pthread_rwlock_t rw
= PTHREAD_RWLOCK_INITIALIZER
;
33 T(pthread_rwlock_rdlock(&rw
));
34 T(pthread_create(&t
, 0, trywrlock
, &rw
));
35 T(pthread_join(t
, &p
));
36 T(pthread_rwlock_unlock(&rw
));
38 T(pthread_rwlock_wrlock(&rw
));
39 T(pthread_create(&t
, 0, tryrdlock
, &rw
));
40 T(pthread_join(t
, &p
));
41 T(pthread_rwlock_unlock(&rw
));