Merge branch 'stable-2.0'
[bpt/guile.git] / libguile / ioext.c
index d324cc2..659eabc 100644 (file)
@@ -1,5 +1,5 @@
 /* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2006,
- *   2014 Free Software Foundation, Inc.
+ *   2011, 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
@@ -88,13 +88,13 @@ SCM_DEFINE (scm_redirect_port, "redirect-port", 2, 0, 0,
     {
       scm_t_port *pt = SCM_PTAB_ENTRY (new);
       scm_t_port *old_pt = SCM_PTAB_ENTRY (old);
-      scm_t_ptob_descriptor *ptob = &scm_ptobs[SCM_PTOBNUM (new)];
+      scm_t_ptob_descriptor *ptob = SCM_PORT_DESCRIPTOR (new);
 
       /* must flush to old fdes.  */
       if (pt->rw_active == SCM_PORT_WRITE)
        ptob->flush (new);
       else if (pt->rw_active == SCM_PORT_READ)
-       scm_end_input (new);
+       scm_end_input_unlocked (new);
       ans = dup2 (oldfd, newfd);
       if (ans == -1)
        SCM_SYSERROR;
@@ -268,7 +268,7 @@ SCM_DEFINE (scm_primitive_move_to_fdes, "primitive-move->fdes", 2, 0, 0,
 #undef FUNC_NAME
 
 static SCM
-get_matching_port (void *closure, SCM port, SCM val, SCM result)
+get_matching_port (void *closure, SCM port, SCM result)
 {
   int fd = * (int *) closure;
   scm_t_port *entry = SCM_PTAB_ENTRY (port);
@@ -291,11 +291,9 @@ SCM_DEFINE (scm_fdes_to_ports, "fdes->ports", 1, 0, 0,
   SCM result = SCM_EOL;
   int int_fd = scm_to_int (fd);
 
-  scm_i_scm_pthread_mutex_lock (&scm_i_port_table_mutex);
-  result = scm_internal_hash_fold (get_matching_port,
-                                  (void*) &int_fd, result, 
-                                  scm_i_port_weak_hash);
-  scm_i_pthread_mutex_unlock (&scm_i_port_table_mutex);
+  result = scm_c_weak_set_fold (get_matching_port,
+                                (void*) &int_fd, result, 
+                                scm_i_port_weak_set);
   return result;
 }
 #undef FUNC_NAME