Skip to content

Commit

Permalink
py/emitglue: Make mp_emit_glue_assign_native's fun_data arg a const ptr.
Browse files Browse the repository at this point in the history
It will only ever be read from, and in some cases (eg on esp8266) can
actually be in ROM.

Signed-off-by: Damien George <damien@micropython.org>
  • Loading branch information
dpgeorge committed Feb 22, 2024
1 parent 01f4e85 commit 9e5b697
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions py/emitglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
}

#if MICROPY_EMIT_MACHINE_CODE
void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len,
void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, const void *fun_data, mp_uint_t fun_len,
mp_raw_code_t **children,
#if MICROPY_PERSISTENT_CODE_SAVE
uint16_t n_children,
Expand All @@ -115,7 +115,7 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void
#endif
#elif MICROPY_EMIT_ARM
#if (defined(__linux__) && defined(__GNUC__)) || __ARM_ARCH == 7
__builtin___clear_cache(fun_data, (uint8_t *)fun_data + fun_len);
__builtin___clear_cache((void *)fun_data, (uint8_t *)fun_data + fun_len);
#elif defined(__arm__)
// Flush I-cache and D-cache.
asm volatile (
Expand Down Expand Up @@ -154,7 +154,7 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void
if (i > 0 && i % 16 == 0) {
DEBUG_printf("\n");
}
DEBUG_printf(" %02x", ((byte *)fun_data)[i]);
DEBUG_printf(" %02x", ((const byte *)fun_data)[i]);
}
DEBUG_printf("\n");

Expand Down
2 changes: 1 addition & 1 deletion py/emitglue.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
#endif
uint16_t scope_flags);

void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len,
void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, const void *fun_data, mp_uint_t fun_len,
mp_raw_code_t **children,
#if MICROPY_PERSISTENT_CODE_SAVE
uint16_t n_children,
Expand Down

0 comments on commit 9e5b697

Please sign in to comment.