aboutsummaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-02-18 10:59:20 +0000
committerUlrich Drepper <drepper@redhat.com>2003-02-18 10:59:20 +0000
commit729924a042266022cc469501d01b33f0f9ae4bfc (patch)
tree3f126578aaeded27587803838c29ca14210c4c4d /nptl
parent8bd3f1844a9912b6ca08ef4bc47b1e3e2ef21029 (diff)
downloadglibc-729924a042266022cc469501d01b33f0f9ae4bfc.zip
glibc-729924a042266022cc469501d01b33f0f9ae4bfc.tar.gz
glibc-729924a042266022cc469501d01b33f0f9ae4bfc.tar.bz2
Update.
2003-02-18 Ulrich Drepper <drepper@redhat.com> * pthreadP.h: Define dummy versio of DEBUGGING_P.
Diffstat (limited to 'nptl')
-rw-r--r--nptl/ChangeLog4
-rw-r--r--nptl/pthreadP.h7
-rw-r--r--nptl/pthread_create.c4
-rw-r--r--nptl/tst-basic6.c132
4 files changed, 144 insertions, 3 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 3204cc7..f92d80c 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,7 @@
+2003-02-18 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h: Define dummy versio of DEBUGGING_P.
+
2003-02-17 Ulrich Drepper <drepper@redhat.com>
* sysdeps/unix/sysv/linux/i386/bits/posix_opt.h: Remnove
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index 2b65192..11f7ede 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -67,7 +67,12 @@ extern unsigned int __nptl_nthreads attribute_hidden;
/* The library can run in debugging mode where it performs a lot more
tests. */
extern int __pthread_debug attribute_hidden;
-#define DEBUGGING_P __builtin_expect (__pthread_debug, 0)
+/** For now disable debugging support. */
+#if 0
+# define DEBUGGING_P __builtin_expect (__pthread_debug, 0)
+#else
+# define DEBUGGING_P 0
+#endif
/* Cancellation test. */
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index 6a59090..172f002 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -226,7 +226,7 @@ start_thread (void *arg)
/* If this is the last thread we terminate the process now. We
do not notify the debugger, it might just irritate it if there
is no thread left. */
- if (atomic_decrement_and_test (&__nptl_nthreads))
+ if (__builtin_expect (atomic_decrement_and_test (&__nptl_nthreads), 0))
/* This was the last thread. */
exit (0);
@@ -328,7 +328,7 @@ __pthread_create_2_1 (newthread, attr, start_routine, arg)
iattr = &default_attr;
err = ALLOCATE_STACK (iattr, &pd);
- if (err != 0)
+ if (__builtin_expect (err != 0, 0))
/* Something went wrong. Maybe a parameter of the attributes is
invalid or we could not allocate memory. */
return err;
diff --git a/nptl/tst-basic6.c b/nptl/tst-basic6.c
new file mode 100644
index 0000000..413ae03
--- /dev/null
+++ b/nptl/tst-basic6.c
@@ -0,0 +1,132 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static char *p;
+
+static pthread_barrier_t b;
+#define BT \
+ e = pthread_barrier_wait (&b); \
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) \
+ { \
+ puts ("barrier_wait failed"); \
+ exit (1); \
+ }
+
+
+static void *
+tf (void *a)
+{
+ int e;
+
+ BT;
+
+ char *p2 = getcwd (NULL, 0);
+ if (p2 == NULL)
+ {
+ puts ("2nd getcwd failed");
+ exit (1);
+ }
+
+ if (strcmp (p, p2) != 0)
+ {
+ printf ("initial cwd mismatch: \"%s\" vs \"%s\"\n", p, p2);
+ exit (1);
+ }
+
+ free (p);
+ free (p2);
+
+ if (chdir ("..") != 0)
+ {
+ puts ("chdir failed");
+ exit (1);
+ }
+
+ p = getcwd (NULL, 0);
+ if (p == NULL)
+ {
+ puts ("getcwd failed");
+ exit (1);
+ }
+
+ return a;
+}
+
+
+int
+do_test (void)
+{
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ p = getcwd (NULL, 0);
+ if (p == NULL)
+ {
+ puts ("getcwd failed");
+ exit (1);
+ }
+
+ int e;
+ BT;
+
+ if (pthread_join (th, NULL) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ char *p2 = getcwd (NULL, 0);
+ if (p2 == NULL)
+ {
+ puts ("2nd getcwd failed");
+ exit (1);
+ }
+
+ if (strcmp (p, p2) != 0)
+ {
+ printf ("cwd after chdir mismatch: \"%s\" vs \"%s\"\n", p, p2);
+ exit (1);
+ }
+
+ free (p);
+ free (p2);
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"