Merge commit 'a7bbba05838cabe2294f498e7008e1c51db6d664'
authorAndy Wingo <wingo@pobox.com>
Thu, 22 Jan 2015 12:04:11 +0000 (13:04 +0100)
committerAndy Wingo <wingo@pobox.com>
Thu, 22 Jan 2015 12:04:11 +0000 (13:04 +0100)
1  2 
configure.ac
libguile/init.c
libguile/load.c

diff --combined configure.ac
@@@ -29,7 -29,7 +29,7 @@@ Floor, Boston, MA 02110-1301, USA
  AC_PREREQ(2.61)
  
  AC_INIT([GNU Guile],
 -        m4_esyscmd([build-aux/git-version-gen --match v2.0.\* .tarball-version]),
 +        m4_esyscmd([build-aux/git-version-gen --match  v2.\[12\].\* .tarball-version]),
          [bug-guile@gnu.org])
  AC_CONFIG_AUX_DIR([build-aux])
  AC_CONFIG_MACRO_DIR([m4])
@@@ -751,9 -751,8 +751,8 @@@ AC_CHECK_HEADERS([assert.h crt_externs.
  #   truncate - not in mingw
  #   isblank - available as a GNU extension or in C99
  #   _NSGetEnviron - Darwin specific
- #   strcoll_l, newlocale - GNU extensions (glibc), also available on Darwin
+ #   strcoll_l, newlocale, uselocale, utimensat - POSIX.1-2008
  #   fork - unavailable on Windows
- #   utimensat - posix.1-2008
  #   sched_getaffinity, sched_setaffinity - GNU extensions (glibc)
  #   sendfile - non-POSIX, found in glibc
  #
@@@ -766,7 -765,7 +765,7 @@@ AC_CHECK_FUNCS([DINFINITY DQNAN cexp ch
    strdup system usleep atexit on_exit chown link fcntl ttyname getpwent       \
    getgrent kill getppid getpgrp fork setitimer getitimer strchr strcmp        \
    index bcopy memcpy rindex truncate unsetenv isblank _NSGetEnviron   \
-   strcoll strcoll_l newlocale utimensat sched_getaffinity             \
+   strcoll strcoll_l newlocale uselocale utimensat sched_getaffinity   \
    sched_setaffinity sendfile])
  
  # Reasons for testing:
@@@ -1247,17 -1246,41 +1246,17 @@@ main (int argc, char **argv
  # Boehm's GC library
  #
  #--------------------------------------------------------------------
 -PKG_CHECK_MODULES([BDW_GC], [bdw-gc])
 +PKG_CHECK_MODULES([BDW_GC], [bdw-gc >= 7.2])
  
  save_LIBS="$LIBS"
  LIBS="$BDW_GC_LIBS $LIBS"
  CFLAGS="$BDW_GC_CFLAGS $CFLAGS"
  
 -AC_CHECK_FUNCS([GC_do_blocking GC_call_with_gc_active GC_pthread_exit \
 -  GC_pthread_cancel GC_allow_register_threads GC_pthread_sigmask      \
 -  GC_set_start_callback GC_get_heap_usage_safe                                \
 -  GC_get_free_space_divisor GC_gcollect_and_unmap GC_get_unmapped_bytes       \
 -  GC_set_finalizer_notifier GC_set_finalize_on_demand                 \
 -  GC_set_all_interior_pointers GC_get_gc_no GC_set_java_finalization])
 -
 -# Though the `GC_do_blocking ()' symbol is present in GC 7.1, it is not
 -# declared, and has a different type (returning void instead of
 -# void*).
 -AC_CHECK_DECL([GC_do_blocking],
 -  [AC_DEFINE([HAVE_DECL_GC_DO_BLOCKING], [1],
 -    [Define this if the `GC_do_blocking ()' function is declared])],
 -  [],
 -  [#include <gc/gc.h>])
 -
 -# `GC_fn_type' is not available in GC 7.1 and earlier.
 -AC_CHECK_TYPE([GC_fn_type],
 -  [AC_DEFINE([HAVE_GC_FN_TYPE], [1],
 -    [Define this if the `GC_fn_type' type is available.])],
 -  [],
 -  [#include <gc/gc.h>])
 +# Functions that might not be defined, depending on configuration.
 +AC_CHECK_FUNCS([GC_pthread_exit GC_pthread_cancel GC_pthread_sigmask])
  
 -# `GC_stack_base' is not available in GC 7.1 and earlier.
 -AC_CHECK_TYPE([struct GC_stack_base],
 -  [AC_DEFINE([HAVE_GC_STACK_BASE], [1],
 -    [Define this if the `GC_stack_base' type is available.])],
 -  [],
 -  [#include <gc/gc.h>])
 +# Functions from GC 7.3.
 +AC_CHECK_FUNCS([GC_move_disappearing_link])
  
  LIBS="$save_LIBS"
  
@@@ -1647,8 -1670,8 +1646,8 @@@ AC_CONFIG_FILES(
    module/Makefile
  ])
  
 -AC_CONFIG_FILES([meta/guile-2.0.pc])
 -AC_CONFIG_FILES([meta/guile-2.0-uninstalled.pc])
 +AC_CONFIG_FILES([meta/guile-2.2.pc])
 +AC_CONFIG_FILES([meta/guile-2.2-uninstalled.pc])
  
  GUILE_CONFIG_SCRIPT([check-guile])
  GUILE_CONFIG_SCRIPT([benchmark-guile])
diff --combined libguile/init.c
@@@ -1,6 -1,4 +1,4 @@@
- /* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-  *   2004, 2006, 2009, 2010, 2011, 2012, 2013,
-  *   2014 Free Software Foundation, Inc.
+ /* Copyright (C) 1995-2004, 2006, 2009-2014 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
@@@ -65,6 -63,7 +63,6 @@@
  #include "libguile/fports.h"
  #include "libguile/frames.h"
  #include "libguile/gc.h"
 -#include "libguile/gdbint.h"
  #include "libguile/generalized-arrays.h"
  #include "libguile/generalized-vectors.h"
  #include "libguile/goops.h"
@@@ -85,7 -84,7 +83,7 @@@
  #include "libguile/modules.h"
  #include "libguile/net_db.h"
  #include "libguile/numbers.h"
 -#include "libguile/objcodes.h"
 +#include "libguile/loader.h"
  #include "libguile/objprop.h"
  #include "libguile/options.h"
  #include "libguile/pairs.h"
  #include "libguile/version.h"
  #include "libguile/vm.h"
  #include "libguile/vports.h"
 -#include "libguile/weaks.h"
  #include "libguile/guardians.h"
  #include "libguile/extensions.h"
  #include "libguile/uniform.h"
@@@ -164,7 -164,8 +162,7 @@@ stream_body (void *data
  {
    stream_body_data *body_data = (stream_body_data *) data;
    SCM port = scm_fdes_to_port (body_data->fdes, body_data->mode, SCM_BOOL_F);
 -
 -  SCM_REVEALED (port) = 1;
 +  scm_set_port_revealed_x (port, SCM_INUM1);
    return port;
  }
  
@@@ -222,7 -223,6 +220,7 @@@ scm_init_standard_ports (
      (scm_standard_stream_to_port (1, isatty (1) ? "w0" : "w"));
    scm_set_current_error_port
      (scm_standard_stream_to_port (2, isatty (2) ? "w0" : "w"));
 +  scm_set_current_warning_port (scm_current_error_port ());
  }
  
  
@@@ -312,7 -312,9 +310,9 @@@ scm_boot_guile (int argc, char ** argv
  
    /* On Windows, convert backslashes in argv[0] to forward
       slashes.  */
-   scm_i_mirror_backslashes (argv[0]);
+   if (argc > 0)
+     scm_i_mirror_backslashes (argv[0]);
    c.main_func = main_func;
    c.closure = closure;
    c.argc = argc;
@@@ -385,16 -387,16 +385,16 @@@ scm_i_init_guile (void *base
  
    scm_storage_prehistory ();
    scm_threads_prehistory (base);  /* requires storage_prehistory */
 -  scm_weaks_prehistory ();        /* requires storage_prehistory */
 +  scm_weak_table_prehistory ();        /* requires storage_prehistory */
  #ifdef GUILE_DEBUG_MALLOC
    scm_debug_malloc_prehistory ();
  #endif
 -  scm_symbols_prehistory ();      /* requires weaks_prehistory */
 +  scm_symbols_prehistory ();      /* requires weak_table_prehistory */
    scm_modules_prehistory ();
    scm_init_array_handle ();
    scm_bootstrap_bytevectors ();   /* Requires array-handle */
    scm_bootstrap_instructions ();
 -  scm_bootstrap_objcodes ();
 +  scm_bootstrap_loader ();
    scm_bootstrap_programs ();
    scm_bootstrap_vm ();
    scm_register_r6rs_ports ();
    scm_init_stime ();
    scm_init_gc ();             /* Requires hooks and `get_internal_run_time' */
    scm_init_gc_protect_object ();  /* requires threads_prehistory */
 -  scm_init_gdbint ();           /* Requires strports, gc_protect_object */
    scm_init_gettext ();
    scm_init_ioext ();
    scm_init_keywords ();    /* Requires smob_prehistory */
    scm_init_throw ();    /* Requires smob_prehistory */
    scm_init_trees ();
    scm_init_version ();
 -  scm_init_weaks ();
 +  scm_init_weak_set ();
 +  scm_init_weak_table ();
 +  scm_init_weak_vectors ();
    scm_init_guardians (); /* requires smob_prehistory */
    scm_init_vports ();
    scm_init_standard_ports ();  /* Requires fports */
  
    scm_initialized_p = 1;
  
 -#ifdef STACK_CHECKING
    scm_stack_checking_enabled_p = SCM_STACK_CHECKING_P;
 -#endif
  
    scm_init_rdelim ();
    scm_init_rw ();
    /* Capture the dynamic state after loading boot-9, so that new threads end up
       in the guile-user module. */
    scm_init_threads_default_dynamic_state ();
 +
 +  /* Finally, cause finalizers to run in a separate thread.  */
 +  scm_init_finalizer_thread ();
  }
  
  /*
diff --combined libguile/load.c
@@@ -28,6 -28,7 +28,6 @@@
  #include <stdio.h>
  
  #include "libguile/_scm.h"
 -#include "libguile/private-gc.h" /* scm_getenv_int */
  #include "libguile/libpath.h"
  #include "libguile/fports.h"
  #include "libguile/read.h"
@@@ -402,24 -403,24 +402,24 @@@ SCM scm_listofnullstr
  /* Utility functions for assembling C strings in a buffer.
   */
  
- struct stringbuf {
+ struct stringbuf
+ {
    char *buf, *ptr;
    size_t buf_len;
  };
  
- static void
- stringbuf_free (void *data)
- {
-   struct stringbuf *buf = (struct stringbuf *)data;
-   free (buf->buf);
- }
  static void
  stringbuf_grow (struct stringbuf *buf)
  {
-   size_t ptroff = buf->ptr - buf->buf;
-   buf->buf_len *= 2; 
-   buf->buf = scm_realloc (buf->buf, buf->buf_len);
+   size_t ptroff, prev_len;
+   void *prev_buf = buf->buf;
+   prev_len = buf->buf_len;
+   ptroff = buf->ptr - buf->buf;
+   buf->buf_len *= 2;
+   buf->buf = scm_gc_malloc_pointerless (buf->buf_len, "search-path");
+   memcpy (buf->buf, prev_buf, prev_len);
    buf->ptr = buf->buf + ptroff;
  }
  
@@@ -557,6 -558,7 +557,7 @@@ search_path (SCM path, SCM filename, SC
    char *filename_chars;
    size_t filename_len;
    SCM result = SCM_BOOL_F;
+   char initial_buffer[256];
  
    if (scm_ilength (path) < 0)
      scm_misc_error ("%search-path", "path is not a proper list: ~a",
    if (scm_is_null (extensions))
      extensions = scm_listofnullstr;
  
-   buf.buf_len = 512;
-   buf.buf = scm_malloc (buf.buf_len);
-   scm_dynwind_unwind_handler (stringbuf_free, &buf, SCM_F_WIND_EXPLICITLY);
+   buf.buf_len = sizeof initial_buffer;
+   buf.buf = initial_buffer;
  
    /* Try every path element.
     */
@@@ -776,11 -777,11 +776,11 @@@ compiled_is_fresh (SCM full_filename, S
    else
      {
        compiled_is_newer = 0;
 -      scm_puts (";;; note: source file ", scm_current_error_port ());
 +      scm_puts_unlocked (";;; note: source file ", scm_current_error_port ());
        scm_display (full_filename, scm_current_error_port ());
 -      scm_puts ("\n;;;       newer than compiled ", scm_current_error_port ());
 +      scm_puts_unlocked ("\n;;;       newer than compiled ", scm_current_error_port ());
        scm_display (compiled_filename, scm_current_error_port ());
 -      scm_puts ("\n", scm_current_error_port ());
 +      scm_puts_unlocked ("\n", scm_current_error_port ());
      }
  
    return compiled_is_newer;
@@@ -795,10 -796,10 +795,10 @@@ SCM_SYMBOL (sym_auto_compilation_option
  static SCM
  do_try_auto_compile (void *data)
  {
 -  SCM source = PTR2SCM (data);
 +  SCM source = SCM_PACK_POINTER (data);
    SCM comp_mod, compile_file;
  
 -  scm_puts (";;; compiling ", scm_current_error_port ());
 +  scm_puts_unlocked (";;; compiling ", scm_current_error_port ());
    scm_display (source, scm_current_error_port ());
    scm_newline (scm_current_error_port ());
  
        /* Assume `*current-warning-prefix*' has an appropriate value.  */
        res = scm_call_n (scm_variable_ref (compile_file), args, 5);
  
 -      scm_puts (";;; compiled ", scm_current_error_port ());
 +      scm_puts_unlocked (";;; compiled ", scm_current_error_port ());
        scm_display (res, scm_current_error_port ());
        scm_newline (scm_current_error_port ());
        return res;
      }
    else
      {
 -      scm_puts (";;; it seems ", scm_current_error_port ());
 +      scm_puts_unlocked (";;; it seems ", scm_current_error_port ());
        scm_display (source, scm_current_error_port ());
 -      scm_puts ("\n;;; is part of the compiler; skipping auto-compilation\n",
 +      scm_puts_unlocked ("\n;;; is part of the compiler; skipping auto-compilation\n",
                  scm_current_error_port ());
        return SCM_BOOL_F;
      }
  static SCM
  auto_compile_catch_handler (void *data, SCM tag, SCM throw_args)
  {
 -  SCM source = PTR2SCM (data);
 +  SCM source = SCM_PACK_POINTER (data);
    SCM oport, lines;
  
    oport = scm_open_output_string ();
    scm_print_exception (oport, SCM_BOOL_F, tag, throw_args);
  
 -  scm_puts (";;; WARNING: compilation of ", scm_current_warning_port ());
 +  scm_puts_unlocked (";;; WARNING: compilation of ", scm_current_warning_port ());
    scm_display (source, scm_current_warning_port ());
 -  scm_puts (" failed:\n", scm_current_warning_port ());
 +  scm_puts_unlocked (" failed:\n", scm_current_warning_port ());
  
    lines = scm_string_split (scm_get_output_string (oport),
                              SCM_MAKE_CHAR ('\n'));
    for (; scm_is_pair (lines); lines = scm_cdr (lines))
      if (scm_c_string_length (scm_car (lines)))
        {
 -        scm_puts (";;; ", scm_current_warning_port ());
 +        scm_puts_unlocked (";;; ", scm_current_warning_port ());
          scm_display (scm_car (lines), scm_current_warning_port ());
          scm_newline (scm_current_warning_port ());
        }
@@@ -878,7 -879,7 +878,7 @@@ SCM_DEFINE (scm_sys_warn_auto_compilati
  
    if (!message_shown)
      {
 -      scm_puts (";;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0\n"
 +      scm_puts_unlocked (";;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0\n"
                  ";;;       or pass the --no-auto-compile argument to disable.\n",
                  scm_current_warning_port ());
        message_shown = 1;
@@@ -897,9 -898,9 +897,9 @@@ scm_try_auto_compile (SCM source
    scm_sys_warn_auto_compilation_enabled ();
    return scm_c_catch (SCM_BOOL_T,
                        do_try_auto_compile,
 -                      SCM2PTR (source),
 +                      SCM_UNPACK_POINTER (source),
                        auto_compile_catch_handler,
 -                      SCM2PTR (source),
 +                      SCM_UNPACK_POINTER (source),
                        NULL, NULL);
  }
  
@@@ -1062,7 -1063,7 +1062,7 @@@ SCM_DEFINE (scm_primitive_load_path, "p
        if (stat_ret == 0 && compiled_is_fresh (full_filename, fallback,
                                                &stat_source, &stat_compiled))
          {
 -          scm_puts (";;; found fresh local cache at ", scm_current_warning_port ());
 +          scm_puts_unlocked (";;; found fresh local cache at ", scm_current_warning_port ());
            scm_display (fallback, scm_current_warning_port ());
            scm_newline (scm_current_warning_port ());
            return scm_load_compiled_with_vm (fallback);
@@@ -1127,7 -1128,7 +1127,7 @@@ init_build_info (
  
    for (i = 0; i < (sizeof (info) / sizeof (info[0])); i++)
      {
 -      SCM key = scm_from_locale_symbol (info[i].name);
 +      SCM key = scm_from_utf8_symbol (info[i].name);
        SCM val = scm_from_locale_string (info[i].value);
        *loc = scm_acons (key, val, *loc);
      }