Integer multiplication with overflow checking */
| 38 | |
| 39 | /* Integer multiplication with overflow checking */ |
| 40 | static inline npy_int64 |
| 41 | safe_mul(npy_int64 a, npy_int64 b, char *overflow_flag) |
| 42 | { |
| 43 | if (a > 0) { |
| 44 | if (b > NPY_MAX_INT64 / a || b < NPY_MIN_INT64 / a) { |
| 45 | *overflow_flag = 1; |
| 46 | } |
| 47 | } |
| 48 | else if (a < 0) { |
| 49 | if (b > 0 && a < NPY_MIN_INT64 / b) { |
| 50 | *overflow_flag = 1; |
| 51 | } |
| 52 | else if (b < 0 && a < NPY_MAX_INT64 / b) { |
| 53 | *overflow_flag = 1; |
| 54 | } |
| 55 | } |
| 56 | return a * b; |
| 57 | } |
| 58 | |
| 59 | |
| 60 | /* Long integer init */ |
no outgoing calls
no test coverage detected