From: Sebastien Bourdeauducq Date: Mon, 4 Jun 2012 17:41:49 +0000 (+0200) Subject: base/stdlib.h: abs/labs X-Git-Tag: 24jan2021_ls180~3132 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2dc346dfd6a74f8976ce6cb81b72b66928acb246;p=litex.git base/stdlib.h: abs/labs --- diff --git a/software/include/base/stdlib.h b/software/include/base/stdlib.h index 7edfac63..2906720c 100644 --- a/software/include/base/stdlib.h +++ b/software/include/base/stdlib.h @@ -32,7 +32,15 @@ #define likely(x) x #define unlikely(x) x -#define abs(x) ((x) > 0 ? (x) : -(x)) +static inline int abs(int x) +{ + return x > 0 ? x : -x; +} + +static inline long int labs(long int x) +{ + return x > 0 ? x : -x; +} unsigned long strtoul(const char *nptr, char **endptr, int base); int skip_atoi(const char **s);