mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-20 20:04:46 +00:00
Add abs() macro to return absolute value
This macro is generally useful to make it available in common. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Warren <twarren@nvidia.com> Acked-by: Tom Rini <trini@ti.com> Acked-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
parent
3ddecfc740
commit
a35925b8c1
3 changed files with 25 additions and 7 deletions
|
@ -46,8 +46,6 @@
|
||||||
#define puts(s)
|
#define puts(s)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define abs(x) (((x) < 0) ? ((x)*-1) : (x))
|
|
||||||
|
|
||||||
struct omap4_prcm_regs *const prcm = (struct omap4_prcm_regs *)0x4A004100;
|
struct omap4_prcm_regs *const prcm = (struct omap4_prcm_regs *)0x4A004100;
|
||||||
|
|
||||||
const u32 sys_clk_array[8] = {
|
const u32 sys_clk_array[8] = {
|
||||||
|
|
|
@ -118,11 +118,6 @@ static u32 x86emu_parity_tab[8] =
|
||||||
|
|
||||||
#define PARITY(x) (((x86emu_parity_tab[(x) / 32] >> ((x) % 32)) & 1) == 0)
|
#define PARITY(x) (((x86emu_parity_tab[(x) / 32] >> ((x) % 32)) & 1) == 0)
|
||||||
#define XOR2(x) (((x) ^ ((x)>>1)) & 0x1)
|
#define XOR2(x) (((x) ^ ((x)>>1)) & 0x1)
|
||||||
/*----------------------------- Implementation ----------------------------*/
|
|
||||||
int abs(int v)
|
|
||||||
{
|
|
||||||
return (v>0)?v:-v;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*----------------------------- Implementation ----------------------------*/
|
/*----------------------------- Implementation ----------------------------*/
|
||||||
|
|
||||||
|
|
|
@ -222,6 +222,31 @@ typedef void (interrupt_handler_t)(void *);
|
||||||
#define MIN(x, y) min(x, y)
|
#define MIN(x, y) min(x, y)
|
||||||
#define MAX(x, y) max(x, y)
|
#define MAX(x, y) max(x, y)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the absolute value of a number.
|
||||||
|
*
|
||||||
|
* This handles unsigned and signed longs, ints, shorts and chars. For all
|
||||||
|
* input types abs() returns a signed long.
|
||||||
|
*
|
||||||
|
* For 64-bit types, use abs64()
|
||||||
|
*/
|
||||||
|
#define abs(x) ({ \
|
||||||
|
long ret; \
|
||||||
|
if (sizeof(x) == sizeof(long)) { \
|
||||||
|
long __x = (x); \
|
||||||
|
ret = (__x < 0) ? -__x : __x; \
|
||||||
|
} else { \
|
||||||
|
int __x = (x); \
|
||||||
|
ret = (__x < 0) ? -__x : __x; \
|
||||||
|
} \
|
||||||
|
ret; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define abs64(x) ({ \
|
||||||
|
s64 __x = (x); \
|
||||||
|
(__x < 0) ? -__x : __x; \
|
||||||
|
})
|
||||||
|
|
||||||
#if defined(CONFIG_ENV_IS_EMBEDDED)
|
#if defined(CONFIG_ENV_IS_EMBEDDED)
|
||||||
#define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN
|
#define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN
|
||||||
#elif ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \
|
#elif ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \
|
||||||
|
|
Loading…
Add table
Reference in a new issue