Integer subtraction with overflow checking */
| 24 | |
| 25 | /* Integer subtraction with overflow checking */ |
| 26 | static inline npy_int64 |
| 27 | safe_sub(npy_int64 a, npy_int64 b, char *overflow_flag) |
| 28 | { |
| 29 | if (a >= 0 && b < a - NPY_MAX_INT64) { |
| 30 | *overflow_flag = 1; |
| 31 | } |
| 32 | else if (a < 0 && b > a - NPY_MIN_INT64) { |
| 33 | *overflow_flag = 1; |
| 34 | } |
| 35 | return a - b; |
| 36 | } |
| 37 | |
| 38 | |
| 39 | /* Integer multiplication with overflow checking */ |