Fix parenthesizing of the `ROUND_UP' macro; factorize.
authorLudovic Courtès <ludo@gnu.org>
Sun, 30 May 2010 20:41:36 +0000 (22:41 +0200)
committerLudovic Courtès <ludo@gnu.org>
Sun, 30 May 2010 20:41:36 +0000 (22:41 +0200)
* libguile/_scm.h (ROUND_UP): New macro.

* libguile/continuations.c (ROUND_UP): Remove.

* libguile/control.c (ROUND_UP): Remove.

* libguile/foreign.c (ROUND_UP): Remove.

libguile/_scm.h
libguile/continuations.c
libguile/control.c
libguile/foreign.c

index 9cd6fad..bf655b3 100644 (file)
 #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)                                   \
+  ((align) ? (((len) - 1UL) | ((align) - 1UL)) + 1UL : (len))
 
 
 #if GUILE_USE_64_CALLS && defined(HAVE_STAT64)
index 69a87d2..dc504f0 100644 (file)
@@ -71,7 +71,6 @@ static scm_t_bits tc16_continuation;
 #define META_HEADER(meta)         meta, 0, 0, 0, 0,      0, 0, 0
 #endif
 
-#define ROUND_UP(len,align) (((len-1)|(align-1))+1)
 #define ALIGN_PTR(type,p,align) (type*)(ROUND_UP (((scm_t_bits)p), align))
 
 #ifdef SCM_ALIGNED
index bb35fdf..6c20675 100644 (file)
@@ -79,7 +79,6 @@ scm_i_prompt_pop_abort_args_x (SCM prompt)
 #define META_HEADER(meta)         meta, 0, 0, 0, 0,      0, 0, 0
 #endif
 
-#define ROUND_UP(len,align) (((len-1)|(align-1))+1)
 #define ALIGN_PTR(type,p,align) (type*)(ROUND_UP (((scm_t_bits)p), align))
 
 #ifdef SCM_ALIGNED
index a58634a..8b3c9be 100644 (file)
@@ -431,9 +431,6 @@ scm_i_foreign_print (SCM foreign, SCM port, scm_print_state *pstate)
 
 \f
 
-
-#define ROUND_UP(len,align) (align?(((len-1)|(align-1))+1):len)
-
 SCM_DEFINE (scm_alignof, "alignof", 1, 0, 0, (SCM type),
             "Return the alignment of @var{type}, in bytes.\n\n"
             "@var{type} should be a valid C type, like @code{int}.\n"