change CIRCUITPY change markers to CIRCUITPY-CHANGE

This commit is contained in:
Dan Halbert 2023-10-19 16:42:36 -04:00
parent c0a4abc03c
commit 367e13c69f
108 changed files with 274 additions and 271 deletions

View File

@ -1,7 +1,7 @@
# This makefile fragment adds the source code files for the core extmod modules # This makefile fragment adds the source code files for the core extmod modules
# and provides rules to build 3rd-party components for extmod modules. # and provides rules to build 3rd-party components for extmod modules.
# CIRCUITPY has removed many extmod modules. # CIRCUITPY-CHANGE: many extmod modules removed
SRC_EXTMOD_C += \ SRC_EXTMOD_C += \
extmod/modasyncio.c \ extmod/modasyncio.c \
extmod/modbinascii.c \ extmod/modbinascii.c \

View File

@ -228,7 +228,7 @@ STATIC mp_obj_t task_cancel(mp_obj_t self_in) {
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_1(task_cancel_obj, task_cancel); STATIC MP_DEFINE_CONST_FUN_OBJ_1(task_cancel_obj, task_cancel);
// CIRCUITPY provides __await__(). // CIRCUITPY-CHANGE: CircuitPython provides __await__().
STATIC mp_obj_t task_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf); STATIC mp_obj_t task_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf);
STATIC mp_obj_t task_await(mp_obj_t self_in) { STATIC mp_obj_t task_await(mp_obj_t self_in) {

View File

@ -127,7 +127,7 @@ STATIC mp_obj_t mod_binascii_b2a_base64(size_t n_args, const mp_obj_t *pos_args,
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
uint8_t newline = args[ARG_newline].u_bool; uint8_t newline = args[ARG_newline].u_bool;
// CIRCUITPY // CIRCUITPY-CHANGE
check_not_unicode(pos_args[0]); check_not_unicode(pos_args[0]);
mp_buffer_info_t bufinfo; mp_buffer_info_t bufinfo;
mp_get_buffer_raise(pos_args[0], &bufinfo, MP_BUFFER_READ); mp_get_buffer_raise(pos_args[0], &bufinfo, MP_BUFFER_READ);
@ -182,7 +182,7 @@ STATIC mp_obj_t mod_binascii_b2a_base64(size_t n_args, const mp_obj_t *pos_args,
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_binascii_b2a_base64_obj, 1, mod_binascii_b2a_base64); STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_binascii_b2a_base64_obj, 1, mod_binascii_b2a_base64);
// CIRCUITPY uses a self-contained implementation of CRC32, // CIRCUITPY-CHANGE: uses a self-contained implementation of CRC32,
// instead of depending on uzlib, like MicroPython. // instead of depending on uzlib, like MicroPython.
/* /*
@ -223,7 +223,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_binascii_b2a_base64_obj, 1, mod_binascii_b
STATIC mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) { STATIC mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) {
mp_buffer_info_t bufinfo; mp_buffer_info_t bufinfo;
// CIRCUITPY // CIRCUITPY-CHANGE
check_not_unicode(args[0]); check_not_unicode(args[0]);
mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ); mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ);
uint32_t crc = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 0; uint32_t crc = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 0;

View File

@ -130,7 +130,7 @@ typedef struct _json_stream_t {
mp_obj_t stream_obj; mp_obj_t stream_obj;
mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode);
int errcode; int errcode;
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_t python_readinto[2 + 1]; mp_obj_t python_readinto[2 + 1];
mp_obj_array_t bytearray_obj; mp_obj_array_t bytearray_obj;
size_t start; size_t start;
@ -154,7 +154,7 @@ STATIC byte json_stream_next(json_stream_t *s) {
return s->cur; return s->cur;
} }
// CIRCUITPY // CIRCUITPY-CHANGE
// We read from an object's `readinto` method in chunks larger than the json // We read from an object's `readinto` method in chunks larger than the json
// parser needs to reduce the number of function calls done. // parser needs to reduce the number of function calls done.
@ -398,7 +398,7 @@ STATIC mp_obj_t _mod_json_load(mp_obj_t stream_obj, bool return_first_json) {
} }
} }
success: success:
// CIRCUITPY // CIRCUITPY-CHANGE
// It is legal for a stream to have contents after JSON. // It is legal for a stream to have contents after JSON.
// E.g., A UART is not closed after receiving an object; in load() we will // E.g., A UART is not closed after receiving an object; in load() we will

View File

@ -206,7 +206,7 @@ STATIC mp_obj_t re_exec(bool is_anchored, uint n_args, const mp_obj_t *args) {
size_t len; size_t len;
subj.begin_line = subj.begin = mp_obj_str_get_data(args[1], &len); subj.begin_line = subj.begin = mp_obj_str_get_data(args[1], &len);
subj.end = subj.begin + len; subj.end = subj.begin + len;
// CIRCUITPY // CIRCUITPY-CHANGE
#if MICROPY_PY_RE_MATCH_SPAN_START_END && !(defined(MICROPY_ENABLE_DYNRUNTIME) && MICROPY_ENABLE_DYNRUNTIME) #if MICROPY_PY_RE_MATCH_SPAN_START_END && !(defined(MICROPY_ENABLE_DYNRUNTIME) && MICROPY_ENABLE_DYNRUNTIME)
if (n_args > 2) { if (n_args > 2) {

View File

@ -367,7 +367,7 @@ STATIC mp_uint_t poll_set_poll_until_ready_or_timeout(poll_set_t *poll_set, size
if (n_ready > 0 || (timeout != (mp_uint_t)-1 && mp_hal_ticks_ms() - start_ticks >= timeout)) { if (n_ready > 0 || (timeout != (mp_uint_t)-1 && mp_hal_ticks_ms() - start_ticks >= timeout)) {
return n_ready; return n_ready;
} }
// CIRCUITPY // CIRCUITPY-CHANGE
RUN_BACKGROUND_TASKS; RUN_BACKGROUND_TASKS;
if (mp_hal_is_interrupted()) { if (mp_hal_is_interrupted()) {
return 0; return 0;
@ -425,7 +425,7 @@ STATIC mp_obj_t select_select(size_t n_args, const mp_obj_t *args) {
if (!mp_map_slot_is_filled(&poll_set.map, i)) { if (!mp_map_slot_is_filled(&poll_set.map, i)) {
continue; continue;
} }
// CIRCUITPY // CIRCUITPY-CHANGE
RUN_BACKGROUND_TASKS; RUN_BACKGROUND_TASKS;
poll_obj_t *poll_obj = MP_OBJ_TO_PTR(poll_set.map.table[i].value); poll_obj_t *poll_obj = MP_OBJ_TO_PTR(poll_set.map.table[i].value);

View File

@ -365,7 +365,7 @@ mp_obj_t mp_vfs_getcwd(void) {
} }
MP_DEFINE_CONST_FUN_OBJ_0(mp_vfs_getcwd_obj, mp_vfs_getcwd); MP_DEFINE_CONST_FUN_OBJ_0(mp_vfs_getcwd_obj, mp_vfs_getcwd);
// CIRCUITPY: accessible from shared-module/os/__init__.c // CIRCUITPY-CHANGE: accessible from shared-module/os/__init__.c
mp_obj_t mp_vfs_ilistdir_it_iternext(mp_obj_t self_in) { mp_obj_t mp_vfs_ilistdir_it_iternext(mp_obj_t self_in) {
mp_vfs_ilistdir_it_t *self = MP_OBJ_TO_PTR(self_in); mp_vfs_ilistdir_it_t *self = MP_OBJ_TO_PTR(self_in);
if (self->is_iter) { if (self->is_iter) {

View File

@ -257,7 +257,7 @@ STATIC mp_obj_t fat_vfs_open(mp_obj_t self_in, mp_obj_t path_in, mp_obj_t mode_i
m_del_obj(pyb_file_obj_t, o); m_del_obj(pyb_file_obj_t, o);
mp_raise_OSError_errno_str(fresult_to_errno_table[res], path_in); mp_raise_OSError_errno_str(fresult_to_errno_table[res], path_in);
} }
// CIRCUITPY does fast seek. // CIRCUITPY-CHANGE: does fast seek.
// If we're reading, turn on fast seek. // If we're reading, turn on fast seek.
if (mode == FA_READ) { if (mode == FA_READ) {
// One call to determine how much space we need. // One call to determine how much space we need.

View File

@ -254,7 +254,7 @@ int re1_5_compilecode(ByteProg *prog, const char *re)
return 0; return 0;
} }
// CIRCUITPY debug as main program // CIRCUITPY-CHANGE: debug as main program
#if defined(DEBUG_COMPILECODE) #if defined(DEBUG_COMPILECODE)
#include <assert.h> #include <assert.h>
void re1_5_fatal(char *x) { void re1_5_fatal(char *x) {

View File

@ -262,13 +262,13 @@ include $(TOP)/py/mkrules.mk
.PHONY: test test_full .PHONY: test test_full
# CIRCUITPY: these two targets are ours # CIRCUITPY-CHANGE: these two targets are for CircuitPython builds
.PHONY: print-failures clean-failures .PHONY: print-failures clean-failures
print-failures clean-failures: print-failures clean-failures:
../../tests/run-tests.py --$@ ../../tests/run-tests.py --$@
# CIRCUITPY: support for passing args to run-tests, like `make test TEST_ARGS="basics/*.py"` # CIRCUITPY-CHANGE: support for passing args to run-tests, like `make test TEST_ARGS="basics/*.py"`
TEST_ARGS ?= TEST_ARGS ?=
test: $(BUILD)/$(PROG) $(TOP)/tests/run-tests.py test: $(BUILD)/$(PROG) $(TOP)/tests/run-tests.py
$(eval DIRNAME=ports/$(notdir $(CURDIR))) $(eval DIRNAME=ports/$(notdir $(CURDIR)))

View File

@ -59,7 +59,7 @@ STATIC mp_obj_t mp_os_getenv(size_t n_args, const mp_obj_t *args) {
} }
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_os_getenv_obj, 1, 2, mp_os_getenv); MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_os_getenv_obj, 1, 2, mp_os_getenv);
// CIRCUITPY getenv differences // CIRCUITPY-CHANGE: getenv differences
#if defined(MICROPY_UNIX_COVERAGE) #if defined(MICROPY_UNIX_COVERAGE)
STATIC mp_obj_t mp_os_getenv_int(mp_obj_t var_in) { STATIC mp_obj_t mp_os_getenv_int(mp_obj_t var_in) {
mp_int_t value; mp_int_t value;

View File

@ -37,7 +37,7 @@
// Variant-specific definitions. // Variant-specific definitions.
#include "mpconfigvariant.h" #include "mpconfigvariant.h"
// CIRCUITPY // CIRCUITPY-CHANGE
#define CIRCUITPY_MICROPYTHON_ADVANCED (1) #define CIRCUITPY_MICROPYTHON_ADVANCED (1)
#define MICROPY_PY_ASYNC_AWAIT (1) #define MICROPY_PY_ASYNC_AWAIT (1)
@ -254,4 +254,5 @@ static inline unsigned long mp_random_seed_init(void) {
#define MICROPY_PY_BLUETOOTH_ENABLE_L2CAP_CHANNELS (MICROPY_BLUETOOTH_NIMBLE) #define MICROPY_PY_BLUETOOTH_ENABLE_L2CAP_CHANNELS (MICROPY_BLUETOOTH_NIMBLE)
#endif #endif
#define RUN_BACKGROUND_TASKS ((void)0) // CIRCUITPY // CIRCUITPY-CHANGE
#define RUN_BACKGROUND_TASKS ((void)0)

View File

@ -8,7 +8,7 @@ MICROPY_FORCE_32BIT = 0
# 1 - use MicroPython version of readline # 1 - use MicroPython version of readline
MICROPY_USE_READLINE = 1 MICROPY_USE_READLINE = 1
# CIRCUITPY: not present # CIRCUITPY-CHANGE: not present
# btree module using Berkeley DB 1.xx # btree module using Berkeley DB 1.xx
MICROPY_PY_BTREE = 0 MICROPY_PY_BTREE = 0
@ -18,14 +18,14 @@ MICROPY_PY_THREAD = 1
# Subset of CPython termios module # Subset of CPython termios module
MICROPY_PY_TERMIOS = 1 MICROPY_PY_TERMIOS = 1
# CIRCUITPY: not present # CIRCUITPY-CHANGE: not present
# Subset of CPython socket module # Subset of CPython socket module
MICROPY_PY_SOCKET = 0 MICROPY_PY_SOCKET = 0
# ffi module requires libffi (libffi-dev Debian package) # ffi module requires libffi (libffi-dev Debian package)
MICROPY_PY_FFI = 1 MICROPY_PY_FFI = 1
# CIRCUITPY: not present # CIRCUITPY-CHANGE: not present
# ssl module requires one of the TLS libraries below # ssl module requires one of the TLS libraries below
MICROPY_PY_SSL = 0 MICROPY_PY_SSL = 0
# axTLS has minimal size but implements only a subset of modern TLS # axTLS has minimal size but implements only a subset of modern TLS
@ -33,7 +33,7 @@ MICROPY_PY_SSL = 0
MICROPY_SSL_AXTLS = 0 MICROPY_SSL_AXTLS = 0
# mbedTLS is more up to date and complete implementation, but also # mbedTLS is more up to date and complete implementation, but also
# more bloated. # more bloated.
# CIRCUITPY: not present # CIRCUITPY-CHANGE: not present
MICROPY_SSL_MBEDTLS = 0 MICROPY_SSL_MBEDTLS = 0
# jni module requires JVM/JNI # jni module requires JVM/JNI
@ -43,15 +43,15 @@ MICROPY_PY_JNI = 0
# as submodules (currently affects only libffi). # as submodules (currently affects only libffi).
MICROPY_STANDALONE = 0 MICROPY_STANDALONE = 0
# CIRCUITPY: not used # CIRCUITPY-CHANGE: not used
MICROPY_ROM_TEXT_COMPRESSION = 0 MICROPY_ROM_TEXT_COMPRESSION = 0
MICROPY_VFS_FAT = 1 MICROPY_VFS_FAT = 1
# CIRCUITPY: not used # CIRCUITPY-CHANGE: not used
MICROPY_VFS_LFS1 = 0 MICROPY_VFS_LFS1 = 0
MICROPY_VFS_LFS2 = 0 MICROPY_VFS_LFS2 = 0
# CIRCUITPY # CIRCUITPY-CHANGE
CIRCUITPY_ULAB = 1 CIRCUITPY_ULAB = 1
MICROPY_EMIT_NATIVE = 0 MICROPY_EMIT_NATIVE = 0
CFLAGS += -DCIRCUITPY=1 CFLAGS += -DCIRCUITPY=1

View File

@ -95,7 +95,7 @@ void mp_hal_set_interrupt_char(char c) {
} }
} }
// CIRCUITPY // CIRCUITPY-CHANGE
bool mp_hal_is_interrupted(void) { bool mp_hal_is_interrupted(void) {
return false; return false;
} }
@ -192,7 +192,7 @@ main_term:;
void mp_hal_stdout_tx_strn(const char *str, size_t len) { void mp_hal_stdout_tx_strn(const char *str, size_t len) {
ssize_t ret; ssize_t ret;
MP_HAL_RETRY_SYSCALL(ret, write(STDOUT_FILENO, str, len), {}); MP_HAL_RETRY_SYSCALL(ret, write(STDOUT_FILENO, str, len), {});
// CIRCUITPY: need to conditionalize MICROPY_PY_OS_DUPTERM // CIRCUITPY-CHANGE: need to conditionalize MICROPY_PY_OS_DUPTERM
#if MICROPY_PY_OS_DUPTERM #if MICROPY_PY_OS_DUPTERM
mp_os_dupterm_tx_strn(str, len); mp_os_dupterm_tx_strn(str, len);
#endif #endif

View File

@ -42,7 +42,7 @@
#define MICROPY_TRACKED_ALLOC (1) #define MICROPY_TRACKED_ALLOC (1)
#define MICROPY_WARNINGS_CATEGORY (1) #define MICROPY_WARNINGS_CATEGORY (1)
// CIRCUITPY Disable things never used in circuitpython // CIRCUITPY-CHANGE: Disable things never used in circuitpython
#define MICROPY_PY_CRYPTOLIB (0) #define MICROPY_PY_CRYPTOLIB (0)
#define MICROPY_PY_CRYPTOLIB_CTR (0) #define MICROPY_PY_CRYPTOLIB_CTR (0)
#define MICROPY_PY_STRUCT (0) // uses shared-bindings struct #define MICROPY_PY_STRUCT (0) // uses shared-bindings struct

View File

@ -215,7 +215,7 @@ long long mp_binary_get_int(size_t size, bool is_signed, bool big_endian, const
val = -1; val = -1;
} }
for (uint i = 0; i < size; i++) { for (uint i = 0; i < size; i++) {
// CIRCUITPY fix for undefined behavior on left shift // CIRCUITPY-CHANGE: fix for undefined behavior on left shift
val *= 256; val *= 256;
val |= *src; val |= *src;
src += delta; src += delta;

View File

@ -31,7 +31,7 @@
#include <assert.h> #include <assert.h>
#include "py/compile.h" #include "py/compile.h"
// CIRCUITPY: for gc_collect() after each import // CIRCUITPY-CHANGE: for gc_collect() after each import
#include "py/gc.h" #include "py/gc.h"
#include "py/objmodule.h" #include "py/objmodule.h"
#include "py/persistentcode.h" #include "py/persistentcode.h"
@ -511,7 +511,7 @@ STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name,
// a __path__ attribute, and not attempt to stat it. // a __path__ attribute, and not attempt to stat it.
} }
// CIRCUITPY // CIRCUITPY-CHANGE
// Loading a module thrashes the heap significantly so we explicitly clean up // Loading a module thrashes the heap significantly so we explicitly clean up
// afterwards. // afterwards.
gc_collect(); gc_collect();

View File

@ -74,7 +74,7 @@ static inline bool emit_inline_thumb_allow_float(emit_inline_asm_t *emit) {
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
STATIC void emit_inline_thumb_error_msg(emit_inline_asm_t *emit, const compressed_string_t *msg) { STATIC void emit_inline_thumb_error_msg(emit_inline_asm_t *emit, const compressed_string_t *msg) {
*emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg); *emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
} }

View File

@ -43,7 +43,7 @@ struct _emit_inline_asm_t {
qstr *label_lookup; qstr *label_lookup;
}; };
// CIRCUITPY // CIRCUITPY-CHANGE
STATIC void emit_inline_xtensa_error_msg(emit_inline_asm_t *emit, const compressed_string_t *msg) { STATIC void emit_inline_xtensa_error_msg(emit_inline_asm_t *emit, const compressed_string_t *msg) {
*emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg); *emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
} }

View File

@ -58,7 +58,7 @@
#define DEBUG_printf(...) (void)0 #define DEBUG_printf(...) (void)0
#endif #endif
// CIRCUITPY: force definitions // CIRCUITPY-CHANGE: force definitions
#ifndef N_X64 #ifndef N_X64
#define N_X64 (0) #define N_X64 (0)
#endif #endif

36
py/gc.c
View File

@ -36,7 +36,7 @@
#include <valgrind/memcheck.h> #include <valgrind/memcheck.h>
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
#include "supervisor/shared/safe_mode.h" #include "supervisor/shared/safe_mode.h"
#if CIRCUITPY_MEMORYMONITOR #if CIRCUITPY_MEMORYMONITOR
@ -53,7 +53,7 @@
#define DEBUG_printf(...) (void)0 #define DEBUG_printf(...) (void)0
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
// Uncomment this if you want to use a debugger to capture state at every allocation and free. // Uncomment this if you want to use a debugger to capture state at every allocation and free.
// #define LOG_HEAP_ACTIVITY 1 // #define LOG_HEAP_ACTIVITY 1
@ -131,7 +131,7 @@
#define GC_EXIT() #define GC_EXIT()
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
#ifdef LOG_HEAP_ACTIVITY #ifdef LOG_HEAP_ACTIVITY
volatile uint32_t change_me; volatile uint32_t change_me;
#pragma GCC push_options #pragma GCC push_options
@ -338,7 +338,7 @@ STATIC bool gc_try_add_heap(size_t failed_alloc) {
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
// TODO FOR MERGE: fix this for multiple areas?? // TODO FOR MERGE: fix this for multiple areas??
void gc_deinit(void) { void gc_deinit(void) {
// Run any finalisers before we stop using the heap. // Run any finalisers before we stop using the heap.
@ -381,7 +381,7 @@ STATIC inline mp_state_mem_area_t *gc_get_ptr_area(const void *ptr) {
} }
#endif #endif
// CIRCUITPY: VERIFY_PTR moved to gc.h to make it available elsewhere. // CIRCUITPY-CHANGE: VERIFY_PTR moved to gc.h to make it available elsewhere.
#ifndef TRACE_MARK #ifndef TRACE_MARK
#if DEBUG_PRINT #if DEBUG_PRINT
@ -395,7 +395,7 @@ STATIC inline mp_state_mem_area_t *gc_get_ptr_area(const void *ptr) {
// children: mark the unmarked child blocks and put those newly marked // children: mark the unmarked child blocks and put those newly marked
// blocks on the stack. When all children have been checked, pop off the // blocks on the stack. When all children have been checked, pop off the
// topmost block on the stack and repeat with that one. // topmost block on the stack and repeat with that one.
// CIRCUITPY: We don't instrument these functions because they occur a lot during GC and // CIRCUITPY-CHANGE: We don't instrument these functions because they occur a lot during GC and
#if MICROPY_GC_SPLIT_HEAP #if MICROPY_GC_SPLIT_HEAP
STATIC void MP_NO_INSTRUMENT PLACE_IN_ITCM(gc_mark_subtree)(mp_state_mem_area_t * area, size_t block) STATIC void MP_NO_INSTRUMENT PLACE_IN_ITCM(gc_mark_subtree)(mp_state_mem_area_t * area, size_t block)
#else #else
@ -599,7 +599,7 @@ void gc_collect_start(void) {
#endif #endif
} }
// CIRCUITPY // CIRCUITPY-CHANGE
void gc_collect_ptr(void *ptr) { void gc_collect_ptr(void *ptr) {
void *ptrs[1] = { ptr }; void *ptrs[1] = { ptr };
gc_collect_root(ptrs, 1); gc_collect_root(ptrs, 1);
@ -611,7 +611,7 @@ void gc_collect_ptr(void *ptr) {
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
__attribute__((no_sanitize_address)) __attribute__((no_sanitize_address))
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
static void *MP_NO_INSTRUMENT PLACE_IN_ITCM(gc_get_ptr)(void **ptrs, int i) { static void *MP_NO_INSTRUMENT PLACE_IN_ITCM(gc_get_ptr)(void **ptrs, int i) {
#if MICROPY_DEBUG_VALGRIND #if MICROPY_DEBUG_VALGRIND
if (!VALGRIND_CHECK_MEM_IS_ADDRESSABLE(&ptrs[i], sizeof(*ptrs))) { if (!VALGRIND_CHECK_MEM_IS_ADDRESSABLE(&ptrs[i], sizeof(*ptrs))) {
@ -744,7 +744,7 @@ void gc_info(gc_info_t *info) {
GC_EXIT(); GC_EXIT();
} }
// CIRCUITPY // CIRCUITPY-CHANGE
bool gc_alloc_possible(void) { bool gc_alloc_possible(void) {
#if MICROPY_GC_SPLIT_HEAP #if MICROPY_GC_SPLIT_HEAP
return MP_STATE_MEM(gc_last_free_area) != 0; return MP_STATE_MEM(gc_last_free_area) != 0;
@ -797,7 +797,7 @@ void *gc_alloc(size_t n_bytes, unsigned int alloc_flags) {
area = &MP_STATE_MEM(area); area = &MP_STATE_MEM(area);
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
if (area == 0) { if (area == 0) {
reset_into_safe_mode(SAFE_MODE_GC_ALLOC_OUTSIDE_VM); reset_into_safe_mode(SAFE_MODE_GC_ALLOC_OUTSIDE_VM);
} }
@ -861,7 +861,7 @@ found:
area->gc_last_free_atb_index = (i + 1) / BLOCKS_PER_ATB; area->gc_last_free_atb_index = (i + 1) / BLOCKS_PER_ATB;
} }
// CIRCUITPY // CIRCUITPY-CHANGE
#ifdef LOG_HEAP_ACTIVITY #ifdef LOG_HEAP_ACTIVITY
gc_log_change(start_block, end_block - start_block + 1); gc_log_change(start_block, end_block - start_block + 1);
#endif #endif
@ -958,7 +958,7 @@ void gc_free(void *ptr) {
mp_state_mem_area_t *area; mp_state_mem_area_t *area;
#if MICROPY_GC_SPLIT_HEAP #if MICROPY_GC_SPLIT_HEAP
area = gc_get_ptr_area(ptr); area = gc_get_ptr_area(ptr);
// CIRCUITPY extra checking // CIRCUITPY-CHANGE: extra checking
if (MP_STATE_MEM(gc_pool_start) == 0) { if (MP_STATE_MEM(gc_pool_start) == 0) {
reset_into_safe_mode(SAFE_MODE_GC_ALLOC_OUTSIDE_VM); reset_into_safe_mode(SAFE_MODE_GC_ALLOC_OUTSIDE_VM);
} }
@ -995,7 +995,7 @@ void gc_free(void *ptr) {
area->gc_last_free_atb_index = block / BLOCKS_PER_ATB; area->gc_last_free_atb_index = block / BLOCKS_PER_ATB;
} }
// CIRCUITPY // CIRCUITPY-CHANGE
#ifdef LOG_HEAP_ACTIVITY #ifdef LOG_HEAP_ACTIVITY
gc_log_change(start_block, 0); gc_log_change(start_block, 0);
#endif #endif
@ -1166,7 +1166,7 @@ void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) {
gc_dump_alloc_table(&mp_plat_print); gc_dump_alloc_table(&mp_plat_print);
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
#ifdef LOG_HEAP_ACTIVITY #ifdef LOG_HEAP_ACTIVITY
gc_log_change(block, new_blocks); gc_log_change(block, new_blocks);
#endif #endif
@ -1203,7 +1203,7 @@ void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) {
gc_dump_alloc_table(&mp_plat_print); gc_dump_alloc_table(&mp_plat_print);
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
#ifdef LOG_HEAP_ACTIVITY #ifdef LOG_HEAP_ACTIVITY
gc_log_change(block, new_blocks); gc_log_change(block, new_blocks);
#endif #endif
@ -1243,7 +1243,7 @@ void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) {
} }
#endif // Alternative gc_realloc impl #endif // Alternative gc_realloc impl
// CIRCUITPY // CIRCUITPY-CHANGE
bool gc_never_free(void *ptr) { bool gc_never_free(void *ptr) {
// Check to make sure the pointer is on the heap in the first place. // Check to make sure the pointer is on the heap in the first place.
if (gc_nbytes(ptr) == 0) { if (gc_nbytes(ptr) == 0) {
@ -1353,7 +1353,7 @@ void gc_dump_alloc_table(const mp_print_t *print) {
*/ */
/* this prints the uPy object type of the head block */ /* this prints the uPy object type of the head block */
case AT_HEAD: { case AT_HEAD: {
// CIRCUITPY compiler warning avoidance // CIRCUITPY-CHANGE: compiler warning avoidance
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-align" #pragma GCC diagnostic ignored "-Wcast-align"
void **ptr = (void **)(area->gc_pool_start + bl * BYTES_PER_BLOCK); void **ptr = (void **)(area->gc_pool_start + bl * BYTES_PER_BLOCK);
@ -1419,7 +1419,7 @@ void gc_dump_alloc_table(const mp_print_t *print) {
} }
mp_print_str(print, "\n"); mp_print_str(print, "\n");
} }
// CIRCUITPY // CIRCUITPY-CHANGE
mp_print_str(&mp_plat_print, "\n"); mp_print_str(&mp_plat_print, "\n");
GC_EXIT(); GC_EXIT();
} }

