1b725ae77Skettenis /* This testcase is part of GDB, the GNU debugger.
2b725ae77Skettenis
3b725ae77Skettenis Copyright 2004 Free Software Foundation, Inc.
4b725ae77Skettenis
5b725ae77Skettenis This program is free software; you can redistribute it and/or modify
6b725ae77Skettenis it under the terms of the GNU General Public License as published by
7b725ae77Skettenis the Free Software Foundation; either version 2 of the License, or
8b725ae77Skettenis (at your option) any later version.
9b725ae77Skettenis
10b725ae77Skettenis This program is distributed in the hope that it will be useful,
11b725ae77Skettenis but WITHOUT ANY WARRANTY; without even the implied warranty of
12b725ae77Skettenis MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13b725ae77Skettenis GNU General Public License for more details.
14b725ae77Skettenis
15b725ae77Skettenis You should have received a copy of the GNU General Public License
16b725ae77Skettenis along with this program; if not, write to the Free Software
17b725ae77Skettenis Foundation, Inc., 59 Temple Place - Suite 330,
18b725ae77Skettenis Boston, MA 02111-1307, USA. */
19b725ae77Skettenis
20b725ae77Skettenis #include <stdio.h>
21b725ae77Skettenis #include <unistd.h>
22b725ae77Skettenis #include <stdlib.h>
23b725ae77Skettenis #include <pthread.h>
24b725ae77Skettenis
25b725ae77Skettenis void *thread_function(void *arg);
26b725ae77Skettenis
27b725ae77Skettenis unsigned int args[1];
28b725ae77Skettenis
main()29b725ae77Skettenis int main() {
30b725ae77Skettenis int res;
31b725ae77Skettenis pthread_t threads[2];
32b725ae77Skettenis void *thread_result;
33b725ae77Skettenis long i = 1;
34b725ae77Skettenis
35b725ae77Skettenis args[0] = 1;
36b725ae77Skettenis res = pthread_create(&threads[0],
37b725ae77Skettenis NULL,
38b725ae77Skettenis thread_function,
39b725ae77Skettenis (void *) 0);
40b725ae77Skettenis
41b725ae77Skettenis /* thread-specific.exp: last thread start. */
42b725ae77Skettenis args[1] = 1;
43b725ae77Skettenis
44b725ae77Skettenis /* Don't run forever. Run just short of it :) */
45b725ae77Skettenis while (i > 0)
46b725ae77Skettenis {
47b725ae77Skettenis /* thread-specific.exp: main loop. */
48b725ae77Skettenis (i) ++;
49b725ae77Skettenis }
50b725ae77Skettenis
51b725ae77Skettenis exit(EXIT_SUCCESS);
52b725ae77Skettenis }
53b725ae77Skettenis
thread_function(void * arg)54b725ae77Skettenis void *thread_function(void *arg) {
55b725ae77Skettenis int my_number = (long) arg;
56*11efff7fSkettenis int *myp = (int *) &args[my_number];
57b725ae77Skettenis
58b725ae77Skettenis /* Don't run forever. Run just short of it :) */
59b725ae77Skettenis while (*myp > 0)
60b725ae77Skettenis {
61b725ae77Skettenis /* thread-specific.exp: thread loop. */
62b725ae77Skettenis (*myp) ++;
63b725ae77Skettenis }
64b725ae77Skettenis
65b725ae77Skettenis pthread_exit(NULL);
66b725ae77Skettenis }
67