xref: /openbsd-src/gnu/usr.bin/binutils/gdb/testsuite/gdb.threads/switch-threads.c (revision b725ae7711052a2233e31a66fefb8a752c388d7a)
1*b725ae77Skettenis /* A minimal multi-threaded test case.
2*b725ae77Skettenis 
3*b725ae77Skettenis    Copyright 2003
4*b725ae77Skettenis    Free Software Foundation, Inc.
5*b725ae77Skettenis 
6*b725ae77Skettenis    This file is part of GDB.
7*b725ae77Skettenis 
8*b725ae77Skettenis    This program is free software; you can redistribute it and/or modify
9*b725ae77Skettenis    it under the terms of the GNU General Public License as published by
10*b725ae77Skettenis    the Free Software Foundation; either version 2 of the License, or
11*b725ae77Skettenis    (at your option) any later version.
12*b725ae77Skettenis 
13*b725ae77Skettenis    This program is distributed in the hope that it will be useful,
14*b725ae77Skettenis    but WITHOUT ANY WARRANTY; without even the implied warranty of
15*b725ae77Skettenis    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*b725ae77Skettenis    GNU General Public License for more details.
17*b725ae77Skettenis 
18*b725ae77Skettenis    You should have received a copy of the GNU General Public License
19*b725ae77Skettenis    along with this program; if not, write to the Free Software
20*b725ae77Skettenis    Foundation, Inc., 59 Temple Place - Suite 330,
21*b725ae77Skettenis    Boston, MA 02111-1307, USA.  */
22*b725ae77Skettenis 
23*b725ae77Skettenis #include <pthread.h>
24*b725ae77Skettenis 
foo(void)25*b725ae77Skettenis void foo (void)
26*b725ae77Skettenis {
27*b725ae77Skettenis }
28*b725ae77Skettenis 
thread_func(void * arg)29*b725ae77Skettenis void *thread_func (void *arg)
30*b725ae77Skettenis {
31*b725ae77Skettenis   int x;
32*b725ae77Skettenis   for (x = 0; x < 10; x++)
33*b725ae77Skettenis     foo ();
34*b725ae77Skettenis   return 0;
35*b725ae77Skettenis }
36*b725ae77Skettenis 
main()37*b725ae77Skettenis int main()
38*b725ae77Skettenis {
39*b725ae77Skettenis   pthread_t thr;
40*b725ae77Skettenis   void *ret;
41*b725ae77Skettenis   int x;
42*b725ae77Skettenis 
43*b725ae77Skettenis   pthread_create (&thr, NULL, thread_func, NULL);
44*b725ae77Skettenis   pthread_join (thr, &ret);
45*b725ae77Skettenis   for (x = 0; x < 10; x++)
46*b725ae77Skettenis     foo ();
47*b725ae77Skettenis }
48