diff options
author | Alessandro Gatti <a.gatti@frob.it> | 2024-09-12 13:08:32 +0200 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-10-30 17:21:30 +1100 |
commit | d34b15ac6f03ecad224d02aec9491d6a04605f72 (patch) | |
tree | 8f91299e617a89bbe9f663e2f15341531ef2d267 /py/misc.h | |
parent | 548babf8a04510d99a49b2d129a9579afc33e182 (diff) |
pic16bit: Make it build with recent XC16 versions.
The PIC16 port didn't catch up with the other ports, so it required a bit
of work to make it build with the latest version of XC16.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Diffstat (limited to 'py/misc.h')
-rw-r--r-- | py/misc.h | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -380,6 +380,18 @@ static inline bool mp_check(bool value) { // mp_int_t can be larger than long, i.e. Windows 64-bit, nan-box variants static inline uint32_t mp_clz_mpi(mp_int_t x) { + #ifdef __XC16__ + mp_uint_t mask = MP_OBJ_WORD_MSBIT_HIGH; + mp_uint_t zeroes = 0; + while (mask != 0) { + if (mask & (mp_uint_t)x) { + break; + } + zeroes++; + mask >>= 1; + } + return zeroes; + #else MP_STATIC_ASSERT(sizeof(mp_int_t) == sizeof(long long) || sizeof(mp_int_t) == sizeof(long)); @@ -389,6 +401,7 @@ static inline uint32_t mp_clz_mpi(mp_int_t x) { } else { return mp_clzll((unsigned long long)x); } + #endif } #endif // MICROPY_INCLUDED_PY_MISC_H |