1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2010-2016 Free Software Foundation, Inc.
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.
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.
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/>.
18 Contributed by Ulrich Weigand <uweigand@de.ibm.com> */
24 #include <sys/types.h>
28 extern spe_program_handle_t fork_spu
;
31 spe_thread (void * arg
)
34 unsigned int entry
= SPE_DEFAULT_ENTRY
;
35 spe_context_ptr_t
*ctx
= (spe_context_ptr_t
*) arg
;
37 spe_program_load (*ctx
, &fork_spu
);
38 spe_context_run (*ctx
, &entry
, flags
, NULL
, NULL
, NULL
);
47 spe_context_ptr_t ctx
;
51 ctx
= spe_context_create (0, NULL
);
52 pthread_create (&pts
, NULL
, &spe_thread
, &ctx
);
54 /* Wait until the SPU thread is running. */
55 spe_out_intr_mbox_read (ctx
, &value
, 1, SPE_MBOX_ALL_BLOCKING
);
60 /* This is the child. Just exit immediately. */
65 /* This is the parent. Wait for the child to exit. */
66 waitpid (pid
, NULL
, 0);
69 /* Tell SPU to continue. */
70 spe_in_mbox_write (ctx
, &value
, 1, SPE_MBOX_ALL_BLOCKING
);
72 pthread_join (pts
, NULL
);
73 spe_context_destroy (ctx
);