aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/inttypes.h3
-rw-r--r--include/stdlib.h9
-rw-r--r--src/inttypes/imaxabs.c2
-rw-r--r--src/stdlib/abs/abs.c2
-rw-r--r--src/stdlib/abs/labs.c2
-rw-r--r--src/stdlib/abs/llabs.c2
6 files changed, 12 insertions, 8 deletions
diff --git a/include/inttypes.h b/include/inttypes.h
index 9463412..d99b334 100644
--- a/include/inttypes.h
+++ b/include/inttypes.h
@@ -57,8 +57,9 @@ imaxdiv_t imaxdiv(intmax_t, intmax_t)
* @param value The integer.
* @return The absolute value of the integer.
*/
-intmax_t imaxabs(intmax_t)
+intmax_t (imaxabs)(intmax_t)
__GCC_ONLY(__attribute__((__const__)));
+#define imaxabs(value) ((intmax_t)value < 0 ? -(intmax_t)value : (intmax_t)value)
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)
diff --git a/src/inttypes/imaxabs.c b/src/inttypes/imaxabs.c
index 1f3b337..651452a 100644
--- a/src/inttypes/imaxabs.c
+++ b/src/inttypes/imaxabs.c
@@ -30,7 +30,7 @@
* @param value The integer.
* @return The absolute value of the integer.
*/
-intmax_t imaxabs(intmax_t value)
+intmax_t (imaxabs)(intmax_t value)
{
return value < 0 ? -value : value;
}
diff --git a/src/stdlib/abs/abs.c b/src/stdlib/abs/abs.c
index 9452a5b..9bc3bd4 100644
--- a/src/stdlib/abs/abs.c
+++ b/src/stdlib/abs/abs.c
@@ -30,7 +30,7 @@
* @param value The integer.
* @return The absolute value of the integer.
*/
-int abs(int value)
+int (abs)(int value)
{
return value < 0 ? -value : value;
}
diff --git a/src/stdlib/abs/labs.c b/src/stdlib/abs/labs.c
index 360122d..20d0ac6 100644
--- a/src/stdlib/abs/labs.c
+++ b/src/stdlib/abs/labs.c
@@ -30,7 +30,7 @@
* @param value The integer.
* @return The absolute value of the integer.
*/
-long int labs(long int value)
+long int (labs)(long int value)
{
return value < 0 ? -value : value;
}
diff --git a/src/stdlib/abs/llabs.c b/src/stdlib/abs/llabs.c
index 23ae2ed..71e5a1b 100644
--- a/src/stdlib/abs/llabs.c
+++ b/src/stdlib/abs/llabs.c
@@ -30,7 +30,7 @@
* @param value The integer.
* @return The absolute value of the integer.
*/
-long long int llabs(long long int value)
+long long int (llabs)(long long int value)
{
return value < 0 ? -value : value;
}