[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG=1 on x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG=1’ (on 
x86_64-linux) has changed from "Success" to "Failed with output".  For details, 
see

  https://hydra.nixos.org/build/39520436

This may be due to 3 commits by Andy Wingo  or Christopher 
Allan Webber .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_clang.i686-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_clang.i686-linux’ has changed 
from "Success" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/39520431

This may be due to 3 commits by Andy Wingo  or Christopher 
Allan Webber .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build.i686-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build.i686-linux’ has changed from 
"Success" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/39520438

This may be due to 3 commits by Andy Wingo  or Christopher 
Allan Webber .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_without_threads.i686-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_without_threads.i686-linux’ has 
changed from "Success" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/39520429

This may be due to 3 commits by Andy Wingo  or Christopher 
Allan Webber .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_enable_guile_debug on x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_enable_guile_debug’ (on 
x86_64-linux) has changed from "Success" to "Failed with output".  For details, 
see

  https://hydra.nixos.org/build/39520433

This may be due to 3 commits by Andy Wingo  or Christopher 
Allan Webber .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_clang.x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_clang.x86_64-linux’ has changed 
from "Success" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/39520430

This may be due to 3 commits by Andy Wingo  or Christopher 
Allan Webber .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build.x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build.x86_64-linux’ has changed from 
"Success" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/39520424

This may be due to 3 commits by Andy Wingo  or Christopher 
Allan Webber .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_without_threads.x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_without_threads.x86_64-linux’ 
has changed from "Success" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/39520432

This may be due to 3 commits by Andy Wingo  or Christopher 
Allan Webber .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG_TYPING_STRICTNESS=2 on x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job 
‘gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG_TYPING_STRICTNESS=2’ (on 
x86_64-linux) has changed from "Success" to "Failed with output".  For details, 
see

  https://hydra.nixos.org/build/39520422

This may be due to 3 commits by Andy Wingo  or Christopher 
Allan Webber .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] 01/02: Only ptob->close() after read/write finish

2016-08-31 Thread Andy Wingo
wingo pushed a commit to branch master
in repository guile.

commit b8a53b98b33dc89b0ed526ca66232655d24f2ce8
Author: Andy Wingo 
Date:   Wed Aug 31 19:00:27 2016 +0200

Only ptob->close() after read/write finish

* libguile/Makefile.am (noinst_HEADERS): Add atomics-internal.h.
* libguile/atomics-internal.h: New file.
* libguile/ports-internal.h (refcount): New member.
* libguile/ports.c (release_port, scm_dynwind_acquire_port): New
  facility for acquiring a port within a dynwind.
  (scm_port_poll, scm_i_read_bytes, scm_setvbuf, scm_end_input)
  (scm_i_write_bytes, scm_char_ready_p, scm_seek)
  (scm_truncate_file, trampoline_to_c_read)
  (trampoline_to_c_write): Acquire port.
  (scm_c_make_port_with_encoding): Init refcount to 1.
  (scm_close_port): Release port.
* doc/ref/api-io.texi (I/O Extensions): Add documentation
---
 doc/ref/api-io.texi |7 +++
 libguile/Makefile.am|1 +
 libguile/atomics-internal.h |   85 ++
 libguile/ports-internal.h   |   13 +++-
 libguile/ports.c|  138 +++
 5 files changed, 216 insertions(+), 28 deletions(-)

diff --git a/doc/ref/api-io.texi b/doc/ref/api-io.texi
index e4e4f36..9facb38 100644
--- a/doc/ref/api-io.texi
+++ b/doc/ref/api-io.texi
@@ -1694,6 +1694,13 @@ operating system inform Guile about the appropriate 
buffer sizes for the
 particular file opened by the port.
 @end table
 
+Note that calls to all of these methods can proceed in parallel and
+concurrently and from any thread up until the point that the port is
+closed.  The call to @code{close} will happen when no other method is
+running, and no method will be called after the @code{close} method is
+called.  If your port implementation needs mutual exclusion to prevent
+concurrency, it is responsible for locking appropriately.
+
 @node Non-Blocking I/O
 @subsection Non-Blocking I/O
 
diff --git a/libguile/Makefile.am b/libguile/Makefile.am
index 8161ade..ba6be20 100644
--- a/libguile/Makefile.am
+++ b/libguile/Makefile.am
@@ -507,6 +507,7 @@ noinst_HEADERS = conv-integer.i.c conv-uinteger.i.c 
\
  elf.h \
  srfi-14.i.c   \
  quicksort.i.c  \
+ atomics-internal.h\
  posix-w32.h   \
 private-options.h ports-internal.h
 
diff --git a/libguile/atomics-internal.h b/libguile/atomics-internal.h
new file mode 100644
index 000..1859daa
--- /dev/null
+++ b/libguile/atomics-internal.h
@@ -0,0 +1,85 @@
+#ifndef SCM_ATOMICS_INTERNAL_H
+#define SCM_ATOMICS_INTERNAL_H
+
+/* Copyright (C) 2016
+ * 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
+ */
+
+
+
+
+#include 
+
+
+
+
+#define HAVE_C11_ATOMICS (__STDC_VERSION__ >= 201112L && 
!defined(__STDC_NO_ATOMICS__))
+
+#if HAVE_C11_ATOMICS
+
+#include 
+static inline uint32_t
+scm_atomic_subtract_uint32 (uint32_t *obj, uint32_t arg)
+{
+  return atomic_fetch_sub (obj, arg);
+}
+static inline _Bool
+scm_atomic_compare_and_swap_uint32 (uint32_t *obj, uint32_t *expected,
+uint32_t desired)
+{
+  return atomic_compare_exchange_weak (obj, expected, desired);
+}
+
+#else /* HAVE_C11_ATOMICS */
+
+/* Fallback implementation using locks.  */
+#include "libguile/threads.h"
+static scm_i_pthread_mutex_t atomics_lock = SCM_I_PTHREAD_MUTEX_INITIALIZER;
+static inline uint32_t
+scm_atomic_subtract_uint32 (uint32_t *obj, uint32_t arg)
+{
+  uint32_t ret;
+  scm_i_pthread_mutex_lock (&atomics_lock);
+  ret = *obj;
+  *obj -= arg;
+  scm_i_pthread_mutex_unlock (&atomics_lock);
+  return ret;
+}
+static inline int
+scm_atomic_compare_and_swap_uint32 (uint32_t *obj, uint32_t *expected,
+uint32_t desired)
+{
+  int ret;
+  scm_i_pthread_mutex_lock (&atomics_lock);
+  if (*obj == *expected)
+{
+  *obj = desired;
+  ret = 1;
+}
+  else
+{
+  *expected = *obj;
+  ret = 0;
+}
+  scm_i_pthread_mutex_unlock (&atomics_lock);
+  return ret;
+}
+
+#endif /* 

