diff options
author | stijn <stijn@ignitron.net> | 2020-04-09 09:05:48 +0200 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-04-18 22:36:14 +1000 |
commit | 0ba68f8a1dae84de950420aebf8ad46582a38e66 (patch) | |
tree | c996a9b3d26f58b286ef6f9deb508de141b66574 /py/nativeglue.c | |
parent | b909e8b2dd007d8e7d61547768518b29bb4f833c (diff) | |
download | micropython-0ba68f8a1dae84de950420aebf8ad46582a38e66.tar.gz micropython-0ba68f8a1dae84de950420aebf8ad46582a38e66.zip |
all: Fix implicit floating point promotion.
Initially some of these were found building the unix coverage variant on
MacOS because that build uses clang and has -Wdouble-promotion enabled, and
clang performs more vigorous promotion checks than gcc. Additionally the
codebase has been compiled with clang and msvc (the latter with warning
level 3), and with MICROPY_FLOAT_IMPL_FLOAT to find the rest of the
conversions.
Fixes are implemented either as explicit casts, or by using the correct
type, or by using one of the utility functions to handle floating point
casting; these have been moved from nativeglue.c to the public API.
Diffstat (limited to 'py/nativeglue.c')
-rw-r--r-- | py/nativeglue.c | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/py/nativeglue.c b/py/nativeglue.c index eebbe18bb7..30e5b40061 100644 --- a/py/nativeglue.c +++ b/py/nativeglue.c @@ -227,25 +227,7 @@ STATIC bool mp_native_yield_from(mp_obj_t gen, mp_obj_t send_value, mp_obj_t *re return false; } -#if MICROPY_PY_BUILTINS_FLOAT - -STATIC mp_obj_t mp_obj_new_float_from_f(float f) { - return mp_obj_new_float((mp_float_t)f); -} - -STATIC mp_obj_t mp_obj_new_float_from_d(double d) { - return mp_obj_new_float((mp_float_t)d); -} - -STATIC float mp_obj_get_float_to_f(mp_obj_t o) { - return (float)mp_obj_get_float(o); -} - -STATIC double mp_obj_get_float_to_d(mp_obj_t o) { - return (double)mp_obj_get_float(o); -} - -#else +#if !MICROPY_PY_BUILTINS_FLOAT STATIC mp_obj_t mp_obj_new_float_from_f(float f) { (void)f; |