]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nptl/tst-cond18.c
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / nptl / tst-cond18.c
index 9fd81d29888b006e7b4bd985ede4bb7e6bd502c2..033770ea2badef376cd8aa1e360b735c67525e72 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2004-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
 
    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.  */
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
+#include <limits.h>
 #include <fcntl.h>
 #include <pthread.h>
 #include <stdbool.h>
@@ -28,7 +28,8 @@
 pthread_cond_t cv = PTHREAD_COND_INITIALIZER;
 pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
 bool exiting;
-int fd, count, spins, nn;
+int fd, spins, nn;
+enum { count = 8 };            /* Number of worker threads.  */
 
 void *
 tf (void *id)
@@ -82,16 +83,17 @@ do_test (void)
       return 1;
     }
 
-  count = sysconf (_SC_NPROCESSORS_ONLN);
-  if (count <= 0)
-    count = 1;
-  count *= 8;
-
   pthread_t th[count + 1];
-  int i, ret;
+  pthread_attr_t attr;
+  int i, ret, sz;
+  pthread_attr_init (&attr);
+  sz = sysconf (_SC_PAGESIZE);
+  if (sz < PTHREAD_STACK_MIN)
+         sz = PTHREAD_STACK_MIN;
+  pthread_attr_setstacksize (&attr, sz);
 
   for (i = 0; i <= count; ++i)
-    if ((ret = pthread_create (&th[i], NULL, tf, (void *) (long) i)) != 0)
+    if ((ret = pthread_create (&th[i], &attr, tf, (void *) (long) i)) != 0)
       {
        errno = ret;
        printf ("pthread_create %d failed: %m\n", i);