Remove obsolete test from gdb.cp/var-tag.exp
[binutils-gdb.git] / gdb / testsuite / gdb.threads / kill.c
blob4003d81f0862db6aae49f0ff861a4cc12a1341ac
1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2014-2024 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program 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
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 #ifdef USE_THREADS
20 #include <unistd.h>
21 #include <pthread.h>
23 #define NUM 5
25 pthread_barrier_t barrier;
27 void *
28 thread_function (void *arg)
30 volatile unsigned int counter = 1;
32 pthread_barrier_wait (&barrier);
34 while (counter > 0)
36 counter++;
37 usleep (1);
40 pthread_exit (NULL);
43 #endif /* USE_THREADS */
45 void
46 setup (void)
48 #ifdef USE_THREADS
49 pthread_t threads[NUM];
50 int i;
52 pthread_barrier_init (&barrier, NULL, NUM + 1);
53 for (i = 0; i < NUM; i++)
54 pthread_create (&threads[i], NULL, thread_function, NULL);
55 pthread_barrier_wait (&barrier);
56 #endif /* USE_THREADS */
59 int
60 main (void)
62 setup ();
63 return 0; /* set break here */