aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/inttypes.h14
-rw-r--r--include/stdlib.h43
2 files changed, 57 insertions, 0 deletions
diff --git a/include/inttypes.h b/include/inttypes.h
index 3f24e9b..4530fef 100644
--- a/include/inttypes.h
+++ b/include/inttypes.h
@@ -40,6 +40,20 @@
imaxdiv_t imaxdiv(intmax_t, intmax_t)
__GCC_ONLY(__attribute__((const)));
+/**
+ * Return the absolute value of an integer.
+ *
+ * Be aware, if the value is `INTMAX_MIN` and
+ * `-INTMAX_MAX != -INTMAX_MIN`, the result will
+ * overflow, and `INTMAX_MIN` will (probably)
+ * be returned.
+ *
+ * @param value The integer.
+ * @return The absolute value of the integer.
+ */
+intmax_t imaxabs(intmax_t)
+ __GCC_ONLY(__attribute__((const)));
+
#endif
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.