Skip to content

Commit

Permalink
Util: add ASM version ROUNDDOWN and ROUNDUP definitions
Browse files Browse the repository at this point in the history
Add ROUNDDOWN and ROUNDUP definitions for ASM version which are
different from C versions

Signed-off-by: Kevin Peng <kevinp@marvell.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
  • Loading branch information
Kevin Peng committed Oct 16, 2017
1 parent 01c52fb commit 7f0a2bd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/libutils/ext/include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,17 @@

#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

#ifndef ASM
/* Round up the even multiple of size, size has to be a multiple of 2 */
#define ROUNDUP(v, size) (((v) + ((__typeof__(v))(size) - 1)) & \
~((__typeof__(v))(size) - 1))

/* Round down the even multiple of size, size has to be a multiple of 2 */
#define ROUNDDOWN(v, size) ((v) & ~((__typeof__(v))(size) - 1))
#else
#define ROUNDUP(x, y) ((((x) + (y) - 1) / (y)) * (y))
#define ROUNDDOWN(x, y) (((x) / (y)) * (y))
#endif

/* x has to be of an unsigned type */
#define IS_POWER_OF_TWO(x) (((x) != 0) && (((x) & (~(x) + 1)) == (x)))
Expand Down

0 comments on commit 7f0a2bd

Please sign in to comment.