8000 Merge pull request #10269 from tannewt/shrink_samd · unwiredben/circuitpython@b3ff084 · GitHub
[go: up one dir, main page]

Skip to content

Commit b3ff084

Browse files
authored
Merge pull request adafruit#10269 from tannewt/shrink_samd
Shrink non-FULL builds (SAMDs mostly)
2 parents d5865e5 + 8571634 commit b3ff084

File tree

7 files changed

+26
-1
lines changed

7 files changed

+26
-1
lines changed

ports/atmel-samd/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ CFLAGS += \
117117
-msoft-float \
118118
-mfloat-abi=soft \
119119
-DSAMD21
120-
LIBS := libs/libgcc-12.1.0-Os-v6-m-nofp.a -lc
120+
LIBS := libs/libgcc-14.2.0-Os-v6-m-nofp.a -lc
121121
else
122122
LIBS := -lgcc -lc
123123
endif

ports/atmel-samd/boards/adafruit_trrs_trinkey_m0/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@
4040
// no PA29
4141
#define IGNORE_PIN_PA30 1
4242
#define IGNORE_PIN_PA31 1
43+
44+
// A couple Learn examples do `array.array('d', ...)` so enable it.
45+
#define MICROPY_PY_DOUBLE_TYPECODE 1
Binary file not shown.
Binary file not shown.

py/binary.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,10 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, size_t index) {
289289
#if MICROPY_PY_BUILTINS_FLOAT
290290
case 'f':
291291
return mp_obj_new_float_from_f(((float *)p)[index]);
292+
#if MICROPY_PY_DOUBLE_TYPECODE
292293
case 'd':
293294
return mp_obj_new_float_from_d(((double *)p)[index]);
295+
#endif
294296
#endif
295297
// CIRCUITPY-CHANGE: non-standard typecodes can be turned off
296298
#if MICROPY_NONSTANDARD_TYPECODES
@@ -367,13 +369,15 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte *p_base, byte *
367369
float f;
368370
} fpu = {val};
369371
return mp_obj_new_float_from_f(fpu.f);
372+
#if MICROPY_PY_DOUBLE_TYPECODE
370373
} else if (val_type == 'd') {
371374
union {
372375
uint64_t i;
373376
double f;
374377
} fpu = {val};
375378
return mp_obj_new_float_from_d(fpu.f);
376379
#endif
380+
#endif
377381
} else if (is_signed(val_type)) {
378382
if ((long long)MP_SMALL_INT_MIN <= val && val <= (long long)MP_SMALL_INT_MAX) {
379383
return mp_obj_new_int((mp_int_t)val);
@@ -445,6 +449,7 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte *p
445449
val = fp_sp.i;
446450
break;
447451
}
452+
#if MICROPY_PY_DOUBLE_TYPECODE
448453
case 'd': {
449454
union {
450455
uint64_t i64;
@@ -463,6 +468,7 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte *p
463468
break;
464469
}
465470
#endif
471+
#endif
466472
default: {
467473
// CIRCUITPY-CHANGE: add overflow checks
468474
bool signed_type = is_signed(val_type);
@@ -501,10 +507,12 @@ void mp_binary_set_val_array(char typecode, void *p, size_t index, mp_obj_t val_
501507
case 'f':
502508
((float *)p)[index] = mp_obj_get_float_to_f(val_in);
503509
break;
510+
#if MICROPY_PY_DOUBLE_TYPECODE
504511
case 'd':
505512
((double *)p)[index] = mp_obj_get_float_to_d(val_in);
506513
break;
507514
#endif
515+
#endif
508516
// CIRCUITPY-CHANGE: non-standard typecodes can be turned off
509517
#if MICROPY_NONSTANDARD_TYPECODES
510518
// Extension to CPython: array of objects
@@ -574,9 +582,11 @@ void mp_binary_set_val_array_from_int(char typecode, void *p, size_t index, mp_i
574582
case 'f':
575583
((float *)p)[index] = (float)val;
576584
break;
585+
#if MICROPY_PY_DOUBLE_TYPECODE
577586
case 'd':
578587
((double *)p)[index] = (double)val;
579588
break;
589+
#endif
580590
#endif
581591
// CIRCUITPY-CHANGE: non-standard typecodes can be turned off
582592
#if MICROPY_NONSTANDARD_TYPECODES

py/circuitpy_mpconfig.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ extern void common_hal_mcu_enable_interrupts(void);
141141
#define MICROPY_PY_UCTYPES (0)
142142
#define MICROPY_PY___FILE__ (1)
143143

144+
#if CIRCUITPY_FULL_BUILD
144145
#define MICROPY_QSTR_BYTES_IN_HASH (1)
146+
#else
147+
#define MICROPY_QSTR_BYTES_IN_HASH (0)
148+
#endif
145149
#define MICROPY_REPL_AUTO_INDENT (1)
146150
#define MICROPY_REPL_EVENT_DRIVEN (0)
147151
#define MICROPY_STACK_CHECK (1)
@@ -257,6 +261,10 @@ typedef long mp_off_t;
257261
#define MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR (CIRCUITPY_FULL_BUILD)
258262
#endif
259263

264+
#ifndef MICROPY_PY_DOUBLE_TYPECODE
265+
#define MICROPY_PY_DOUBLE_TYPECODE (CIRCUITPY_FULL_BUILD ? 1 : 0)
266+
#endif
267+
260268
#ifndef MICROPY_PY_FUNCTION_ATTRS
261269
#define MICROPY_PY_FUNCTION_ATTRS (CIRCUITPY_FULL_BUILD)
262270
#endif

py/mpconfig.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,10 @@ typedef double mp_float_t;
881881
#define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT)
882882
#endif
883883

884+
#ifndef MICROPY_PY_DOUBLE_TYPECODE
885+
#define MICROPY_PY_DOUBLE_TYPECODE (MICROPY_PY_BUILTINS_FLOAT)
886+
#endif
887+
884888
// Whether to use the native _Float16 for 16-bit float support
885889
#ifndef MICROPY_FLOAT_USE_NATIVE_FLT16
886890
#ifdef __FLT16_MAX__

0 commit comments

Comments
 (0)
0