1 /* Copyright (C) 2011, 2013 Free Software Foundation, Inc.
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.
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.
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
19 /* Test whether threads created with `pthread_create' work, and whether
20 a secondary thread can call `scm_with_guile'. (bug #32436). */
33 /* Currently, calling `GC_INIT' from a secondary thread is only
34 supported on some systems, notably Linux-based systems (and not on
35 FreeBSD, for instance.)
37 Up to GC 7.2alpha5, calling `GC_INIT' from a secondary thread would
38 lead to a segfault. This was fixed in BDW-GC on 2011-04-16 by Ivan
39 Maidanski. See <http://thread.gmane.org/gmane.lisp.guile.bugs/5340>
42 #if defined __linux__ \
43 && (GC_VERSION_MAJOR > 7 \
44 || (GC_VERSION_MAJOR == 7 && GC_VERSION_MINOR > 2) \
45 || (GC_VERSION_MAJOR == 7 && GC_VERSION_MINOR == 2 \
46 && GC_ALPHA_VERSION > 5))
49 do_something (void *arg
)
51 scm_list_copy (scm_make_list (scm_from_int (1234), SCM_BOOL_T
));
59 scm_with_guile (do_something
, NULL
);
65 main (int argc
, char *argv
[])
69 for (i
= 0; i
< 77; i
++)
73 pthread_create (&thr
, NULL
, thread
, NULL
);
74 pthread_join (thr
, NULL
);
81 #else /* Linux && GC < 7.2alpha5 */
84 main (int argc
, char *argv
[])