aboutsummaryrefslogblamecommitdiffstats
path: root/abs.c
blob: feac9a70c6a1938b1a5979a2d91e72775a3ce9cf (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14



                                                         









                                                                                  







                              
                                      
                               


                 
/* See LICENSE file for copyright and license details. */
#include "internal.h"


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


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_abs_failed(i);
	return i;
#endif
}