12
py/gc.h
View File

@ -34,7 +34,7 @@
#include "py/mpstate.h" #include "py/mpstate.h"
#include "py/misc.h" #include "py/misc.h"
// CIRCUITPY - this may change when use split heap // CIRCUITPY-CHANGE: - this may change when use split heap
#if !MICROPY_GC_SPLIT_HEAP #if !MICROPY_GC_SPLIT_HEAP
#define HEAP_PTR(ptr) ( \ #define HEAP_PTR(ptr) ( \
MP_STATE_MEM(area).gc_pool_start != 0 /* Not on the heap if it isn't inited */ \ MP_STATE_MEM(area).gc_pool_start != 0 /* Not on the heap if it isn't inited */ \
@ -42,7 +42,7 @@
&& ptr < (void *)MP_STATE_MEM(area).gc_pool_end /* must be below end of pool */ \ && ptr < (void *)MP_STATE_MEM(area).gc_pool_end /* must be below end of pool */ \
) )
// CIRCUITPY: defined here so available outside of gc.c // CIRCUITPY-CHANGE: defined here so available outside of gc.c
// ptr should be of type void* // ptr should be of type void*
#define VERIFY_PTR(ptr) ( \ #define VERIFY_PTR(ptr) ( \
((uintptr_t)(ptr) & (MICROPY_BYTES_PER_GC_BLOCK - 1)) == 0 /* must be aligned on a block */ \ ((uintptr_t)(ptr) & (MICROPY_BYTES_PER_GC_BLOCK - 1)) == 0 /* must be aligned on a block */ \
@ -51,7 +51,7 @@
#endif #endif
void gc_init(void *start, void *end); void gc_init(void *start, void *end);
// CIRCUITPY // CIRCUITPY-CHANGE
void gc_deinit(void); void gc_deinit(void);
#if MICROPY_GC_SPLIT_HEAP #if MICROPY_GC_SPLIT_HEAP
@ -74,12 +74,12 @@ bool gc_is_locked(void);
// A given port must implement gc_collect by using the other collect functions. // A given port must implement gc_collect by using the other collect functions.
void gc_collect(void); void gc_collect(void);
void gc_collect_start(void); void gc_collect_start(void);
// CIRCUITPY // CIRCUITPY-CHANGE
void gc_collect_ptr(void *ptr); void gc_collect_ptr(void *ptr);
void gc_collect_root(void **ptrs, size_t len); void gc_collect_root(void **ptrs, size_t len);
void gc_collect_end(void); void gc_collect_end(void);
// CIRCUITPY // CIRCUITPY-CHANGE
// Is the gc heap available? // Is the gc heap available?
bool gc_alloc_possible(void); bool gc_alloc_possible(void);
@ -96,7 +96,7 @@ size_t gc_nbytes(const void *ptr);
bool gc_has_finaliser(const void *ptr); bool gc_has_finaliser(const void *ptr);
void *gc_realloc(void *ptr, size_t n_bytes, bool allow_move); void *gc_realloc(void *ptr, size_t n_bytes, bool allow_move);
// CIRCUITPY // CIRCUITPY-CHANGE
// Prevents a pointer from ever being freed because it establishes a permanent reference to it. Use // Prevents a pointer from ever being freed because it establishes a permanent reference to it. Use
// very sparingly because it can leak memory. // very sparingly because it can leak memory.
bool gc_never_free(void *ptr); bool gc_never_free(void *ptr);

View File

@ -3,7 +3,7 @@ Process raw qstr file and output qstr data with length, hash and data bytes.
This script works with Python 2.7, 3.3 and 3.4. This script works with Python 2.7, 3.3 and 3.4.
CIRCUITPY: CIRCUITPY-CHANGE:
For documentation about the format of compressed translated strings, see For documentation about the format of compressed translated strings, see
supervisor/shared/translate/translate.h supervisor/shared/translate/translate.h
""" """
@ -272,7 +272,7 @@ def qstr_escape(qst):
return re.sub(r"[^A-Za-z0-9_]", esc_char, qst) return re.sub(r"[^A-Za-z0-9_]", esc_char, qst)
# CIRCUITPY: add translations handling # CIRCUITPY-CHANGE: add translations handling
def parse_input_headers_with_translations(infiles): def parse_input_headers_with_translations(infiles):
qcfgs = {} qcfgs = {}
qstrs = {} qstrs = {}
@ -306,7 +306,7 @@ def parse_input_headers_with_translations(infiles):
qcfgs[match.group(1)] = value qcfgs[match.group(1)] = value
continue continue
# CIRCUITPY # CIRCUITPY-CHANGE
match = re.match(r'^TRANSLATE\("(.*)"\)$', line) match = re.match(r'^TRANSLATE\("(.*)"\)$', line)
if match: if match:
translations.add(match.group(1)) translations.add(match.group(1))
@ -345,7 +345,7 @@ def parse_input_headers_with_translations(infiles):
order = -190000 order = -190000
elif ident.startswith("__"): elif ident.startswith("__"):
order -= 100000 order -= 100000
# CIRCUITPY # CIRCUITPY-CHANGE
elif ident.startswith("_lt"): elif ident.startswith("_lt"):
order -= 100000 order -= 100000
elif ident.startswith("_gt"): elif ident.startswith("_gt"):
@ -359,7 +359,7 @@ def parse_input_headers_with_translations(infiles):
return qcfgs, qstrs, translations return qcfgs, qstrs, translations
# CIRCUITPY: Used externally by mpy-tool.py. Don't pass back translations. # CIRCUITPY-CHANGE: Used externally by mpy-tool.py. Don't pass back translations.
def parse_input_headers(infiles): def parse_input_headers(infiles):
qcfgs, qstrs, translations = parse_input_headers_with_translations(infiles) qcfgs, qstrs, translations = parse_input_headers_with_translations(infiles)
return (qcfgs, qstrs) return (qcfgs, qstrs)
@ -385,7 +385,7 @@ def make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr):
return '%d, %d, "%s"' % (qhash, qlen, qdata) return '%d, %d, "%s"' % (qhash, qlen, qdata)
# CIRCUITPY: add translations # CIRCUITPY-CHANGE: add translations
def print_qstr_data(qcfgs, qstrs, translations): def print_qstr_data(qcfgs, qstrs, translations):
# get config variables # get config variables
cfg_bytes_len = int(qcfgs["BYTES_IN_LEN"]) cfg_bytes_len = int(qcfgs["BYTES_IN_LEN"])

View File

@ -2,7 +2,7 @@
This script processes the output from the C preprocessor and extracts all This script processes the output from the C preprocessor and extracts all
qstr. Each qstr is transformed into a qstr definition of the form 'Q(...)'. qstr. Each qstr is transformed into a qstr definition of the form 'Q(...)'.
This script works with Python 3.x (CIRCUITPY: not 2.x) This script works with Python 3.x (CIRCUITPY-CHANGE: not 2.x)
""" """
from __future__ import print_function from __future__ import print_function
@ -165,7 +165,7 @@ def process_file(f):
for match in re_match.findall(line): for match in re_match.findall(line):
if args.mode == _MODE_QSTR: if args.mode == _MODE_QSTR:
name = match.replace("MP_QSTR_", "") name = match.replace("MP_QSTR_", "")
# CIRCUITPY: undo character escapes in qstrs in C code # CIRCUITPY-CHANGE: undo character escapes in qstrs in C code
output.append("Q(" + qstr_unescape(name) + ")") output.append("Q(" + qstr_unescape(name) + ")")
elif args.mode in (_MODE_COMPRESS, _MODE_MODULE, _MODE_ROOT_POINTER): elif args.mode in (_MODE_COMPRESS, _MODE_MODULE, _MODE_ROOT_POINTER):
output.append(match) output.append(match)

View File

@ -13,7 +13,7 @@ import pathlib
import datetime import datetime
import subprocess import subprocess
# CIRCUITPY: use external script that can override git describe output with an # CIRCUITPY-CHANGE: use external script that can override git describe output with an
# environment variable. # environment variable.
tools_describe = str(pathlib.Path(__file__).resolve().parent.parent / "tools/describe") tools_describe = str(pathlib.Path(__file__).resolve().parent.parent / "tools/describe")
@ -72,7 +72,7 @@ def get_version_info_from_git(repo_path):
except OSError: except OSError:
return None return None
# CIRCUITPY # CIRCUITPY-CHANGE
# Try to extract MicroPython version from git tag # Try to extract MicroPython version from git tag
ver = git_tag.split("-")[0].split(".") ver = git_tag.split("-")[0].split(".")

View File

@ -69,7 +69,7 @@ typedef unsigned int uint;
// TODO make a lazy m_renew that can increase by a smaller amount than requested (but by at least 1 more element) // TODO make a lazy m_renew that can increase by a smaller amount than requested (but by at least 1 more element)
#define m_new(type, num) ((type *)(m_malloc(sizeof(type) * (num)))) #define m_new(type, num) ((type *)(m_malloc(sizeof(type) * (num))))
#define m_new_ll(type, num) m_new(type, num) // CIRCUITPY: clue to long-lived allocator #define m_new_ll(type, num) m_new(type, num) // CIRCUITPY-CHANGE: clue to long-lived allocator
#define m_new_maybe(type, num) ((type *)(m_malloc_maybe(sizeof(type) * (num)))) #define m_new_maybe(type, num) ((type *)(m_malloc_maybe(sizeof(type) * (num))))
#define m_new0(type, num) ((type *)(m_malloc0(sizeof(type) * (num)))) #define m_new0(type, num) ((type *)(m_malloc0(sizeof(type) * (num))))
#define m_new_obj(type) (m_new(type, 1)) #define m_new_obj(type) (m_new(type, 1))
@ -79,7 +79,7 @@ typedef unsigned int uint;
#define m_new_obj_var_maybe(obj_type, var_type, var_num) ((obj_type *)m_malloc_maybe(sizeof(obj_type) + sizeof(var_type) * (var_num))) #define m_new_obj_var_maybe(obj_type, var_type, var_num) ((obj_type *)m_malloc_maybe(sizeof(obj_type) + sizeof(var_type) * (var_num)))
#if MICROPY_ENABLE_FINALISER #if MICROPY_ENABLE_FINALISER
#define m_new_obj_with_finaliser(type) ((type *)(m_malloc_with_finaliser(sizeof(type)))) #define m_new_obj_with_finaliser(type) ((type *)(m_malloc_with_finaliser(sizeof(type))))
#define m_new_ll_obj_with_finaliser(type) m_new_obj_with_finaliser(type) // CIRCUITPY: clue to long-lived allocator #define m_new_ll_obj_with_finaliser(type) m_new_obj_with_finaliser(type) // CIRCUITPY-CHANGE: clue to long-lived allocator
#define m_new_obj_var_with_finaliser(type, var_type, var_num) ((type *)m_malloc_with_finaliser(sizeof(type) + sizeof(var_type) * (var_num))) #define m_new_obj_var_with_finaliser(type, var_type, var_num) ((type *)m_malloc_with_finaliser(sizeof(type) + sizeof(var_type) * (var_num)))
#else #else
#define m_new_obj_with_finaliser(type) m_new_obj(type) #define m_new_obj_with_finaliser(type) m_new_obj(type)
@ -134,7 +134,7 @@ size_t m_get_peak_bytes_allocated(void);
// align ptr to the nearest multiple of "alignment" // align ptr to the nearest multiple of "alignment"
#define MP_ALIGN(ptr, alignment) (void *)(((uintptr_t)(ptr) + ((alignment) - 1)) & ~((alignment) - 1)) #define MP_ALIGN(ptr, alignment) (void *)(((uintptr_t)(ptr) + ((alignment) - 1)) & ~((alignment) - 1))
// CIRCUITPY // CIRCUITPY-CHANGE
#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) #define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER))
/** unichar / UTF-8 *********************************************/ /** unichar / UTF-8 *********************************************/
@ -341,7 +341,7 @@ typedef const char *mp_rom_error_text_t;
// Might add more types of compressed text in the future. // Might add more types of compressed text in the future.
// For now, forward directly to MP_COMPRESSED_ROM_TEXT. // For now, forward directly to MP_COMPRESSED_ROM_TEXT.
// CIRCUITPY: MP_ERROR_TEXT() -> translate() // CIRCUITPY-CHANGE: MP_ERROR_TEXT() -> translate()
#if CIRCUITPY #if CIRCUITPY
#include "supervisor/shared/translate/translate.h" #include "supervisor/shared/translate/translate.h"
#else #else

