* Computes the python `ret, d = divmod(d, unit)`. * * Note that GCC is smart enough at -O2 to eliminate the `if(*d < 0)` branch * for subsequent calls to this command - it is able to deduce that `*d >= 0`. */
| 41 | * for subsequent calls to this command - it is able to deduce that `*d >= 0`. |
| 42 | */ |
| 43 | static inline |
| 44 | npy_int64 extract_unit_64(npy_int64 *d, npy_int64 unit) { |
| 45 | assert(unit > 0); |
| 46 | npy_int64 div = *d / unit; |
| 47 | npy_int64 mod = *d % unit; |
| 48 | if (mod < 0) { |
| 49 | mod += unit; |
| 50 | div -= 1; |
| 51 | } |
| 52 | assert(mod >= 0); |
| 53 | *d = mod; |
| 54 | return div; |
| 55 | } |
| 56 | |
| 57 | static inline |
| 58 | npy_int32 extract_unit_32(npy_int32 *d, npy_int32 unit) { |
no outgoing calls
no test coverage detected