guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-208-g4a235


From: Ludovic Courtès
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-208-g4a23562
Date: Mon, 25 Apr 2011 14:45:58 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=4a235623391dd0d3d46f87dcf00d152e1787c191

The branch, stable-2.0 has been updated
       via  4a235623391dd0d3d46f87dcf00d152e1787c191 (commit)
       via  912308835dd0d3af61976cf1a4c19b60cb348b68 (commit)
      from  96128014bfaabe9e123c4f4928ce4c20427eaa53 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4a235623391dd0d3d46f87dcf00d152e1787c191
Author: Ludovic Courtès <address@hidden>
Date:   Fri Apr 22 12:29:50 2011 +0200

    Add pthread-related tests.
    
    * test-suite/standalone/Makefile.am (test_scm_spawn_thread_CFLAGS,
      test_scm_spawn_thread_LDADD, test_pthread_create_CFLAGS,
      test_pthread_create_LDADD, test_pthread_create_secondary_CFLAGS,
      test_pthread_create_secondary_LDADD): New variables.
      (check_PROGRAMS)[BUILD_PTHREAD_SUPPORT]: Add `test-scm-spawn-thread',
      `test-pthread_create', `test-pthread_create-secondary'.
      (TESTS)[BUILD_PTHREAD_SUPPORT]: Likewise.
    
    * test-suite/standalone/test-scm-spawn-thread.c,
      test-suite/standalone/test-pthread-create.c,
      test-suite/standalone/test-pthread-create-secondary.c: New files.

commit 912308835dd0d3af61976cf1a4c19b60cb348b68
Author: Ludovic Courtès <address@hidden>
Date:   Mon Apr 25 16:44:54 2011 +0200

    Make `scm_i_ensure_signal_delivery_thread' call in Guile mode.
    
    * libguile/threads.c (on_thread_exit): Move
      `scm_i_ensure_signal_delivery_thread' call...
      (do_thread_exit): ... here.

-----------------------------------------------------------------------

Summary of changes:
 .gitignore                                         |    3 +
 libguile/threads.c                                 |    8 +-
 test-suite/standalone/Makefile.am                  |   15 ++++
 .../standalone/test-pthread-create-secondary.c     |   85 ++++++++++++++++++++
 ...t-scm-take-u8vector.c => test-pthread-create.c} |   56 ++++++-------
 ...scm-take-u8vector.c => test-scm-spawn-thread.c} |   55 ++++++-------
 6 files changed, 160 insertions(+), 62 deletions(-)
 create mode 100644 test-suite/standalone/test-pthread-create-secondary.c
 copy test-suite/standalone/{test-scm-take-u8vector.c => test-pthread-create.c} 
(57%)
 copy test-suite/standalone/{test-scm-take-u8vector.c => 
test-scm-spawn-thread.c} (52%)

diff --git a/.gitignore b/.gitignore
index f24e589..a0eeeca 100644
--- a/.gitignore
+++ b/.gitignore
@@ -139,3 +139,6 @@ INSTALL
 /.sc-start-*
 /lib/math.h
 /lib/sys/time.h
