mruby/mruby — pull request #2200 by cremno (2014-05-05 13:43:24+00:00)
Title: Add functions for safe addition and subtraction

Tests are #2190. This fixes signed integer overflow and `MRB_WORD_BOXING`. Also, the new functions are easier to use:
```c
z = x + y;
#ifdef MRB_WORD_BOXING
z = (z << MRB_FIXNUM_SHIFT) / (1 << MRB_FIXNUM_SHIFT);
#endif
if ((x < 0) != (z < 0) && ((x < 0) ^ (y < 0)) == 0) {
/* integer overflow */
```
vs.
```c
if (mrb_int_add_overflow(x, y, &z)) {
```