xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.threads/corethreads.c (revision 8b657b0747480f8989760d71343d6dd33f8d4cf9)
1 /* Copyright 2011-2023 Free Software Foundation, Inc.
2 
3    This file is part of GDB.
4 
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.
9 
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.
14 
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/>.  */
17 
18 #include <pthread.h>
19 #include <stdlib.h>
20 #include <assert.h>
21 
22 pthread_t thread0;
23 pthread_t thread1;
24 
25 static void *
26 start (void *arg)
27 {
28   assert (pthread_self () == thread1);
29 
30   abort ();
31 }
32 
33 int
34 main (void)
35 {
36   int i;
37 
38   thread0 = pthread_self ();
39 
40   i = pthread_create (&thread1, NULL, start, NULL);
41   assert (i == 0);
42 
43   i = pthread_join (thread1, NULL);
44   assert (i == 0);
45 
46   return 0;
47 }
48