blob: 6168d77af670d113519f4a4fd7a1a35463aebf94 [file] [log] [blame]
unsigned
sat_add (unsigned i)
{
unsigned ret = i + 1;
if (ret < i)
ret = i;
return ret;
}
unsigned
sat_add2 (unsigned i)
{
unsigned ret = i + 1;
if (ret > i)
return ret;
return i;
}
unsigned
sat_add3 (unsigned i)
{
unsigned ret = i - 1;
if (ret > i)
ret = i;
return ret;
}
unsigned
sat_add4 (unsigned i)
{
unsigned ret = i - 1;
if (ret < i)
return ret;
return i;
}
main ()
{
if (sat_add (~0U) != ~0U)
abort ();
if (sat_add2 (~0U) != ~0U)
abort ();
if (sat_add3 (0U) != 0U)
abort ();
if (sat_add4 (0U) != 0U)
abort ();
exit (0);
}