defensive addition More...


Defensive addition operations that add two positive addends and throw an exception if overflow is detected.
| CGUL_BEGIN_C CGUL_EXPORT char cgul_defensive__add_char | ( | cgul_exception_t * | cex, |
| char | x1, | ||
| char | x2 | ||
| ) |
This function detects whether the char type is signed or unsigned and forwards the call to either cgul_defensive__add_signed_char() or cgul_defensive__add_unsigned_char() whichever is correct.
| [in,out] | cex | c-style exception |
| [in] | x1 | first positive addend |
| [in] | x2 | second positive addend |
| CGUL_EXPORT signed char cgul_defensive__add_signed_char | ( | cgul_exception_t * | cex, |
| signed char | x1, | ||
| signed char | x2 | ||
| ) |
This function returns the sum of the positive addends x1 and x2. If overflow or negative addends are detected, an exception is thrown, and 0 is returned.
| [in,out] | cex | c-style exception |
| [in] | x1 | first positive addend |
| [in] | x2 | second positive addend |
| CGUL_EXPORT unsigned char cgul_defensive__add_unsigned_char | ( | cgul_exception_t * | cex, |
| unsigned char | x1, | ||
| unsigned char | x2 | ||
| ) |
This function returns the sum of the addends x1 and x2. If overflow is detected, an exception is thrown, and 0 is returned.
| [in,out] | cex | c-style exception |
| [in] | x1 | first addend |
| [in] | x2 | second addend |
| CGUL_EXPORT short cgul_defensive__add_short | ( | cgul_exception_t * | cex, |
| short | x1, | ||
| short | x2 | ||
| ) |
This function returns the sum of the positive addends x1 and x2. If overflow or negative addends are detected, an exception is thrown, and 0 is returned.
| [in,out] | cex | c-style exception |
| [in] | x1 | first positive addend |
| [in] | x2 | second positive addend |
| CGUL_EXPORT unsigned short cgul_defensive__add_unsigned_short | ( | cgul_exception_t * | cex, |
| unsigned short | x1, | ||
| unsigned short | x2 | ||
| ) |
This function returns the sum of the addends x1 and x2. If overflow is detected, an exception is thrown, and 0 is returned.
| [in,out] | cex | c-style exception |
| [in] | x1 | first addend |
| [in] | x2 | second addend |
| CGUL_EXPORT int cgul_defensive__add_int | ( | cgul_exception_t * | cex, |
| int | x1, | ||
| int | x2 | ||
| ) |
This function returns the sum of the positive addends x1 and x2. If overflow or negative addends are detected, an exception is thrown, and 0 is returned.
| [in,out] | cex | c-style exception |
| [in] | x1 | first positive addend |
| [in] | x2 | second positive addend |
| CGUL_EXPORT unsigned int cgul_defensive__add_unsigned | ( | cgul_exception_t * | cex, |
| unsigned int | x1, | ||
| unsigned int | x2 | ||
| ) |
This function returns the sum of the addends x1 and x2. If overflow is detected, an exception is thrown, and 0 is returned.
| [in,out] | cex | c-style exception |
| [in] | x1 | first addend |
| [in] | x2 | second addend |
| CGUL_EXPORT long cgul_defensive__add_long | ( | cgul_exception_t * | cex, |
| long | x1, | ||
| long | x2 | ||
| ) |
This function returns the sum of the positive addends x1 and x2. If overflow or negative addends are detected, an exception is thrown, and 0 is returned.
| [in,out] | cex | c-style exception |
| [in] | x1 | first positive addend |
| [in] | x2 | second positive addend |
| CGUL_EXPORT unsigned long cgul_defensive__add_unsigned_long | ( | cgul_exception_t * | cex, |
| unsigned long | x1, | ||
| unsigned long | x2 | ||
| ) |
This function returns the sum of the addends x1 and x2. If overflow is detected, an exception is thrown, and 0 is returned.
| [in,out] | cex | c-style exception |
| [in] | x1 | first addend |
| [in] | x2 | second addend |
| CGUL_EXPORT size_t cgul_defensive__add_size_type | ( | cgul_exception_t * | cex, |
| size_t | x1, | ||
| size_t | x2 | ||
| ) |
This function returns the sum of the addends x1 and x2. If overflow is detected, an exception is thrown, and 0 is returned.
| [in,out] | cex | c-style exception |
| [in] | x1 | first addend |
| [in] | x2 | second addend |