Commit | Line | Data |
---|---|---|
20181478 NJ |
1 | /* Copyright (C) 2008 Free Software Foundation, Inc. |
2 | * | |
3 | * This library is free software; you can redistribute it and/or | |
53befeb7 NJ |
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. | |
20181478 | 7 | * |
53befeb7 NJ |
8 | * This library is distributed in the hope that it will be useful, but |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
20181478 NJ |
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 | |
53befeb7 NJ |
15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
16 | * 02110-1301 USA | |
20181478 NJ |
17 | */ |
18 | ||
eb0ffdd8 | 19 | #ifdef HAVE_CONFIG_H |
3394818c LC |
20 | # include <config.h> |
21 | #endif | |
22 | ||
01be513e NJ |
23 | #include <pthread.h> |
24 | #include <libguile.h> | |
25 | ||
20181478 NJ |
26 | void *thread_inner_main (void *unused); |
27 | void *thread_main (void *unused); | |
28 | void *do_join (void *data); | |
29 | void *inner_main (void *unused); | |
01be513e | 30 | |
20181478 NJ |
31 | void * |
32 | thread_inner_main (void *unused) | |
01be513e NJ |
33 | { |
34 | int argc = 3; | |
20181478 NJ |
35 | char *argv[] = { |
36 | "guile", | |
37 | "-c", | |
38 | "(or (current-module) (exit -1))", | |
39 | 0 | |
40 | }; | |
41 | ||
01be513e NJ |
42 | scm_shell (argc, argv); |
43 | ||
20181478 | 44 | return NULL; /* dummy */ |
01be513e NJ |
45 | } |
46 | ||
20181478 NJ |
47 | void * |
48 | thread_main (void *unused) | |
01be513e NJ |
49 | { |
50 | scm_with_guile (&thread_inner_main, NULL); | |
51 | ||
20181478 | 52 | return NULL; /* dummy */ |
01be513e NJ |
53 | } |
54 | ||
20181478 NJ |
55 | void * |
56 | do_join (void *data) | |
01be513e | 57 | { |
20181478 | 58 | pthread_t *thread = (pthread_t *) data; |
01be513e NJ |
59 | |
60 | pthread_join (*thread, NULL); | |
61 | ||
20181478 | 62 | return NULL; /* dummy */ |
01be513e NJ |
63 | } |
64 | ||
20181478 NJ |
65 | void * |
66 | inner_main (void *unused) | |
01be513e NJ |
67 | { |
68 | pthread_t thread; | |
69 | ||
70 | pthread_create (&thread, NULL, &thread_main, NULL); | |
71 | scm_without_guile (do_join, &thread); | |
72 | ||
20181478 | 73 | return NULL; /* dummy */ |
01be513e NJ |
74 | } |
75 | ||
20181478 NJ |
76 | int |
77 | main (int argc, char **argv) | |
01be513e NJ |
78 | { |
79 | scm_with_guile (&inner_main, NULL); | |
80 | ||
81 | return 0; | |
82 | } |