[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 07/11: Move "min" and "max" macros out of _scm.h
From: |
Andy Wingo |
Subject: |
[Guile-commits] 07/11: Move "min" and "max" macros out of _scm.h |
Date: |
Sun, 17 Jun 2018 07:46:22 -0400 (EDT) |
wingo pushed a commit to branch master
in repository guile.
commit f6ec873a8be7190a44e247022754755f501ef7e1
Author: Andy Wingo <address@hidden>
Date: Sun Jun 17 09:42:19 2018 +0200
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.
---
libguile/_scm.h | 7 -------
libguile/array-map.c | 7 ++++---
libguile/foreign.c | 6 ++++--
libguile/numbers.c | 6 ++++--
libguile/quicksort.i.c | 4 +++-
libguile/socket.c | 4 +++-
libguile/strports.c | 4 +++-
7 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/libguile/_scm.h b/libguile/_scm.h
index 5bf3acb..60f5d5c 100644
--- a/libguile/_scm.h
+++ b/libguile/_scm.h
@@ -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
LEN % ALIGN == 0. Return LEN if ALIGN is zero. */
#define ROUND_UP(len, align) \
diff --git a/libguile/array-map.c b/libguile/array-map.c
index 29e4aa7..c24b088 100644
--- a/libguile/array-map.c
+++ b/libguile/array-map.c
@@ -1,5 +1,5 @@
-/* Copyright (C) 1996, 1998, 2000, 2001, 2004, 2005, 2006, 2008, 2009,
- * 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
+/* Copyright (C) 1996,1998,2000-2001,2004-2006,2008-2015,2018
+ * 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
@@ -85,6 +85,7 @@ cindk (SCM ra, ssize_t *ve, int kend)
#define LBND(ra, k) SCM_I_ARRAY_DIMS (ra)[k].lbnd
#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
@@ -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);
/* 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);
if (inc != SCM_I_ARRAY_DIMS (ra0)[kroll-1].inc)
diff --git a/libguile/foreign.c b/libguile/foreign.c
index 1b7d345..67c7d41 100644
--- a/libguile/foreign.c
+++ b/libguile/foreign.c
@@ -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_i_foreign_call (SCM cif_scm, SCM pointer_scm, int *errno_ret,
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. */
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. */
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
the case with `char'. */
rvalue = (void *) ROUND_UP ((scm_t_uintptr) data + off,
- max (sizeof (void *), cif->rtype->alignment));
+ MAX (sizeof (void *), cif->rtype->alignment));
/* off we go! */
errno = 0;
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 094c1a9..dc13e4d 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -5123,6 +5123,8 @@ SCM_DEFINE (scm_round_ash, "round-ash", 2, 0, 0,
#undef FUNC_NAME
+#define MIN(A, B) ((A) <= (B) ? (A) : (B))
+
SCM_DEFINE (scm_bit_extract, "bit-extract", 3, 0, 0,
(SCM n, SCM start, SCM end),
"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
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)
{
@@ -5166,7 +5168,7 @@ SCM_DEFINE (scm_bit_extract, "bit-extract", 3, 0, 0,
}
/* 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));
}
else if (SCM_BIGP (n))
diff --git a/libguile/quicksort.i.c b/libguile/quicksort.i.c
index 5982672..bce5902 100644
--- a/libguile/quicksort.i.c
+++ b/libguile/quicksort.i.c
@@ -12,6 +12,7 @@
*/
#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
@@ -177,7 +178,7 @@ NAME (VEC_PARAM ssize_t lbnd, ssize_t ubnd, INC_PARAM SCM
less)
{
ssize_t tmp = lbnd;
ssize_t end = ubnd;
- ssize_t thresh = min (end, MAX_THRESH);
+ ssize_t thresh = MIN (end, MAX_THRESH);
ssize_t run;
/* 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 GET
#undef SET
+#undef MIN
#undef NAME
#undef INC_PARAM
diff --git a/libguile/socket.c b/libguile/socket.c
index 2a30890..13ce514 100644
--- a/libguile/socket.c
+++ b/libguile/socket.c
@@ -711,6 +711,8 @@ SCM_DEFINE (scm_shutdown, "shutdown", 2, 0, 0,
proc is the name of the original procedure.
size returns the size of the structure allocated. */
+#define MAX(A, B) ((A) >= (B) ? (A) : (B))
+
static struct sockaddr *
scm_fill_sockaddr (int fam, SCM address, SCM *args, int which_arg,
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
member of the structure. */
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);
memset (soka, 0, addr_size); /* for sun_len: see sin_len above. */
soka->sun_family = AF_UNIX;
diff --git a/libguile/strports.c b/libguile/strports.c
index e99ceb8..84ca0b2 100644
--- a/libguile/strports.c
+++ b/libguile/strports.c
@@ -81,6 +81,8 @@ string_port_read (SCM port, SCM dst, size_t start, size_t
count)
return count;
}
+#define MAX(A, B) ((A) >= (B) ? (A) : (B))
+
static size_t
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;
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);
new_bv = scm_c_make_bytevector (new_size);
memcpy (SCM_BYTEVECTOR_CONTENTS (new_bv),
- [Guile-commits] branch master updated (601d0ea -> f84ce54), Andy Wingo, 2018/06/17
- [Guile-commits] 01/11: Remove unused macro in vm-engine, Andy Wingo, 2018/06/17
- [Guile-commits] 02/11: Remove unused vm_error_unbound, Andy Wingo, 2018/06/17
- [Guile-commits] 06/11: Simplify definition of SCM_SYSCALL., Andy Wingo, 2018/06/17
- [Guile-commits] 09/11: Remove unused getters for register backing store base, Andy Wingo, 2018/06/17
- [Guile-commits] 10/11: Add configure check for auxiliary stacks, Andy Wingo, 2018/06/17
- [Guile-commits] 03/11: Call out to expand_stack through new VM intrinsic, Andy Wingo, 2018/06/17
- [Guile-commits] 08/11: Remove #ifdef cases for VMS and Cray., Andy Wingo, 2018/06/17
- [Guile-commits] 05/11: Move some definitions out of _scm.h, Andy Wingo, 2018/06/17
- [Guile-commits] 07/11: Move "min" and "max" macros out of _scm.h,
Andy Wingo <=
- [Guile-commits] 11/11: Refactor handling of auxiliary stacks and setjmp/longjmp, Andy Wingo, 2018/06/17
- [Guile-commits] 04/11: Fix libguile subcomponent headers not to include <libguile.h>, Andy Wingo, 2018/06/17