View File

@ -12,7 +12,7 @@ endif
THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST)) THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
TOP := $(patsubst %/py/mkenv.mk,%,$(THIS_MAKEFILE)) TOP := $(patsubst %/py/mkenv.mk,%,$(THIS_MAKEFILE))
# CIRCUITPY: verbosity differences, STEPECHO # CIRCUITPY-CHANGE: verbosity differences, STEPECHO
# Turn on increased build verbosity by defining BUILD_VERBOSE in your main # Turn on increased build verbosity by defining BUILD_VERBOSE in your main
# Makefile or in your environment. You can also use V="steps commands rules" or any combination thereof # Makefile or in your environment. You can also use V="steps commands rules" or any combination thereof
# on the make command line. # on the make command line.
@ -74,7 +74,7 @@ AR = $(CROSS_COMPILE)ar
MAKE_MANIFEST = $(PYTHON) $(TOP)/tools/makemanifest.py MAKE_MANIFEST = $(PYTHON) $(TOP)/tools/makemanifest.py
MAKE_FROZEN = $(PYTHON) $(TOP)/tools/make-frozen.py MAKE_FROZEN = $(PYTHON) $(TOP)/tools/make-frozen.py
MPY_TOOL = $(PYTHON) $(TOP)/tools/mpy-tool.py MPY_TOOL = $(PYTHON) $(TOP)/tools/mpy-tool.py
# CIRCUITPY # CIRCUITPY-CHANGE
PREPROCESS_FROZEN_MODULES = PYTHONPATH=$(TOP)/tools/python-semver $(TOP)/tools/preprocess_frozen_modules.py PREPROCESS_FROZEN_MODULES = PYTHONPATH=$(TOP)/tools/python-semver $(TOP)/tools/preprocess_frozen_modules.py
MPY_LIB_SUBMODULE_DIR = $(TOP)/lib/micropython-lib MPY_LIB_SUBMODULE_DIR = $(TOP)/lib/micropython-lib

View File

@ -44,7 +44,7 @@ QSTR_GEN_CXXFLAGS += $(QSTR_GEN_FLAGS)
# can be located. By following this scheme, it allows a single build rule # can be located. By following this scheme, it allows a single build rule
# to be used to compile all .c files. # to be used to compile all .c files.
# CIRCUITPY adds STEPECHO # CIRCUITPY-CHANGE: adds STEPECHO
vpath %.S . $(TOP) $(USER_C_MODULES) vpath %.S . $(TOP) $(USER_C_MODULES)
$(BUILD)/%.o: %.S $(BUILD)/%.o: %.S
$(STEPECHO) "CC $<" $(STEPECHO) "CC $<"
@ -79,7 +79,7 @@ $(Q)$(CXX) $(CXXFLAGS) -c -MD -o $@ $< || (echo -e $(HELP_BUILD_ERROR); false)
$(RM) -f $(@:.o=.d) $(RM) -f $(@:.o=.d)
endef endef
# CIRCUITPY: add $(DEVICES_MODULES) and $(BUILD) # CIRCUITPY-CHANGE: add $(DEVICES_MODULES) and $(BUILD)
vpath %.c . $(TOP) $(USER_C_MODULES) $(DEVICES_MODULES) $(BUILD) vpath %.c . $(TOP) $(USER_C_MODULES) $(DEVICES_MODULES) $(BUILD)
$(BUILD)/%.o: %.c $(BUILD)/%.o: %.c
$(call compile_c) $(call compile_c)
@ -191,7 +191,7 @@ CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
CFLAGS += -DMICROPY_MODULE_FROZEN_STR CFLAGS += -DMICROPY_MODULE_FROZEN_STR
# to build frozen_content.c from a manifest # to build frozen_content.c from a manifest
# CIRCUITPY: FROZEN_MANIFEST is constructed at build time # CIRCUITPY-CHANGE: FROZEN_MANIFEST is constructed at build time
$(BUILD)/frozen_content.c: FORCE $(BUILD)/genhdr/qstrdefs.generated.h $(BUILD)/genhdr/root_pointers.h $(FROZEN_MANIFEST) | $(MICROPY_MPYCROSS_DEPENDENCY) $(BUILD)/frozen_content.c: FORCE $(BUILD)/genhdr/qstrdefs.generated.h $(BUILD)/genhdr/root_pointers.h $(FROZEN_MANIFEST) | $(MICROPY_MPYCROSS_DEPENDENCY)
$(Q)test -e "$(MPY_LIB_DIR)/README.md" || (echo -e $(HELP_MPY_LIB_SUBMODULE); false) $(Q)test -e "$(MPY_LIB_DIR)/README.md" || (echo -e $(HELP_MPY_LIB_SUBMODULE); false)
$(Q)$(MAKE_MANIFEST) -o $@ -v "MPY_DIR=$(TOP)" -v "MPY_LIB_DIR=$(MPY_LIB_DIR)" -v "PORT_DIR=$(shell pwd)" -v "BOARD_DIR=$(BOARD_DIR)" -b "$(BUILD)" $(if $(MPY_CROSS_FLAGS),-f"$(MPY_CROSS_FLAGS)",) --mpy-tool-flags="$(MPY_TOOL_FLAGS)" $(FROZEN_MANIFEST) $(Q)$(MAKE_MANIFEST) -o $@ -v "MPY_DIR=$(TOP)" -v "MPY_LIB_DIR=$(MPY_LIB_DIR)" -v "PORT_DIR=$(shell pwd)" -v "BOARD_DIR=$(BOARD_DIR)" -b "$(BUILD)" $(if $(MPY_CROSS_FLAGS),-f"$(MPY_CROSS_FLAGS)",) --mpy-tool-flags="$(MPY_TOOL_FLAGS)" $(FROZEN_MANIFEST)

View File

@ -188,7 +188,7 @@ STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
// Implemented by probing all possible qstrs with mp_load_method_maybe // Implemented by probing all possible qstrs with mp_load_method_maybe
size_t nqstr = QSTR_TOTAL(); size_t nqstr = QSTR_TOTAL();
for (size_t i = MP_QSTR_ + 1; i < nqstr; ++i) { for (size_t i = MP_QSTR_ + 1; i < nqstr; ++i) {
// CIRCUITPY changes PR #6539 // CIRCUITPY-CHANGE: changes PR #6539
mp_obj_t dest[2] = {}; mp_obj_t dest[2] = {};
mp_load_method_protected(args[0], i, dest, true); mp_load_method_protected(args[0], i, dest, true);
if (dest[0] != MP_OBJ_NULL) { if (dest[0] != MP_OBJ_NULL) {
@ -398,7 +398,7 @@ STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
} }
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj, 2, 3, mp_builtin_pow); MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj, 2, 3, mp_builtin_pow);
// CIRCUITPY adds flush() // CIRCUITPY-CHANGE: adds flush()
STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_sep, ARG_end, ARG_flush, ARG_file }; enum { ARG_sep, ARG_end, ARG_flush, ARG_file };
static const mp_arg_t allowed_args[] = { static const mp_arg_t allowed_args[] = {

View File

@ -252,7 +252,7 @@ STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
if (base <= (mp_float_t)0.0) { if (base <= (mp_float_t)0.0) {
math_error(); math_error();
} else if (base == (mp_float_t)1.0) { } else if (base == (mp_float_t)1.0) {
// CIRCUITPY: remove redundant text error message // CIRCUITPY-CHANGE: remove redundant text error message
mp_raise_ZeroDivisionError(); mp_raise_ZeroDivisionError();
} }
return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base)); return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base));

View File

