From e159ac072b5cf24542bd630474e6cd1e1ec11aee Mon Sep 17 00:00:00 2001 From: Kees Jongenburger Date: Fri, 11 Oct 2013 10:19:35 +0200 Subject: [PATCH] doc:document roundup, rounddown and variants. --- sys/sys/param.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sys/sys/param.h b/sys/sys/param.h index d3f50c824..ea4ec8919 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -246,9 +246,22 @@ #ifndef howmany #define howmany(x, y) (((x)+((y)-1))/(y)) #endif -#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) +/* + * Integer round x up to a multiple of y + */ +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) +/* + * Integer round x down to a multiple of y + */ #define rounddown(x,y) (((x)/(y))*(y)) +/* + * Integer round x up to a multiple of m assuming + * m is a power of two + */ #define roundup2(x, m) (((x) + (m) - 1) & ~((m) - 1)) +/* + * determine if x is a power of two + */ #define powerof2(x) ((((x)-1)&(x))==0) /* Macros for min/max. */