]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nptl/tst-signal3.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / nptl / tst-signal3.c
index 3de28875454b2aca50cdac8e6cb22229ebb0a831..618a306255d4718069a5ccb5bd7be48c95615f68 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    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
+   <http://www.gnu.org/licenses/>.  */
 
+#include <errno.h>
 #include <pthread.h>
 #include <semaphore.h>
 #include <signal.h>
 #include <unistd.h>
 
 
-/* Number of different signalss to use.  Also is the number of
-   threads.  */
-#define N 10
+#ifdef SIGRTMIN
+
+/* Number of different signals to use.  Also is the number of threads.  */
+# define N 10
 /* Maximum number of threads in flight at any one time.  */
-#define INFLIGHT 5
+# define INFLIGHT 5
 /* Number of signals sent in total.  */
-#define ROUNDS 10000
+# define ROUNDS 10000
 
 
 static int received[N][N];
@@ -131,6 +132,20 @@ do_test (void)
       exit (1);
     }
 
+  pthread_attr_t a;
+
+  if (pthread_attr_init (&a) != 0)
+    {
+      puts ("attr_init failed");
+      exit (1);
+    }
+
+  if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
   for (i = 0; i < N; ++i)
     {
       if (pthread_mutex_init (&lock[i], NULL) != 0)
@@ -143,20 +158,26 @@ do_test (void)
          printf ("mutex_lock[%d] failed\n", i);
        }
 
-      if (pthread_create (&th[i], NULL, tf, (void *) (long int) i) != 0)
+      if (pthread_create (&th[i], &a, tf, (void *) (long int) i) != 0)
        {
          printf ("create of thread %d failed\n", i);
          exit (1);
        }
     }
 
+  if (pthread_attr_destroy (&a) != 0)
+    {
+      puts ("attr_destroy failed");
+      exit (1);
+    }
+
   int result = 0;
   unsigned int r = 42;
   pid_t pid = getpid ();
 
   for (i = 0; i < ROUNDS; ++i)
     {
-      if (sem_wait (&sem) != 0)
+      if (TEMP_FAILURE_RETRY (sem_wait (&sem)) != 0)
        {
          printf ("sem_wait round %d failed: %m\n", i);
          exit (1);
@@ -235,6 +256,10 @@ do_test (void)
   return result;
 }
 
-#define TIMEOUT 10
-#define TEST_FUNCTION do_test ()
+# define TEST_FUNCTION do_test ()
+
+#else
+# define TEST_FUNCTION 0
+#endif
+
 #include "../test-skeleton.c"