aboutsummaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-02-14 01:12:02 +0000
committerUlrich Drepper <drepper@redhat.com>2003-02-14 01:12:02 +0000
commita1ea4c0638ecf4ef3c421b03089000aca7d0f0eb (patch)
tree6ecd88fb4921750225d856d4f425b81e06986d3f /nptl
parente8cda341a4e8893a5932a0d22440e7c191c37564 (diff)
downloadglibc-a1ea4c0638ecf4ef3c421b03089000aca7d0f0eb.tar
glibc-a1ea4c0638ecf4ef3c421b03089000aca7d0f0eb.tar.gz
glibc-a1ea4c0638ecf4ef3c421b03089000aca7d0f0eb.tar.bz2
glibc-a1ea4c0638ecf4ef3c421b03089000aca7d0f0eb.zip
Update.
* 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.
Diffstat (limited to 'nptl')
-rw-r--r--nptl/ChangeLog5
-rw-r--r--nptl/sysdeps/pthread/pthread.h37
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S3
-rw-r--r--nptl/tst-cond7.c14
4 files changed, 43 insertions, 16 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 1b56f1c025..0bcd27e189 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,5 +1,10 @@
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.
diff --git a/nptl/sysdeps/pthread/pthread.h b/nptl/sysdeps/pthread/pthread.h
index aeb3ef520e..135b255a53 100644
--- a/nptl/sysdeps/pthread/pthread.h
+++ b/nptl/sysdeps/pthread/pthread.h
@@ -1,4 +1,4 @@
-/* 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
@@ -38,20 +38,7 @@ enum
};
-/* 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,
@@ -71,6 +58,18 @@ enum
#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
@@ -83,6 +82,14 @@ enum
};
#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
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S
index b2a5d53e31..fffef03bd5 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S
@@ -65,7 +65,8 @@ __pthread_cond_broadcast:
cmpl (%ebx), %ecx
jna 4f
- /* Case all currently waiting threads to wake up. */
+ /* Cause all currently waiting threads to recognize they are
+ woken up. */
3: movl %ecx, (%ebx)
movl %eax, 4(%ebx)
diff --git a/nptl/tst-cond7.c b/nptl/tst-cond7.c
index 4cc7cfbecc..5ab7b8f8f9 100644
--- a/nptl/tst-cond7.c
+++ b/nptl/tst-cond7.c
@@ -43,6 +43,13 @@ tf (void *arg)
{
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)
@@ -121,6 +128,13 @@ do_test (void)
}
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");