+/test-suite/standalone/test-scm-spawn-thread
+/test-suite/standalone/test-pthread-create
+/test-suite/standalone/test-pthread-create-secondary
diff --git a/libguile/threads.c b/libguile/threads.c
index 66869e7..4de8193 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -613,6 +613,10 @@ do_thread_exit (void *v)
 {
   scm_i_thread *t = (scm_i_thread *) v;
 
+  /* Ensure the signal handling thread has been launched, because we might be
+     shutting it down.  This needs to be done in Guile mode.  */
+  scm_i_ensure_signal_delivery_thread ();
+
   if (!scm_is_false (t->cleanup_handler))
     {
       SCM ptr = t->cleanup_handler;
@@ -687,10 +691,6 @@ on_thread_exit (void *v)
      case but it doesn't hurt to be consistent.  */
   scm_i_pthread_setspecific (scm_i_thread_key, t);
 
-  /* Ensure the signal handling thread has been launched, because we might be
-     shutting it down.  */
-  scm_i_ensure_signal_delivery_thread ();
-
   /* Scheme-level thread finalizers and other cleanup needs to happen in
      guile mode.  */
   GC_call_with_stack_base (do_thread_exit_trampoline, t);
diff --git a/test-suite/standalone/Makefile.am 
b/test-suite/standalone/Makefile.am
index b21edd2..cf1fc4f 100644
--- a/test-suite/standalone/Makefile.am
+++ b/test-suite/standalone/Makefile.am
@@ -198,6 +198,21 @@ test_scm_with_guile_LDADD = $(LIBGUILE_LDADD)
 check_PROGRAMS += test-scm-with-guile
 TESTS += test-scm-with-guile
 
+test_scm_spawn_thread_CFLAGS = ${test_cflags}
+test_scm_spawn_thread_LDADD = $(LIBGUILE_LDADD)
+check_PROGRAMS += test-scm-spawn-thread
+TESTS += test-scm-spawn-thread
+
+test_pthread_create_CFLAGS = ${test_cflags}
+test_pthread_create_LDADD = $(LIBGUILE_LDADD)
+check_PROGRAMS += test-pthread-create
+TESTS += test-pthread-create
+
+test_pthread_create_secondary_CFLAGS = ${test_cflags} $(BDW_GC_CFLAGS)
+test_pthread_create_secondary_LDADD = $(LIBGUILE_LDADD)
+check_PROGRAMS += test-pthread-create-secondary
+TESTS += test-pthread-create-secondary
+
 else
 
 EXTRA_DIST += test-with-guile-module.c test-scm-with-guile.c
diff --git a/test-suite/standalone/test-pthread-create-secondary.c 
b/test-suite/standalone/test-pthread-create-secondary.c
new file mode 100644
index 0000000..fe39c2a
--- /dev/null
+++ b/test-suite/standalone/test-pthread-create-secondary.c
@@ -0,0 +1,85 @@
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+/* Test whether threads created with `pthread_create' work, and whether
+   a secondary thread can call `scm_with_guile'. (bug #32436).  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <pthread.h>
+#include <stdlib.h>
+#include <libguile.h>
+
+#include <gc/gc_version.h>
+
+
+/* Up to GC 7.2alpha5, calling `GC_INIT' from a secondary thread would
+   lead to a segfault.  This was fixed in BDW-GC on 2011-04-16 by Ivan
+   Maidanski.  See <http://thread.gmane.org/gmane.lisp.guile.bugs/5340>
+   for details.  */
+
+#if (GC_VERSION_MAJOR > 7)                                     \
+  || ((GC_VERSION_MAJOR == 7) && (GC_VERSION_MINOR > 2))       \
+  || ((GC_VERSION_MAJOR == 7) && (GC_VERSION_MINOR == 2)       \
+      && (GC_ALPHA_VERSION > 5))
+
+static void *
+do_something (void *arg)
+{
+  scm_list_copy (scm_make_list (scm_from_int (1234), SCM_BOOL_T));
+  scm_gc ();
+  return NULL;
+}
+
+static void *
+thread (void *arg)
+{
+  scm_with_guile (do_something, NULL);
+  return NULL;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+  int i;
+
+  for (i = 0; i < 77; i++)
+    {
+      pthread_t thr;
+
+      pthread_create (&thr, NULL, thread, NULL);
+      pthread_join (thr, NULL);
+    }
+
+  return EXIT_SUCCESS;
+}
+
+
+#else /* GC < 7.2 */
+
+int
+main (int argc, char *argv[])
+{
+  /* Skip.  */
+  return 77;
+}
+
+#endif /* GC < 7.2 */
diff --git a/test-suite/standalone/test-scm-take-u8vector.c 
b/test-suite/standalone/test-pthread-create.c
similarity index 57%
copy from test-suite/standalone/test-scm-take-u8vector.c
copy to test-suite/standalone/test-pthread-create.c
index fff3af4..8d9617b 100644
--- a/test-suite/standalone/test-scm-take-u8vector.c
+++ b/test-suite/standalone/test-pthread-create.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2011 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -16,50 +16,48 @@
  * 02110-1301 USA
  */
 
-/* Make sure `scm_take_u8vector ()' returns a u8vector that actually uses the
-   provided storage.  */
-
+/* Test whether threads created with `pthread_create' work (bug #32436)
+   when then main thread is the one that initializes Guile.  */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
-#include <libguile.h>
-
+#include <pthread.h>
 #include <stdlib.h>
+#include <libguile.h>
 
-
 static void *
-do_test (void *result)
+do_something (void *arg)
 {
-#define LEN 123
-  SCM u8v;
-  scm_t_uint8 *data;
-  scm_t_array_handle handle;
-
-  data = scm_malloc (LEN);
-  u8v = scm_take_u8vector (data, LEN);
-
-  scm_array_get_handle (u8v, &handle);
-
-  if (scm_array_handle_u8_writable_elements (&handle) == data
-      && scm_array_handle_u8_elements (&handle) == data)
-    * (int *) result = EXIT_SUCCESS;
-  else
-    * (int *) result = EXIT_FAILURE;
-
-  scm_array_handle_release (&handle);
+  scm_list_copy (scm_make_list (scm_from_int (1234), SCM_BOOL_T));
+  scm_gc ();
+  return NULL;
+}
 
+static void *
+thread (void *arg)
+{
+  scm_with_guile (do_something, NULL);
   return NULL;
-#undef LEN
 }
 
+
 int
 main (int argc, char *argv[])
 {
-  int result;
+  int i;
+  pthread_t thr;
+
+  scm_init_guile ();
+
+  do_something (NULL);
 
-  scm_with_guile (do_test, &result);
+  for (i = 0; i < 77; i++)
+    {
+      pthread_create (&thr, NULL, thread, NULL);
+      pthread_join (thr, NULL);
+    }
 
-  return result;
+  return EXIT_SUCCESS;
 }
diff --git a/test-suite/standalone/test-scm-take-u8vector.c 
b/test-suite/standalone/test-scm-spawn-thread.c
similarity index 52%
copy from test-suite/standalone/test-scm-take-u8vector.c
copy to test-suite/standalone/test-scm-spawn-thread.c
index fff3af4..b632ab0 100644
--- a/test-suite/standalone/test-scm-take-u8vector.c
+++ b/test-suite/standalone/test-scm-spawn-thread.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2011 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -16,9 +16,9 @@
  * 02110-1301 USA
  */
 
-/* Make sure `scm_take_u8vector ()' returns a u8vector that actually uses the
-   provided storage.  */
-
+/* Test whether a thread created with `scm_spawn_thread' can be joined.
+   See <http://thread.gmane.org/gmane.lisp.guile.devel/11804> for the
+   original report.  */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -26,40 +26,37 @@
 
 #include <libguile.h>
 
+#include <time.h>
 #include <stdlib.h>
 
-
-static void *
-do_test (void *result)
+static SCM
+thread_main (void *data)
 {
-#define LEN 123
-  SCM u8v;
-  scm_t_uint8 *data;
-  scm_t_array_handle handle;
-
-  data = scm_malloc (LEN);
-  u8v = scm_take_u8vector (data, LEN);
-
-  scm_array_get_handle (u8v, &handle);
+  return SCM_BOOL_T;
+}
 
-  if (scm_array_handle_u8_writable_elements (&handle) == data
-      && scm_array_handle_u8_elements (&handle) == data)
-    * (int *) result = EXIT_SUCCESS;
-  else
-    * (int *) result = EXIT_FAILURE;
+static SCM
+thread_handler (void *data, SCM key, SCM args)
+{
+  return SCM_BOOL_T;
+}
 
-  scm_array_handle_release (&handle);
+static void *
+inner_main (void *data)
+{
+  SCM thread, timeout;
 
-  return NULL;
-#undef LEN
+  thread = scm_spawn_thread (thread_main, 0, thread_handler, 0);
+  timeout = scm_from_unsigned_integer (time (NULL) + 10);
+  return (void *) scm_join_thread_timed (thread, timeout, SCM_BOOL_F);
 }
 
+
 int
-main (int argc, char *argv[])
+main (int argc, char **argv)
 {
-  int result;
-
-  scm_with_guile (do_test, &result);
+  SCM result;
 
-  return result;
+  result = PTR2SCM (scm_with_guile (inner_main, 0));
+  return scm_is_true (result) ? EXIT_SUCCESS : EXIT_FAILURE;
 }


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]