Use TYPE macro to decide what type of rwlock to use.
authordrepper <drepper>
Sat, 31 May 2008 08:55:54 +0000 (08:55 +0000)
committerdrepper <drepper>
Sat, 31 May 2008 08:55:54 +0000 (08:55 +0000)
nptl/tst-rwlock2.c

index 6f38682..2d2e8e4 100644 (file)
@@ -26,15 +26,41 @@ static int
 do_test (void)
 {
   pthread_rwlock_t r;
+  pthread_rwlockattr_t at;
   int e;
 
-  if (pthread_rwlock_init (&r, NULL) != 0)
+  if (pthread_rwlockattr_init (&at) != 0)
+    {
+      puts ("rwlockattr_init failed");
+      return 1;
+    }
+  puts ("rwlockattr_init succeeded");
+
+#ifndef TYPE
+# define TYPE PTHREAD_RWLOCK_PREFER_READER_NP
+#endif
+
+  if (pthread_rwlockattr_setkind_np (&at, TYPE) != 0)
+    {
+      puts ("rwlockattr_setkind failed");
+      return 1;
+    }
+  puts ("rwlockattr_setkind succeeded");
+
+  if (pthread_rwlock_init (&r, &at) != 0)
     {
       puts ("rwlock_init failed");
       return 1;
     }
   puts ("rwlock_init succeeded");
 
+  if (pthread_rwlockattr_destroy (&at) != 0)
+    {
+      puts ("rwlockattr_destroy failed");
+      return 1;
+    }
+  puts ("rwlockattr_destroy succeeded");
+
   if (pthread_rwlock_wrlock (&r) != 0)
     {
       puts ("1st rwlock_wrlock failed");