@ -181,7 +181,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_unpack_from_obj, 2, 3, struct_unpack_
// This function assumes there is enough room in p to store all the values // This function assumes there is enough room in p to store all the values
STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, const mp_obj_t *args) { STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, const mp_obj_t *args) {
// CIRCUITPY additional error checking // CIRCUITPY-CHANGE: additional error checking
size_t size; size_t size;
size_t count = calc_size_items(mp_obj_str_get_str(fmt_in), &size); size_t count = calc_size_items(mp_obj_str_get_str(fmt_in), &size);
if (count != n_args) { if (count != n_args) {

View File

@ -166,7 +166,7 @@ STATIC mp_obj_t mp_sys_exc_info(void) {
t->items[0] = MP_OBJ_FROM_PTR(mp_obj_get_type(cur_exc)); t->items[0] = MP_OBJ_FROM_PTR(mp_obj_get_type(cur_exc));
t->items[1] = cur_exc; t->items[1] = cur_exc;
// CIRCUITPY has traceback obj // CIRCUITPY-CHANGE: has traceback obj
t->items[2] = mp_obj_exception_get_traceback_obj(cur_exc); t->items[2] = mp_obj_exception_get_traceback_obj(cur_exc);
return MP_OBJ_FROM_PTR(t); return MP_OBJ_FROM_PTR(t);
} }

View File

@ -129,7 +129,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
STATIC size_t thread_stack_size = 0; STATIC size_t thread_stack_size = 0;
STATIC mp_obj_t mod_thread_get_ident(void) { STATIC mp_obj_t mod_thread_get_ident(void) {
// CIRCUITPY: uintptr_t cast to avoid warning // CIRCUITPY-CHANGE: uintptr_t cast to avoid warning
return mp_obj_new_int_from_uint((uintptr_t)mp_thread_get_state()); return mp_obj_new_int_from_uint((uintptr_t)mp_thread_get_state());
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_get_ident_obj, mod_thread_get_ident); STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_get_ident_obj, mod_thread_get_ident);

View File

@ -540,7 +540,7 @@
#define MICROPY_OPT_COMPUTED_GOTO (0) #define MICROPY_OPT_COMPUTED_GOTO (0)
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
// Whether to save trade flash space for speed in MICROPY_OPT_COMPUTED_GOTO. // Whether to save trade flash space for speed in MICROPY_OPT_COMPUTED_GOTO.
// Costs about 3% speed, saves about 1500 bytes space. In addition to the assumptions // Costs about 3% speed, saves about 1500 bytes space. In addition to the assumptions
// of MICROPY_OPT_COMPUTED_GOTO, also assumes that mp_execute_bytecode is less than // of MICROPY_OPT_COMPUTED_GOTO, also assumes that mp_execute_bytecode is less than
@ -606,7 +606,7 @@
#define MICROPY_HAS_FILE_READER (MICROPY_READER_POSIX || MICROPY_READER_VFS) #define MICROPY_HAS_FILE_READER (MICROPY_READER_POSIX || MICROPY_READER_VFS)
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
// Number of VFS mounts to persist across soft-reset. // Number of VFS mounts to persist across soft-reset.
#ifndef MICROPY_FATFS_NUM_PERSISTENT #ifndef MICROPY_FATFS_NUM_PERSISTENT
#define MICROPY_FATFS_NUM_PERSISTENT (0) #define MICROPY_FATFS_NUM_PERSISTENT (0)
@ -811,13 +811,13 @@ typedef long long mp_longint_impl_t;
#define MICROPY_ERROR_PRINTER (&mp_plat_print) #define MICROPY_ERROR_PRINTER (&mp_plat_print)
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
// Whether to support chained exceptions // Whether to support chained exceptions
#ifndef MICROPY_CPYTHON_EXCEPTION_CHAIN #ifndef MICROPY_CPYTHON_EXCEPTION_CHAIN
#define MICROPY_CPYTHON_EXCEPTION_CHAIN (0) #define MICROPY_CPYTHON_EXCEPTION_CHAIN (0)
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
// Whether the statically allocated GeneratorExit exception may be const // Whether the statically allocated GeneratorExit exception may be const
#ifndef MICROPY_CONST_GENERATOREXIT_OBJ #ifndef MICROPY_CONST_GENERATOREXIT_OBJ
#define MICROPY_CONST_GENERATOREXIT_OBJ (!MICROPY_CPYTHON_EXCEPTION_CHAIN) #define MICROPY_CONST_GENERATOREXIT_OBJ (!MICROPY_CPYTHON_EXCEPTION_CHAIN)
@ -1606,7 +1606,7 @@ typedef double mp_float_t;
#define MICROPY_PY_UCTYPES_NATIVE_C_TYPES (1) #define MICROPY_PY_UCTYPES_NATIVE_C_TYPES (1)
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
// TODO? CIRCUITPY_ZLIB instead // TODO? CIRCUITPY_ZLIB instead
#ifndef MICROPY_PY_ZLIB #ifndef MICROPY_PY_ZLIB
#define MICROPY_PY_ZLIB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #define MICROPY_PY_ZLIB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
@ -1696,7 +1696,7 @@ typedef double mp_float_t;
#define MICROPY_PY_BINASCII (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #define MICROPY_PY_BINASCII (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
#endif #endif
// CIRCUITPY: does not depend on MICROPY_PY_DEFLATE // CIRCUITPY-CHANGE: does not depend on MICROPY_PY_DEFLATE
#ifndef MICROPY_PY_BINASCII_CRC32 #ifndef MICROPY_PY_BINASCII_CRC32
#define MICROPY_PY_BINASCII_CRC32 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #define MICROPY_PY_BINASCII_CRC32 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
#endif #endif
@ -1993,14 +1993,14 @@ typedef double mp_float_t;
#define MP_WEAK __attribute__((weak)) #define MP_WEAK __attribute__((weak))
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
// Modifier for functions which should not be instrumented when tracing with // Modifier for functions which should not be instrumented when tracing with
// -finstrument-functions // -finstrument-functions
#ifndef MP_NO_INSTRUMENT #ifndef MP_NO_INSTRUMENT
#define MP_NO_INSTRUMENT __attribute__((no_instrument_function)) #define MP_NO_INSTRUMENT __attribute__((no_instrument_function))
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
// Modifier for functions which should ideally inlined // Modifier for functions which should ideally inlined
#ifndef MP_INLINE #ifndef MP_INLINE
#define MP_INLINE inline MP_NO_INSTRUMENT #define MP_INLINE inline MP_NO_INSTRUMENT
@ -2026,7 +2026,7 @@ typedef double mp_float_t;
#define MP_UNLIKELY(x) __builtin_expect((x), 0) #define MP_UNLIKELY(x) __builtin_expect((x), 0)
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
// Modifier for functions which aren't often used. Calls will also be considered // Modifier for functions which aren't often used. Calls will also be considered
// unlikely. Section names are `.text.unlikely` for use in linker scripts. // unlikely. Section names are `.text.unlikely` for use in linker scripts.
#ifndef MP_COLD #ifndef MP_COLD

View File

@ -147,7 +147,7 @@
#include "py/obj.h" #include "py/obj.h"
qstr mp_errno_to_str(mp_obj_t errno_val); qstr mp_errno_to_str(mp_obj_t errno_val);
// CIRCUITPY // CIRCUITPY-CHANGE
const char *mp_common_errno_to_str(mp_obj_t errno_val, char *buf, size_t len); const char *mp_common_errno_to_str(mp_obj_t errno_val, char *buf, size_t len);
#endif #endif

View File

@ -376,7 +376,7 @@ int mp_print_float(const mp_print_t *print, mp_float_t f, char fmt, int flags, c
} }
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
static int print_str_common(const mp_print_t *print, const char *str, int prec, size_t len, int flags, int fill, int width) { static int print_str_common(const mp_print_t *print, const char *str, int prec, size_t len, int flags, int fill, int width) {
if (prec >= 0 && (size_t)prec < len) { if (prec >= 0 && (size_t)prec < len) {
len = prec; len = prec;

View File

@ -79,7 +79,7 @@ int mp_printf(const mp_print_t *print, const char *fmt, ...);
int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args);
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
struct compressed_string; struct compressed_string;
int mp_cprintf(const mp_print_t *print, const struct compressed_string *compressed_fmt, ...); int mp_cprintf(const mp_print_t *print, const struct compressed_string *compressed_fmt, ...);
#ifdef va_start #ifdef va_start

View File

@ -25,7 +25,7 @@
*/ */
#include "py/mpstate.h" #include "py/mpstate.h"
// CIRCUITPY // CIRCUITPY-CHANGE
#include "supervisor/linker.h" #include "supervisor/linker.h"
#if MICROPY_DYNAMIC_COMPILER #if MICROPY_DYNAMIC_COMPILER

View File

@ -142,7 +142,7 @@ typedef struct _mp_state_mem_t {
mp_thread_mutex_t gc_mutex; mp_thread_mutex_t gc_mutex;
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
void **permanent_pointers; void **permanent_pointers;
} mp_state_mem_t; } mp_state_mem_t;
@ -270,7 +270,7 @@ typedef struct _mp_state_thread_t {
// Stack top at the start of program // Stack top at the start of program
char *stack_top; char *stack_top;
// CIRCUITPY // CIRCUITPY-CHANGE
#if MICROPY_MAX_STACK_USAGE #if MICROPY_MAX_STACK_USAGE
char *stack_bottom; char *stack_bottom;
#endif #endif

View File

@ -452,7 +452,7 @@ STATIC size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t *
} }
ilen = id - oidig; ilen = id - oidig;
// CIRCUITPY: check to prevent usb starvation // CIRCUITPY-CHANGE: check to prevent usb starvation
#ifdef RUN_BACKGROUND_TASKS #ifdef RUN_BACKGROUND_TASKS
RUN_BACKGROUND_TASKS; RUN_BACKGROUND_TASKS;
#endif #endif

View File

@ -142,7 +142,7 @@ void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const m
static inline size_t mpz_max_num_bits(const mpz_t *z) { static inline size_t mpz_max_num_bits(const mpz_t *z) {
return z->len * MPZ_DIG_SIZE; return z->len * MPZ_DIG_SIZE;
} }
// CIRCUITPY // CIRCUITPY-CHANGE
static inline size_t mpz_num_bits(const mpz_t *z) { static inline size_t mpz_num_bits(const mpz_t *z) {
if (mpz_is_zero(z)) { if (mpz_is_zero(z)) {
return 0; return 0;

View File

@ -320,7 +320,7 @@ const mp_fun_table_t mp_fun_table = {
gc_realloc, gc_realloc,
mp_printf, mp_printf,
mp_vprintf, mp_vprintf,
mp_raise_msg_str, // CIRCUITPY mp_raise_msg_str, // CIRCUITPY-CHANGE
mp_obj_get_type, mp_obj_get_type,
mp_obj_new_str, mp_obj_new_str,
mp_obj_new_bytes, mp_obj_new_bytes,

View File

@ -36,7 +36,7 @@
// For reference, arm/thumb callee save regs are: // For reference, arm/thumb callee save regs are:
// r4-r11, r13=sp // r4-r11, r13=sp
// CIRCUITPY: added returns_twice // CIRCUITPY-CHANGE: added returns_twice
__attribute__((naked, returns_twice)) unsigned int nlr_push(nlr_buf_t *nlr) { __attribute__((naked, returns_twice)) unsigned int nlr_push(nlr_buf_t *nlr) {
__asm volatile ( __asm volatile (

View File

@ -107,14 +107,14 @@ const mp_obj_type_t *MICROPY_WRAP_MP_OBJ_GET_TYPE(mp_obj_get_type)(mp_const_obj_
} }
const char *mp_obj_get_type_str(mp_const_obj_t o_in) { const char *mp_obj_get_type_str(mp_const_obj_t o_in) {
// CIRCUITPY // CIRCUITPY-CHANGE
return qstr_str(mp_obj_get_type_qstr(o_in)); return qstr_str(mp_obj_get_type_qstr(o_in));
} }
void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
// There can be data structures nested too deep, or just recursive // There can be data structures nested too deep, or just recursive
MP_STACK_CHECK(); MP_STACK_CHECK();
// CIRCUITPY // CIRCUITPY-CHANGE
#ifdef RUN_BACKGROUND_TASKS #ifdef RUN_BACKGROUND_TASKS
RUN_BACKGROUND_TASKS; RUN_BACKGROUND_TASKS;
#endif #endif
@ -143,7 +143,7 @@ void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind) {
mp_obj_print_helper(MP_PYTHON_PRINTER, o_in, kind); mp_obj_print_helper(MP_PYTHON_PRINTER, o_in, kind);
} }
// CIRCUITPY // CIRCUITPY-CHANGE
static void mp_obj_print_inner_exception(const mp_print_t *print, mp_obj_t self_in, mp_int_t limit) { static void mp_obj_print_inner_exception(const mp_print_t *print, mp_obj_t self_in, mp_int_t limit) {
#if MICROPY_CPYTHON_EXCEPTION_CHAIN #if MICROPY_CPYTHON_EXCEPTION_CHAIN
mp_obj_exception_t *self = mp_obj_exception_get_native(self_in); mp_obj_exception_t *self = mp_obj_exception_get_native(self_in);
@ -166,7 +166,7 @@ static void mp_obj_print_inner_exception(const mp_print_t *print, mp_obj_t self_
#endif #endif
} }
// CIRCUITPY // CIRCUITPY-CHANGE
// helper function to print an exception with traceback // helper function to print an exception with traceback
void mp_obj_print_exception_with_limit(const mp_print_t *print, mp_obj_t exc, mp_int_t limit) { void mp_obj_print_exception_with_limit(const mp_print_t *print, mp_obj_t exc, mp_int_t limit) {
if (mp_obj_is_exception_instance(exc) && stack_ok()) { if (mp_obj_is_exception_instance(exc) && stack_ok()) {
@ -227,7 +227,7 @@ void mp_obj_print_exception_with_limit(const mp_print_t *print, mp_obj_t exc, mp
mp_print_str(print, "\n"); mp_print_str(print, "\n");
} }
// CIRCUITPY // CIRCUITPY-CHANGE
void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) { void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) {
mp_obj_print_exception_with_limit(print, exc, 0); mp_obj_print_exception_with_limit(print, exc, 0);
} }
@ -488,7 +488,7 @@ void mp_obj_get_complex(mp_obj_t arg, mp_float_t *real, mp_float_t *imag) {
// note: returned value in *items may point to the interior of a GC block // note: returned value in *items may point to the interior of a GC block
void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items) { void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items) {
// CIRCUITPY // CIRCUITPY-CHANGE
if (mp_obj_is_tuple_compatible(o)) { if (mp_obj_is_tuple_compatible(o)) {
mp_obj_tuple_get(o, len, items); mp_obj_tuple_get(o, len, items);
} else if (mp_obj_is_type(o, &mp_type_list)) { } else if (mp_obj_is_type(o, &mp_type_list)) {
@ -542,7 +542,7 @@ size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool
i = len; i = len;
} }
} else { } else {
// CIRCUITPY // CIRCUITPY-CHANGE
mp_arg_validate_index_range(i, 0, len - 1, MP_QSTR_index); mp_arg_validate_index_range(i, 0, len - 1, MP_QSTR_index);
} }
@ -645,7 +645,7 @@ mp_obj_t mp_identity(mp_obj_t self) {
} }
MP_DEFINE_CONST_FUN_OBJ_1(mp_identity_obj, mp_identity); MP_DEFINE_CONST_FUN_OBJ_1(mp_identity_obj, mp_identity);
// CIRCUITPY // CIRCUITPY-CHANGE
// generic subscript iterator, which iterates through anything with a 0-based subscript. // generic subscript iterator, which iterates through anything with a 0-based subscript.
typedef struct { typedef struct {
mp_obj_base_t base; mp_obj_base_t base;

View File

@ -34,7 +34,7 @@
#include "py/mpprint.h" #include "py/mpprint.h"
#include "py/runtime0.h" #include "py/runtime0.h"
// CIRCUITPY // CIRCUITPY-CHANGE
#include "supervisor/shared/translate/compressed_string.h" #include "supervisor/shared/translate/compressed_string.h"
// This is the definition of the opaque MicroPython object type. // This is the definition of the opaque MicroPython object type.
@ -833,7 +833,7 @@ extern const mp_obj_type_t mp_type_bytearray;
extern const mp_obj_type_t mp_type_memoryview; extern const mp_obj_type_t mp_type_memoryview;
extern const mp_obj_type_t mp_type_float; extern const mp_obj_type_t mp_type_float;
extern const mp_obj_type_t mp_type_complex; extern const mp_obj_type_t mp_type_complex;
// CIRCUITPY // CIRCUITPY-CHANGE
extern const mp_obj_type_t mp_type_traceback; extern const mp_obj_type_t mp_type_traceback;
extern const mp_obj_type_t mp_type_tuple; extern const mp_obj_type_t mp_type_tuple;
extern const mp_obj_type_t mp_type_list; extern const mp_obj_type_t mp_type_list;
@ -851,13 +851,13 @@ extern const mp_obj_type_t mp_type_zip;
extern const mp_obj_type_t mp_type_array; extern const mp_obj_type_t mp_type_array;
extern const mp_obj_type_t mp_type_super; extern const mp_obj_type_t mp_type_super;
extern const mp_obj_type_t mp_type_gen_wrap; extern const mp_obj_type_t mp_type_gen_wrap;
// CIRCUITPY distinguishes generators and coroutines // CIRCUITPY-CHANGE: distinguishes generators and coroutines
extern const mp_obj_type_t mp_type_coro_wrap; extern const mp_obj_type_t mp_type_coro_wrap;
extern const mp_obj_type_t mp_type_native_gen_wrap; extern const mp_obj_type_t mp_type_native_gen_wrap;
// CIRCUITPY distinguishes generators and coroutines // CIRCUITPY-CHANGE: distinguishes generators and coroutines
extern const mp_obj_type_t mp_type_native_coro_wrap; extern const mp_obj_type_t mp_type_native_coro_wrap;
extern const mp_obj_type_t mp_type_gen_instance; extern const mp_obj_type_t mp_type_gen_instance;
// CIRCUITPY distinguishes generators and coroutines // CIRCUITPY-CHANGE: distinguishes generators and coroutines
extern const mp_obj_type_t mp_type_coro_instance; extern const mp_obj_type_t mp_type_coro_instance;
extern const mp_obj_type_t mp_type_fun_builtin_0; extern const mp_obj_type_t mp_type_fun_builtin_0;
extern const mp_obj_type_t mp_type_fun_builtin_1; extern const mp_obj_type_t mp_type_fun_builtin_1;
@ -889,7 +889,7 @@ extern const mp_obj_type_t mp_type_ImportError;
extern const mp_obj_type_t mp_type_IndentationError; extern const mp_obj_type_t mp_type_IndentationError;
extern const mp_obj_type_t mp_type_IndexError; extern const mp_obj_type_t mp_type_IndexError;
extern const mp_obj_type_t mp_type_KeyboardInterrupt; extern const mp_obj_type_t mp_type_KeyboardInterrupt;
// CIRCUITPY // CIRCUITPY-CHANGE
extern const mp_obj_type_t mp_type_ReloadException; extern const mp_obj_type_t mp_type_ReloadException;
extern const mp_obj_type_t mp_type_KeyError; extern const mp_obj_type_t mp_type_KeyError;
extern const mp_obj_type_t mp_type_LookupError; extern const mp_obj_type_t mp_type_LookupError;
@ -897,9 +897,9 @@ extern const mp_obj_type_t mp_type_MemoryError;
extern const mp_obj_type_t mp_type_NameError; extern const mp_obj_type_t mp_type_NameError;
extern const mp_obj_type_t mp_type_NotImplementedError; extern const mp_obj_type_t mp_type_NotImplementedError;
extern const mp_obj_type_t mp_type_OSError; extern const mp_obj_type_t mp_type_OSError;
// CIRCUITPY // CIRCUITPY-CHANGE
extern const mp_obj_type_t mp_type_ConnectionError; extern const mp_obj_type_t mp_type_ConnectionError;
// CIRCUITPY // CIRCUITPY-CHANGE
extern const mp_obj_type_t mp_type_BrokenPipeError; extern const mp_obj_type_t mp_type_BrokenPipeError;
extern const mp_obj_type_t mp_type_OverflowError; extern const mp_obj_type_t mp_type_OverflowError;
extern const mp_obj_type_t mp_type_RuntimeError; extern const mp_obj_type_t mp_type_RuntimeError;
@ -943,7 +943,7 @@ extern const struct _mp_obj_str_t mp_const_empty_bytes_obj;
extern const struct _mp_obj_tuple_t mp_const_empty_tuple_obj; extern const struct _mp_obj_tuple_t mp_const_empty_tuple_obj;
extern const struct _mp_obj_dict_t mp_const_empty_dict_obj; extern const struct _mp_obj_dict_t mp_const_empty_dict_obj;
extern const struct _mp_obj_singleton_t mp_const_ellipsis_obj; extern const struct _mp_obj_singleton_t mp_const_ellipsis_obj;
// CIRCUITPY next several lines // CIRCUITPY-CHANGE: next several lines
extern const struct _mp_obj_traceback_t mp_const_empty_traceback_obj; extern const struct _mp_obj_traceback_t mp_const_empty_traceback_obj;
extern const struct _mp_obj_singleton_t mp_const_notimplemented_obj; extern const struct _mp_obj_singleton_t mp_const_notimplemented_obj;
#if MICROPY_CONST_GENERATOREXIT_OBJ #if MICROPY_CONST_GENERATOREXIT_OBJ
@ -992,7 +992,7 @@ void *mp_obj_malloc_helper(size_t num_bytes, const mp_obj_type_t *type);
#define mp_obj_is_str_or_bytes(o) (mp_obj_is_qstr(o) || (mp_obj_is_obj(o) && MP_OBJ_TYPE_GET_SLOT_OR_NULL(((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type, binary_op) == mp_obj_str_binary_op)) #define mp_obj_is_str_or_bytes(o) (mp_obj_is_qstr(o) || (mp_obj_is_obj(o) && MP_OBJ_TYPE_GET_SLOT_OR_NULL(((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type, binary_op) == mp_obj_str_binary_op))
bool mp_obj_is_dict_or_ordereddict(mp_obj_t o); bool mp_obj_is_dict_or_ordereddict(mp_obj_t o);
#define mp_obj_is_fun(o) (mp_obj_is_obj(o) && (((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type->name == MP_QSTR_function)) #define mp_obj_is_fun(o) (mp_obj_is_obj(o) && (((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type->name == MP_QSTR_function))
// CIRCUITPY // CIRCUITPY-CHANGE
// type check is done on iter method to allow tuple, namedtuple, attrtuple // type check is done on iter method to allow tuple, namedtuple, attrtuple
#define mp_obj_is_tuple_compatible(o) (MP_OBJ_TYPE_GET_SLOT_OR_NULL(mp_obj_get_type(o), iter) == mp_obj_tuple_getiter) #define mp_obj_is_tuple_compatible(o) (MP_OBJ_TYPE_GET_SLOT_OR_NULL(mp_obj_get_type(o), iter) == mp_obj_tuple_getiter)
@ -1016,16 +1016,17 @@ mp_obj_t mp_obj_new_str_from_utf8_vstr(vstr_t *vstr); // input data must be vali
#endif #endif
mp_obj_t mp_obj_new_bytes_from_vstr(vstr_t *vstr); mp_obj_t mp_obj_new_bytes_from_vstr(vstr_t *vstr);
mp_obj_t mp_obj_new_bytes(const byte *data, size_t len); mp_obj_t mp_obj_new_bytes(const byte *data, size_t len);
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_t mp_obj_new_bytes_of_zeros(size_t len); mp_obj_t mp_obj_new_bytes_of_zeros(size_t len);
mp_obj_t mp_obj_new_bytearray(size_t n, const void *items); mp_obj_t mp_obj_new_bytearray(size_t n, const void *items);
mp_obj_t mp_obj_new_bytearray_of_zeros(size_t n); // CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_t mp_obj_new_bytearray_of_zeros(size_t n);
mp_obj_t mp_obj_new_bytearray_by_ref(size_t n, void *items); mp_obj_t mp_obj_new_bytearray_by_ref(size_t n, void *items);
#if MICROPY_PY_BUILTINS_FLOAT #if MICROPY_PY_BUILTINS_FLOAT
mp_obj_t mp_obj_new_int_from_float(mp_float_t val); mp_obj_t mp_obj_new_int_from_float(mp_float_t val);
mp_obj_t mp_obj_new_complex(mp_float_t real, mp_float_t imag); mp_obj_t mp_obj_new_complex(mp_float_t real, mp_float_t imag);
// CIRCUITPY: our own conversion routines that don't bring double routines // CIRCUITPY-CHANGE: our own conversion routines that don't bring double routines
extern mp_float_t uint64_to_float(uint64_t ui64); extern mp_float_t uint64_to_float(uint64_t ui64);
extern uint64_t float_to_uint64(float f); extern uint64_t float_to_uint64(float f);
#endif #endif
@ -1035,12 +1036,12 @@ mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args,
#define mp_obj_new_exception_msg(exc_type, msg) mp_obj_new_exception(exc_type) #define mp_obj_new_exception_msg(exc_type, msg) mp_obj_new_exception(exc_type)
#define mp_obj_new_exception_msg_varg(exc_type, ...) mp_obj_new_exception(exc_type) #define mp_obj_new_exception_msg_varg(exc_type, ...) mp_obj_new_exception(exc_type)
#else #else
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg); mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg);
mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, ...); // counts args by number of % symbols in fmt, excluding %%; can only handle void* sizes (ie no float/double!) mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, ...); // counts args by number of % symbols in fmt, excluding %%; can only handle void* sizes (ie no float/double!)
#endif #endif
#ifdef va_start #ifdef va_start
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_t mp_obj_new_exception_msg_vlist(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, va_list arg); // same fmt restrictions as above mp_obj_t mp_obj_new_exception_msg_vlist(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, va_list arg); // same fmt restrictions as above
#endif #endif
mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun); mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun);
@ -1057,7 +1058,7 @@ mp_obj_t mp_obj_new_memoryview(byte typecode, size_t nitems, void *items);
const mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in); const mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in);
const char *mp_obj_get_type_str(mp_const_obj_t o_in); const char *mp_obj_get_type_str(mp_const_obj_t o_in);
// CIRCUITPY // CIRCUITPY-CHANGE
#define mp_obj_get_type_qstr(o_in) (mp_obj_get_type((o_in))->name) #define mp_obj_get_type_qstr(o_in) (mp_obj_get_type((o_in))->name)
bool mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); // arguments should be type objects bool mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); // arguments should be type objects
mp_obj_t mp_obj_cast_to_native_base(mp_obj_t self_in, mp_const_obj_t native_type); mp_obj_t mp_obj_cast_to_native_base(mp_obj_t self_in, mp_const_obj_t native_type);
@ -1065,7 +1066,7 @@ mp_obj_t mp_obj_cast_to_native_base(mp_obj_t self_in, mp_const_obj_t native_type
void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind); void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind);
void mp_obj_print(mp_obj_t o, mp_print_kind_t kind); void mp_obj_print(mp_obj_t o, mp_print_kind_t kind);
void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc); void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc);
// CIRCUITPY // CIRCUITPY-CHANGE
void mp_obj_print_exception_with_limit(const mp_print_t *print, mp_obj_t exc, mp_int_t limit); void mp_obj_print_exception_with_limit(const mp_print_t *print, mp_obj_t exc, mp_int_t limit);
bool mp_obj_is_true(mp_obj_t arg); bool mp_obj_is_true(mp_obj_t arg);
@ -1128,7 +1129,7 @@ bool mp_obj_exception_match(mp_obj_t exc, mp_const_obj_t exc_type);
void mp_obj_exception_clear_traceback(mp_obj_t self_in); void mp_obj_exception_clear_traceback(mp_obj_t self_in);
void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qstr block); void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qstr block);
void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values); void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values);
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_t mp_obj_exception_get_traceback_obj(mp_obj_t self_in); mp_obj_t mp_obj_exception_get_traceback_obj(mp_obj_t self_in);
mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in); mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in);
mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
@ -1205,7 +1206,7 @@ void mp_obj_tuple_del(mp_obj_t self_in);
mp_int_t mp_obj_tuple_hash(mp_obj_t self_in); mp_int_t mp_obj_tuple_hash(mp_obj_t self_in);
// list // list
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_t mp_obj_list_clear(mp_obj_t self_in); mp_obj_t mp_obj_list_clear(mp_obj_t self_in);
mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg); mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg);
mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value); mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value);
@ -1275,7 +1276,7 @@ qstr mp_obj_fun_get_name(mp_const_obj_t fun);
mp_obj_t mp_identity(mp_obj_t self); mp_obj_t mp_identity(mp_obj_t self);
MP_DECLARE_CONST_FUN_OBJ_1(mp_identity_obj); MP_DECLARE_CONST_FUN_OBJ_1(mp_identity_obj);
// CIRCUITPY // CIRCUITPY-CHANGE
// Generic iterator that uses unary op and subscr to iterate over a native type. It will be slower // Generic iterator that uses unary op and subscr to iterate over a native type. It will be slower
// than a custom iterator but applies broadly. // than a custom iterator but applies broadly.
mp_obj_t mp_obj_generic_subscript_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf); mp_obj_t mp_obj_generic_subscript_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf);
@ -1301,12 +1302,12 @@ typedef struct _mp_rom_obj_static_class_method_t {
} mp_rom_obj_static_class_method_t; } mp_rom_obj_static_class_method_t;
// property // property
// CIRCUITPY // CIRCUITPY-CHANGE
const mp_obj_t *mp_obj_property_get(mp_obj_t self_in, size_t *n_proxy); const mp_obj_t *mp_obj_property_get(mp_obj_t self_in, size_t *n_proxy);
// sequence helpers // sequence helpers
// CIRCUITPY // CIRCUITPY-CHANGE
// Compute the new length of a sequence and ensure an exception is thrown on overflow. // Compute the new length of a sequence and ensure an exception is thrown on overflow.
size_t mp_seq_multiply_len(size_t item_sz, size_t len); size_t mp_seq_multiply_len(size_t item_sz, size_t len);
void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest);

View File

