libc: add labs() and llabs()
Add support for abs with additional integer types. This is needed to make LLVM quiet and stop warning about abs being used with int64_t and such. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
104f100749
commit
43989ca675
2 changed files with 16 additions and 3 deletions
|
@ -261,9 +261,9 @@ This is implemented as part of the minimal C library available in Zephyr.
|
|||
isspace(),+
|
||||
isupper(),+
|
||||
isxdigit(),+
|
||||
labs(),
|
||||
labs(),+
|
||||
ldiv(),
|
||||
llabs(),
|
||||
llabs(),+
|
||||
lldiv(),
|
||||
localeconv(),
|
||||
localtime(),+
|
||||
|
|
|
@ -39,7 +39,20 @@ void abort(void);
|
|||
|
||||
int rand(void);
|
||||
|
||||
#define abs(x) ((x) < 0 ? -(x) : (x))
|
||||
static inline int abs(int __n)
|
||||
{
|
||||
return (__n < 0) ? -__n : __n;
|
||||
}
|
||||
|
||||
static inline long labs(long __n)
|
||||
{
|
||||
return (__n < 0L) ? -__n : __n;
|
||||
}
|
||||
|
||||
static inline long long llabs(long long __n)
|
||||
{
|
||||
return (__n < 0LL) ? -__n : __n;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue