Define __intmax_t, __uintmax_t in bits/types.h.
[glibc.git] / nptl / tst-eintr1.c
blob0946894fbed1c66a625365eccb662452d8c30fb2
1 /* Copyright (C) 2003-2016 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <errno.h>
20 #include <pthread.h>
21 #include <signal.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
26 static int do_test (void);
28 #define TEST_FUNCTION do_test ()
29 #include "../test-skeleton.c"
31 #include "eintr.c"
34 static void *
35 tf2 (void *arg)
37 return arg;
41 static void *
42 tf1 (void *arg)
44 while (1)
46 pthread_t th;
48 int e = pthread_create (&th, NULL, tf2, NULL);
49 if (e != 0)
51 if (e == EINTR)
53 puts ("pthread_create returned EINTR");
54 exit (1);
57 char buf[100];
58 printf ("tf1: pthread_create failed: %s\n",
59 strerror_r (e, buf, sizeof (buf)));
60 exit (1);
63 e = pthread_join (th, NULL);
64 if (e != 0)
66 if (e == EINTR)
68 puts ("pthread_join returned EINTR");
69 exit (1);
72 char buf[100];
73 printf ("tf1: pthread_join failed: %s\n",
74 strerror_r (e, buf, sizeof (buf)));
75 exit (1);
81 static int
82 do_test (void)
84 setup_eintr (SIGUSR1, NULL);
86 int i;
87 for (i = 0; i < 10; ++i)
89 pthread_t th;
90 int e = pthread_create (&th, NULL, tf1, NULL);
91 if (e != 0)
93 char buf[100];
94 printf ("main: pthread_create failed: %s\n",
95 strerror_r (e, buf, sizeof (buf)));
96 exit (1);
100 delayed_exit (3);
101 /* This call must never return. */
102 (void) tf1 (NULL);
103 return 1;