As far as I know there is no such utility, so you would need to build you own.
There is a good article that covers saturating arithmetic: Branchfree Saturating Arithmetic and they cover all the arithmetic operations. Their examples are in C but should not be difficult to translate.
For your case we would be looking at addition. They assume the following:
#include <limits.h>
typedef unsigned u32b;
typedef signed s32b;
and for unsigned addition they provide the following code:
u32b sat_addu32b(u32b x, u32b y)
{
u32b res = x + y;
res |= -(res < x);
return res;
}
and for signed addition:
s32b sat_adds32b(s32b x, s32b y)
{
u32b ux = x;
u32b uy = y;
u32b res = ux + uy;
/* Calculate overflowed result. (Don't change the sign bit of ux) */
ux = (ux >> 31) + INT_MAX;
/* Force compiler to use cmovns instruction */
if ((s32b) ((ux ^ uy) | ~(uy ^ res)) >= 0)
{
res = ux;
}
return res;
}
As Pascal Cuoq notes in a comment the unsigned case assumes twos complement which should be fine for the vast majority of the cases but the standard does not make assumptions on the underlying representation.