aboutsummaryrefslogtreecommitdiffstats
path: root/labs.c
blob: 2a5f05031c25999b6d08006e02fa95f4b9be8c3d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* See LICENSE file for copyright and license details. */
#include "internal.h"


void
liberror_labs_failed(long int i)
{
	liberror_set_error_errno("The absolute value of largest negative integer "
	                         "cannot be represented as a signed integer",
	                         "labs", EOVERFLOW);
	(void) i;
}


long int
liberror_labs(long int i)
{
#if LONG_MIN == -LONG_MAX
	return labs(i);
#else
	if (i != LONG_MIN)
		return labs(i);
	liberror_save_backtrace(NULL);
	liberror_labs_failed(i);
	return i;
#endif
}