add scm_dynwind_lock_port
authorAndy Wingo <wingo@pobox.com>
Tue, 8 Nov 2011 18:16:33 +0000 (19:16 +0100)
committerAndy Wingo <wingo@pobox.com>
Tue, 8 Nov 2011 18:16:33 +0000 (19:16 +0100)
* libguile/ports.h:
* libguile/ports.c (scm_dynwind_lock_port): New function.

libguile/ports.c
libguile/ports.h

index a95774b..bad524e 100644 (file)
@@ -1098,6 +1098,32 @@ SCM_DEFINE (scm_set_port_conversion_strategy_x, "set-port-conversion-strategy!",
 
 \f
 
+/* The port lock.  */
+
+static void
+lock_port (SCM port)
+{
+  scm_c_lock_port (port);
+}
+
+static void
+unlock_port (SCM port)
+{
+  scm_c_unlock_port (port);
+}
+
+void
+scm_dynwind_lock_port (SCM port)
+{
+  scm_dynwind_unwind_handler_with_scm (unlock_port, port,
+                                       SCM_F_WIND_EXPLICITLY);
+  scm_dynwind_rewind_handler_with_scm (lock_port, port,
+                                       SCM_F_WIND_EXPLICITLY);
+}
+
+
+\f
+
 /* Revealed counts --- an oddity inherited from SCSH.  */
 
 /* Find a port in the table and return its revealed count.
index 56cafdb..624b7b8 100644 (file)
@@ -294,6 +294,7 @@ SCM_API SCM scm_port_conversion_strategy (SCM port);
 SCM_API SCM scm_set_port_conversion_strategy_x (SCM port, SCM behavior);
 
 /* Acquiring and releasing the port lock.  */
+SCM_API void scm_dynwind_lock_port (SCM port);
 SCM_INLINE int scm_c_lock_port (SCM port);
 SCM_INLINE int scm_c_try_lock_port (SCM port);
 SCM_INLINE int scm_c_unlock_port (SCM port);