diff options
author | Damien George <damien@micropython.org> | 2021-02-04 15:32:59 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2021-02-04 22:46:42 +1100 |
commit | 7e956fae28e4e3fdea30f834d448eacfc4429de7 (patch) | |
tree | 7404f6f2fda3d8c5533db9d56481cb703714e8b7 /py/runtime.c | |
parent | 8a41ee19c22d7bb85fcbd90c9d06b9937a1b8c87 (diff) |
py: Rename BITS_PER_BYTE to MP_BITS_PER_BYTE.
To give this macro a standard MP_ prefix.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/runtime.c')
-rw-r--r-- | py/runtime.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/py/runtime.c b/py/runtime.c index 2e2fa1d17..5d476a276 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -387,7 +387,7 @@ mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { if (rhs_val < 0) { // negative shift not allowed mp_raise_ValueError(MP_ERROR_TEXT("negative shift count")); - } else if (rhs_val >= (mp_int_t)(sizeof(lhs_val) * BITS_PER_BYTE) + } else if (rhs_val >= (mp_int_t)(sizeof(lhs_val) * MP_BITS_PER_BYTE) || lhs_val > (MP_SMALL_INT_MAX >> rhs_val) || lhs_val < (MP_SMALL_INT_MIN >> rhs_val)) { // left-shift will overflow, so use higher precision integer @@ -406,10 +406,10 @@ mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { mp_raise_ValueError(MP_ERROR_TEXT("negative shift count")); } else { // standard precision is enough for right-shift - if (rhs_val >= (mp_int_t)(sizeof(lhs_val) * BITS_PER_BYTE)) { + if (rhs_val >= (mp_int_t)(sizeof(lhs_val) * MP_BITS_PER_BYTE)) { // Shifting to big amounts is underfined behavior // in C and is CPU-dependent; propagate sign bit. - rhs_val = sizeof(lhs_val) * BITS_PER_BYTE - 1; + rhs_val = sizeof(lhs_val) * MP_BITS_PER_BYTE - 1; } lhs_val >>= rhs_val; } |