aboutsummaryrefslogtreecommitdiffstats
path: root/imaxabs.c
blob: 81008948dc305fb8fc4e913d6b3d0bc90b053b13 (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_imaxabs_failed(intmax_t i)
{
	liberror_set_error_errno("The absolute value of largest negative integer "
	                         "cannot be represented as a signed integer",
	                         "imaxabs", EOVERFLOW);
	(void) i;
}


intmax_t
liberror_imaxabs(intmax_t i)
{
#if INTMAX_MIN == -INTMAX_MAX
	return imaxabs(i);
#else
	if (i != INTMAX_MIN)
		return imaxabs(i);
	liberror_save_backtrace(NULL);
	liberror_imaxabs_failed(i);
	return i;
#endif
}