aboutsummaryrefslogtreecommitdiffstats
path: root/include/stdlib.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-11-17 02:31:11 +0100
committerMattias Andrée <maandree@operamail.com>2015-11-17 02:31:11 +0100
commitae942840140e38835e562e8d235578c017d00766 (patch)
treef71696eba1addd25ad0393926a3f0787f26a2e98 /include/stdlib.h
parentsplit abs.c (diff)
downloadslibc-ae942840140e38835e562e8d235578c017d00766.tar.gz
slibc-ae942840140e38835e562e8d235578c017d00766.tar.bz2
slibc-ae942840140e38835e562e8d235578c017d00766.tar.xz
add macros for abs, labs, llabs, and imaxabs
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--include/stdlib.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/include/stdlib.h b/include/stdlib.h
index fe0c5f7..075d3a4 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -107,8 +107,9 @@ lldiv_t lldiv(long long, long long)
* @param value The integer.
* @return The absolute value of the integer.
*/
-int abs(int)
+int (abs)(int)
__GCC_ONLY(__attribute__((__const__)));
+#define abs(value) ((int)value < 0 ? -(int)value : (int)value)
/**
* Return the absolute value of an integer.
@@ -121,8 +122,9 @@ int abs(int)
* @param value The integer.
* @return The absolute value of the integer.
*/
-long int labs(long int)
+long int (labs)(long int)
__GCC_ONLY(__attribute__((__const__)));
+#define labs(value) ((long int)value < 0 ? -(long int)value : (long int)value)
/**
* Return the absolute value of an integer.
@@ -135,8 +137,9 @@ long int labs(long int)
* @param value The integer.
* @return The absolute value of the integer.
*/
-long long int llabs(long long int)
+long long int (llabs)(long long int)
__GCC_ONLY(__attribute__((__const__)));
+#define llabs(value) ((long long int)value < 0 ? -(long long int)value : (long long int)value)
#if !defined(__PORTABLE)