summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorScott Shawcroft <scott.shawcroft@gmail.com>2017-02-25 12:19:33 +0100
committerScott Shawcroft <scott.shawcroft@gmail.com>2017-02-26 01:00:33 +0100
commit062fac1d43d42b35e0ecdaaec124c29b65db7c68 (patch)
treeab2b653796caea6d368ae793e07e5382b0759bab /py
parent3fd19c60ccd879ed676bae72d42b709b34eeaa23 (diff)
atmel-samd: Use link time optimization to reduce code size of builds which
share space with the file system. "Express" builds with SPI flash crash the compiler for some reason so its currently disabled for them.
Diffstat (limited to 'py')
-rw-r--r--py/objnamedtuple.c6
-rw-r--r--py/objnamedtuple.h7
-rw-r--r--py/objtuple.h10
3 files changed, 20 insertions, 3 deletions
diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c
index 19fd3c5db..f0134d9be 100644
--- a/py/objnamedtuple.c
+++ b/py/objnamedtuple.c
@@ -125,7 +125,11 @@ mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t
return MP_OBJ_FROM_PTR(tuple);
}
-const mp_rom_obj_tuple_t namedtuple_base_tuple = {{&mp_type_tuple}, 1, {MP_ROM_PTR(&mp_type_tuple)}};
+const mp_rom_obj_tuple1_t namedtuple_base_tuple = {
+ .base = {&mp_type_tuple},
+ .len = 1u,
+ .items = {MP_OBJ_FROM_PTR(&mp_type_tuple)}
+};
STATIC mp_obj_t mp_obj_new_namedtuple_type(qstr name, mp_uint_t n_fields, mp_obj_t *fields) {
mp_obj_namedtuple_type_t *o = m_new_obj_var(mp_obj_namedtuple_type_t, qstr, n_fields);
diff --git a/py/objnamedtuple.h b/py/objnamedtuple.h
index f6621642a..89bc16311 100644
--- a/py/objnamedtuple.h
+++ b/py/objnamedtuple.h
@@ -25,6 +25,9 @@
* THE SOFTWARE.
*/
+#ifndef __MICROPY_INCLUDED_PY_OBJNAMEDTUPLE_H__
+#define __MICROPY_INCLUDED_PY_OBJNAMEDTUPLE_H__
+
#include <string.h>
#include "py/nlr.h"
@@ -50,6 +53,8 @@ void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
-const mp_rom_obj_tuple_t namedtuple_base_tuple;
+const mp_rom_obj_tuple1_t namedtuple_base_tuple;
#endif // MICROPY_PY_COLLECTIONS
+
+#endif // __MICROPY_INCLUDED_PY_OBJNAMEDTUPLE_H__
diff --git a/py/objtuple.h b/py/objtuple.h
index ebfc5c406..024f38a0d 100644
--- a/py/objtuple.h
+++ b/py/objtuple.h
@@ -36,10 +36,18 @@ typedef struct _mp_obj_tuple_t {
typedef struct _mp_rom_obj_tuple_t {
mp_obj_base_t base;
- mp_uint_t len;
+ uint32_t len;
mp_rom_obj_t items[];
} mp_rom_obj_tuple_t;
+// This is identical to the type above except it makes it clear that there is
+// only one item. This makes lto happy with the namedtuple_base_tuple.
+typedef struct _mp_rom_obj_tuple1_t {
+ mp_obj_base_t base;
+ uint32_t len;
+ mp_rom_obj_t items[1];
+} mp_rom_obj_tuple1_t;
+
void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind);
mp_obj_t mp_obj_tuple_unary_op(mp_uint_t op, mp_obj_t self_in);
mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs);