diff options
Diffstat (limited to 'libguile/filesys.c')
-rw-r--r-- | libguile/filesys.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/libguile/filesys.c b/libguile/filesys.c index 5f6208d82..8597f9096 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" @@ -141,6 +140,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 @@ -982,7 +985,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 @@ -1192,7 +1195,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) { @@ -1743,11 +1746,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 @@ -1761,15 +1764,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; @@ -1849,12 +1852,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; } |