[Guile-commits] 02/02: GC of non-blocking port does not block

2016-08-31 Thread Andy Wingo
wingo pushed a commit to branch master
in repository guile.

commit b733ca461ce03c6daeadca0f2eb4da13ccdd2930
Author: Andy Wingo 
Date:   Wed Aug 31 19:31:12 2016 +0200

GC of non-blocking port does not block

* libguile/ports.h (SCM_F_PORT_FINALIZING)
  (SCM_PORT_FINALIZING_P, SCM_SET_PORT_FINALIZING): New private
  definitions.
* libguile/ports.c (finalize_port): Set the port-finalizing flag.
  (scm_i_write_bytes): If the port is finalizing but output returned
  EWOULDBLOCK, warn and discard the output.
---
 libguile/ports.c |   27 ++-
 libguile/ports.h |   19 ++-
 2 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/libguile/ports.c b/libguile/ports.c
index 278bbe9..1209b43 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -691,6 +691,7 @@ finalize_port (void *ptr, void *data)
 
   if (SCM_OPENP (port))
 {
+  SCM_SET_PORT_FINALIZING (port);
   scm_internal_catch (SCM_BOOL_T, do_close, ptr,
   scm_handle_by_message_noexit, NULL);
   scm_gc_ports_collected++;
@@ -2797,7 +2798,31 @@ scm_i_write_bytes (SCM port, SCM src, size_t start, 
size_t count)
   size_t ret = ptob->c_write (port, src, start + written, count - written);
 
   if (ret == (size_t) -1)
-port_poll (port, POLLOUT, -1);
+{
+  if (SCM_PORT_FINALIZING_P (port))
+{
+  /* This port is being closed because it became unreachable
+ and was finalized, but it has buffered output, and the
+ resource is not currently writable.  Instead of
+ blocking, discard buffered output and warn.  To avoid
+ this situation, force-output on the port before letting
+ it go!  */
+  scm_puts
+("Warning: Discarding buffered output on non-blocking port\n"
+ " ",
+ scm_current_warning_port ());
+  scm_display (port, scm_current_warning_port());
+  scm_puts
+("\n"
+ " closed by the garbage collector.  To avoid this\n"
+ " behavior and this warning, call `force-output' or\n"
+ " `close-port' on the port before letting go of 
it.\n",
+ scm_current_warning_port ());
+  break;
+}
+  else
+port_poll (port, POLLOUT, -1);
+}
   else
 written += ret;
 }
diff --git a/libguile/ports.h b/libguile/ports.h
index 6fe9ecd..93a1a59 100644
--- a/libguile/ports.h
+++ b/libguile/ports.h
@@ -52,11 +52,14 @@ SCM_INTERNAL SCM scm_i_port_weak_set;
there is a flag indicating whether the port is open or not, and then
some "mode bits": flags indicating whether the port is an input
and/or an output port and how Guile should buffer the port.  */
-#define SCM_OPN(1U<<16) /* Is the port open? */
-#define SCM_RDNG   (1U<<17) /* Is it a readable port? */
-#define SCM_WRTNG  (1U<<18) /* Is it writable? */
-#define SCM_BUF0   (1U<<19) /* Is it unbuffered? */
-#define SCM_BUFLINE (1U<<20) /* Is it line-buffered? */
+#define SCM_OPN(1U<<8) /* Is the port open? */
+#define SCM_RDNG   (1U<<9) /* Is it a readable port? */
+#define SCM_WRTNG  (1U<<10) /* Is it writable? */
+#define SCM_BUF0   (1U<<11) /* Is it unbuffered? */
+#define SCM_BUFLINE (1U<<12) /* Is it line-buffered? */
+#ifdef BUILDING_LIBGUILE
+#define SCM_F_PORT_FINALIZING (1U<<13) /* Port is being closed via GC. */
+#endif
 
 #define SCM_PORTP(x) (SCM_HAS_TYP7 (x, scm_tc7_port))
 #define SCM_OPPORTP(x) (SCM_PORTP (x) && (SCM_CELL_WORD_0 (x) & SCM_OPN))
@@ -68,6 +71,12 @@ SCM_INTERNAL SCM scm_i_port_weak_set;
 #define SCM_CLOSEDP(x) (!SCM_OPENP (x))
 #define SCM_CLR_PORT_OPEN_FLAG(p) \
   SCM_SET_CELL_WORD_0 ((p), SCM_CELL_WORD_0 (p) & ~SCM_OPN)
+#ifdef BUILDING_LIBGUILE
+#define SCM_PORT_FINALIZING_P(x) \
+  (SCM_CELL_WORD_0 (x) & SCM_F_PORT_FINALIZING)
+#define SCM_SET_PORT_FINALIZING(p) \
+  SCM_SET_CELL_WORD_0 ((p), SCM_CELL_WORD_0 (p) | SCM_F_PORT_FINALIZING)
+#endif
 
 typedef struct scm_t_port_type scm_t_port_type;
 typedef struct scm_t_port scm_t_port;



