diff options
| author | Jeff Epler <jepler@unpythonic.net> | 2025-10-11 19:12:55 -0500 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-10-23 15:12:28 +1100 |
| commit | 007f127a61ea058ca010b85883072bdefe0234c0 (patch) | |
| tree | f39d63b4cdc67ff1374b4e774511e9bb07718c58 /py/misc.h | |
| parent | eac81de4e0a462dd8121f93b42271774ced3c85f (diff) | |
all: Simplify mp_int_t/mp_uint_t definition.
Assuming proper C99 language support, we can select "the int type as big as
a pointer" (most of the time) or "the 64-bit int type" (nanboxing with
REPR_D), and then define everything else automatically.
This simplifies port configuration files. And the types can still be
overridden if needed.
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
Diffstat (limited to 'py/misc.h')
| -rw-r--r-- | py/misc.h | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -456,15 +456,15 @@ static inline uint32_t mp_clz_mpi(mp_int_t x) { } return zeroes; #else - MP_STATIC_ASSERT(sizeof(mp_int_t) == sizeof(long long) - || sizeof(mp_int_t) == sizeof(long)); - - // ugly, but should compile to single intrinsic unless O0 is set - if (mp_check(sizeof(mp_int_t) == sizeof(long))) { - return mp_clzl((unsigned long)x); - } else { - return mp_clzll((unsigned long long)x); - } + #if MP_INT_MAX == INT_MAX + return mp_clz((unsigned)x); + #elif MP_INT_MAX == LONG_MAX + return mp_clzl((unsigned long)x); + #elif MP_INT_MAX == LLONG_MAX + return mp_clzll((unsigned long long)x); + #else + #error Unexpected MP_INT_MAX value + #endif #endif } |
