Merge branch 'master' into boehm-demers-weiser-gc
authorLudovic Courtès <ludo@gnu.org>
Sun, 14 Dec 2008 19:25:56 +0000 (20:25 +0100)
committerLudovic Courtès <ludo@gnu.org>
Sun, 14 Dec 2008 19:48:15 +0000 (20:48 +0100)
Conflicts:
lib/Makefile.am
libguile/struct.c
libguile/threads.c
m4/gnulib-cache.m4
m4/gnulib-comp.m4

1  2 
configure.in
lib/Makefile.am
libguile/Makefile.am
libguile/async.c
libguile/fports.c
libguile/ports.c
libguile/strings.c
libguile/struct.c
libguile/threads.c
m4/gnulib-cache.m4
m4/gnulib-comp.m4

diff --cc configure.in
Simple merge
diff --cc lib/Makefile.am
@@@ -9,7 -9,7 +9,7 @@@
  # the same distribution terms as the rest of that program.
  #
  # Generated by gnulib-tool.
- # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --aux-dir=build-aux --lgpl --libtool --macro-prefix=gl alloca autobuild extensions strcase strftime
 -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl --libtool --macro-prefix=gl alloca autobuild count-one-bits extensions full-read full-write strcase strftime
++# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl --libtool --macro-prefix=gl alloca autobuild extensions full-read full-write strcase strftime
  
  AUTOMAKE_OPTIONS = 1.5 gnits
  
@@@ -63,6 -64,25 +64,18 @@@ EXTRA_DIST += alloca.in.
  
  ## end   gnulib module alloca-opt
  
 -## begin gnulib module count-one-bits
 -
 -
 -EXTRA_DIST += count-one-bits.h
 -
 -## end   gnulib module count-one-bits
 -
+ ## begin gnulib module full-read
+ libgnu_la_SOURCES += full-read.h full-read.c
+ ## end   gnulib module full-read
+ ## begin gnulib module full-write
+ libgnu_la_SOURCES += full-write.h full-write.c
+ ## end   gnulib module full-write
  ## begin gnulib module link-warning
  
  LINK_WARNING_H=$(top_srcdir)/build-aux/link-warning.h
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -409,9 -449,15 +409,15 @@@ SCM_DEFINE (scm_make_struct, "make-stru
        if (! SCM_LAYOUT_TAILP (SCM_CHAR (last_char)))
          goto bad_tail;
      }
-     
-   SCM_CRITICAL_SECTION_START;
+   /* In guile 1.8.5 and earlier, everything below was covered by a
+      CRITICAL_SECTION lock.  This can lead to deadlocks in garbage
+      collection, since other threads might be holding the heap_mutex, while
+      sleeping on the CRITICAL_SECTION lock.  There does not seem to be any
+      need for a lock on the section below, as it does not access or update
+      any globals, so the critical section has been removed. */
 -  if (SCM_STRUCT_DATA (vtable)[scm_struct_i_flags] & SCM_STRUCTF_ENTITY)
 +  if (c_vtable[scm_struct_i_flags] & SCM_STRUCTF_ENTITY)
      {
        data = scm_alloc_struct (basic_size + tail_elts,
                               scm_struct_entity_n_extra_words,
                             + scm_tc3_struct),
                            (scm_t_bits) data, 0, 0);
  
-   SCM_CRITICAL_SECTION_END;
-   /* In guile 1.8.1 and earlier, the SCM_CRITICAL_SECTION_END above covered
-      also the following scm_struct_init.  But that meant if scm_struct_init
-      finds an invalid type for a "u" field then there's an error throw in a
-      critical section, which results in an abort().  Not sure if we need any
-      protection across scm_struct_init.  The data array contains garbage at
-      this point, but until we return it's not visible to anyone except
-      `gc'.  */
 +  if (c_vtable[scm_struct_i_free])
 +    {
 +      /* Register a finalizer for the newly created instance.  */
 +      GC_finalization_proc prev_finalizer;
 +      GC_PTR prev_finalizer_data;
 +      scm_t_struct_free free_struct =
 +      (scm_t_struct_free)c_vtable[scm_struct_i_free];
 +
 +      GC_REGISTER_FINALIZER_NO_ORDER (SCM2PTR (handle),
 +                                    struct_finalizer_trampoline,
 +                                    free_struct,
 +                                    &prev_finalizer,
 +                                    &prev_finalizer_data);
 +    }
 +
    scm_struct_init (handle, layout, data, tail_elts, init);
  
    return handle;
