1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

More private-gc excisions

* libguile/private-gc.h (SCM_DOUBLECELL_ALIGNED_P): Remove; unused.
* libguile/filesys.c (MAX, MIN): Move definitions here, from
  private-gc.h.
  (scm_sendfile, scm_readdir): Adapt uses of SCM_MAX and SCM_MIN to use
  MAX or MIN.
This commit is contained in:
Andy Wingo 2013-11-28 11:43:51 +01:00
parent 8d78304e4d
commit 5a706f0342
2 changed files with 14 additions and 18 deletions

View file

@ -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
@ -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;

View file

@ -25,15 +25,8 @@
#include "_scm.h"
#define SCM_DOUBLECELL_ALIGNED_P(x) (((2 * sizeof (scm_t_cell) - 1) & SCM_UNPACK (x)) == 0)
SCM_INTERNAL int scm_getenv_int (const char *var, int def);
#define SCM_MAX(A, B) ((A) > (B) ? (A) : (B))
#define SCM_MIN(A, B) ((A) < (B) ? (A) : (B))
SCM_INTERNAL char const *scm_i_tag_name (scm_t_bits tag); /* MOVEME */
#endif