Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / testsuite / gdb.threads / bp_in_thread.c
blobae87f8cb76510bc79a32b04b3672c83611a14b61
1 /* A small multi-threaded test case.
3 Copyright 2004
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 #include <pthread.h>
24 #include <stdio.h>
25 #include <time.h>
27 void
28 cond_wait (pthread_cond_t *cond, pthread_mutex_t *mut)
30 pthread_mutex_lock(mut);
31 pthread_cond_wait (cond, mut);
32 pthread_mutex_unlock (mut);
35 void
36 noreturn (void)
38 pthread_mutex_t mut;
39 pthread_cond_t cond;
41 pthread_mutex_init (&mut, NULL);
42 pthread_cond_init (&cond, NULL);
44 /* Wait for a condition that will never be signaled, so we effectively
45 block the thread here. */
46 cond_wait (&cond, &mut);
49 void *
50 forever_pthread (void *unused)
52 noreturn ();
55 void
56 break_me (void)
58 /* Just an anchor to help putting a breakpoint. */
61 int
62 main (void)
64 pthread_t forever;
65 const struct timespec ts = { 0, 10000000 }; /* 0.01 sec */
67 pthread_create (&forever, NULL, forever_pthread, NULL);
68 for (;;)
70 nanosleep (&ts, NULL);
71 break_me();
74 return 0;