@@@ -460,14 -483,24 +463,19 @@@ guilify_self_1 (SCM_STACKITEM *base
    t->sleep_mutex = NULL;
    t->sleep_object = SCM_BOOL_F;
    t->sleep_fd = -1;
-   /* XXX - check for errors. */
-   pipe (t->sleep_pipe);
+   if (pipe (t->sleep_pipe) != 0)
+     /* FIXME: Error conditions during the initialization phase are handled
+        gracelessly since public functions such as `scm_init_guile ()'
+        currently have type `void'.  */
+     abort ();
 -  scm_i_pthread_mutex_init (&t->heap_mutex, NULL);
    scm_i_pthread_mutex_init (&t->admin_mutex, NULL);
 -  t->clear_freelists_p = 0;
 -  t->gc_running_p = 0;
 +  t->current_mark_stack_ptr = NULL;
 +  t->current_mark_stack_limit = NULL;
    t->canceled = 0;
    t->exited = 0;
 -
 -  t->freelist = SCM_EOL;
 -  t->freelist2 = SCM_EOL;
 -  SCM_SET_FREELIST_LOC (scm_i_freelist, &t->freelist);
 -  SCM_SET_FREELIST_LOC (scm_i_freelist2, &t->freelist2);
 +  t->guile_mode = 0;
  
    scm_i_pthread_setspecific (scm_i_thread_key, t);
  
  
  
  # Specification in the form of a command-line invocation:
- #   gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --aux-dir=build-aux --lgpl --libtool --macro-prefix=gl alloca autobuild extensions strcase strftime
 -#   gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl --libtool --macro-prefix=gl alloca autobuild count-one-bits extensions full-read full-write strcase strftime
++#   gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl --libtool --macro-prefix=gl alloca autobuild extensions full-read full-write strcase strftime
  
  # Specification in the form of a few gnulib-tool.m4 macro invocations:
  gl_LOCAL_DIR([])
  gl_MODULES([
    alloca
    autobuild
 -  count-one-bits
    extensions
+   full-read
+   full-write
    strcase
    strftime
  ])
@@@ -47,6 -47,11 +47,9 @@@ LTALLOCA=`echo "$ALLOCA" | sed 's/\.[^.
  changequote([, ])dnl
  AC_SUBST([LTALLOCA])
    gl_FUNC_ALLOCA
 -  gl_COUNT_ONE_BITS
 -  gl_INLINE
+   gl_SAFE_READ
+   gl_SAFE_WRITE
+   gt_TYPE_SSIZE_T
    AM_STDBOOL_H
    gl_STRCASE
    gl_FUNC_GNU_STRFTIME
@@@ -185,7 -193,15 +191,14 @@@ AC_DEFUN([gl_FILE_LIST], 
    build-aux/link-warning.h
    lib/alloca.c
    lib/alloca.in.h
-   lib/dummy.c
 -  lib/count-one-bits.h
+   lib/full-read.c
+   lib/full-read.h
+   lib/full-write.c
+   lib/full-write.h
+   lib/safe-read.c
+   lib/safe-read.h
+   lib/safe-write.c
+   lib/safe-write.h
    lib/stdbool.in.h
    lib/strcasecmp.c
    lib/strftime.c
    lib/strncasecmp.c
    lib/time.in.h
    lib/time_r.c
+   lib/unistd.in.h
+   lib/verify.h
    lib/wchar.in.h
+   lib/write.c
    m4/alloca.m4
    m4/autobuild.m4
 -  m4/count-one-bits.m4
    m4/extensions.m4
    m4/gnulib-common.m4
    m4/include_next.m4
 -  m4/inline.m4
    m4/mbstate_t.m4
+   m4/safe-read.m4
+   m4/safe-write.m4
+   m4/ssize_t.m4
    m4/stdbool.m4
    m4/strcase.m4
    m4/strftime.m4