Include <config.h> in standalone tests.
[bpt/guile.git] / test-suite / standalone / test-with-guile-module.c
1 /* Copyright (C) 2008 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
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but 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 02110-1301 USA
16 */
17
18 #ifndef HAVE_CONFIG_H
19 # include <config.h>
20 #endif
21
22 #include <pthread.h>
23 #include <libguile.h>
24
25 void *thread_inner_main (void *unused);
26 void *thread_main (void *unused);
27 void *do_join (void *data);
28 void *inner_main (void *unused);
29
30 void *
31 thread_inner_main (void *unused)
32 {
33 int argc = 3;
34 char *argv[] = {
35 "guile",
36 "-c",
37 "(or (current-module) (exit -1))",
38 0
39 };
40
41 scm_shell (argc, argv);
42
43 return NULL; /* dummy */
44 }
45
46 void *
47 thread_main (void *unused)
48 {
49 scm_with_guile (&thread_inner_main, NULL);
50
51 return NULL; /* dummy */
52 }
53
54 void *
55 do_join (void *data)
56 {
57 pthread_t *thread = (pthread_t *) data;
58
59 pthread_join (*thread, NULL);
60
61 return NULL; /* dummy */
62 }
63
64 void *
65 inner_main (void *unused)
66 {
67 pthread_t thread;
68
69 pthread_create (&thread, NULL, &thread_main, NULL);
70 scm_without_guile (do_join, &thread);
71
72 return NULL; /* dummy */
73 }
74
75 int
76 main (int argc, char **argv)
77 {
78 scm_with_guile (&inner_main, NULL);
79
80 return 0;
81 }