[Guile-commits] branch master updated (cc9e72b -> b733ca4)

2016-08-31 Thread Andy Wingo
wingo pushed a change to branch master
in repository guile.

  from  cc9e72b   Fix example in make-custom-binary-input-port documentation
   new  b8a53b9   Only ptob->close() after read/write finish
   new  b733ca4   GC of non-blocking port does not block

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.


Summary of changes:
 doc/ref/api-io.texi |7 ++
 libguile/Makefile.am|1 +
 libguile/atomics-internal.h |   85 ++
 libguile/ports-internal.h   |   13 +++-
 libguile/ports.c|  165 ---
 libguile/ports.h|   19 +++--
 6 files changed, 256 insertions(+), 34 deletions(-)
 create mode 100644 libguile/atomics-internal.h



[Guile-commits] Success: Hydra job gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG=1 on x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG=1’ (on 
x86_64-linux) has changed from "Failed with output" to "Success".  For details, 
see

  https://hydra.nixos.org/build/39516044

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] Success: Hydra job gnu:guile-master:build_clang.i686-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_clang.i686-linux’ has changed 
from "Failed with output" to "Success".  For details, see

  https://hydra.nixos.org/build/39516032

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] Success: Hydra job gnu:guile-master:build_without_threads.i686-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_without_threads.i686-linux’ has 
changed from "Failed with output" to "Success".  For details, see

  https://hydra.nixos.org/build/39516029

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] Success: Hydra job gnu:guile-master:build.i686-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build.i686-linux’ has changed from 
"Failed with output" to "Success".  For details, see

  https://hydra.nixos.org/build/39516039

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] Success: Hydra job gnu:guile-master:build_clang.x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_clang.x86_64-linux’ has changed 
from "Failed with output" to "Success".  For details, see

  https://hydra.nixos.org/build/39516028

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] Success: Hydra job gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG_TYPING_STRICTNESS=2 on x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job 
‘gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG_TYPING_STRICTNESS=2’ (on 
x86_64-linux) has changed from "Failed with output" to "Success".  For details, 
see

  https://hydra.nixos.org/build/39516043

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] 01/01: Fix example in make-custom-binary-input-port documentation

2016-08-31 Thread Andy Wingo
wingo pushed a commit to branch master
in repository guile.

commit cc9e72bd2b896048af2a65c8af9a57868df4352f
Author: Christopher Allan Webber 
Date:   Thu Aug 11 15:10:19 2016 -0500

Fix example in make-custom-binary-input-port documentation

* doc/ref/api-io.texi (Custom Ports): Add additional argument to example's
  invocation of make-custom-binary-input-port.  Previously had mismatched 
arity
  by missing "closed" argument.
---
 doc/ref/api-io.texi |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/doc/ref/api-io.texi b/doc/ref/api-io.texi
index 76c8db8..e4e4f36 100644
--- a/doc/ref/api-io.texi
+++ b/doc/ref/api-io.texi
@@ -1,7 +1,7 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
 @c Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2007, 2009,
-@c   2010, 2011, 2013  Free Software Foundation, Inc.
+@c   2010, 2011, 2013, 2016  Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
 @node Input and Output
@@ -1278,8 +1278,8 @@ procedure (@pxref{Bytevector Ports}) could be implemented 
as follows:
 (set! position new-position))
 
   (make-custom-binary-input-port "the port" read!
-  get-position
-  set-position!))
+  get-position set-position!
+  #f))
 
 (read (open-bytevector-input-port (string->utf8 "hello")))
 @result{} hello



[Guile-commits] branch master updated (f46cb25 -> cc9e72b)

2016-08-31 Thread Andy Wingo
wingo pushed a change to branch master
in repository guile.

  from  f46cb25   Set rw_random correctly for all custom binary port types
   new  cc9e72b   Fix example in make-custom-binary-input-port documentation

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.


Summary of changes:
 doc/ref/api-io.texi |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)



[Guile-commits] 02/02: Set rw_random correctly for all custom binary port types

2016-08-31 Thread Andy Wingo
wingo pushed a commit to branch master
in repository guile.

commit f46cb25a17fd9b014e2d7ad0b2d27c5dd94688cd
Author: Andy Wingo 
Date:   Wed Aug 31 15:42:51 2016 +0200

Set rw_random correctly for all custom binary port types

* libguile/r6rs-ports.c (custom_binary_port_random_access_p): Rename
  from custom_binary_input_output_port_type, and use for all custom
  binary port types.
---
 libguile/r6rs-ports.c |   23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c
index b52eb85..674d89a 100644
--- a/libguile/r6rs-ports.c
+++ b/libguile/r6rs-ports.c
@@ -193,6 +193,14 @@ struct custom_binary_port {
   SCM close;
 };
 
+static int
+custom_binary_port_random_access_p (SCM port)
+{
+  struct custom_binary_port *stream = (void *) SCM_STREAM (port);
+
+  return scm_is_true (stream->set_position_x);
+}
+
 static scm_t_off
 custom_binary_port_seek (SCM port, scm_t_off offset, int whence)
 #define FUNC_NAME "custom_binary_port_seek"
@@ -336,6 +344,8 @@ initialize_custom_binary_input_ports (void)
custom_binary_input_port_read, NULL);
 
   scm_set_port_seek (custom_binary_input_port_type, custom_binary_port_seek);
+  scm_set_port_random_access_p (custom_binary_input_port_type,
+custom_binary_port_random_access_p);
   scm_set_port_close (custom_binary_input_port_type, custom_binary_port_close);
 }
 
