Skip to content

py/obj: Verify floating point type is correct for OBJ_REPR_C. #9649

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ports/stm32/boards/ARDUINO_PORTENTA_H7/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BOOTLOADER_DFU_USB_PID = 0x035b
# MCU settings
MCU_SERIES = h7
CMSIS_MCU = STM32H747xx
MICROPY_FLOAT_IMPL = double
MICROPY_FLOAT_IMPL = single
AF_FILE = boards/stm32h743_af.csv
LD_FILES = boards/ARDUINO_PORTENTA_H7/stm32h747.ld
TEXT0_ADDR = 0x08040000
Expand Down
7 changes: 7 additions & 0 deletions py/obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ static inline bool mp_obj_is_obj(mp_const_obj_t o) {

#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C

#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_NONE
#error "MICROPY_OBJ_REPR_C requires float to be enabled."
#endif

static inline bool mp_obj_is_small_int(mp_const_obj_t o) {
return (((mp_int_t)(o)) & 1) != 0;
}
Expand All @@ -189,6 +193,9 @@ static inline bool mp_obj_is_small_int(mp_const_obj_t o) {
#endif

static inline bool mp_obj_is_float(mp_const_obj_t o) {
// Ensure that 32-bit arch can only use single precision.
MP_STATIC_ASSERT(sizeof(mp_float_t) <= sizeof(mp_obj_t));

return (((mp_uint_t)(o)) & 3) == 2 && (((mp_uint_t)(o)) & 0xff800007) != 0x00000006;
}
static inline mp_float_t mp_obj_float_get(mp_const_obj_t o) {
Expand Down