~peter-pearse/ubuntu/natty/guile-1.8/prop001

« back to all changes in this revision

Viewing changes to test-suite/standalone/test-with-guile-module.c

  • Committer: Bazaar Package Importer
  • Author(s): Rob Browning
  • Date: 2008-05-10 12:18:50 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080510121850-mwi7tobbfkat03vr
Tags: 1.8.5+1-1
* Incorporate new upstream stable release.

* Fix gcc 4.3 compilation problems (fixed upstream now).  Thanks to
  Alexander Schmehl <tolimar@debian.org> for the previous, related
  1.8.4+1-2.1 NMU, and to Maximiliano Curia and Daniel Schepler for the
  original patch. (closes: #462384, #466778)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
1
18
#include <pthread.h>
2
19
#include <libguile.h>
3
20
 
4
 
void * thread_inner_main (void * unused);
5
 
void * thread_main (void * unused);
6
 
void * do_join (void * data);
7
 
void * inner_main (void * unused);
 
21
void *thread_inner_main (void *unused);
 
22
void *thread_main (void *unused);
 
23
void *do_join (void *data);
 
24
void *inner_main (void *unused);
8
25
 
9
 
void * thread_inner_main (void * unused)
 
26
void *
 
27
thread_inner_main (void *unused)
10
28
{
11
29
  int argc = 3;
12
 
  char* argv[] = { "guile",
13
 
                   "-c",
14
 
                   "(or (current-module) (exit -1))",
15
 
                   0 };
 
30
  char *argv[] = {
 
31
    "guile",
 
32
    "-c",
 
33
    "(or (current-module) (exit -1))",
 
34
    0
 
35
  };
 
36
 
16
37
  scm_shell (argc, argv);
17
38
 
18
 
  return NULL; /* dummy */
 
39
  return NULL;                  /* dummy */
19
40
}
20
41
 
21
 
void * thread_main (void * unused)
 
42
void *
 
43
thread_main (void *unused)
22
44
{
23
45
  scm_with_guile (&thread_inner_main, NULL);
24
46
 
25
 
  return NULL; /* dummy */
 
47
  return NULL;                  /* dummy */
26
48
}
27
49
 
28
 
void * do_join (void * data)
 
50
void *
 
51
do_join (void *data)
29
52
{
30
 
  pthread_t *thread = (pthread_t *)data;
 
53
  pthread_t *thread = (pthread_t *) data;
31
54
 
32
55
  pthread_join (*thread, NULL);
33
56
 
34
 
  return NULL; /* dummy */
 
57
  return NULL;                  /* dummy */
35
58
}
36
59
 
37
 
void * inner_main (void * unused)
 
60
void *
 
61
inner_main (void *unused)
38
62
{
39
63
  pthread_t thread;
40
64
 
41
65
  pthread_create (&thread, NULL, &thread_main, NULL);
42
66
  scm_without_guile (do_join, &thread);
43
67
 
44
 
  return NULL; /* dummy */
 
68
  return NULL;                  /* dummy */
45
69
}
46
70
 
47
 
int main (int argc, char **argv)
 
71
int
 
72
main (int argc, char **argv)
48
73
{
49
74
  scm_with_guile (&inner_main, NULL);
50
75