From 41f350e672007ee64657b4ac67ffc95229ad841d Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 10 Oct 2015 21:48:37 +0200 Subject: add abs, labs, llabs, and imaxabs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- include/stdlib.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'include/stdlib.h') diff --git a/include/stdlib.h b/include/stdlib.h index 8d65597..4fba1a0 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -93,6 +93,49 @@ lldiv_t lldiv(long long, long long) __GCC_ONLY(__attribute__((const))); +/** + * Return the absolute value of an integer. + * + * Be aware, if the value is `INT_MIN` and + * `-INT_MAX != -INT_MIN`, the result will + * overflow, and `INT_MIN` will (probably) + * be returned. + * + * @param value The integer. + * @return The absolute value of the integer. + */ +int abs(int) + __GCC_ONLY(__attribute__((const))); + +/** + * Return the absolute value of an integer. + * + * Be aware, if the value is `LONG_MIN` and + * `-LONG_MAX != -LONG_MIN`, the result will + * overflow, and `LONG_MIN` will (probably) + * be returned. + * + * @param value The integer. + * @return The absolute value of the integer. + */ +long int labs(long int) + __GCC_ONLY(__attribute__((const))); + +/** + * Return the absolute value of an integer. + * + * Be aware, if the value is `LLONG_MIN` and + * `-LLONG_MAX != -LLONG_MIN`, the result will + * overflow, and `LLONG_MIN` will (probably) + * be returned. + * + * @param value The integer. + * @return The absolute value of the integer. + */ +long long int llabs(long long int) + __GCC_ONLY(__attribute__((const))); + + #if !defined(__PORTABLE) /** * Get the absolute path of a file. -- cgit v1.2.3-70-g09d2