@ -65,7 +65,7 @@ STATIC mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_bu
STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg); STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg);
STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in); STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in);
STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags);
// CIRCUITPY // CIRCUITPY-CHANGE
#if MICROPY_CPYTHON_COMPAT #if MICROPY_CPYTHON_COMPAT
STATIC mp_obj_t array_decode(size_t n_args, const mp_obj_t *args); STATIC mp_obj_t array_decode(size_t n_args, const mp_obj_t *args);
#endif #endif
@ -100,7 +100,7 @@ STATIC void array_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
#if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
STATIC mp_obj_array_t *array_new(char typecode, size_t n) { STATIC mp_obj_array_t *array_new(char typecode, size_t n) {
// CIRCUITPY // CIRCUITPY-CHANGE
if (typecode == 'x') { if (typecode == 'x') {
mp_raise_ValueError(MP_ERROR_TEXT("bad typecode")); mp_raise_ValueError(MP_ERROR_TEXT("bad typecode"));
} }
@ -134,7 +134,7 @@ STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
&& mp_get_buffer(initializer, &bufinfo, MP_BUFFER_READ)) { && mp_get_buffer(initializer, &bufinfo, MP_BUFFER_READ)) {
// construct array from raw bytes // construct array from raw bytes
size_t sz = mp_binary_get_size('@', typecode, NULL); size_t sz = mp_binary_get_size('@', typecode, NULL);
// CIRCUITPY // CIRCUITPY-CHANGE
if (bufinfo.len % sz) { if (bufinfo.len % sz) {
mp_raise_ValueError(MP_ERROR_TEXT("bytes length not a multiple of item size")); mp_raise_ValueError(MP_ERROR_TEXT("bytes length not a multiple of item size"));
} }
@ -198,7 +198,7 @@ STATIC mp_obj_t bytearray_make_new(const mp_obj_type_t *type_in, size_t n_args,
// no args: construct an empty bytearray // no args: construct an empty bytearray
return MP_OBJ_FROM_PTR(array_new(BYTEARRAY_TYPECODE, 0)); return MP_OBJ_FROM_PTR(array_new(BYTEARRAY_TYPECODE, 0));
} else if (mp_obj_is_int(args[0])) { } else if (mp_obj_is_int(args[0])) {
// CIRCUITPY error checks this // CIRCUITPY-CHANGE: error checks this
if (n_args > 1) { if (n_args > 1) {
mp_raise_TypeError(MP_ERROR_TEXT("wrong number of arguments")); mp_raise_TypeError(MP_ERROR_TEXT("wrong number of arguments"));
} }
@ -261,7 +261,7 @@ STATIC mp_obj_t memoryview_make_new(const mp_obj_type_t *type_in, size_t n_args,
return MP_OBJ_FROM_PTR(self); return MP_OBJ_FROM_PTR(self);
} }
// CIRCUITPY adds cast // CIRCUITPY-CHANGE: adds cast
#if MICROPY_CPYTHON_COMPAT #if MICROPY_CPYTHON_COMPAT
STATIC mp_obj_t memoryview_cast(const mp_obj_t self_in, const mp_obj_t typecode_in) { STATIC mp_obj_t memoryview_cast(const mp_obj_t self_in, const mp_obj_t typecode_in) {
mp_obj_array_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_array_t *self = MP_OBJ_TO_PTR(self_in);
@ -330,7 +330,7 @@ STATIC int typecode_for_comparison(int typecode, bool *is_unsigned) {
STATIC mp_obj_t array_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { STATIC mp_obj_t array_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
mp_obj_array_t *lhs = MP_OBJ_TO_PTR(lhs_in); mp_obj_array_t *lhs = MP_OBJ_TO_PTR(lhs_in);
switch (op) { switch (op) {
// CIRCUITPY does multiply // CIRCUITPY-CHANGE: does multiply
case MP_BINARY_OP_MULTIPLY: case MP_BINARY_OP_MULTIPLY:
case MP_BINARY_OP_INPLACE_MULTIPLY: { case MP_BINARY_OP_INPLACE_MULTIPLY: {
if (!mp_obj_is_int(rhs_in)) { if (!mp_obj_is_int(rhs_in)) {
@ -486,7 +486,7 @@ STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) {
// allow to extend by anything that has the buffer protocol (extension to CPython) // allow to extend by anything that has the buffer protocol (extension to CPython)
mp_buffer_info_t arg_bufinfo; mp_buffer_info_t arg_bufinfo;
// CIRCUITPY: allow appending an iterable // CIRCUITPY-CHANGE: allow appending an iterable
if (mp_get_buffer(arg_in, &arg_bufinfo, MP_BUFFER_READ)) { if (mp_get_buffer(arg_in, &arg_bufinfo, MP_BUFFER_READ)) {
size_t sz = mp_binary_get_size('@', self->typecode, NULL); size_t sz = mp_binary_get_size('@', self->typecode, NULL);
@ -557,7 +557,7 @@ STATIC mp_obj_t buffer_finder(size_t n_args, const mp_obj_t *args, int direction
return MP_OBJ_NEW_SMALL_INT(p - (const byte *)haystack_bufinfo.buf); return MP_OBJ_NEW_SMALL_INT(p - (const byte *)haystack_bufinfo.buf);
} }
// CIRCUITPY provides find, rfind, index // CIRCUITPY-CHANGE: provides find, rfind, index
STATIC mp_obj_t buffer_find(size_t n_args, const mp_obj_t *args) { STATIC mp_obj_t buffer_find(size_t n_args, const mp_obj_t *args) {
return buffer_finder(n_args, args, 1, false); return buffer_finder(n_args, args, 1, false);
} }
@ -733,7 +733,7 @@ STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_ui
} }
// CIRCUITPY // CIRCUITPY-CHANGE
#if MICROPY_CPYTHON_COMPAT && MICROPY_PY_BUILTINS_BYTEARRAY #if MICROPY_CPYTHON_COMPAT && MICROPY_PY_BUILTINS_BYTEARRAY
// Directly lifted from objstr.c // Directly lifted from objstr.c
STATIC mp_obj_t array_decode(size_t n_args, const mp_obj_t *args) { STATIC mp_obj_t array_decode(size_t n_args, const mp_obj_t *args) {
@ -808,7 +808,8 @@ MP_DEFINE_CONST_OBJ_TYPE(
#define MEMORYVIEW_TYPE_ATTR #define MEMORYVIEW_TYPE_ATTR
#endif #endif
#if MICROPY_CPYTHON_COMPAT // CIRCUITPY provides cast #if MICROPY_CPYTHON_COMPAT
// CIRCUITPY-CHANGE: provides cast
STATIC const mp_rom_map_elem_t memoryview_locals_dict_table[] = { STATIC const mp_rom_map_elem_t memoryview_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_cast), MP_ROM_PTR(&memoryview_cast_obj) }, { MP_ROM_QSTR(MP_QSTR_cast), MP_ROM_PTR(&memoryview_cast_obj) },
#if MICROPY_PY_BUILTINS_BYTES_HEX #if MICROPY_PY_BUILTINS_BYTES_HEX
@ -851,7 +852,7 @@ mp_obj_t mp_obj_new_bytearray(size_t n, const void *items) {
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_t mp_obj_new_bytearray_of_zeros(size_t n) { mp_obj_t mp_obj_new_bytearray_of_zeros(size_t n) {
mp_obj_array_t *o = array_new(BYTEARRAY_TYPECODE, n); mp_obj_array_t *o = array_new(BYTEARRAY_TYPECODE, n);
memset(o->items, 0, n); memset(o->items, 0, n);

View File

@ -36,7 +36,7 @@
#include <math.h> #include <math.h>
#include "py/formatfloat.h" #include "py/formatfloat.h"
// CIRCUITPY compilation warning removal // CIRCUITPY-CHANGE: compilation warning removal
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal" #pragma GCC diagnostic ignored "-Wfloat-equal"

View File

@ -305,7 +305,7 @@ STATIC mp_obj_t dict_fromkeys(size_t n_args, const mp_obj_t *args) {
mp_obj_t len = mp_obj_len_maybe(args[1]); mp_obj_t len = mp_obj_len_maybe(args[1]);
if (len == MP_OBJ_NULL) { if (len == MP_OBJ_NULL) {
/* object's type doesn't have a __len__ slot */ /* object's type doesn't have a __len__ slot */
// CIRCUITPY uses dict_new_typed() here. // CIRCUITPY-CHANGE: uses dict_new_typed() here.
self_out = dict_new_typed(type, 0); self_out = dict_new_typed(type, 0);
} else { } else {
self_out = dict_new_typed(type, MP_OBJ_SMALL_INT_VALUE(len)); self_out = dict_new_typed(type, MP_OBJ_SMALL_INT_VALUE(len));
@ -442,7 +442,7 @@ STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwarg
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(dict_update_obj, 1, dict_update); STATIC MP_DEFINE_CONST_FUN_OBJ_KW(dict_update_obj, 1, dict_update);
// CIRCUITPY // CIRCUITPY-CHANGE
#if MICROPY_PY_COLLECTIONS_ORDEREDDICT #if MICROPY_PY_COLLECTIONS_ORDEREDDICT
STATIC mp_obj_t dict_move_to_end(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { STATIC mp_obj_t dict_move_to_end(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
mp_obj_dict_t *self = MP_OBJ_TO_PTR(pos_args[0]); mp_obj_dict_t *self = MP_OBJ_TO_PTR(pos_args[0]);
@ -578,7 +578,7 @@ STATIC void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_
mp_print_str(print, "])"); mp_print_str(print, "])");
} }
// CIRCUITPY // CIRCUITPY-CHANGE
STATIC mp_obj_t dict_view_unary_op(mp_unary_op_t op, mp_obj_t o_in) { STATIC mp_obj_t dict_view_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
mp_obj_dict_view_t *o = MP_OBJ_TO_PTR(o_in); mp_obj_dict_view_t *o = MP_OBJ_TO_PTR(o_in);
// only dict.values() supports __hash__. // only dict.values() supports __hash__.
@ -663,7 +663,7 @@ STATIC const mp_rom_map_elem_t dict_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&dict_get_obj) }, { MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&dict_get_obj) },
{ MP_ROM_QSTR(MP_QSTR_items), MP_ROM_PTR(&dict_items_obj) }, { MP_ROM_QSTR(MP_QSTR_items), MP_ROM_PTR(&dict_items_obj) },
{ MP_ROM_QSTR(MP_QSTR_keys), MP_ROM_PTR(&dict_keys_obj) }, { MP_ROM_QSTR(MP_QSTR_keys), MP_ROM_PTR(&dict_keys_obj) },
// CIRCUITPY // CIRCUITPY-CHANGE
#if MICROPY_PY_COLLECTIONS_ORDEREDDICT #if MICROPY_PY_COLLECTIONS_ORDEREDDICT
{ MP_ROM_QSTR(MP_QSTR_move_to_end), MP_ROM_PTR(&dict_move_to_end_obj) }, { MP_ROM_QSTR(MP_QSTR_move_to_end), MP_ROM_PTR(&dict_move_to_end_obj) },
#endif #endif

View File

@ -116,7 +116,7 @@ bool mp_obj_is_native_exception_instance(mp_obj_t self_in) {
return MP_OBJ_TYPE_GET_SLOT_OR_NULL(mp_obj_get_type(self_in), make_new) == mp_obj_exception_make_new; return MP_OBJ_TYPE_GET_SLOT_OR_NULL(mp_obj_get_type(self_in), make_new) == mp_obj_exception_make_new;
} }
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_exception_t *mp_obj_exception_get_native(mp_obj_t self_in) { mp_obj_exception_t *mp_obj_exception_get_native(mp_obj_t self_in) {
assert(mp_obj_is_exception_instance(self_in)); assert(mp_obj_is_exception_instance(self_in));
if (mp_obj_is_native_exception_instance(self_in)) { if (mp_obj_is_native_exception_instance(self_in)) {
@ -183,7 +183,7 @@ void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kin
#if MICROPY_PY_ERRNO #if MICROPY_PY_ERRNO
// try to provide a nice OSError error message // try to provide a nice OSError error message
if (o->base.type == &mp_type_OSError && o->args->len > 0 && o->args->len < 3 && mp_obj_is_small_int(o->args->items[0])) { if (o->base.type == &mp_type_OSError && o->args->len > 0 && o->args->len < 3 && mp_obj_is_small_int(o->args->items[0])) {
// CIRCUITPY can print a whole string, not just the errno qstr // CIRCUITPY-CHANGE: can print a whole string, not just the errno qstr
char decompressed[50]; char decompressed[50];
const char *msg = mp_common_errno_to_str(o->args->items[0], decompressed, sizeof(decompressed)); const char *msg = mp_common_errno_to_str(o->args->items[0], decompressed, sizeof(decompressed));
if (msg != NULL) { if (msg != NULL) {
@ -206,7 +206,7 @@ void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kin
mp_obj_tuple_print(print, MP_OBJ_FROM_PTR(o->args), kind); mp_obj_tuple_print(print, MP_OBJ_FROM_PTR(o->args), kind);
} }
// CIRCUITPY // CIRCUITPY-CHANGE
void mp_obj_exception_initialize0(mp_obj_exception_t *o_exc, const mp_obj_type_t *type) { void mp_obj_exception_initialize0(mp_obj_exception_t *o_exc, const mp_obj_type_t *type) {
o_exc->base.type = type; o_exc->base.type = type;
o_exc->args = (mp_obj_tuple_t *)&mp_const_empty_tuple_obj; o_exc->args = (mp_obj_tuple_t *)&mp_const_empty_tuple_obj;
@ -224,7 +224,7 @@ mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, siz
// Populate the exception object // Populate the exception object
o_exc->base.type = type; o_exc->base.type = type;
// CIRCUITPY // CIRCUITPY-CHANGE
o_exc->traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj; o_exc->traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj;
mp_obj_tuple_t *o_tuple; mp_obj_tuple_t *o_tuple;
@ -265,7 +265,7 @@ mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, siz
// Get exception "value" - that is, first argument, or None // Get exception "value" - that is, first argument, or None
mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in) { mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in) {
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_exception_t *self = mp_obj_exception_get_native(self_in); mp_obj_exception_t *self = mp_obj_exception_get_native(self_in);
if (self->args->len == 0) { if (self->args->len == 0) {
return mp_const_none; return mp_const_none;
@ -279,7 +279,7 @@ void mp_obj_exception_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
mp_obj_exception_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_exception_t *self = MP_OBJ_TO_PTR(self_in);
if (dest[0] != MP_OBJ_NULL) { if (dest[0] != MP_OBJ_NULL) {
// store/delete attribute // store/delete attribute
// CIRCUITPY changes till end of function // CIRCUITPY-CHANGE: changes till end of function
#if MICROPY_CONST_GENERATOREXIT_OBJ #if MICROPY_CONST_GENERATOREXIT_OBJ
if (self == &mp_const_GeneratorExit_obj) { if (self == &mp_const_GeneratorExit_obj) {
mp_raise_AttributeError(MP_ERROR_TEXT("can't set attribute")); mp_raise_AttributeError(MP_ERROR_TEXT("can't set attribute"));
@ -380,7 +380,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
// http://docs.python.org/3/library/exceptions.html // http://docs.python.org/3/library/exceptions.html
MP_DEFINE_EXCEPTION(SystemExit, BaseException) MP_DEFINE_EXCEPTION(SystemExit, BaseException)
MP_DEFINE_EXCEPTION(KeyboardInterrupt, BaseException) MP_DEFINE_EXCEPTION(KeyboardInterrupt, BaseException)
// CIRCUITPY // CIRCUITPY-CHANGE
MP_DEFINE_EXCEPTION(ReloadException, BaseException) MP_DEFINE_EXCEPTION(ReloadException, BaseException)
MP_DEFINE_EXCEPTION(GeneratorExit, BaseException) MP_DEFINE_EXCEPTION(GeneratorExit, BaseException)
MP_DEFINE_EXCEPTION(Exception, BaseException) MP_DEFINE_EXCEPTION(Exception, BaseException)
@ -410,7 +410,7 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
MP_DEFINE_EXCEPTION(BlockingIOError, OSError) MP_DEFINE_EXCEPTION(BlockingIOError, OSError)
MP_DEFINE_EXCEPTION(ChildProcessError, OSError) MP_DEFINE_EXCEPTION(ChildProcessError, OSError)
*/ */
// CIRCUITPY // CIRCUITPY-CHANGE
MP_DEFINE_EXCEPTION(ConnectionError, OSError) MP_DEFINE_EXCEPTION(ConnectionError, OSError)
MP_DEFINE_EXCEPTION(BrokenPipeError, ConnectionError) MP_DEFINE_EXCEPTION(BrokenPipeError, ConnectionError)
/* /*
@ -423,7 +423,7 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
MP_DEFINE_EXCEPTION(PermissionError, OSError) MP_DEFINE_EXCEPTION(PermissionError, OSError)
MP_DEFINE_EXCEPTION(ProcessLookupError, OSError) MP_DEFINE_EXCEPTION(ProcessLookupError, OSError)
*/ */
// CIRCUITPY // CIRCUITPY-CHANGE
MP_DEFINE_EXCEPTION(TimeoutError, OSError) MP_DEFINE_EXCEPTION(TimeoutError, OSError)
/* /*
MP_DEFINE_EXCEPTION(FileExistsError, OSError) MP_DEFINE_EXCEPTION(FileExistsError, OSError)
@ -478,7 +478,7 @@ mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args,
#if MICROPY_ERROR_REPORTING != MICROPY_ERROR_REPORTING_NONE #if MICROPY_ERROR_REPORTING != MICROPY_ERROR_REPORTING_NONE
mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg) { mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg) {
// CIRCUITPY is different here and for many lines below. // CIRCUITPY-CHANGE: is different here and for many lines below.
return mp_obj_new_exception_msg_varg(exc_type, msg); return mp_obj_new_exception_msg_varg(exc_type, msg);
} }
@ -712,7 +712,7 @@ void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values
} }
} }
// CIRCUITPY // CIRCUITPY-CHANGE
#if MICROPY_PY_SYS_EXC_INFO #if MICROPY_PY_SYS_EXC_INFO
STATIC const mp_obj_namedtuple_type_t code_type_obj = { STATIC const mp_obj_namedtuple_type_t code_type_obj = {
NAMEDTUPLE_TYPE_BASE_AND_SLOTS(MP_QSTR_code), NAMEDTUPLE_TYPE_BASE_AND_SLOTS(MP_QSTR_code),

View File

@ -28,7 +28,7 @@
#include "py/obj.h" #include "py/obj.h"
#include "py/objtuple.h" #include "py/objtuple.h"
// CIRCUITPY changes here and below for traceback. // CIRCUITPY-CHANGE: changes here and below for traceback.
#include "py/objtraceback.h" #include "py/objtraceback.h"
typedef struct _mp_obj_exception_t { typedef struct _mp_obj_exception_t {

View File

@ -37,7 +37,7 @@
#include <math.h> #include <math.h>
#include "py/formatfloat.h" #include "py/formatfloat.h"
// CIRCUITPY avoid compiler warning // CIRCUITPY-CHANGE: avoid compiler warning
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal" #pragma GCC diagnostic ignored "-Wfloat-equal"
@ -347,7 +347,7 @@ mp_obj_t mp_obj_float_binary_op(mp_binary_op_t op, mp_float_t lhs_val, mp_obj_t
return mp_obj_new_float(lhs_val); return mp_obj_new_float(lhs_val);
} }
// CIRCUITPY // CIRCUITPY-CHANGE
// Convert a uint64_t to a 32-bit float without invoking the double-precision math routines, // Convert a uint64_t to a 32-bit float without invoking the double-precision math routines,
// which are large. // which are large.
mp_float_t uint64_to_float(uint64_t ui64) { mp_float_t uint64_to_float(uint64_t ui64) {
@ -355,7 +355,7 @@ mp_float_t uint64_to_float(uint64_t ui64) {
return (mp_float_t)((uint32_t)(ui64 >> 32) * 4294967296.0f + (uint32_t)(ui64 & 0xffffffff)); return (mp_float_t)((uint32_t)(ui64 >> 32) * 4294967296.0f + (uint32_t)(ui64 & 0xffffffff));
} }
// CIRCUITPY // CIRCUITPY-CHANGE
// Convert a uint64_t to a 32-bit float to a uint64_t without invoking extra math routines. // Convert a uint64_t to a 32-bit float to a uint64_t without invoking extra math routines.
// which are large. // which are large.
// Assume f >= 0. // Assume f >= 0.

View File

@ -36,7 +36,7 @@
#include "py/stackctrl.h" #include "py/stackctrl.h"
// Instance of GeneratorExit exception - needed by generator.close() // Instance of GeneratorExit exception - needed by generator.close()
// CIRCUITPY: https://github.com/adafruit/circuitpython/pull/7069 fix // CIRCUITPY-CHANGE: https://github.com/adafruit/circuitpython/pull/7069 fix
#if MICROPY_CONST_GENERATOREXIT_OBJ #if MICROPY_CONST_GENERATOREXIT_OBJ
const const
mp_obj_exception_t mp_const_GeneratorExit_obj = {{&mp_type_GeneratorExit}, (mp_obj_tuple_t *)&mp_const_empty_tuple_obj, (mp_obj_traceback_t *)&mp_const_empty_traceback_obj}; mp_obj_exception_t mp_const_GeneratorExit_obj = {{&mp_type_GeneratorExit}, (mp_obj_tuple_t *)&mp_const_empty_tuple_obj, (mp_obj_traceback_t *)&mp_const_empty_traceback_obj};
@ -205,7 +205,7 @@ STATIC void gen_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_pri
mp_printf(print, "<generator object '%q' at %p>", mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self); mp_printf(print, "<generator object '%q' at %p>", mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self);
} }
// CIRCUITPY // CIRCUITPY-CHANGE
#if MICROPY_PY_ASYNC_AWAIT #if MICROPY_PY_ASYNC_AWAIT
STATIC void coro_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { STATIC void coro_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
(void)kind; (void)kind;
@ -216,7 +216,7 @@ STATIC void coro_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_pr
mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, mp_obj_t *ret_val) { mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, mp_obj_t *ret_val) {
MP_STACK_CHECK(); MP_STACK_CHECK();
// CIRCUITPY // CIRCUITPY-CHANGE
// note that self may have as its type either gen or coro, // note that self may have as its type either gen or coro,
// both of which are stored as an mp_obj_gen_instance_t . // both of which are stored as an mp_obj_gen_instance_t .
mp_check_self( mp_check_self(
@ -453,7 +453,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
); );
#if MICROPY_PY_ASYNC_AWAIT #if MICROPY_PY_ASYNC_AWAIT
// CIRCUITPY // CIRCUITPY-CHANGE
// coroutine instance locals dict and type // coroutine instance locals dict and type
// same as generator, but with addition of __await()__. // same as generator, but with addition of __await()__.
STATIC const mp_rom_map_elem_t coro_instance_locals_dict_table[] = { STATIC const mp_rom_map_elem_t coro_instance_locals_dict_table[] = {

View File

@ -300,7 +300,7 @@ char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_co
return b; return b;
} }
// CIRCUITPY // CIRCUITPY-CHANGE
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
void mp_obj_int_buffer_overflow_check(mp_obj_t self_in, size_t nbytes, bool is_signed) { void mp_obj_int_buffer_overflow_check(mp_obj_t self_in, size_t nbytes, bool is_signed) {
@ -395,7 +395,7 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
// This is called only with strings whose value doesn't fit in SMALL_INT // This is called only with strings whose value doesn't fit in SMALL_INT
mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, bool neg, unsigned int base) { mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, bool neg, unsigned int base) {
// CIRCUITPY different error message // CIRCUITPY-CHANGE: different error message
mp_raise_msg(&mp_type_OverflowError, MP_ERROR_TEXT("No long integer support")); mp_raise_msg(&mp_type_OverflowError, MP_ERROR_TEXT("No long integer support"));
return mp_const_none; return mp_const_none;
} }
@ -458,7 +458,7 @@ mp_obj_t mp_obj_int_binary_op_extra_cases(mp_binary_op_t op, mp_obj_t lhs_in, mp
return MP_OBJ_NULL; // op not supported return MP_OBJ_NULL; // op not supported
} }
// CIRCUITPY // CIRCUITPY-CHANGE
#if MICROPY_CPYTHON_COMPAT #if MICROPY_CPYTHON_COMPAT
STATIC mp_obj_t int_bit_length(mp_obj_t self_in) { STATIC mp_obj_t int_bit_length(mp_obj_t self_in) {
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
@ -480,7 +480,7 @@ STATIC mp_obj_t int_bit_length(mp_obj_t self_in) {
MP_DEFINE_CONST_FUN_OBJ_1(int_bit_length_obj, int_bit_length); MP_DEFINE_CONST_FUN_OBJ_1(int_bit_length_obj, int_bit_length);
#endif #endif
// CIRCUITPY more functionality // CIRCUITPY-CHANGE: more functionality
// this is a classmethod // this is a classmethod
STATIC mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { STATIC mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
// TODO: Support signed param (assumes signed=False at the moment) // TODO: Support signed param (assumes signed=False at the moment)
@ -575,7 +575,7 @@ STATIC mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *pos_args, mp_map_t *
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(int_to_bytes_obj, 3, int_to_bytes); STATIC MP_DEFINE_CONST_FUN_OBJ_KW(int_to_bytes_obj, 3, int_to_bytes);
STATIC const mp_rom_map_elem_t int_locals_dict_table[] = { STATIC const mp_rom_map_elem_t int_locals_dict_table[] = {
// CIRCUITPY // CIRCUITPY-CHANGE
#if MICROPY_CPYTHON_COMPAT #if MICROPY_CPYTHON_COMPAT
{ MP_ROM_QSTR(MP_QSTR_bit_length), MP_ROM_PTR(&int_bit_length_obj) }, { MP_ROM_QSTR(MP_QSTR_bit_length), MP_ROM_PTR(&int_bit_length_obj) },
#endif #endif

View File

@ -53,7 +53,7 @@ char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_co
int base, const char *prefix, char base_char, char comma); int base, const char *prefix, char base_char, char comma);
char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in,
int base, const char *prefix, char base_char, char comma); int base, const char *prefix, char base_char, char comma);
// CIRCUITPY // CIRCUITPY-CHANGE
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
void mp_obj_int_buffer_overflow_check(mp_obj_t self_in, size_t nbytes, bool is_signed); void mp_obj_int_buffer_overflow_check(mp_obj_t self_in, size_t nbytes, bool is_signed);
#endif #endif
@ -61,7 +61,7 @@ void mp_obj_int_buffer_overflow_check(mp_obj_t self_in, size_t nbytes, bool is_s
void mp_small_int_buffer_overflow_check(mp_int_t val, size_t nbytes, bool is_signed); void mp_small_int_buffer_overflow_check(mp_int_t val, size_t nbytes, bool is_signed);
mp_int_t mp_obj_int_hash(mp_obj_t self_in); mp_int_t mp_obj_int_hash(mp_obj_t self_in);
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_t mp_obj_int_bit_length_impl(mp_obj_t self_in); mp_obj_t mp_obj_int_bit_length_impl(mp_obj_t self_in);
mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf); mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf);
void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf); void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf);

View File

@ -43,7 +43,7 @@
const mp_obj_int_t mp_sys_maxsize_obj = {{&mp_type_int}, MP_SSIZE_MAX}; const mp_obj_int_t mp_sys_maxsize_obj = {{&mp_type_int}, MP_SSIZE_MAX};
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_t mp_obj_int_bit_length_impl(mp_obj_t self_in) { mp_obj_t mp_obj_int_bit_length_impl(mp_obj_t self_in) {
assert(mp_obj_is_type(self_in, &mp_type_int)); assert(mp_obj_is_type(self_in, &mp_type_int));
mp_obj_int_t *self = self_in; mp_obj_int_t *self = self_in;

View File

@ -106,7 +106,7 @@ char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size,
return str; return str;
} }
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_t mp_obj_int_bit_length_impl(mp_obj_t self_in) { mp_obj_t mp_obj_int_bit_length_impl(mp_obj_t self_in) {
assert(mp_obj_is_exact_type(self_in, &mp_type_int)); assert(mp_obj_is_exact_type(self_in, &mp_type_int));
mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in);

View File

@ -39,7 +39,7 @@ STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args);
// TODO: Move to mpconfig.h // TODO: Move to mpconfig.h
#define LIST_MIN_ALLOC 4 #define LIST_MIN_ALLOC 4
// CIRCUITPY: native_list() and other changes here for broadcom port // CIRCUITPY-CHANGE: native_list() and other changes here for broadcom port
// https://github.com/adafruit/circuitpython/pull/5610 // https://github.com/adafruit/circuitpython/pull/5610
/******************************************************************************/ /******************************************************************************/
@ -293,7 +293,7 @@ inline mp_obj_t mp_obj_list_pop(mp_obj_list_t *self, size_t index) {
return ret; return ret;
} }
// CIRCUITPY // CIRCUITPY-CHANGE
STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) { STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) {
mp_check_self(mp_obj_is_type(args[0], &mp_type_list)); mp_check_self(mp_obj_is_type(args[0], &mp_type_list));
mp_obj_list_t *self = native_list(args[0]); mp_obj_list_t *self = native_list(args[0]);

View File

@ -37,7 +37,7 @@ typedef struct _mp_obj_list_t {
void mp_obj_list_init(mp_obj_list_t *o, size_t n); void mp_obj_list_init(mp_obj_list_t *o, size_t n);
mp_obj_t mp_obj_list_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); mp_obj_t mp_obj_list_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_t mp_obj_list_pop(mp_obj_list_t *self, size_t index); mp_obj_t mp_obj_list_pop(mp_obj_list_t *self, size_t index);
void mp_obj_list_insert(mp_obj_list_t *self, size_t index, mp_obj_t obj); void mp_obj_list_insert(mp_obj_list_t *self, size_t index, mp_obj_t obj);

View File

@ -44,7 +44,7 @@ size_t mp_obj_namedtuple_find_field(const mp_obj_namedtuple_type_t *type, qstr n
return (size_t)-1; return (size_t)-1;
} }
// CIRCUITPY differences // CIRCUITPY-CHANGE: differences
#if MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT #if MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT
STATIC mp_obj_t namedtuple_asdict(mp_obj_t self_in) { STATIC mp_obj_t namedtuple_asdict(mp_obj_t self_in) {
mp_obj_namedtuple_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_namedtuple_t *self = MP_OBJ_TO_PTR(self_in);

View File

@ -52,7 +52,7 @@ void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
mp_obj_namedtuple_type_t *mp_obj_new_namedtuple_base(size_t n_fields, mp_obj_t *fields); mp_obj_namedtuple_type_t *mp_obj_new_namedtuple_base(size_t n_fields, mp_obj_t *fields);
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); 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);
// CIRCUITPY yikes // CIRCUITPY-CHANGE: yikes
#define NAMEDTUPLE_TYPE_BASE_AND_SLOTS_MAKE_NEW(type_name, make_new_fun) \ #define NAMEDTUPLE_TYPE_BASE_AND_SLOTS_MAKE_NEW(type_name, make_new_fun) \
.base = { \ .base = { \
.base = { .type = &mp_type_type }, \ .base = { .type = &mp_type_type }, \

View File

@ -49,7 +49,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__);
STATIC mp_obj_t object___new__(mp_obj_t cls) { STATIC mp_obj_t object___new__(mp_obj_t cls) {
if (!mp_obj_is_type(cls, &mp_type_type) || !mp_obj_is_instance_type((mp_obj_type_t *)MP_OBJ_TO_PTR(cls))) { if (!mp_obj_is_type(cls, &mp_type_type) || !mp_obj_is_instance_type((mp_obj_type_t *)MP_OBJ_TO_PTR(cls))) {
// CIRCUITPY better error // CIRCUITPY-CHANGE: better error
mp_raise_TypeError(MP_ERROR_TEXT("__new__ arg must be a user-type")); mp_raise_TypeError(MP_ERROR_TEXT("__new__ arg must be a user-type"));
} }
// This executes only "__new__" part of instance creation. // This executes only "__new__" part of instance creation.

View File

@ -31,7 +31,7 @@
#include "py/objproperty.h" #include "py/objproperty.h"
#include "py/runtime.h" #include "py/runtime.h"
// CIRCUITPY changes to reduce property proxy table size // CIRCUITPY-CHANGE: changes to reduce property proxy table size
// when possible // when possible
#if MICROPY_PY_BUILTINS_PROPERTY #if MICROPY_PY_BUILTINS_PROPERTY

View File

@ -34,7 +34,7 @@
#include "py/runtime.h" #include "py/runtime.h"
#include "py/stackctrl.h" #include "py/stackctrl.h"
// CIRCUITPY // CIRCUITPY-CHANGE
const char nibble_to_hex_upper[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', const char nibble_to_hex_upper[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F'}; 'A', 'B', 'C', 'D', 'E', 'F'};
@ -272,7 +272,7 @@ STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, size
return mp_obj_new_bytes_from_vstr(&vstr); return mp_obj_new_bytes_from_vstr(&vstr);
} }
// CIRCUITPY // CIRCUITPY-CHANGE
// check if __bytes__ exists, and if so delegate to it // check if __bytes__ exists, and if so delegate to it
mp_obj_t dest[2]; mp_obj_t dest[2];
mp_load_method_maybe(args[0], MP_QSTR___bytes__, dest); mp_load_method_maybe(args[0], MP_QSTR___bytes__, dest);
@ -381,7 +381,7 @@ mp_obj_t mp_obj_str_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
return mp_const_empty_bytes; return mp_const_empty_bytes;
} }
} }
// CIRCUITPY: more careful checking of length // CIRCUITPY-CHANGE: more careful checking of length
size_t new_len = mp_seq_multiply_len(lhs_len, n); size_t new_len = mp_seq_multiply_len(lhs_len, n);
vstr_t vstr; vstr_t vstr;
vstr_init_len(&vstr, new_len); vstr_init_len(&vstr, new_len);
@ -1024,7 +1024,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
#if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
terse_str_format_value_error(); terse_str_format_value_error();
#else #else
// CIRCUITPY better error message // CIRCUITPY-CHANGE: better error message
mp_raise_ValueError_varg(MP_ERROR_TEXT("unmatched '%c' in format"), '}'); mp_raise_ValueError_varg(MP_ERROR_TEXT("unmatched '%c' in format"), '}');
#endif #endif
} }
@ -2179,7 +2179,7 @@ MP_DEFINE_CONST_DICT_WITH_SIZE(mp_obj_array_locals_dict,
TABLE_ENTRIES_ARRAY); TABLE_ENTRIES_ARRAY);
#endif #endif
// CIRCUITPY: hex() but no cast() // CIRCUITPY-CHANGE: hex() but no cast()
#if MICROPY_PY_BUILTINS_MEMORYVIEW && MICROPY_PY_BUILTINS_BYTES_HEX && !MICROPY_CPYTHON_COMPAT #if MICROPY_PY_BUILTINS_MEMORYVIEW && MICROPY_PY_BUILTINS_BYTES_HEX && !MICROPY_CPYTHON_COMPAT
MP_DEFINE_CONST_DICT_WITH_SIZE(mp_obj_memoryview_locals_dict, MP_DEFINE_CONST_DICT_WITH_SIZE(mp_obj_memoryview_locals_dict,
array_bytearray_str_bytes_locals_table + TABLE_ENTRIES_ARRAY, array_bytearray_str_bytes_locals_table + TABLE_ENTRIES_ARRAY,
@ -2342,7 +2342,7 @@ mp_obj_t mp_obj_new_bytes(const byte *data, size_t len) {
return mp_obj_new_str_copy(&mp_type_bytes, data, len); return mp_obj_new_str_copy(&mp_type_bytes, data, len);
} }
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_t mp_obj_new_bytes_of_zeros(size_t len) { mp_obj_t mp_obj_new_bytes_of_zeros(size_t len) {
vstr_t vstr; vstr_t vstr;
vstr_init_len(&vstr, len); vstr_init_len(&vstr, len);

View File

@ -29,7 +29,7 @@
#include "py/obj.h" #include "py/obj.h"
#include "py/objarray.h" #include "py/objarray.h"
// CIRCUITPY // CIRCUITPY-CHANGE
extern const char nibble_to_hex_upper[16]; extern const char nibble_to_hex_upper[16];
extern const char nibble_to_hex_lower[16]; extern const char nibble_to_hex_lower[16];
@ -121,7 +121,7 @@ extern const mp_obj_dict_t mp_obj_bytearray_locals_dict;
extern const mp_obj_dict_t mp_obj_array_locals_dict; extern const mp_obj_dict_t mp_obj_array_locals_dict;
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_decode_obj); MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_decode_obj);
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_obj_bytes_hex_as_str_obj); MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_obj_bytes_hex_as_str_obj);

View File

@ -73,7 +73,7 @@ STATIC void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint
mp_print_str(print, "\\r"); mp_print_str(print, "\\r");
} else if (ch == '\t') { } else if (ch == '\t') {
mp_print_str(print, "\\t"); mp_print_str(print, "\\t");
// CIRCUITPY difference: print printable Unicode chars // CIRCUITPY-CHANGE: print printable Unicode chars
} else if (ch <= 0x1f || (0x7f <= ch && ch <= 0xa0) || ch == 0xad) { } else if (ch <= 0x1f || (0x7f <= ch && ch <= 0xa0) || ch == 0xad) {
mp_printf(print, "\\x%02x", ch); mp_printf(print, "\\x%02x", ch);
} else if ((0x2000 <= ch && ch <= 0x200f) || ch == 0x2028 || ch == 0x2029) { } else if ((0x2000 <= ch && ch <= 0x200f) || ch == 0x2028 || ch == 0x2029) {

View File

@ -165,7 +165,7 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
if (n <= 0) { if (n <= 0) {
return mp_const_empty_tuple; return mp_const_empty_tuple;
} }
// CIRCUITPY // CIRCUITPY-CHANGE
size_t new_len = mp_seq_multiply_len(o->len, n); size_t new_len = mp_seq_multiply_len(o->len, n);
mp_obj_tuple_t *s = MP_OBJ_TO_PTR(mp_obj_new_tuple(new_len, NULL)); mp_obj_tuple_t *s = MP_OBJ_TO_PTR(mp_obj_new_tuple(new_len, NULL));
mp_seq_multiply(o->items, sizeof(*o->items), o->len, n, s->items); mp_seq_multiply(o->items, sizeof(*o->items), o->len, n, s->items);

View File

@ -50,7 +50,7 @@ mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf);
extern const mp_obj_type_t mp_type_attrtuple; extern const mp_obj_type_t mp_type_attrtuple;
// CIRCUITPY // CIRCUITPY-CHANGE
// Relies on gcc Variadic Macros and Statement Expressions // Relies on gcc Variadic Macros and Statement Expressions
#define MP_OBJ_NEW_TUPLE(...) ({mp_obj_t _z[] = {__VA_ARGS__}; mp_obj_new_tuple(MP_ARRAY_SIZE(_z), _z);}) #define MP_OBJ_NEW_TUPLE(...) ({mp_obj_t _z[] = {__VA_ARGS__}; mp_obj_new_tuple(MP_ARRAY_SIZE(_z), _z);})

View File

@ -82,7 +82,7 @@ STATIC int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_t
} }
} }
// CIRCUITPY differences // CIRCUITPY-CHANGE: differences
// This wrapper function is allows a subclass of a native type to call the // This wrapper function is allows a subclass of a native type to call the
// __init__() method (corresponding to type->make_new) of the native type. // __init__() method (corresponding to type->make_new) of the native type.
STATIC mp_obj_t native_base_init_wrapper(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { STATIC mp_obj_t native_base_init_wrapper(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
@ -128,7 +128,7 @@ mp_obj_instance_t *mp_obj_new_instance(const mp_obj_type_t *class, const mp_obj_
return o; return o;
} }
// CIRCUITPY // CIRCUITPY-CHANGE
// When instances are first created they have the base_init wrapper as their native parent's // When instances are first created they have the base_init wrapper as their native parent's
// instance because make_new combines __new__ and __init__. This object is invalid for the native // instance because make_new combines __new__ and __init__. This object is invalid for the native
// code so it must call this method to ensure that the given object has been __init__'d and is // code so it must call this method to ensure that the given object has been __init__'d and is
@ -303,7 +303,7 @@ STATIC void instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_k
} }
// TODO: CPython prints fully-qualified type name // TODO: CPython prints fully-qualified type name
// CIRCUITPY: use qstr // CIRCUITPY-CHANGE: use qstr
mp_printf(print, "<%q object at %p>", mp_obj_get_type_qstr(self_in), self); mp_printf(print, "<%q object at %p>", mp_obj_get_type_qstr(self_in), self);
} }
@ -732,7 +732,7 @@ STATIC bool mp_obj_instance_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t val
// would be called by the descriptor code down below. But that way // would be called by the descriptor code down below. But that way
// requires overhead for the nested mp_call's and overhead for // requires overhead for the nested mp_call's and overhead for
// the code. // the code.
// CIRCUITPY: variable number of proxies // CIRCUITPY-CHANGE: variable number of proxies
size_t n_proxy; size_t n_proxy;
const mp_obj_t *proxy = mp_obj_property_get(member[0], &n_proxy); const mp_obj_t *proxy = mp_obj_property_get(member[0], &n_proxy);
mp_obj_t dest[2] = {self_in, value}; mp_obj_t dest[2] = {self_in, value};
@ -1347,7 +1347,7 @@ STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
// Looked up native __init__ so defer to it // Looked up native __init__ so defer to it
dest[0] = MP_OBJ_FROM_PTR(&native_base_init_wrapper_obj); dest[0] = MP_OBJ_FROM_PTR(&native_base_init_wrapper_obj);
dest[1] = self->obj; dest[1] = self->obj;
// CIRCUITPY better support for properties // CIRCUITPY-CHANGE: better support for properties
} else { } else {
mp_obj_t member = dest[0]; mp_obj_t member = dest[0];
// changes to mp_obj_instance_load_attr may require changes // changes to mp_obj_instance_load_attr may require changes

View File

@ -52,7 +52,7 @@ mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons
// this needs to be exposed for mp_getiter // this needs to be exposed for mp_getiter
mp_obj_t mp_obj_instance_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf); mp_obj_t mp_obj_instance_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf);
// CIRCUITPY addition // CIRCUITPY-CHANGE: addition
void mp_obj_assert_native_inited(mp_obj_t native_object); void mp_obj_assert_native_inited(mp_obj_t native_object);
#endif // MICROPY_INCLUDED_PY_OBJTYPE_H #endif // MICROPY_INCLUDED_PY_OBJTYPE_H

View File

@ -252,7 +252,7 @@ STATIC const uint16_t *get_rule_arg(uint8_t r_id) {
return &rule_arg_combined_table[off]; return &rule_arg_combined_table[off];
} }
// CIRCUITPY ignore compiler warning // CIRCUITPY-CHANGE: ignore compiler warning
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-align" #pragma GCC diagnostic ignored "-Wcast-align"
@ -1038,7 +1038,7 @@ mp_parse_tree_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind) {
parser.rule_stack_alloc = MICROPY_ALLOC_PARSE_RULE_INIT; parser.rule_stack_alloc = MICROPY_ALLOC_PARSE_RULE_INIT;
parser.rule_stack_top = 0; parser.rule_stack_top = 0;
// CIRCUITPY make parsing more memory flexible // CIRCUITPY-CHANGE: make parsing more memory flexible
// https://github.com/adafruit/circuitpython/pull/552 // https://github.com/adafruit/circuitpython/pull/552
parser.rule_stack = NULL; parser.rule_stack = NULL;
while (parser.rule_stack_alloc > 1) { while (parser.rule_stack_alloc > 1) {

View File

@ -53,7 +53,7 @@ mp_obj_t mp_parse_num_integer(const char *restrict str_, size_t len, int base, m
mp_obj_t ret_val; mp_obj_t ret_val;
// check radix base // check radix base
// CIRCUITPY use validator // CIRCUITPY-CHANGE: use validator
if (base != 0) { if (base != 0) {
// this won't be reached if lex!=NULL // this won't be reached if lex!=NULL
mp_arg_validate_int_range(base, 2, 36, MP_QSTR_base); mp_arg_validate_int_range(base, 2, 36, MP_QSTR_base);

View File

@ -87,7 +87,7 @@ void mp_native_relocate(void *ri_in, uint8_t *text, uintptr_t reloc_text) {
size_t addr = read_uint(ri->reader); size_t addr = read_uint(ri->reader);
if ((addr & 1) == 0) { if ((addr & 1) == 0) {
// Point to somewhere in text // Point to somewhere in text
// CIRCUITPY avoid compiler warnings // CIRCUITPY-CHANGE: avoid compiler warnings
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-align" #pragma GCC diagnostic ignored "-Wcast-align"
addr_to_adjust = &((uintptr_t *)text)[addr >> 1]; addr_to_adjust = &((uintptr_t *)text)[addr >> 1];
@ -405,7 +405,7 @@ void mp_raw_code_load(mp_reader_t *reader, mp_compiled_module_t *cm) {
byte header[4]; byte header[4];
read_bytes(reader, header, sizeof(header)); read_bytes(reader, header, sizeof(header));
byte arch = MPY_FEATURE_DECODE_ARCH(header[2]); byte arch = MPY_FEATURE_DECODE_ARCH(header[2]);
// CIRCUITPY: 'C', not 'M' // CIRCUITPY-CHANGE: 'C', not 'M'
if (header[0] != 'C' if (header[0] != 'C'
|| header[1] != MPY_VERSION || header[1] != MPY_VERSION
|| (arch != MP_NATIVE_ARCH_NONE && MPY_FEATURE_DECODE_SUB_VERSION(header[2]) != MPY_SUB_VERSION) || (arch != MP_NATIVE_ARCH_NONE && MPY_FEATURE_DECODE_SUB_VERSION(header[2]) != MPY_SUB_VERSION)

View File

@ -7,7 +7,7 @@ HEADER_BUILD = $(BUILD)/genhdr
# file containing qstr defs for the core Python bit # file containing qstr defs for the core Python bit
PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h
# CIRCUITPY # CIRCUITPY-CHANGE
TRANSLATION ?= en_US TRANSLATION ?= en_US
# If qstr autogeneration is not disabled we specify the output header # If qstr autogeneration is not disabled we specify the output header
@ -75,7 +75,7 @@ PY_O += $(addprefix $(BUILD)/, $(SRC_USERMOD_PATHFIX_LIB_C:.c=.o))
PY_O += $(addprefix $(BUILD)/, $(SRC_USERMOD_PATHFIX_LIB_CXX:.cpp=.o)) PY_O += $(addprefix $(BUILD)/, $(SRC_USERMOD_PATHFIX_LIB_CXX:.cpp=.o))
endif # USER_C_MODULES endif # USER_C_MODULES
# CIRCUITPY # CIRCUITPY-CHANGE
ifeq ($(CIRCUITPY_ULAB),1) ifeq ($(CIRCUITPY_ULAB),1)
ULAB_SRCS := $(shell find $(TOP)/extmod/ulab/code -type f -name "*.c") ULAB_SRCS := $(shell find $(TOP)/extmod/ulab/code -type f -name "*.c")
ULAB_SRC_PATHFIX := $(patsubst $(TOP)/%,%,$(ULAB_SRCS)) ULAB_SRC_PATHFIX := $(patsubst $(TOP)/%,%,$(ULAB_SRCS))
@ -255,7 +255,7 @@ $(HEADER_BUILD)/compressed.data.h: $(HEADER_BUILD)/compressed.collected
$(ECHO) "GEN $@" $(ECHO) "GEN $@"
$(Q)$(PYTHON) $(PY_SRC)/makecompresseddata.py $< > $@ $(Q)$(PYTHON) $(PY_SRC)/makecompresseddata.py $< > $@
# CIRCUITPY: for translations # CIRCUITPY-CHANGE: for translations
$(HEADER_BUILD)/$(TRANSLATION).mo: $(TOP)/locale/$(TRANSLATION).po | $(HEADER_BUILD) $(HEADER_BUILD)/$(TRANSLATION).mo: $(TOP)/locale/$(TRANSLATION).po | $(HEADER_BUILD)
$(Q)$(PYTHON) $(TOP)/tools/msgfmt.py -o $@ $^ $(Q)$(PYTHON) $(TOP)/tools/msgfmt.py -o $@ $^
@ -293,7 +293,7 @@ $(BUILD)/shared/libc/string0.o: CFLAGS += $(CFLAGS_BUILTIN)
# that the function preludes are of a minimal and predictable form. # that the function preludes are of a minimal and predictable form.
$(PY_BUILD)/nlr%.o: CFLAGS += -Os $(PY_BUILD)/nlr%.o: CFLAGS += -Os
# CIRCUITPY: separate SUPEROPT for gc.o and vm.o # CIRCUITPY-CHANGE: separate SUPEROPT for gc.o and vm.o
# optimising gc for speed; 5ms down to 4ms on pybv2 # optimising gc for speed; 5ms down to 4ms on pybv2
ifndef SUPEROPT_GC ifndef SUPEROPT_GC
SUPEROPT_GC = 1 SUPEROPT_GC = 1

View File

@ -33,7 +33,7 @@
#include "py/gc.h" #include "py/gc.h"
#include "py/runtime.h" #include "py/runtime.h"
// CIRCUITPY changes for TRANSLATION // CIRCUITPY-CHANGE: changes for TRANSLATION
// NOTE: we are using linear arrays to store and search for qstr's (unique strings, interned strings) // NOTE: we are using linear arrays to store and search for qstr's (unique strings, interned strings)
// ultimately we will replace this with a static hash table of some kind // ultimately we will replace this with a static hash table of some kind
@ -121,7 +121,7 @@ extern const qstr_pool_t MICROPY_QSTR_EXTRA_POOL;
#define CONST_POOL mp_qstr_const_pool #define CONST_POOL mp_qstr_const_pool
#endif #endif
// CIRCUITPY // CIRCUITPY-CHANGE
void qstr_reset(void) { void qstr_reset(void) {
MP_STATE_VM(last_pool) = (qstr_pool_t *)&CONST_POOL; // we won't modify the const_pool since it has no allocated room left MP_STATE_VM(last_pool) = (qstr_pool_t *)&CONST_POOL; // we won't modify the const_pool since it has no allocated room left
MP_STATE_VM(qstr_last_chunk) = NULL; MP_STATE_VM(qstr_last_chunk) = NULL;

View File

@ -39,7 +39,7 @@
enum { enum {
#ifndef NO_QSTR #ifndef NO_QSTR
#define QDEF(id, hash, len, str) id, #define QDEF(id, hash, len, str) id,
// CIRCUITPY // CIRCUITPY-CHANGE
#define TRANSLATION(english_id, number) #define TRANSLATION(english_id, number)
#include "genhdr/qstrdefs.generated.h" #include "genhdr/qstrdefs.generated.h"
#undef QDEF #undef QDEF

View File

@ -35,7 +35,7 @@
QCFG(BYTES_IN_LEN, MICROPY_QSTR_BYTES_IN_LEN) QCFG(BYTES_IN_LEN, MICROPY_QSTR_BYTES_IN_LEN)
QCFG(BYTES_IN_HASH, MICROPY_QSTR_BYTES_IN_HASH) QCFG(BYTES_IN_HASH, MICROPY_QSTR_BYTES_IN_HASH)
// CIRCUITPY translatable messages removed // CIRCUITPY-CHANGE: translatable messages removed
Q() Q()
Q(*) Q(*)

View File

@ -26,7 +26,7 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
// CIRCUITPY thoroughly reworked // CIRCUITPY-CHANGE: thoroughly reworked
#include "ringbuf.h" #include "ringbuf.h"

View File

@ -31,7 +31,7 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
// CIRCUITPY thoroughly reworked // CIRCUITPY-CHANGE: thoroughly reworked
typedef struct _ringbuf_t { typedef struct _ringbuf_t {
uint8_t *buf; uint8_t *buf;

View File

@ -89,7 +89,7 @@ void mp_init(void) {
#if MICROPY_KBD_EXCEPTION #if MICROPY_KBD_EXCEPTION
// initialise the exception object for raising KeyboardInterrupt // initialise the exception object for raising KeyboardInterrupt
// CIRCUITPY chained exception support // CIRCUITPY-CHANGE: chained exception support
mp_obj_exception_initialize0(&MP_STATE_VM(mp_kbd_exception), &mp_type_KeyboardInterrupt); mp_obj_exception_initialize0(&MP_STATE_VM(mp_kbd_exception), &mp_type_KeyboardInterrupt);
#endif #endif
@ -134,7 +134,7 @@ void mp_init(void) {
} }
#endif #endif
// CIRCUITPY: do not unmount / // CIRCUITPY-CHANGE: do not unmount /
#if MICROPY_VFS && 0 #if MICROPY_VFS && 0
// initialise the VFS sub-system // initialise the VFS sub-system
MP_STATE_VM(vfs_cur) = NULL; MP_STATE_VM(vfs_cur) = NULL;
@ -248,7 +248,7 @@ mp_obj_t MICROPY_WRAP_MP_LOAD_GLOBAL(mp_load_global)(qstr qst) {
return elem->value; return elem->value;
} }
// CIRCUITPY noinline // CIRCUITPY-CHANGE: noinline
// https://github.com/adafruit/circuitpython/pull/8071 // https://github.com/adafruit/circuitpython/pull/8071
mp_obj_t __attribute__((noinline)) mp_load_build_class(void) { mp_obj_t __attribute__((noinline)) mp_load_build_class(void) {
DEBUG_OP_printf("load_build_class\n"); DEBUG_OP_printf("load_build_class\n");
@ -950,7 +950,7 @@ mp_obj_t mp_call_method_n_kw_var(bool have_self, size_t n_args_n_kw, const mp_ob
} }
// unpacked items are stored in reverse order into the array pointed to by items // unpacked items are stored in reverse order into the array pointed to by items
// CIRCUITPY noline // CIRCUITPY-CHANGE: noline
void __attribute__((noinline, )) mp_unpack_sequence(mp_obj_t seq_in, size_t num, mp_obj_t *items) { void __attribute__((noinline, )) mp_unpack_sequence(mp_obj_t seq_in, size_t num, mp_obj_t *items) {
size_t seq_len; size_t seq_len;
if (mp_obj_is_type(seq_in, &mp_type_tuple) || mp_obj_is_type(seq_in, &mp_type_list)) { if (mp_obj_is_type(seq_in, &mp_type_tuple) || mp_obj_is_type(seq_in, &mp_type_list)) {
@ -998,7 +998,7 @@ too_long:
} }
// unpacked items are stored in reverse order into the array pointed to by items // unpacked items are stored in reverse order into the array pointed to by items
// CIRCUITPY noinline // CIRCUITPY-CHANGE: noinline
void __attribute__((noinline)) mp_unpack_ex(mp_obj_t seq_in, size_t num_in, mp_obj_t *items) { void __attribute__((noinline)) mp_unpack_ex(mp_obj_t seq_in, size_t num_in, mp_obj_t *items) {
size_t num_left = num_in & 0xff; size_t num_left = num_in & 0xff;
size_t num_right = (num_in >> 8) & 0xff; size_t num_right = (num_in >> 8) & 0xff;
@ -1164,7 +1164,7 @@ void mp_convert_member_lookup(mp_obj_t self, const mp_obj_type_t *type, mp_obj_t
} }
dest[0] = ((mp_obj_static_class_method_t *)MP_OBJ_TO_PTR(member))->fun; dest[0] = ((mp_obj_static_class_method_t *)MP_OBJ_TO_PTR(member))->fun;
dest[1] = MP_OBJ_FROM_PTR(type); dest[1] = MP_OBJ_FROM_PTR(type);
// CIRCUITPY // CIRCUITPY-CHANGE
// https://github.com/adafruit/circuitpython/commit/8fae7d2e3024de6336affc4b2a8fa992c946e017 // https://github.com/adafruit/circuitpython/commit/8fae7d2e3024de6336affc4b2a8fa992c946e017
#if MICROPY_PY_BUILTINS_PROPERTY #if MICROPY_PY_BUILTINS_PROPERTY
// If self is MP_OBJ_NULL, we looking at the class itself, not an instance. // If self is MP_OBJ_NULL, we looking at the class itself, not an instance.
@ -1297,7 +1297,7 @@ void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t value) {
// success // success
return; return;
} }
// CIRCUITPY https://github.com/adafruit/circuitpython/pull/50 // CIRCUITPY-CHANGE: https://github.com/adafruit/circuitpython/pull/50
#if MICROPY_PY_BUILTINS_PROPERTY #if MICROPY_PY_BUILTINS_PROPERTY
} else if (MP_OBJ_TYPE_HAS_SLOT(type, locals_dict)) { } else if (MP_OBJ_TYPE_HAS_SLOT(type, locals_dict)) {
// generic method lookup // generic method lookup
@ -1334,7 +1334,7 @@ void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t value) {
mp_raise_AttributeError(MP_ERROR_TEXT("no such attribute")); mp_raise_AttributeError(MP_ERROR_TEXT("no such attribute"));
#else #else
mp_raise_msg_varg(&mp_type_AttributeError, mp_raise_msg_varg(&mp_type_AttributeError,
// CIRCUITPY better error message // CIRCUITPY-CHANGE: better error message
MP_ERROR_TEXT("can't set attribute '%q'"), MP_ERROR_TEXT("can't set attribute '%q'"),
attr); attr);
#endif #endif
@ -1393,7 +1393,7 @@ mp_obj_t mp_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
STATIC mp_fun_1_t type_get_iternext(const mp_obj_type_t *type) { STATIC mp_fun_1_t type_get_iternext(const mp_obj_type_t *type) {
if ((type->flags & MP_TYPE_FLAG_ITER_IS_STREAM) == MP_TYPE_FLAG_ITER_IS_STREAM) { if ((type->flags & MP_TYPE_FLAG_ITER_IS_STREAM) == MP_TYPE_FLAG_ITER_IS_STREAM) {
// CIRCUITPY: unneeded declaration // CIRCUITPY-CHANGE: unneeded declaration
// mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); // mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self);
return mp_stream_unbuffered_iter; return mp_stream_unbuffered_iter;
} else if (type->flags & MP_TYPE_FLAG_ITER_IS_ITERNEXT) { } else if (type->flags & MP_TYPE_FLAG_ITER_IS_ITERNEXT) {
@ -1471,7 +1471,7 @@ mp_vm_return_kind_t mp_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t th
assert((send_value != MP_OBJ_NULL) ^ (throw_value != MP_OBJ_NULL)); assert((send_value != MP_OBJ_NULL) ^ (throw_value != MP_OBJ_NULL));
const mp_obj_type_t *type = mp_obj_get_type(self_in); const mp_obj_type_t *type = mp_obj_get_type(self_in);
// CIRCUITPY distinguishes generators and coroutines. // CIRCUITPY-CHANGE: distinguishes generators and coroutines.
if (type == &mp_type_gen_instance if (type == &mp_type_gen_instance
#if MICROPY_PY_ASYNC_AWAIT #if MICROPY_PY_ASYNC_AWAIT
|| type == &mp_type_coro_instance || type == &mp_type_coro_instance
@ -1597,7 +1597,7 @@ mp_obj_t mp_import_name(qstr name, mp_obj_t fromlist, mp_obj_t level) {
return mp_builtin___import__(5, args); return mp_builtin___import__(5, args);
} }
// CIRCUITPY noinline // CIRCUITPY-CHANGE: noinline
mp_obj_t __attribute__((noinline, )) mp_import_from(mp_obj_t module, qstr name) { mp_obj_t __attribute__((noinline, )) mp_import_from(mp_obj_t module, qstr name) {
DEBUG_printf("import from %p %s\n", module, qstr_str(name)); DEBUG_printf("import from %p %s\n", module, qstr_str(name));
@ -1702,7 +1702,7 @@ mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_i
#endif // MICROPY_ENABLE_COMPILER #endif // MICROPY_ENABLE_COMPILER
// CIRCUITPY MP_COLD are CIRCUITPY // CIRCUITPY-CHANGE: MP_COLD are CIRCUITPY
NORETURN MP_COLD void m_malloc_fail(size_t num_bytes) { NORETURN MP_COLD void m_malloc_fail(size_t num_bytes) {
DEBUG_printf("memory allocation failed, allocating %u bytes\n", (uint)num_bytes); DEBUG_printf("memory allocation failed, allocating %u bytes\n", (uint)num_bytes);
#if MICROPY_ENABLE_GC #if MICROPY_ENABLE_GC

View File

@ -31,7 +31,7 @@
#include "py/mpstate.h" #include "py/mpstate.h"
#include "py/pystack.h" #include "py/pystack.h"
// CIRCUITPY // CIRCUITPY-CHANGE
#include "supervisor/linker.h" #include "supervisor/linker.h"
#include "supervisor/shared/translate/translate.h" #include "supervisor/shared/translate/translate.h"
@ -127,7 +127,7 @@ void mp_arg_parse_all_kw_array(size_t n_pos, size_t n_kw, const mp_obj_t *args,
NORETURN void mp_arg_error_terse_mismatch(void); NORETURN void mp_arg_error_terse_mismatch(void);
NORETURN void mp_arg_error_unimpl_kw(void); NORETURN void mp_arg_error_unimpl_kw(void);
// CIRCUITPY arg validation routines // CIRCUITPY-CHANGE: arg validation routines
NORETURN void mp_arg_error_invalid(qstr arg_name); NORETURN void mp_arg_error_invalid(qstr arg_name);
mp_int_t mp_arg_validate_int(mp_int_t i, mp_int_t required_i, qstr arg_name); mp_int_t mp_arg_validate_int(mp_int_t i, mp_int_t required_i, qstr arg_name);
mp_int_t mp_arg_validate_int_min(mp_int_t i, mp_int_t min, qstr arg_name); mp_int_t mp_arg_validate_int_min(mp_int_t i, mp_int_t min, qstr arg_name);

View File

@ -35,7 +35,7 @@
#define MP_SCOPE_FLAG_VARKEYWORDS (0x02) #define MP_SCOPE_FLAG_VARKEYWORDS (0x02)
#define MP_SCOPE_FLAG_VARARGS (0x04) #define MP_SCOPE_FLAG_VARARGS (0x04)
#define MP_SCOPE_FLAG_DEFKWARGS (0x08) #define MP_SCOPE_FLAG_DEFKWARGS (0x08)
// CIRCUITPY // CIRCUITPY-CHANGE
#define MP_SCOPE_FLAG_ASYNC (0x10) #define MP_SCOPE_FLAG_ASYNC (0x10)
#define MP_SCOPE_FLAG_REFGLOBALS (0x20) // used only if native emitter enabled #define MP_SCOPE_FLAG_REFGLOBALS (0x20) // used only if native emitter enabled
#define MP_SCOPE_FLAG_HASCONSTS (0x40) // used only if native emitter enabled #define MP_SCOPE_FLAG_HASCONSTS (0x40) // used only if native emitter enabled

View File

@ -46,7 +46,7 @@ void MICROPY_WRAP_MP_SCHED_EXCEPTION(mp_sched_exception)(mp_obj_t exc) {
#if MICROPY_KBD_EXCEPTION #if MICROPY_KBD_EXCEPTION
// This function may be called asynchronously at any time so only do the bare minimum. // This function may be called asynchronously at any time so only do the bare minimum.
void MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT(mp_sched_keyboard_interrupt)(void) { void MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT(mp_sched_keyboard_interrupt)(void) {
// CIRCUITPY // CIRCUITPY-CHANGE
MP_STATE_VM(mp_kbd_exception).traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj; MP_STATE_VM(mp_kbd_exception).traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj;
mp_sched_exception(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))); mp_sched_exception(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)));
} }

View File

@ -28,7 +28,7 @@
#include "py/stackctrl.h" #include "py/stackctrl.h"
void mp_stack_ctrl_init(void) { void mp_stack_ctrl_init(void) {
// CIRCUITPY: Force routine to not be inlined. Better guarantee than MP_NOINLINE for -flto. // CIRCUITPY-CHANGE: Force routine to not be inlined. Better guarantee than MP_NOINLINE for -flto.
__asm volatile (""); __asm volatile ("");
#if __GNUC__ >= 13 #if __GNUC__ >= 13
#pragma GCC diagnostic push #pragma GCC diagnostic push
@ -47,7 +47,7 @@ void mp_stack_set_top(void *top) {
mp_uint_t PLACE_IN_ITCM(mp_stack_usage)(void) { mp_uint_t PLACE_IN_ITCM(mp_stack_usage)(void) {
// Assumes descending stack // Assumes descending stack
// CIRCUITPY: Force routine to not be inlined. Better guarantee than MP_NOINLINE for -flto. // CIRCUITPY-CHANGE: Force routine to not be inlined. Better guarantee than MP_NOINLINE for -flto.
__asm volatile (""); __asm volatile ("");
volatile int stack_dummy; volatile int stack_dummy;
return MP_STATE_THREAD(stack_top) - (char *)&stack_dummy; return MP_STATE_THREAD(stack_top) - (char *)&stack_dummy;

View File

@ -28,7 +28,7 @@
#define MICROPY_INCLUDED_PY_STREAM_H #define MICROPY_INCLUDED_PY_STREAM_H
#include "py/obj.h" #include "py/obj.h"
// CIRCUITPY // CIRCUITPY-CHANGE
#include "py/proto.h" #include "py/proto.h"
#include "py/mperrno.h" #include "py/mperrno.h"
@ -69,7 +69,7 @@ struct mp_stream_seek_t {
// Stream protocol // Stream protocol
typedef struct _mp_stream_p_t { typedef struct _mp_stream_p_t {
// CIRCUITPY // CIRCUITPY-CHANGE
MP_PROTOCOL_HEAD MP_PROTOCOL_HEAD
// On error, functions should return MP_STREAM_ERROR and fill in *errcode (values // On error, functions should return MP_STREAM_ERROR and fill in *errcode (values
// are implementation-dependent, but will be exposed to user, e.g. via exception). // are implementation-dependent, but will be exposed to user, e.g. via exception).
@ -123,7 +123,7 @@ mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode,
#define mp_stream_read_exactly(stream, buf, size, err) mp_stream_rw(stream, buf, size, err, MP_STREAM_RW_READ) #define mp_stream_read_exactly(stream, buf, size, err) mp_stream_rw(stream, buf, size, err, MP_STREAM_RW_READ)
void mp_stream_write_adaptor(void *self, const char *buf, size_t len); void mp_stream_write_adaptor(void *self, const char *buf, size_t len);
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_t mp_stream_flush(mp_obj_t self); mp_obj_t mp_stream_flush(mp_obj_t self);
#if MICROPY_STREAMS_POSIX_API #if MICROPY_STREAMS_POSIX_API

16
py/vm.c
View File

@ -195,7 +195,7 @@
#define TRACE_TICK(current_ip, current_sp, is_exception) #define TRACE_TICK(current_ip, current_sp, is_exception)
#endif // MICROPY_PY_SYS_SETTRACE #endif // MICROPY_PY_SYS_SETTRACE
// CIRCUITPY // CIRCUITPY-CHANGE
STATIC mp_obj_t get_active_exception(mp_exc_stack_t *exc_sp, mp_exc_stack_t *exc_stack) { STATIC mp_obj_t get_active_exception(mp_exc_stack_t *exc_sp, mp_exc_stack_t *exc_stack) {
for (mp_exc_stack_t *e = exc_sp; e >= exc_stack; --e) { for (mp_exc_stack_t *e = exc_sp; e >= exc_stack; --e) {
if (e->prev_exc != NULL) { if (e->prev_exc != NULL) {
@ -237,7 +237,7 @@ mp_vm_return_kind_t MICROPY_WRAP_MP_EXECUTE_BYTECODE(mp_execute_bytecode)(mp_cod
#endif #endif
#if MICROPY_OPT_COMPUTED_GOTO #if MICROPY_OPT_COMPUTED_GOTO
#include "py/vmentrytable.h" #include "py/vmentrytable.h"
// CIRCUITPY // CIRCUITPY-CHANGE
#if MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE #if MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE
#define ONE_TRUE_DISPATCH() one_true_dispatch : do { \ #define ONE_TRUE_DISPATCH() one_true_dispatch : do { \
TRACE(ip); \ TRACE(ip); \
@ -328,7 +328,7 @@ outer_dispatch_loop:
for (;;) { for (;;) {
dispatch_loop: dispatch_loop:
#if MICROPY_OPT_COMPUTED_GOTO #if MICROPY_OPT_COMPUTED_GOTO
// CIRCUITPY // CIRCUITPY-CHANGE
ONE_TRUE_DISPATCH(); ONE_TRUE_DISPATCH();
#else #else
TRACE(ip); TRACE(ip);
@ -1061,7 +1061,7 @@ unwind_jump:;
} }
#endif #endif
SET_TOP(mp_call_method_n_kw(unum & 0xff, (unum >> 8) & 0xff, sp)); SET_TOP(mp_call_method_n_kw(unum & 0xff, (unum >> 8) & 0xff, sp));
// CIRCUITPY // CIRCUITPY-CHANGE
DISPATCH_WITH_PEND_EXC_CHECK(); DISPATCH_WITH_PEND_EXC_CHECK();
} }
@ -1172,7 +1172,7 @@ unwind_return:
ENTRY(MP_BC_RAISE_LAST): { ENTRY(MP_BC_RAISE_LAST): {
MARK_EXC_IP_SELECTIVE(); MARK_EXC_IP_SELECTIVE();
// search for the inner-most previous exception, to reraise it // search for the inner-most previous exception, to reraise it
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_t obj = get_active_exception(exc_sp, exc_stack); mp_obj_t obj = get_active_exception(exc_sp, exc_stack);
if (obj == MP_OBJ_NULL) { if (obj == MP_OBJ_NULL) {
obj = mp_obj_new_exception_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("no active exception to reraise")); obj = mp_obj_new_exception_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("no active exception to reraise"));
@ -1183,7 +1183,7 @@ unwind_return:
ENTRY(MP_BC_RAISE_OBJ): { ENTRY(MP_BC_RAISE_OBJ): {
MARK_EXC_IP_SELECTIVE(); MARK_EXC_IP_SELECTIVE();
mp_obj_t obj = mp_make_raise_obj(TOP()); mp_obj_t obj = mp_make_raise_obj(TOP());
// CIRCUITPY // CIRCUITPY-CHANGE
#if MICROPY_CPYTHON_EXCEPTION_CHAIN #if MICROPY_CPYTHON_EXCEPTION_CHAIN
mp_obj_t active_exception = get_active_exception(exc_sp, exc_stack); mp_obj_t active_exception = get_active_exception(exc_sp, exc_stack);
if (active_exception != MP_OBJ_NULL && active_exception != obj) { if (active_exception != MP_OBJ_NULL && active_exception != obj) {
@ -1195,7 +1195,7 @@ unwind_return:
ENTRY(MP_BC_RAISE_FROM): { ENTRY(MP_BC_RAISE_FROM): {
MARK_EXC_IP_SELECTIVE(); MARK_EXC_IP_SELECTIVE();
// CIRCUITPY // CIRCUITPY-CHANGE
mp_obj_t cause = POP(); mp_obj_t cause = POP();
mp_obj_t obj = mp_make_raise_obj(TOP()); mp_obj_t obj = mp_make_raise_obj(TOP());
#if MICROPY_CPYTHON_EXCEPTION_CHAIN #if MICROPY_CPYTHON_EXCEPTION_CHAIN
@ -1445,7 +1445,7 @@ unwind_loop:
// - exceptions re-raised by END_FINALLY // - exceptions re-raised by END_FINALLY
// - exceptions re-raised explicitly by "raise" // - exceptions re-raised explicitly by "raise"
if ( true if ( true
// CIRCUITPY // CIRCUITPY-CHANGE
#if MICROPY_CONST_GENERATOREXIT_OBJ #if MICROPY_CONST_GENERATOREXIT_OBJ
&& nlr.ret_val != &mp_const_GeneratorExit_obj && nlr.ret_val != &mp_const_GeneratorExit_obj
#endif #endif

View File

@ -51,7 +51,7 @@ void vstr_init(vstr_t *vstr, size_t alloc) {
// Init the vstr so it allocs exactly enough ram to hold a null-terminated // Init the vstr so it allocs exactly enough ram to hold a null-terminated
// string of the given length, and set the length. // string of the given length, and set the length.
void vstr_init_len(vstr_t *vstr, size_t len) { void vstr_init_len(vstr_t *vstr, size_t len) {
// CIRCUITPY // CIRCUITPY-CHANGE
if (len == SIZE_MAX) { if (len == SIZE_MAX) {
m_malloc_fail(len); m_malloc_fail(len);
} }

View File

@ -34,7 +34,7 @@
#define likely(x) __builtin_expect((x), 1) #define likely(x) __builtin_expect((x), 1)
#endif #endif
// CIRCUITPY avoid compiler warnings // CIRCUITPY-CHANGE: avoid compiler warnings
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-align" #pragma GCC diagnostic ignored "-Wcast-align"
void *memcpy(void *dst, const void *src, size_t n) { void *memcpy(void *dst, const void *src, size_t n) {
@ -75,7 +75,7 @@ void *memcpy(void *dst, const void *src, size_t n) {
return dst; return dst;
} }
// CIRCUITPY extern // CIRCUITPY-CHANGE: extern
extern void *__memcpy_chk(void *dest, const void *src, size_t len, size_t slen); extern void *__memcpy_chk(void *dest, const void *src, size_t len, size_t slen);
void *__memcpy_chk(void *dest, const void *src, size_t len, size_t slen) { void *__memcpy_chk(void *dest, const void *src, size_t len, size_t slen) {
if (len > slen) { if (len > slen) {

View File

@ -40,7 +40,7 @@
#define DEBUG_printf(...) (void)0 #define DEBUG_printf(...) (void)0
#endif #endif
// CIRCUITPY a number of changes // CIRCUITPY-CHANGE: a number of changes
#define READLINE_HIST_SIZE (MP_ARRAY_SIZE(MP_STATE_PORT(readline_hist))) #define READLINE_HIST_SIZE (MP_ARRAY_SIZE(MP_STATE_PORT(readline_hist)))

View File

@ -26,7 +26,7 @@
#ifndef MICROPY_INCLUDED_LIB_MP_READLINE_READLINE_H #ifndef MICROPY_INCLUDED_LIB_MP_READLINE_READLINE_H
#define MICROPY_INCLUDED_LIB_MP_READLINE_READLINE_H #define MICROPY_INCLUDED_LIB_MP_READLINE_READLINE_H
// CIRCUITPY: a number of changes // CIRCUITPY-CHANGE: a number of changes
#include "py/misc.h" #include "py/misc.h"

View File

@ -36,7 +36,7 @@ void mp_hal_set_interrupt_char(int c) {
mp_interrupt_char = c; mp_interrupt_char = c;
} }
// CIRCUITPY // CIRCUITPY-CHANGE
// Check to see if we've been CTRL-C'ed by autoreload or the user. // Check to see if we've been CTRL-C'ed by autoreload or the user.
bool mp_hal_is_interrupted(void) { bool mp_hal_is_interrupted(void) {
return MP_STATE_THREAD(mp_pending_exception) != MP_OBJ_FROM_PTR(NULL); return MP_STATE_THREAD(mp_pending_exception) != MP_OBJ_FROM_PTR(NULL);

View File

@ -26,7 +26,7 @@
#ifndef MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H #ifndef MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H
#define MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H #define MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H
// CIRCUITPY changes // CIRCUITPY-CHANGE: various changes
#include <stdbool.h> #include <stdbool.h>
extern int mp_interrupt_char; extern int mp_interrupt_char;

View File

@ -44,7 +44,7 @@
#include "shared/runtime/pyexec.h" #include "shared/runtime/pyexec.h"
#include "genhdr/mpversion.h" #include "genhdr/mpversion.h"
// CIRCUITPY multiple changes for atexit(), interrupts // CIRCUITPY-CHANGE: multiple changes for atexit(), interrupts
#if CIRCUITPY_ATEXIT #if CIRCUITPY_ATEXIT
#include "shared-module/atexit/__init__.h" #include "shared-module/atexit/__init__.h"

View File

@ -28,7 +28,7 @@
#include "py/obj.h" #include "py/obj.h"
// CIRCUITPY multiple changes // CIRCUITPY-CHANGE: multiple changes
typedef enum { typedef enum {
PYEXEC_MODE_FRIENDLY_REPL, PYEXEC_MODE_FRIENDLY_REPL,

View File

@ -35,7 +35,7 @@
* implementation below can be used. * implementation below can be used.
*/ */
// CIRCUITPY changes // CIRCUITPY-CHANGE: changes
// Send "cooked" string of given length, where every occurrence of // Send "cooked" string of given length, where every occurrence of
// LF character is replaced with CR LF. // LF character is replaced with CR LF.
void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) { void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {

View File

@ -37,11 +37,11 @@ class Cud():
def __floordiv__(self, other): def __floordiv__(self, other):
print("__floordiv__ called") print("__floordiv__ called")
# CIRCUITPY # CIRCUITPY-CHANGE
def __index__(self, other): def __index__(self, other):
print("__index__ called") print("__index__ called")
# CIRCUITPY # CIRCUITPY-CHANGE
def __inv__(self): def __inv__(self):
print("__inv__ called") print("__inv__ called")

View File

@ -125,7 +125,7 @@ try:
except: except:
print('struct.error') print('struct.error')
# CIRCUITPY # CIRCUITPY-CHANGE
# check padding bytes # check padding bytes
print(struct.pack("xb", 3)) print(struct.pack("xb", 3))
# Make sure pack doesn't reuse a larger value and error # Make sure pack doesn't reuse a larger value and error

View File

@ -13,7 +13,7 @@ except AttributeError:
print(True) print(True)
try: try:
# CIRCUITPY # CIRCUITPY-CHANGE
print(sys.implementation.name in ('cpython', 'micropython', 'circuitpython')) print(sys.implementation.name in ('cpython', 'micropython', 'circuitpython'))
except AttributeError: except AttributeError:
# Effectively skip subtests # Effectively skip subtests

View File

@ -4,7 +4,7 @@ except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit
# CIRCUITPY provides __await()__ # CIRCUITPY-CHANGE: CircuitPython provides __await__()
async def foo(): async def foo():
return 42 return 42

View File

@ -8,7 +8,7 @@ except ImportError:
raise SystemExit raise SystemExit
# CIRCUITPY provides __await__() # CIRCUITPY-CHANGE: CircuitPython provides __await__()
async def foo(): async def foo():
return 42 return 42

View File

@ -7,7 +7,7 @@ except ImportError:
raise SystemExit raise SystemExit
# CIRCUITPY provides __await__() # CIRCUITPY-CHANGE: CircuitPython provides __await__()
async def foo(): async def foo():
return 42 return 42

Some files were not shown because too many files have changed in this diff Show More