aboutsummaryrefslogtreecommitdiffstats
path: root/imaxabs.c
diff options
context:
space:
mode:
Diffstat (limited to 'imaxabs.c')
-rw-r--r--imaxabs.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/imaxabs.c b/imaxabs.c
new file mode 100644
index 0000000..cffacc2
--- /dev/null
+++ b/imaxabs.c
@@ -0,0 +1,18 @@
+/* See LICENSE file for copyright and license details. */
+#include "internal.h"
+
+
+intmax_t
+liberror_imaxabs(intmax_t i)
+{
+#if INTMAX_MIN == -INTMAX_MAX
+ return imaxabs(i);
+#else
+ if (i != INTMAX_MIN)
+ return imaxabs(i);
+ liberror_set_error_errno("The absolute value of largest negative integer "
+ "cannot be represented as a signed integer",
+ "imaxabs", EOVERFLOW);
+ return i;
+#endif
+}