aboutsummaryrefslogtreecommitdiffstats
path: root/labs.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-04-12 21:12:31 +0200
committerMattias Andrée <maandree@kth.se>2019-04-12 21:13:37 +0200
commitbafb07a1644896d56ad4b8effaeaae601c5a275b (patch)
treeef4e38f529ba2f0cadc73ad88493a1cca206fe7b /labs.c
downloadliberror-libc-bafb07a1644896d56ad4b8effaeaae601c5a275b.tar.gz
liberror-libc-bafb07a1644896d56ad4b8effaeaae601c5a275b.tar.bz2
liberror-libc-bafb07a1644896d56ad4b8effaeaae601c5a275b.tar.xz
First commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'labs.c')
-rw-r--r--labs.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/labs.c b/labs.c
new file mode 100644
index 0000000..3979dff
--- /dev/null
+++ b/labs.c
@@ -0,0 +1,18 @@
+/* See LICENSE file for copyright and license details. */
+#include "internal.h"
+
+
+long int
+liberror_labs(long int i)
+{
+#if LONG_MIN == -LONG_MAX
+ return labs(i);
+#else
+ if (i != LONG_MIN)
+ return labs(i);
+ liberror_set_error_errno("The absolute value of largest negative integer "
+ "cannot be represented as a signed integer",
+ "labs", EOVERFLOW);
+ return i;
+#endif
+}