diff options
Diffstat (limited to 'libguile/filesys.c')
-rw-r--r-- | libguile/filesys.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/libguile/filesys.c b/libguile/filesys.c index b473af811..95d1a9dff 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -44,7 +44,6 @@ #include "libguile/smob.h" #include "libguile/feature.h" #include "libguile/fports.h" -#include "libguile/private-gc.h" /* for SCM_MAX */ #include "libguile/strings.h" #include "libguile/vectors.h" #include "libguile/dynwind.h" @@ -134,6 +133,10 @@ eno = errno; scm_dynwind_end (); errno = eno; \ } while (0) + +#define MAX(A, B) ((A) > (B) ? (A) : (B)) +#define MIN(A, B) ((A) < (B) ? (A) : (B)) + #ifdef HAVE_POSIX @@ -680,7 +683,7 @@ fill_select_type (fd_set *set, SCM *ports_ready, SCM list_or_vec, int pos) { int max_fd = 0; - if (scm_is_simple_vector (list_or_vec)) + if (scm_is_vector (list_or_vec)) { int i = SCM_SIMPLE_VECTOR_LENGTH (list_or_vec); @@ -741,7 +744,7 @@ retrieve_select_type (fd_set *set, SCM ports_ready, SCM list_or_vec) { SCM answer_list = ports_ready; - if (scm_is_simple_vector (list_or_vec)) + if (scm_is_vector (list_or_vec)) { int i = SCM_SIMPLE_VECTOR_LENGTH (list_or_vec); @@ -815,7 +818,7 @@ SCM_DEFINE (scm_select, "select", 3, 2, 0, SCM write_ports_ready = SCM_EOL; int max_fd; - if (scm_is_simple_vector (reads)) + if (scm_is_vector (reads)) { read_count = SCM_SIMPLE_VECTOR_LENGTH (reads); } @@ -824,7 +827,7 @@ SCM_DEFINE (scm_select, "select", 3, 2, 0, read_count = scm_ilength (reads); SCM_ASSERT (read_count >= 0, reads, SCM_ARG1, FUNC_NAME); } - if (scm_is_simple_vector (writes)) + if (scm_is_vector (writes)) { write_count = SCM_SIMPLE_VECTOR_LENGTH (writes); } @@ -833,7 +836,7 @@ SCM_DEFINE (scm_select, "select", 3, 2, 0, write_count = scm_ilength (writes); SCM_ASSERT (write_count >= 0, writes, SCM_ARG2, FUNC_NAME); } - if (scm_is_simple_vector (excepts)) + if (scm_is_vector (excepts)) { except_count = SCM_SIMPLE_VECTOR_LENGTH (excepts); } @@ -976,7 +979,7 @@ SCM_DEFINE (scm_fsync, "fsync", 1, 0, 0, if (SCM_OPFPORTP (object)) { - scm_flush (object); + scm_flush_unlocked (object); fdes = SCM_FPORT_FDES (object); } else @@ -1184,7 +1187,7 @@ SCM_DEFINE (scm_sendfile, "sendfile", 3, 1, 0, { size_t asked, obtained, written; - asked = SCM_MIN (sizeof buf, left); + asked = MIN (sizeof buf, left); obtained = full_read (in_fd, buf, asked); if (obtained < asked) { @@ -1710,11 +1713,11 @@ SCM_DEFINE (scm_readdir, "readdir", 1, 0, 0, SCM_MISC_ERROR ("Directory ~S is not open.", scm_list_1 (port)); #if HAVE_READDIR_R - /* As noted in the glibc manual, on various systems (such as Solaris) the - d_name[] field is only 1 char and you're expected to size the dirent - buffer for readdir_r based on NAME_MAX. The SCM_MAX expressions below - effectively give either sizeof(d_name) or NAME_MAX+1, whichever is - bigger. + /* As noted in the glibc manual, on various systems (such as Solaris) + the d_name[] field is only 1 char and you're expected to size the + dirent buffer for readdir_r based on NAME_MAX. The MAX expressions + below effectively give either sizeof(d_name) or NAME_MAX+1, + whichever is bigger. On solaris 10 there's no NAME_MAX constant, it's necessary to use pathconf(). We prefer NAME_MAX though, since it should be a constant @@ -1728,15 +1731,15 @@ SCM_DEFINE (scm_readdir, "readdir", 1, 0, 0, struct dirent_or_dirent64 de; /* just for sizeof */ DIR *ds = (DIR *) SCM_SMOB_DATA_1 (port); #ifdef NAME_MAX - char buf [SCM_MAX (sizeof (de), - sizeof (de) - sizeof (de.d_name) + NAME_MAX + 1)]; + char buf [MAX (sizeof (de), + sizeof (de) - sizeof (de.d_name) + NAME_MAX + 1)]; #else char *buf; long name_max = fpathconf (dirfd (ds), _PC_NAME_MAX); if (name_max == -1) SCM_SYSERROR; - buf = alloca (SCM_MAX (sizeof (de), - sizeof (de) - sizeof (de.d_name) + name_max + 1)); + buf = alloca (MAX (sizeof (de), + sizeof (de) - sizeof (de.d_name) + name_max + 1)); #endif errno = 0; @@ -1816,12 +1819,12 @@ SCM_DEFINE (scm_closedir, "closedir", 1, 0, 0, static int scm_dir_print (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED) { - scm_puts ("#<", port); + scm_puts_unlocked ("#<", port); if (!SCM_DIR_OPEN_P (exp)) - scm_puts ("closed: ", port); - scm_puts ("directory stream ", port); + scm_puts_unlocked ("closed: ", port); + scm_puts_unlocked ("directory stream ", port); scm_uintprint (SCM_SMOB_DATA_1 (exp), 16, port); - scm_putc ('>', port); + scm_putc_unlocked ('>', port); return 1; } |