mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Move "min" and "max" macros out of _scm.h
* libguile/_scm.h: Remove definitions of min and max macros. * libguile/array-map.c (MAX): * libguile/foreign.c (MAX): * libguile/numbers.c (MIN): * libguile/quicksort.i.c (MIN): * libguile/socket.c (MAX): * libguile/strports.c (MAX): Inline definitions into callers. We're going to remove _scm.h, which will pay off this duplication.
This commit is contained in:
parent
2f39771c84
commit
f6ec873a8b
7 changed files with 21 additions and 17 deletions
|
@ -106,13 +106,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef min
|
|
||||||
#define min(A, B) ((A) <= (B) ? (A) : (B))
|
|
||||||
#endif
|
|
||||||
#ifndef max
|
|
||||||
#define max(A, B) ((A) >= (B) ? (A) : (B))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Return the first integer greater than or equal to LEN such that
|
/* Return the first integer greater than or equal to LEN such that
|
||||||
LEN % ALIGN == 0. Return LEN if ALIGN is zero. */
|
LEN % ALIGN == 0. Return LEN if ALIGN is zero. */
|
||||||
#define ROUND_UP(len, align) \
|
#define ROUND_UP(len, align) \
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* Copyright (C) 1996, 1998, 2000, 2001, 2004, 2005, 2006, 2008, 2009,
|
/* Copyright (C) 1996,1998,2000-2001,2004-2006,2008-2015,2018
|
||||||
* 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
|
* Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -85,6 +85,7 @@ cindk (SCM ra, ssize_t *ve, int kend)
|
||||||
|
|
||||||
#define LBND(ra, k) SCM_I_ARRAY_DIMS (ra)[k].lbnd
|
#define LBND(ra, k) SCM_I_ARRAY_DIMS (ra)[k].lbnd
|
||||||
#define UBND(ra, k) SCM_I_ARRAY_DIMS (ra)[k].ubnd
|
#define UBND(ra, k) SCM_I_ARRAY_DIMS (ra)[k].ubnd
|
||||||
|
#define MAX(A, B) ((A) >= (B) ? (A) : (B))
|
||||||
|
|
||||||
|
|
||||||
/* scm_ramapc() always calls cproc with rank-1 arrays created by
|
/* scm_ramapc() always calls cproc with rank-1 arrays created by
|
||||||
|
@ -107,7 +108,7 @@ scm_ramapc (void *cproc_ptr, SCM data, SCM ra0, SCM lra, const char *what)
|
||||||
va0 = make1array (SCM_I_ARRAY_V (ra0), inc);
|
va0 = make1array (SCM_I_ARRAY_V (ra0), inc);
|
||||||
|
|
||||||
/* Find unroll depth */
|
/* Find unroll depth */
|
||||||
for (kroll = max(0, kmax); kroll > 0; --kroll)
|
for (kroll = MAX (0, kmax); kroll > 0; --kroll)
|
||||||
{
|
{
|
||||||
inc *= (UBND (ra0, kroll) - LBND (ra0, kroll) + 1);
|
inc *= (UBND (ra0, kroll) - LBND (ra0, kroll) + 1);
|
||||||
if (inc != SCM_I_ARRAY_DIMS (ra0)[kroll-1].inc)
|
if (inc != SCM_I_ARRAY_DIMS (ra0)[kroll-1].inc)
|
||||||
|
|
|
@ -1000,6 +1000,8 @@ pack (const ffi_type * type, const void *loc, int return_value_p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX(A, B) ((A) >= (B) ? (A) : (B))
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
scm_i_foreign_call (SCM cif_scm, SCM pointer_scm, int *errno_ret,
|
scm_i_foreign_call (SCM cif_scm, SCM pointer_scm, int *errno_ret,
|
||||||
const union scm_vm_stack_element *argv)
|
const union scm_vm_stack_element *argv)
|
||||||
|
@ -1029,7 +1031,7 @@ scm_i_foreign_call (SCM cif_scm, SCM pointer_scm, int *errno_ret,
|
||||||
|
|
||||||
/* Space for argument values, followed by return value. */
|
/* Space for argument values, followed by return value. */
|
||||||
data = alloca (arg_size + cif->rtype->size
|
data = alloca (arg_size + cif->rtype->size
|
||||||
+ max (sizeof (void *), cif->rtype->alignment));
|
+ MAX (sizeof (void *), cif->rtype->alignment));
|
||||||
|
|
||||||
/* Unpack ARGV to native values, setting ARGV pointers. */
|
/* Unpack ARGV to native values, setting ARGV pointers. */
|
||||||
for (i = 0, off = 0;
|
for (i = 0, off = 0;
|
||||||
|
@ -1049,7 +1051,7 @@ scm_i_foreign_call (SCM cif_scm, SCM pointer_scm, int *errno_ret,
|
||||||
word-aligned, even if its type doesn't have any alignment requirement as is
|
word-aligned, even if its type doesn't have any alignment requirement as is
|
||||||
the case with `char'. */
|
the case with `char'. */
|
||||||
rvalue = (void *) ROUND_UP ((scm_t_uintptr) data + off,
|
rvalue = (void *) ROUND_UP ((scm_t_uintptr) data + off,
|
||||||
max (sizeof (void *), cif->rtype->alignment));
|
MAX (sizeof (void *), cif->rtype->alignment));
|
||||||
|
|
||||||
/* off we go! */
|
/* off we go! */
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
|
@ -5123,6 +5123,8 @@ SCM_DEFINE (scm_round_ash, "round-ash", 2, 0, 0,
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
|
||||||
|
#define MIN(A, B) ((A) <= (B) ? (A) : (B))
|
||||||
|
|
||||||
SCM_DEFINE (scm_bit_extract, "bit-extract", 3, 0, 0,
|
SCM_DEFINE (scm_bit_extract, "bit-extract", 3, 0, 0,
|
||||||
(SCM n, SCM start, SCM end),
|
(SCM n, SCM start, SCM end),
|
||||||
"Return the integer composed of the @var{start} (inclusive)\n"
|
"Return the integer composed of the @var{start} (inclusive)\n"
|
||||||
|
@ -5151,7 +5153,7 @@ SCM_DEFINE (scm_bit_extract, "bit-extract", 3, 0, 0,
|
||||||
|
|
||||||
/* When istart>=SCM_I_FIXNUM_BIT we can just limit the shift to
|
/* When istart>=SCM_I_FIXNUM_BIT we can just limit the shift to
|
||||||
SCM_I_FIXNUM_BIT-1 to get either 0 or -1 per the sign of "in". */
|
SCM_I_FIXNUM_BIT-1 to get either 0 or -1 per the sign of "in". */
|
||||||
in = SCM_SRS (in, min (istart, SCM_I_FIXNUM_BIT-1));
|
in = SCM_SRS (in, MIN (istart, SCM_I_FIXNUM_BIT-1));
|
||||||
|
|
||||||
if (in < 0 && bits >= SCM_I_FIXNUM_BIT)
|
if (in < 0 && bits >= SCM_I_FIXNUM_BIT)
|
||||||
{
|
{
|
||||||
|
@ -5166,7 +5168,7 @@ SCM_DEFINE (scm_bit_extract, "bit-extract", 3, 0, 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mask down to requisite bits */
|
/* mask down to requisite bits */
|
||||||
bits = min (bits, SCM_I_FIXNUM_BIT);
|
bits = MIN (bits, SCM_I_FIXNUM_BIT);
|
||||||
return SCM_I_MAKINUM (in & ((1L << bits) - 1));
|
return SCM_I_MAKINUM (in & ((1L << bits) - 1));
|
||||||
}
|
}
|
||||||
else if (SCM_BIGP (n))
|
else if (SCM_BIGP (n))
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SWAP(a, b) do { const SCM _tmp = GET(a); SET(a, GET(b)); SET(b, _tmp); } while (0)
|
#define SWAP(a, b) do { const SCM _tmp = GET(a); SET(a, GET(b)); SET(b, _tmp); } while (0)
|
||||||
|
#define MIN(A, B) ((A) <= (B) ? (A) : (B))
|
||||||
|
|
||||||
|
|
||||||
/* Order using quicksort. This implementation incorporates four
|
/* Order using quicksort. This implementation incorporates four
|
||||||
|
@ -177,7 +178,7 @@ NAME (VEC_PARAM ssize_t lbnd, ssize_t ubnd, INC_PARAM SCM less)
|
||||||
{
|
{
|
||||||
ssize_t tmp = lbnd;
|
ssize_t tmp = lbnd;
|
||||||
ssize_t end = ubnd;
|
ssize_t end = ubnd;
|
||||||
ssize_t thresh = min (end, MAX_THRESH);
|
ssize_t thresh = MIN (end, MAX_THRESH);
|
||||||
ssize_t run;
|
ssize_t run;
|
||||||
|
|
||||||
/* Find smallest element in first threshold and place it at the
|
/* Find smallest element in first threshold and place it at the
|
||||||
|
@ -230,6 +231,7 @@ NAME (VEC_PARAM ssize_t lbnd, ssize_t ubnd, INC_PARAM SCM less)
|
||||||
#undef STACK_NOT_EMPTY
|
#undef STACK_NOT_EMPTY
|
||||||
#undef GET
|
#undef GET
|
||||||
#undef SET
|
#undef SET
|
||||||
|
#undef MIN
|
||||||
|
|
||||||
#undef NAME
|
#undef NAME
|
||||||
#undef INC_PARAM
|
#undef INC_PARAM
|
||||||
|
|
|
@ -711,6 +711,8 @@ SCM_DEFINE (scm_shutdown, "shutdown", 2, 0, 0,
|
||||||
proc is the name of the original procedure.
|
proc is the name of the original procedure.
|
||||||
size returns the size of the structure allocated. */
|
size returns the size of the structure allocated. */
|
||||||
|
|
||||||
|
#define MAX(A, B) ((A) >= (B) ? (A) : (B))
|
||||||
|
|
||||||
static struct sockaddr *
|
static struct sockaddr *
|
||||||
scm_fill_sockaddr (int fam, SCM address, SCM *args, int which_arg,
|
scm_fill_sockaddr (int fam, SCM address, SCM *args, int which_arg,
|
||||||
const char *proc, size_t *size)
|
const char *proc, size_t *size)
|
||||||
|
@ -798,7 +800,7 @@ scm_fill_sockaddr (int fam, SCM address, SCM *args, int which_arg,
|
||||||
connect/bind etc., to fail. sun_path is always the last
|
connect/bind etc., to fail. sun_path is always the last
|
||||||
member of the structure. */
|
member of the structure. */
|
||||||
addr_size = sizeof (struct sockaddr_un)
|
addr_size = sizeof (struct sockaddr_un)
|
||||||
+ max (0, strlen (c_address) + 1 - (sizeof soka->sun_path));
|
+ MAX (0, strlen (c_address) + 1 - (sizeof soka->sun_path));
|
||||||
soka = (struct sockaddr_un *) scm_malloc (addr_size);
|
soka = (struct sockaddr_un *) scm_malloc (addr_size);
|
||||||
memset (soka, 0, addr_size); /* for sun_len: see sin_len above. */
|
memset (soka, 0, addr_size); /* for sun_len: see sin_len above. */
|
||||||
soka->sun_family = AF_UNIX;
|
soka->sun_family = AF_UNIX;
|
||||||
|
|
|
@ -81,6 +81,8 @@ string_port_read (SCM port, SCM dst, size_t start, size_t count)
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MAX(A, B) ((A) >= (B) ? (A) : (B))
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
string_port_write (SCM port, SCM src, size_t start, size_t count)
|
string_port_write (SCM port, SCM src, size_t start, size_t count)
|
||||||
{
|
{
|
||||||
|
@ -91,7 +93,7 @@ string_port_write (SCM port, SCM src, size_t start, size_t count)
|
||||||
SCM new_bv;
|
SCM new_bv;
|
||||||
size_t new_size;
|
size_t new_size;
|
||||||
|
|
||||||
new_size = max (SCM_BYTEVECTOR_LENGTH (stream->bytevector) * 2,
|
new_size = MAX (SCM_BYTEVECTOR_LENGTH (stream->bytevector) * 2,
|
||||||
stream->pos + count);
|
stream->pos + count);
|
||||||
new_bv = scm_c_make_bytevector (new_size);
|
new_bv = scm_c_make_bytevector (new_size);
|
||||||
memcpy (SCM_BYTEVECTOR_CONTENTS (new_bv),
|
memcpy (SCM_BYTEVECTOR_CONTENTS (new_bv),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue