2003-02-13 Ulrich Drepper <drepper@redhat.com>
+ * tst-cond7.c (do_test): Unlock the mutex before canceling the thread.
+
+ * sysdeps/pthread/pthread.h: Add missing initializers. Protect
+ non-standard initializers with __USE_GNU.
+
* Makefile (tests): Add tst-cleanup3.
* tst-cleanup3.c: New file.
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
};
-/* Mutex handling. */
-
-#define PTHREAD_MUTEX_INITIALIZER \
- { }
-
-#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
- { .__data = { .__kind = PTHREAD_MUTEX_RECURSIVE_NP } }
-
-#define PTHREAD_RWLOCK_INITIALIZER \
- { }
-
-#define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
- { .__data = { .__flags = PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
-
+/* Mutex types. */
enum
{
PTHREAD_MUTEX_TIMED_NP,
#endif
};
+/* Mutex initializers. */
+#define PTHREAD_MUTEX_INITIALIZER \
+ { }
+#ifdef __USE_GNU
+# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
+ { .__data = { .__kind = PTHREAD_MUTEX_RECURSIVE_NP } }
+# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
+ { .__data = { .__kind = PTHREAD_MUTEX_ERRORCHECK_NP } }
+# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
+ { .__data = { .__kind = PTHREAD_MUTEX_ADAPTIVE_NP } }
+#endif
+
/* Read-write lock types. */
#ifdef __USE_UNIX98
};
#endif /* Unix98 */
+/* Read-write lock initializers. */
+#define PTHREAD_RWLOCK_INITIALIZER \
+ { }
+#ifdef __USE_GNU
+# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
+ { .__data = { .__flags = PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
+#endif
+
/* Scheduler inheritance. */
enum
{
puts ("child created");
+ if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) != 0
+ || pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, NULL) != 0)
+ {
+ puts ("cannot set cancellation options");
+ exit (1);
+ }
+
T *t = (T *) arg;
if (pthread_mutex_lock (&t->lock) != 0)
}
while (! done);
+ /* Release the lock since the cancel handler will get it. */
+ if (pthread_mutex_unlock (&t[i]->lock) != 0)
+ {
+ puts ("mutex_unlock failed");
+ exit (1);
+ }
+
if (pthread_cancel (t[i]->h) != 0)
{
puts ("cancel failed");