mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-21 01:12:26 +08:00
Update.
2003-02-18 Ulrich Drepper <drepper@redhat.com> * pthreadP.h: Define dummy versio of DEBUGGING_P.
This commit is contained in:
parent
8bd3f1844a
commit
729924a042
@ -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
|
||||
|
@ -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. */
|
||||
|
@ -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;
|
||||
|
132
nptl/tst-basic6.c
Normal file
132
nptl/tst-basic6.c
Normal file
@ -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"
|
Loading…
Reference in New Issue
Block a user