@@ -942,6 +952,8 @@ initialize_custom_binary_output_ports (void)
NULL, custom_binary_output_port_write);
 
   scm_set_port_seek (custom_binary_output_port_type, custom_binary_port_seek);
+  scm_set_port_random_access_p (custom_binary_output_port_type,
+custom_binary_port_random_access_p);
   scm_set_port_close (custom_binary_output_port_type, 
custom_binary_port_close);
 }
 
@@ -1004,15 +1016,6 @@ SCM_DEFINE (scm_make_custom_binary_input_output_port,
 #undef FUNC_NAME
 
 
-static int
-custom_binary_input_output_port_random_access_p (SCM port)
-{
-  struct custom_binary_port *stream = (void *) SCM_STREAM (port);
-
-  return scm_is_true (stream->set_position_x);
-}
-
-
 /* Instantiate the custom binary input_output port type.  */
 static inline void
 initialize_custom_binary_input_output_ports (void)
@@ -1025,7 +1028,7 @@ initialize_custom_binary_input_output_ports (void)
   scm_set_port_seek (custom_binary_input_output_port_type,
  custom_binary_port_seek);
   scm_set_port_random_access_p (custom_binary_input_output_port_type,
-
custom_binary_input_output_port_random_access_p);
+custom_binary_port_random_access_p);
   scm_set_port_close (custom_binary_input_output_port_type,
   custom_binary_port_close);
 }



[Guile-commits] Success: Hydra job gnu:guile-master:build_without_threads.x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_without_threads.x86_64-linux’ 
has changed from "Failed with output" to "Success".  For details, see

  https://hydra.nixos.org/build/39516036

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] branch master updated (9996695 -> f46cb25)

2016-08-31 Thread Andy Wingo
wingo pushed a change to branch master
in repository guile.

  from  9996695   Require C99 to build Guile.
   new  eeb23e7   Avoid flushing buffers for ftell
   new  f46cb25   Set rw_random correctly for all custom binary port types

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.


Summary of changes:
 libguile/ports.c|   14 +++---
 libguile/r6rs-ports.c   |   23 +--
 test-suite/tests/ports.test |8 
 3 files changed, 28 insertions(+), 17 deletions(-)



[Guile-commits] Success: Hydra job gnu:guile-master:build_enable_guile_debug on x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_enable_guile_debug’ (on 
x86_64-linux) has changed from "Failed with output" to "Success".  For details, 
see

  https://hydra.nixos.org/build/39516037

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] Success: Hydra job gnu:guile-master:build.x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build.x86_64-linux’ has changed from 
"Failed with output" to "Success".  For details, see

  https://hydra.nixos.org/build/39516041

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] 01/02: Avoid flushing buffers for ftell

2016-08-31 Thread Andy Wingo
wingo pushed a commit to branch master
in repository guile.

commit eeb23e776abc7ec4ae6c71cf4d53814e38695d8e
Author: Andy Wingo 
Date:   Wed Aug 31 15:39:01 2016 +0200

Avoid flushing buffers for ftell

* libguile/ports.c (scm_seek): Avoid flushing buffers for an ftell.
  Also allows non-random-access ports to ftell() if they have a seek
  implementation, as is the case for custom binary ports with a
  get-position function but no set-position function.
* test-suite/tests/ports.test: Adapt expectations, reverting changes
  made in April by me in b77fb752dd7e14876741ecb6360ef0319eae18e0.
