Fix accessor struct inlining in GOOPS
[bpt/guile.git] / test-suite / standalone / test-pthread-create.c
CommitLineData
4a235623
LC
1/* Copyright (C) 2011 Free Software Foundation, Inc.
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public License
5 * as published by the Free Software Foundation; either version 3 of
6 * the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 * 02110-1301 USA
17 */
18
19/* Test whether threads created with `pthread_create' work (bug #32436)
20 when then main thread is the one that initializes Guile. */
21
22#ifdef HAVE_CONFIG_H
23# include <config.h>
24#endif
25
26#include <pthread.h>
27#include <stdlib.h>
28#include <libguile.h>
29
30static void *
31do_something (void *arg)
32{
33 scm_list_copy (scm_make_list (scm_from_int (1234), SCM_BOOL_T));
34 scm_gc ();
35 return NULL;
36}
37
38static void *
39thread (void *arg)
40{
41 scm_with_guile (do_something, NULL);
42 return NULL;
43}
44
7c86abd9
LC
45static void *
46inner_main (void *data)
4a235623
LC
47{
48 int i;
49 pthread_t thr;
50
4a235623
LC
51 do_something (NULL);
52
53 for (i = 0; i < 77; i++)
54 {
55 pthread_create (&thr, NULL, thread, NULL);
56 pthread_join (thr, NULL);
57 }
58
7c86abd9
LC
59 return NULL;
60}
61
62\f
63int
64main (int argc, char *argv[])
65{
66 scm_with_guile (inner_main, NULL);
67
4a235623
LC
68 return EXIT_SUCCESS;
69}