include/stdlib.h: Extend common macro collection
Add the following useful macros: * Absolute Value Macro * Taking ceiling of (a / b) * Check if value x is a power of 2 or not Change-Id: I4e9a326aea3cdd963f13548d1fb63331a57d84b1 Signed-off-by: Edward O'Callaghan <eocallaghan@alterapraxis.com> Reviewed-on: http://review.coreboot.org/6198 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
This commit is contained in:
parent
4793328fbd
commit
fd570665ce
|
@ -12,6 +12,9 @@
|
|||
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
#define ABS(a) (((a) < 0) ? (-(a)) : (a))
|
||||
#define CEIL_DIV(a, b) (((a) + (b) - 1) / (b))
|
||||
#define IS_POWER_OF_2(x) (((x) & ((x) - 1)) == 0)
|
||||
|
||||
#define min(a,b) MIN((a),(b))
|
||||
#define max(a,b) MAX((a),(b))
|
||||
|
|
Loading…
Reference in New Issue