Include <config.h> in standalone tests.
[bpt/guile.git] / test-suite / standalone / test-with-guile-module.c
CommitLineData
20181478
NJ
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
3394818c
LC
18#ifndef HAVE_CONFIG_H
19# include <config.h>
20#endif
21
01be513e
NJ
22#include <pthread.h>
23#include <libguile.h>
24
20181478
NJ
25void *thread_inner_main (void *unused);
26void *thread_main (void *unused);
27void *do_join (void *data);
28void *inner_main (void *unused);
01be513e 29
20181478
NJ
30void *
31thread_inner_main (void *unused)
01be513e
NJ
32{
33 int argc = 3;
20181478
NJ
34 char *argv[] = {
35 "guile",
36 "-c",
37 "(or (current-module) (exit -1))",
38 0
39 };
40
01be513e
NJ
41 scm_shell (argc, argv);
42
20181478 43 return NULL; /* dummy */
01be513e
NJ
44}
45
20181478
NJ
46void *
47thread_main (void *unused)
01be513e
NJ
48{
49 scm_with_guile (&thread_inner_main, NULL);
50
20181478 51 return NULL; /* dummy */
01be513e
NJ
52}
53
20181478
NJ
54void *
55do_join (void *data)
01be513e 56{
20181478 57 pthread_t *thread = (pthread_t *) data;
01be513e
NJ
58
59 pthread_join (*thread, NULL);
60
20181478 61 return NULL; /* dummy */
01be513e
NJ
62}
63
20181478
NJ
64void *
65inner_main (void *unused)
01be513e
NJ
66{
67 pthread_t thread;
68
69 pthread_create (&thread, NULL, &thread_main, NULL);
70 scm_without_guile (do_join, &thread);
71
20181478 72 return NULL; /* dummy */
01be513e
NJ
73}
74
20181478
NJ
75int
76main (int argc, char **argv)
01be513e
NJ
77{
78 scm_with_guile (&inner_main, NULL);
79
80 return 0;
81}