2003-02-15  Ulrich Drepper  <drepper@redhat.com>

	* pthread_setconcurrency.c (pthread_setconcurrency): Fail for
	negative arguments.
	* Makefile (tests): Add tst-basic5.
	* tst-basic5.c: New file.

	after thread is done.  If then zero, call exit(0).
This commit is contained in:
Ulrich Drepper 2003-02-15 08:21:36 +00:00
parent 757de559da
commit b270b54840
4 changed files with 88 additions and 3 deletions

View File

@ -1,3 +1,10 @@
2003-02-15 Ulrich Drepper <drepper@redhat.com>
* pthread_setconcurrency.c (pthread_setconcurrency): Fail for
negative arguments.
* Makefile (tests): Add tst-basic5.
* tst-basic5.c: New file.
2003-02-14 Ulrich Drepper <drepper@redhat.com>
* Makefile (tests): Add tst-basic4.
@ -6,7 +13,7 @@
* pthreadP.h: Add declaraction for __nptl_nthreads.
* pthread_create.c: Define __nptl_nthreads
(start_thread): Increment __nptl_nthreads at beginning. Decrement
after thread is done. If Then zero call exit(0).
after thread is done. If then zero, call exit(0).
* sysdeps/pthread/pthread-functions.h (struct pthread_functions):
Add ptr_nthreads. Define HAVE_PTR_NTHREADS.
* init.c (pthread_functions): Initialize ptr_nthreads.

View File

@ -136,7 +136,7 @@ tests = tst-attr1 tst-attr2 \
tst-key1 tst-key2 tst-key3 \
tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem5 \
tst-barrier1 tst-barrier2 tst-barrier3 \
tst-basic1 tst-basic2 tst-basic3 tst-basic4 \
tst-basic1 tst-basic2 tst-basic3 tst-basic4 tst-basic5 \
tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 \
tst-tsd1 tst-tsd2 \
tst-fork1 tst-fork2 tst-fork3 \

View File

@ -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.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@ -17,6 +17,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <errno.h>
#include "pthreadP.h"
@ -28,6 +29,9 @@ int
pthread_setconcurrency (level)
int level;
{
if (level < 0)
return EINVAL;
__concurrency_level = level;
/* XXX For ports which actually need to handle the concurrency level

74
nptl/tst-basic5.c Normal file
View File

@ -0,0 +1,74 @@
/* 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 <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
int
do_test (void)
{
int c = pthread_getconcurrency ();
if (c != 0)
{
puts ("initial concurrencylevel wrong");
exit (1);
}
if (pthread_setconcurrency (1) != 0)
{
puts ("setconcurrency failed");
exit (1);
}
c = pthread_getconcurrency ();
if (c != 1)
{
puts ("getconcurrency didn't return the value previous set");
exit (1);
}
int e = pthread_setconcurrency (-1);
if (e == 0)
{
puts ("setconcurrency of negative value didn't failed");
exit (1);
}
if (e != EINVAL)
{
puts ("setconcurrency didn't return EINVAL for negative value");
exit (1);
}
c = pthread_getconcurrency ();
if (c != 1)
{
puts ("invalid getconcurrency changed level");
exit (1);
}
return 0;
}
#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"