---
 libguile/ports.c|   14 +++---
 test-suite/tests/ports.test |8 
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/libguile/ports.c b/libguile/ports.c
index 434e48e..9e5211f 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -3544,13 +3544,21 @@ SCM_DEFINE (scm_seek, "seek", 3, 0, 0,
   off_t_or_off64_t off = scm_to_off_t_or_off64_t (offset);
   off_t_or_off64_t rv;
 
+  if (ptob->seek && how == SEEK_CUR && off == 0)
+{
+  /* If we are just querying the current position, avoid
+ flushing buffers.  We don't even need to require that the
+ port supports random access.  */
+  rv = ptob->seek (fd_port, off, how);
+  rv -= scm_port_buffer_can_take (pt->read_buf);
+  rv += scm_port_buffer_can_take (pt->write_buf);
+  return scm_from_off_t_or_off64_t (rv);
+}
+
   if (!ptob->seek || !pt->rw_random)
SCM_MISC_ERROR ("port is not seekable", 
 scm_cons (fd_port, SCM_EOL));
 
-  /* FIXME: Avoid flushing buffers for SEEK_CUR with an offset of
- 0.  */
-
   scm_end_input (fd_port);
   scm_flush (fd_port);
 
diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test
index ea8eaa7..86165fd 100644
--- a/test-suite/tests/ports.test
+++ b/test-suite/tests/ports.test
@@ -177,8 +177,8 @@
 (unread-char #\z iport)
 (pass-if "file: in tell 0 after unread"
  (= (seek iport 0 SEEK_CUR) 0))
-(pass-if "file: putback buffer flushed after seek"
- (char=? (read-char iport) #\J))
+(pass-if "file: unread char still there"
+ (char=? (read-char iport) #\z))
 (seek iport 7 SEEK_SET)
 (pass-if "file: in last char"
  (char=? (read-char iport) #\x))
@@ -699,8 +699,8 @@
   (unread-char #\x p)
   (pass-if "input tell back to 0"
(= (seek p 0 SEEK_CUR) 0))
-  (pass-if "putback buffer discarded after seek"
-   (char=? (read-char p) #\t))
+  (pass-if "input ungetted char"
+   (char=? (read-char p) #\x))
   (seek p 0 SEEK_END)
   (pass-if "input seek to end"
(= (seek p 0 SEEK_CUR)



[Guile-commits] Success: Hydra job gnu:guile-master:tarball on x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:tarball’ (on x86_64-linux) has 
changed from "Failed with output" to "Success".  For details, see

  https://hydra.nixos.org/build/39516030

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_without_threads.i686-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_without_threads.i686-linux’ has 
changed from "Success" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/39512096

This may be due to 3 commits by Andy Wingo .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG_TYPING_STRICTNESS=2 on x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job 
‘gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG_TYPING_STRICTNESS=2’ (on 
x86_64-linux) has changed from "Success" to "Failed with output".  For details, 
see

  https://hydra.nixos.org/build/39512105

This may be due to 3 commits by Andy Wingo .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build.i686-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build.i686-linux’ has changed from 
"Success" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/39512102

This may be due to 3 commits by Andy Wingo .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_clang.x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_clang.x86_64-linux’ has changed 
from "Success" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/39512104

This may be due to 3 commits by Andy Wingo .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_without_threads.x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_without_threads.x86_64-linux’ 
has changed from "Success" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/39512093

This may be due to 3 commits by Andy Wingo .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_enable_guile_debug on x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_enable_guile_debug’ (on 
x86_64-linux) has changed from "Success" to "Failed with output".  For details, 
see

  https://hydra.nixos.org/build/39512098

This may be due to 3 commits by Andy Wingo .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_clang.i686-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_clang.i686-linux’ has changed 
from "Success" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/39512100

This may be due to 3 commits by Andy Wingo .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build.x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build.x86_64-linux’ has changed from 
"Success" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/39512095

This may be due to 3 commits by Andy Wingo .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:tarball on x86_64-linux

2016-08-31 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:tarball’ (on x86_64-linux) has 
changed from "Success" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/39512094

This may be due to 3 commits by Andy Wingo .

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] 03/03: Require C99 to build Guile.

2016-08-31 Thread Andy Wingo
wingo pushed a commit to branch master
in repository guile.

commit 9996695f88b19a48bd8d50b84f85509b8626fb01
Author: Andy Wingo 
Date:   Wed Aug 31 11:55:26 2016 +0200

Require C99 to build Guile.

* configure.ac: Require C99 or later.  Emacs does, therefore so can
  we.  Note that by default GCC compiles in "gnu11" mode these days, and
  this declaration doesn't change that.
---
 configure.ac |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index c2c7f52..435bc4e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,7 +83,8 @@ AC_DEFINE([GNULIB_LOCK], [1],
   [Define to allow Gnulib modules to use Guile's locks.])
 
 
-AC_PROG_CC_C89
+dnl Guile needs C99 or later.
+gl_PROG_CC_C99
 
 # for per-target cflags in the libguile subdir
 AM_PROG_CC_C_O



[Guile-commits] branch master updated (ad4fe88 -> 9996695)

2016-08-31 Thread Andy Wingo
wingo pushed a change to branch master
in repository guile.

  from  ad4fe88   Move system* to posix.c, impl on open-process
   new  40c6734   Correct section number for "Input Ports" tests.
   new  b9b2352   Add tests for make-custom-binary-input/output-port
   new  9996695   Require C99 to build Guile.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.


Summary of changes:
 configure.ac |3 +-
 test-suite/tests/r6rs-ports.test |  391 +-
 2 files changed, 388 insertions(+), 6 deletions(-)



[Guile-commits] 01/03: Correct section number for "Input Ports" tests.

2016-08-31 Thread Andy Wingo
wingo pushed a commit to branch master
in repository guile.

commit 40c673446a01970b4146778651ad16f4d5441188
Author: Christopher Allan Webber 
Date:   Thu Aug 11 17:06:10 2016 -0500

Correct section number for "Input Ports" tests.

* test-suite/tests/r6rs-ports.test: Correct "Input Ports" section heading
  from "7.2.7" -> "8.2.7", "7.2.5" -> "8.2.5", "7.2.8" -> "8.2.8",
  and "7.2.11" -> "8.2.11".
---
 test-suite/tests/r6rs-ports.test |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/test-suite/tests/r6rs-ports.test b/test-suite/tests/r6rs-ports.test
index b3f11bb..9aa605b 100644
--- a/test-suite/tests/r6rs-ports.test
+++ b/test-suite/tests/r6rs-ports.test
@@ -74,7 +74,7 @@
 receiver
 
 
-(with-test-prefix "7.2.5 End-of-File Object"
+(with-test-prefix "8.2.5 End-of-File Object"
 
   (pass-if "eof-object"
 (and (eqv? (eof-object) (eof-object))
@@ -84,7 +84,7 @@
 (port-eof? (open-input-string ""
 
 
-(with-test-prefix "7.2.8 Binary Input"
+(with-test-prefix "8.2.8 Binary Input"
 
   (pass-if "get-u8"
 (let ((port (open-input-string "A")))
@@ -236,7 +236,7 @@
  (lambda () #t)) ;; close-port
  "rw")))
 
-(with-test-prefix "7.2.11 Binary Output"
+(with-test-prefix "8.2.11 Binary Output"
 
   (pass-if "put-u8"
 (let ((port (make-soft-output-port)))
@@ -328,7 +328,7 @@
   
   (delete-file filename))
 
-(with-test-prefix "7.2.7 Input Ports"
+(with-test-prefix "8.2.7 Input Ports"
 
   (with-test-prefix "open-file-input-port"
 (test-input-file-opener open-file-input-port (test-file)))



[Guile-commits] 02/03: Add tests for make-custom-binary-input/output-port

2016-08-31 Thread Andy Wingo
wingo pushed a commit to branch master
in repository guile.

commit b9b235243eeb9ad8271bd2a0c9b0f5148cfba7fe
Author: Christopher Allan Webber 
Date:   Sat Aug 20 16:20:53 2016 -0500

Add tests for make-custom-binary-input/output-port

* test-suite/tests/r6rs-ports.test ("8.2.13 Input/output ports"):
  Add tests for custom binary input/output ports, copied from
  existing binary input and binary output tests.
---
 test-suite/tests/r6rs-ports.test |  383 +-
 1 file changed, 382 insertions(+), 1 deletion(-)

diff --git a/test-suite/tests/r6rs-ports.test b/test-suite/tests/r6rs-ports.test
index 9aa605b..94d9fc0 100644
--- a/test-suite/tests/r6rs-ports.test
+++ b/test-suite/tests/r6rs-ports.test
@@ -1059,11 +1059,392 @@ not `set-port-position!'"
 values))
 (delete-file filename)))
 
+;; Used for a lot of the make-custom-input/output tests to stub out
+;; the read/write section for whatever part we're ignoring
+(define dummy-write! (const 0))
+(define dummy-read! (const 0))
+
 (with-test-prefix "8.2.13 Input/output ports"
   (with-test-prefix "open-file-input/output-port [output]"
 (test-output-file-opener open-file-input/output-port (test-file)))
   (with-test-prefix "open-file-input/output-port [input]"
-(test-input-file-opener open-file-input/output-port (test-file
+(test-input-file-opener open-file-input/output-port (test-file)))
+
+  ;; Custom binary input/output tests.  Most of these are simple
+  ;; ports of the custom-binary-input-port tests or custom-binary-ouput-port
+  ;; tests, simply ported to use a custom-binary-input/output port.
+  ;; The copy-pasta is strong here; a diet lighter in spaghetti may wish
+  ;; to make the previous tests more reusable.
+  (pass-if "make-custom-binary-input/output-port"
+(let* ((source (make-bytevector ))
+   (read! (let ((pos 0)
+(len (bytevector-length source)))
+(lambda (bv start count)
+  (let ((amount (min count (- len pos
+(if (> amount 0)
+(bytevector-copy! source pos
+  bv start amount))
+(set! pos (+ pos amount))
+amount
+   (write! (lambda (x y z) 0))
+   (port (make-custom-binary-input/output-port
+  "the port" read! write!
+  #f #f #f)))
+  (and (binary-port? port)
+   (input-port? port)
+   (output-port? port)
+   (bytevector=? (get-bytevector-all port) source)
+   (not (port-has-port-position? port))
+   (not (port-has-set-port-position!? port)
+  
+  (pass-if-equal "make-custom-binary-input/output-port uses ISO-8859-1 (Guile \
+extension) [input]"
+  "©©"
+(with-fluids ((%default-port-encoding "UTF-8"))
+  (let* ((source #vu8(194 169 194 169))
+ (read! (let ((pos 0)
+  (len (bytevector-length source)))
+  (lambda (bv start count)
+(let ((amount (min count (- len pos
+  (if (> amount 0)
+  (bytevector-copy! source pos
+bv start amount))
+  (set! pos (+ pos amount))
+  amount
+ (port (make-custom-binary-input/output-port
+"the port" read! dummy-write!
+#f #f #f)))
+(get-string-all port
+
+  (pass-if "custom binary input/output port does not support `port-position'"
+(let* ((str "Hello Port!")
+   (source (open-bytevector-input-port
+(u8-list->bytevector
+ (map char->integer (string->list str)
+   (read! (lambda (bv start count)
+(let ((r (get-bytevector-n! source bv start count)))
+  (if (eof-object? r)
+  0
+  r
+   (port (make-custom-binary-input/output-port
+  "the port" read! dummy-write!
+  #f #f #f)))
+  (not (or (port-has-port-position? port)
+   (port-has-set-port-position!? port)
+
+  (pass-if-exception "custom binary input/output port 'read!' returns too much"
+  exception:out-of-range
+;; In Guile <= 2.0.9 this would segfault.
+(let* ((read! (lambda (bv start count)
+(+ count 4242)))
+   (port (make-custom-binary-input/output-port
+  "the port" read! dummy-write!
+  #f #f #f)))
+  (get-bytevector-all port)))
+
+  (pass-if-equal "custom binary input/output port supports `port-position', \
+not `set-port-position!'"
+  42
+(let ((port (make-custom-binary-input/output-port
+ "the port" (const 0) dummy-write!
+

[Guile-commits] 01/01: Move system* to posix.c, impl on open-process

2016-08-31 Thread Andy Wingo
wingo pushed a commit to branch stable-2.0
in repository guile.

commit 78eb40c06637e2ab15ee40bcc78c308c9b80bc1f
Author: Andy Wingo 
Date:   Wed Aug 31 10:42:21 2016 +0200

Move system* to posix.c, impl on open-process

* libguile/simpos.c: Trim includes.
  (scm_system_star): Move to posix.c.
* libguile/simpos.h (scm_system_star): Remove.
* libguile/posix.h (scm_system_star): Add.
* libguile/posix.c (scm_system_star): Move here and implement in terms
  of open-process.  This lets system* work on Windows.  Inspired by a
  patch by Eli Zaretskii.
  (start_child): Exit with 127 if the command isn't found.
---
 libguile/posix.c  |   72 -
 libguile/posix.h  |1 +
 libguile/simpos.c |  130 ++---
 libguile/simpos.h |1 -
 4 files changed, 75 insertions(+), 129 deletions(-)

diff --git a/libguile/posix.c b/libguile/posix.c
index 478d648..2359e61 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -1321,7 +1321,9 @@ start_child (const char *exec_file, char **exec_argv,
exec_file, msg);
 }
 
-  _exit (EXIT_FAILURE);
+  /* Use exit status 127, like shells in this case, as per POSIX
+ 
.
  */
+  _exit (127);
 
   /* Not reached.  */
   return -1;
@@ -1428,6 +1430,74 @@ scm_open_process (SCM mode, SCM prog, SCM args)
  scm_from_int (pid)));
 }
 #undef FUNC_NAME
+
+static void
+restore_sigaction (SCM pair)
+{
+  SCM sig, handler, flags;
+  sig = scm_car (pair);
+  handler = scm_cadr (pair);
+  flags = scm_cddr (pair);
+  scm_sigaction (sig, handler, flags);
+}
+
+static void
+scm_dynwind_sigaction (int sig, SCM handler, SCM flags)
+{
+  SCM old, scm_sig;
+  scm_sig = scm_from_int (sig);
+  old = scm_sigaction (scm_sig, handler, flags);
+  scm_dynwind_unwind_handler_with_scm (restore_sigaction,
+   scm_cons (scm_sig, old),
+   SCM_F_WIND_EXPLICITLY);
+}
+
+SCM_DEFINE (scm_system_star, "system*", 0, 0, 1,
+   (SCM args),
+"Execute the command indicated by @var{args}.  The first element must\n"
+"be a string indicating the command to be executed, and the remaining\n"
+"items must be strings representing each of the arguments to that\n"
+"command.\n"
+"\n"
+"This function returns the exit status of the command as provided by\n"
+"@code{waitpid}.  This value can be handled with @code{status:exit-val}\n"
+"and the related functions.\n"
+"\n"
+"@code{system*} is similar to @code{system}, but accepts only one\n"
+"string per-argument, and performs no shell interpretation.  The\n"
+"command is executed using fork and execlp.  Accordingly this function\n"
+"may be safer than @code{system} in situations where shell\n"
+"interpretation is not required.\n"
+"\n"
+"Example: (system* \"echo\" \"foo\" \"bar\")")
+#define FUNC_NAME s_scm_system_star
+{
+  SCM prog, res;
+  int pid, status, wait_result;
+
+  if (scm_is_null (args))
+SCM_WRONG_NUM_ARGS ();
+  prog = scm_car (args);
+  args = scm_cdr (args);
+
+  scm_dynwind_begin (0);
+  /* Make sure the child can't kill us (as per normal system call).  */
+  scm_dynwind_sigaction (SIGINT, scm_from_ulong (SIG_IGN), SCM_UNDEFINED);
+#ifdef SIGQUIT
+  scm_dynwind_sigaction (SIGQUIT, scm_from_ulong (SIG_IGN), SCM_UNDEFINED);
+#endif
+
+  res = scm_open_process (scm_nullstr, prog, args);
+  pid = scm_to_int (scm_c_value_ref (res, 2));
+  SCM_SYSCALL (wait_result = waitpid (pid, &status, 0));
+  if (wait_result == -1)
+SCM_SYSERROR;
+
+  scm_dynwind_end ();
+
+  return scm_from_int (status);
+}
+#undef FUNC_NAME
 #endif /* HAVE_START_CHILD */
 
 #ifdef HAVE_UNAME
diff --git a/libguile/posix.h b/libguile/posix.h
index 92f8b35..078edf5 100644
--- a/libguile/posix.h
+++ b/libguile/posix.h
@@ -72,6 +72,7 @@ SCM_API SCM scm_mkstemp (SCM tmpl);
 SCM_API SCM scm_tmpfile (void);
 SCM_API SCM scm_open_pipe (SCM pipestr, SCM modes);
 SCM_API SCM scm_close_pipe (SCM port);
+SCM_API SCM scm_system_star (SCM cmds);
 SCM_API SCM scm_utime (SCM pathname, SCM actime, SCM modtime,
SCM actimens, SCM modtimens, SCM flags);
 SCM_API SCM scm_access (SCM path, SCM how);
diff --git a/libguile/simpos.c b/libguile/simpos.c
index c0fbd79..e45c606 100644
--- a/libguile/simpos.c
+++ b/libguile/simpos.c
@@ -24,35 +24,15 @@
 #endif
 
 #include 
-#include   /* for SIG constants */
-#include   /* for getenv */
-#include 
+#include   /* for getenv, system, exit, free */
+#include   /* for _exit */
 
 #include "libguile/_scm.h"
 
-#include "libguile/scmsigs.h"
 #include "libguile/strings.h"
-
 #include "libguile/validate.h"
 #include "libguile/simpos.h"
-#include "libguile/dynwind.h"
-
-#ifdef HAVE_STRING_H
-#include 
-#endif
-#include 
-#if HAVE_SYS_WAIT_H
-# include 
-#endif
 
-#ifdef __MINGW32__
-# include   /* for spawnvp and friends */
-#endif
-

[Guile-commits] branch stable-2.0 updated (9eb8c36 -> 78eb40c)

2016-08-31 Thread Andy Wingo
wingo pushed a change to branch stable-2.0
in repository guile.

  from  9eb8c36   build: .x and .doc files depend on generated includes.
   new  78eb40c   Move system* to posix.c, impl on open-process

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.


Summary of changes:
 libguile/posix.c  |   72 -
 libguile/posix.h  |1 +
 libguile/simpos.c |  130 ++---
 libguile/simpos.h |1 -
 4 files changed, 75 insertions(+), 129 deletions(-)



[Guile-commits] 01/01: Move system* to posix.c, impl on open-process

2016-08-31 Thread Andy Wingo
wingo pushed a commit to branch master
in repository guile.

commit ad4fe88ffb9193e7b5da8350d71334be525eed84
Author: Andy Wingo 
Date:   Wed Aug 31 10:42:21 2016 +0200

Move system* to posix.c, impl on open-process

* libguile/simpos.c: Trim includes.
  (scm_system_star): Move to posix.c.
* libguile/simpos.h (scm_system_star): Remove.
* libguile/posix.h (scm_system_star): Add.
* libguile/posix.c (scm_system_star): Move here and implement in terms
  of open-process.  This lets system* work on Windows.  Inspired by a
  patch by Eli Zaretskii.
  (start_child): Exit with 127 if the command isn't found.
---
 libguile/posix.c  |   72 -
 libguile/posix.h  |1 +
 libguile/simpos.c |  130 ++---
 libguile/simpos.h |1 -
 4 files changed, 75 insertions(+), 129 deletions(-)

diff --git a/libguile/posix.c b/libguile/posix.c
index 3383808..5d0b1ed 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -1322,7 +1322,9 @@ start_child (const char *exec_file, char **exec_argv,
exec_file, msg);
 }
 
-  _exit (EXIT_FAILURE);
+  /* Use exit status 127, like shells in this case, as per POSIX
+ 
.
  */
+  _exit (127);
 
   /* Not reached.  */
   return -1;
@@ -1429,6 +1431,74 @@ scm_open_process (SCM mode, SCM prog, SCM args)
  scm_from_int (pid)));
 }
 #undef FUNC_NAME
+
+static void
+restore_sigaction (SCM pair)
+{
+  SCM sig, handler, flags;
+  sig = scm_car (pair);
+  handler = scm_cadr (pair);
+  flags = scm_cddr (pair);
+  scm_sigaction (sig, handler, flags);
+}
+
+static void
+scm_dynwind_sigaction (int sig, SCM handler, SCM flags)
+{
+  SCM old, scm_sig;
+  scm_sig = scm_from_int (sig);
+  old = scm_sigaction (scm_sig, handler, flags);
+  scm_dynwind_unwind_handler_with_scm (restore_sigaction,
+   scm_cons (scm_sig, old),
+   SCM_F_WIND_EXPLICITLY);
+}
+
+SCM_DEFINE (scm_system_star, "system*", 0, 0, 1,
+   (SCM args),
+"Execute the command indicated by @var{args}.  The first element must\n"
+"be a string indicating the command to be executed, and the remaining\n"
+"items must be strings representing each of the arguments to that\n"
+"command.\n"
+"\n"
+"This function returns the exit status of the command as provided by\n"
+"@code{waitpid}.  This value can be handled with @code{status:exit-val}\n"
+"and the related functions.\n"
+"\n"
+"@code{system*} is similar to @code{system}, but accepts only one\n"
+"string per-argument, and performs no shell interpretation.  The\n"
+"command is executed using fork and execlp.  Accordingly this function\n"
+"may be safer than @code{system} in situations where shell\n"
+"interpretation is not required.\n"
+"\n"
+"Example: (system* \"echo\" \"foo\" \"bar\")")
+#define FUNC_NAME s_scm_system_star
+{
+  SCM prog, res;
+  int pid, status, wait_result;
+
+  if (scm_is_null (args))
+SCM_WRONG_NUM_ARGS ();
+  prog = scm_car (args);
+  args = scm_cdr (args);
+
+  scm_dynwind_begin (0);
+  /* Make sure the child can't kill us (as per normal system call).  */
+  scm_dynwind_sigaction (SIGINT, scm_from_ulong (SIG_IGN), SCM_UNDEFINED);
+#ifdef SIGQUIT
+  scm_dynwind_sigaction (SIGQUIT, scm_from_ulong (SIG_IGN), SCM_UNDEFINED);
+#endif
+
+  res = scm_open_process (scm_nullstr, prog, args);
+  pid = scm_to_int (scm_c_value_ref (res, 2));
+  SCM_SYSCALL (wait_result = waitpid (pid, &status, 0));
+  if (wait_result == -1)
+SCM_SYSERROR;
+
+  scm_dynwind_end ();
+
+  return scm_from_int (status);
+}
+#undef FUNC_NAME
 #endif /* HAVE_START_CHILD */
 
 #ifdef HAVE_UNAME
diff --git a/libguile/posix.h b/libguile/posix.h
index 92f8b35..078edf5 100644
--- a/libguile/posix.h
+++ b/libguile/posix.h
@@ -72,6 +72,7 @@ SCM_API SCM scm_mkstemp (SCM tmpl);
 SCM_API SCM scm_tmpfile (void);
 SCM_API SCM scm_open_pipe (SCM pipestr, SCM modes);
 SCM_API SCM scm_close_pipe (SCM port);
+SCM_API SCM scm_system_star (SCM cmds);
 SCM_API SCM scm_utime (SCM pathname, SCM actime, SCM modtime,
SCM actimens, SCM modtimens, SCM flags);
 SCM_API SCM scm_access (SCM path, SCM how);
diff --git a/libguile/simpos.c b/libguile/simpos.c
index 7005828..38d8dfd 100644
--- a/libguile/simpos.c
+++ b/libguile/simpos.c
@@ -24,35 +24,15 @@
 #endif
 
 #include 
-#include   /* for SIG constants */
-#include   /* for getenv */
-#include 
+#include   /* for getenv, system, exit, free */
+#include   /* for _exit */
 
 #include "libguile/_scm.h"
 
-#include "libguile/scmsigs.h"
 #include "libguile/strings.h"
-
 #include "libguile/validate.h"
 #include "libguile/simpos.h"
-#include "libguile/dynwind.h"
-
-#ifdef HAVE_STRING_H
-#include 
-#endif
-#include 
-#if HAVE_SYS_WAIT_H
-# include 
-#endif
 
-#ifdef __MINGW32__
-# include   /* for spawnvp and friends */
-#endif
-
-#i

[Guile-commits] branch master updated (2fa2e50 -> ad4fe88)

2016-08-31 Thread Andy Wingo
wingo pushed a change to branch master
in repository guile.

  from  2fa2e50   Add file descriptor finalizers
   new  ad4fe88   Move system* to posix.c, impl on open-process

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.


Summary of changes:
 libguile/posix.c  |   72 -
 libguile/posix.h  |1 +
 libguile/simpos.c |  130 ++---
 libguile/simpos.h |1 -
 4 files changed, 75 insertions(+), 129 deletions(-)