py: Declare constant data as properly constant.

Otherwise some compilers (eg without optimisation) will put this read-only
data in RAM instead of ROM.
This commit is contained in:
Damien George 2016-05-20 12:38:15 +01:00
parent a0a08b4be1
commit 3ff16ff52e
7 changed files with 8 additions and 8 deletions

View File

@ -2649,7 +2649,7 @@ STATIC void compile_const_object(compiler_t *comp, mp_parse_node_struct_t *pns)
}
typedef void (*compile_function_t)(compiler_t*, mp_parse_node_struct_t*);
STATIC compile_function_t compile_function[] = {
STATIC const compile_function_t compile_function[] = {
#define nc NULL
#define c(f) compile_##f
#define DEF_RULE(rule, comp, kind, ...) comp,

View File

@ -190,7 +190,7 @@ STATIC void indent_pop(mp_lexer_t *lex) {
// c<op> = continue with <op>, if this opchar matches then continue matching
// this means if the start of two ops are the same then they are equal til the last char
STATIC const char *tok_enc =
STATIC const char *const tok_enc =
"()[]{},:;@~" // singles
"<e=c<e=" // < <= << <<=
">e=c>e=" // > >= >> >>=
@ -227,7 +227,7 @@ STATIC const uint8_t tok_enc_kind[] = {
};
// must have the same order as enum in lexer.h
STATIC const char *tok_kw[] = {
STATIC const char *const tok_kw[] = {
"False",
"None",
"True",

View File

@ -49,7 +49,7 @@ const mp_map_t mp_const_empty_map = {
// The first set of sizes are chosen so the allocation fits exactly in a
// 4-word GC block, and it's not so important for these small values to be
// prime. The latter sizes are prime and increase at an increasing rate.
STATIC uint16_t hash_allocation_sizes[] = {
STATIC const uint16_t hash_allocation_sizes[] = {
0, 2, 4, 6, 8, 10, 12, // +2
17, 23, 29, 37, 47, 59, 73, // *1.25
97, 127, 167, 223, 293, 389, 521, 691, 919, 1223, 1627, 2161, // *1.33

View File

@ -414,7 +414,7 @@ typedef enum _mp_dict_view_kind_t {
MP_DICT_VIEW_VALUES,
} mp_dict_view_kind_t;
STATIC char *mp_dict_view_names[] = {"dict_items", "dict_keys", "dict_values"};
STATIC const char *const mp_dict_view_names[] = {"dict_items", "dict_keys", "dict_values"};
typedef struct _mp_obj_dict_view_it_t {
mp_obj_base_t base;

View File

@ -104,7 +104,7 @@ enum {
#undef one_or_more
#undef DEF_RULE
STATIC const rule_t *rules[] = {
STATIC const rule_t *const rules[] = {
#define DEF_RULE(rule, comp, kind, ...) &rule_##rule,
#include "py/grammar.h"
#undef DEF_RULE

View File

@ -223,7 +223,7 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
// If there're no better alternatives, and if it's first word
// in the line, try to complete "import".
if (s_start == org_str) {
static char import_str[] = "import ";
static const char import_str[] = "import ";
if (memcmp(s_start, import_str, s_len) == 0) {
*compl_str = import_str + s_len;
return sizeof(import_str) - 1 - s_len;

View File

@ -29,7 +29,7 @@
#pragma clang diagnostic ignored "-Winitializer-overrides"
#endif // __clang__
static void* entry_table[256] = {
static const void *const entry_table[256] = {
[0 ... 255] = &&entry_default,
[MP_BC_LOAD_CONST_FALSE] = &&entry_MP_BC_LOAD_CONST_FALSE,
[MP_BC_LOAD_CONST_NONE] = &&entry_MP_BC_LOAD_CONST_NONE,