diff options
Diffstat (limited to 'nptl')
-rw-r--r-- | nptl/ChangeLog | 9 | ||||
-rw-r--r-- | nptl/Makefile | 2 | ||||
-rw-r--r-- | nptl/pthread_setconcurrency.c | 6 | ||||
-rw-r--r-- | nptl/tst-basic5.c | 74 |
4 files changed, 88 insertions, 3 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog index 356461f558..3cbc370f50 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -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. diff --git a/nptl/Makefile b/nptl/Makefile index d48c691ac6..04d7c1d38d 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -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 \ diff --git a/nptl/pthread_setconcurrency.c b/nptl/pthread_setconcurrency.c index f65a174d41..8cf1507131 100644 --- a/nptl/pthread_setconcurrency.c +++ b/nptl/pthread_setconcurrency.c @@ -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 diff --git a/nptl/tst-basic5.c b/nptl/tst-basic5.c new file mode 100644 index 0000000000..83a8810f18 --- /dev/null +++ b/nptl/tst-basic5.c @@ -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" |