Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.server / stop-reply-no-thread-multi.c
CommitLineData
8f66807b
AB
1/* This testcase is part of GDB, the GNU debugger.
2
88b9d363 3 Copyright 2021-2022 Free Software Foundation, Inc.
8f66807b
AB
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 <stdlib.h>
19#include <pthread.h>
20#include <unistd.h>
21
22volatile int worker_blocked = 1;
23volatile int main_blocked = 1;
24
25void
26unlock_worker (void)
27{
28 worker_blocked = 0;
29}
30
31void
32unlock_main (void)
33{
34 main_blocked = 0;
35}
36
37void
38breakpt (void)
39{
40 /* Nothing. */
41}
42
43static void *
44worker (void *data)
45{
46 unlock_main ();
47
48 while (worker_blocked)
49 ;
50
51 breakpt ();
52
53 return NULL;
54}
55
56int
57main (void)
58{
59 pthread_t thr;
60 void *retval;
61
62 /* Ensure the test doesn't run forever. */
63 alarm (99);
64
65 if (pthread_create (&thr, NULL, worker, NULL) != 0)
66 abort ();
67
68 while (main_blocked)
69 ;
70
71 unlock_worker ();
72
73 if (pthread_join (thr, &retval) != 0)
74 abort ();
75
76 return 0;
77}
This page took 0.099715 seconds and 4 git commands to generate.