aboutsummaryrefslogtreecommitdiffstats
path: root/abs.c
blob: 71d73b5d57e447240070b82db61064cf7a88a202 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* See LICENSE file for copyright and license details. */
#include "internal.h"


int
liberror_abs(int i)
{
#if INT_MIN == -INT_MAX
	return abs(i);
#else
	if (i != INT_MIN)
		return abs(i);
	liberror_save_backtrace(NULL);
	liberror_set_error_errno("The absolute value of largest negative integer "
	                         "cannot be represented as a signed integer",
	                         "abs", EOVERFLOW);
	return i;
#endif
}