ports/unix VARIANT=coverage fixes

This commit is contained in:
Dan Halbert 2023-10-20 16:51:04 -04:00
parent fdfc4421b1
commit 8017a1ad30
8 changed files with 20 additions and 39 deletions

View File

@ -136,6 +136,7 @@ STATIC mp_obj_t hashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args
} }
STATIC mp_obj_t hashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg) { STATIC mp_obj_t hashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg) {
check_not_unicode(arg);
mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in);
hashlib_ensure_not_final(self); hashlib_ensure_not_final(self);
mp_buffer_info_t bufinfo; mp_buffer_info_t bufinfo;

View File

@ -200,8 +200,6 @@ SRC_C += \
unix_mphal.c \ unix_mphal.c \
mpthreadport.c \ mpthreadport.c \
input.c \ input.c \
modtime.c \
moduselect.c \
alloc.c \ alloc.c \
fatfs_port.c \ fatfs_port.c \
supervisor/stub/filesystem.c \ supervisor/stub/filesystem.c \
@ -211,6 +209,10 @@ SRC_C += \
$(SRC_MOD) \ $(SRC_MOD) \
$(wildcard $(VARIANT_DIR)/*.c) $(wildcard $(VARIANT_DIR)/*.c)
# CIRCUITPY-CHANGE
# CircuitPython doesn't use extmod/modtime.c, but ports/unix/extmod.c depends on it.
SRC_EXTMOD_C += extmod/modtime.c
$(BUILD)/supervisor/shared/translate/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/compressed_translations.generated.h $(BUILD)/supervisor/shared/translate/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/compressed_translations.generated.h
SHARED_SRC_C += $(addprefix shared/,\ SHARED_SRC_C += $(addprefix shared/,\

View File

@ -147,4 +147,4 @@ STATIC mp_obj_t mp_os_errno(size_t n_args, const mp_obj_t *args) {
errno = mp_obj_get_int(args[0]); errno = mp_obj_get_int(args[0]);
return mp_const_none; return mp_const_none;
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_uos_errno_obj, 0, 1, mp_uos_errno); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_os_errno_obj, 0, 1, mp_os_errno);

View File

@ -71,7 +71,6 @@ STATIC mp_obj_t mp_time_time_get(void) {
return mp_obj_new_int((mp_int_t)time(NULL)); return mp_obj_new_int((mp_int_t)time(NULL));
#endif #endif
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_time_time_obj, mod_time_time);
// Note: this is deprecated since CPy3.3, but pystone still uses it. // Note: this is deprecated since CPy3.3, but pystone still uses it.
STATIC mp_obj_t mod_time_clock(void) { STATIC mp_obj_t mod_time_clock(void) {
@ -125,7 +124,6 @@ STATIC mp_obj_t mp_time_sleep(mp_obj_t arg) {
#endif #endif
return mp_const_none; return mp_const_none;
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_time_sleep_obj, mod_time_sleep);
STATIC mp_obj_t mod_time_gm_local_time(size_t n_args, const mp_obj_t *args, struct tm *(*time_func)(const time_t *timep)) { STATIC mp_obj_t mod_time_gm_local_time(size_t n_args, const mp_obj_t *args, struct tm *(*time_func)(const time_t *timep)) {
time_t t; time_t t;
@ -202,31 +200,8 @@ STATIC mp_obj_t mod_time_mktime(mp_obj_t tuple) {
} }
MP_DEFINE_CONST_FUN_OBJ_1(mod_time_mktime_obj, mod_time_mktime); MP_DEFINE_CONST_FUN_OBJ_1(mod_time_mktime_obj, mod_time_mktime);
STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = { #define MICROPY_PY_TIME_EXTRA_GLOBALS \
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time) }, { MP_ROM_QSTR(MP_QSTR_clock), MP_ROM_PTR(&mod_time_clock_obj) }, \
{ MP_ROM_QSTR(MP_QSTR_clock), MP_ROM_PTR(&mod_time_clock_obj) }, { MP_ROM_QSTR(MP_QSTR_gmtime), MP_ROM_PTR(&mod_time_gmtime_obj) }, \
{ MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&mod_time_sleep_obj) }, { MP_ROM_QSTR(MP_QSTR_localtime), MP_ROM_PTR(&mod_time_localtime_obj) }, \
{ MP_ROM_QSTR(MP_QSTR_sleep_ms), MP_ROM_PTR(&mp_time_sleep_ms_obj) },
{ MP_ROM_QSTR(MP_QSTR_sleep_us), MP_ROM_PTR(&mp_time_sleep_us_obj) },
{ MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&mod_time_time_obj) },
{ MP_ROM_QSTR(MP_QSTR_ticks_ms), MP_ROM_PTR(&mp_time_ticks_ms_obj) },
{ MP_ROM_QSTR(MP_QSTR_ticks_us), MP_ROM_PTR(&mp_time_ticks_us_obj) },
{ MP_ROM_QSTR(MP_QSTR_ticks_cpu), MP_ROM_PTR(&mp_time_ticks_cpu_obj) },
{ MP_ROM_QSTR(MP_QSTR_ticks_add), MP_ROM_PTR(&mp_time_ticks_add_obj) },
{ MP_ROM_QSTR(MP_QSTR_ticks_diff), MP_ROM_PTR(&mp_time_ticks_diff_obj) },
{ MP_ROM_QSTR(MP_QSTR_time_ns), MP_ROM_PTR(&mp_time_time_ns_obj) },
{ MP_ROM_QSTR(MP_QSTR_gmtime), MP_ROM_PTR(&mod_time_gmtime_obj) },
{ MP_ROM_QSTR(MP_QSTR_localtime), MP_ROM_PTR(&mod_time_localtime_obj) },
{ MP_ROM_QSTR(MP_QSTR_mktime), MP_ROM_PTR(&mod_time_mktime_obj) }, { MP_ROM_QSTR(MP_QSTR_mktime), MP_ROM_PTR(&mod_time_mktime_obj) },
};
STATIC MP_DEFINE_CONST_DICT(mp_module_time_globals, mp_module_time_globals_table);
const mp_obj_module_t mp_module_time = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t *)&mp_module_time_globals,
};
MP_REGISTER_MODULE(MP_QSTR_time, mp_module_time);
#endif // MICROPY_PY_TIME

View File

@ -31,7 +31,8 @@
#define CHAR_CTRL_C (3) #define CHAR_CTRL_C (3)
#endif #endif
void mp_hal_set_interrupt_char(char c); // CIRCUITPY-CHANGE: mp_hal_set_interrupt_char(int) instead of char
void mp_hal_set_interrupt_char(int c);
bool mp_hal_is_interrupted(void); bool mp_hal_is_interrupted(void);
#define mp_hal_stdio_poll unused // this is not implemented, nor needed #define mp_hal_stdio_poll unused // this is not implemented, nor needed

View File

@ -72,7 +72,8 @@ STATIC void sighandler(int signum) {
} }
#endif #endif
void mp_hal_set_interrupt_char(char c) { // CIRCUITPY-CHANGE: mp_hal_set_interrupt_char(int) instead of char
void mp_hal_set_interrupt_char(int c) {
// configure terminal settings to (not) let ctrl-C through // configure terminal settings to (not) let ctrl-C through
if (c == CHAR_CTRL_C) { if (c == CHAR_CTRL_C) {
#ifndef _WIN32 #ifndef _WIN32

View File

@ -46,4 +46,3 @@
#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
#define MICROPY_GC_SPLIT_HEAP (0)

10
py/gc.c
View File

@ -338,14 +338,16 @@ STATIC bool gc_try_add_heap(size_t failed_alloc) {
#endif #endif
#if !MICROPY_GC_SPLIT_HEAP
// CIRCUITPY-CHANGE // CIRCUITPY-CHANGE
// TODO FOR MERGE: fix this for multiple areas?? // TODO FOR MERGE: fix this for split heap
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.
gc_sweep_all(); gc_sweep_all();
MP_STATIC_ASSERT(!MICROPY_GC_SPLIT_HEAP); /// MP_STATIC_ASSERT(!MICROPY_GC_SPLIT_HEAP);
memset(&MP_STATE_MEM(area), 0, sizeof(MP_STATE_MEM(area))); memset(&MP_STATE_MEM(area), 0, sizeof(MP_STATE_MEM(area)));
} }
#endif
void gc_lock(void) { void gc_lock(void) {
// This does not need to be atomic or have the GC mutex because: // This does not need to be atomic or have the GC mutex because:
@ -958,12 +960,12 @@ 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);
// assert(area);
#else
// CIRCUITPY-CHANGE: 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);
} }
// assert(area);
#else
assert(VERIFY_PTR(ptr)); assert(VERIFY_PTR(ptr));
area = &MP_STATE_MEM(area); area = &MP_STATE_MEM(area);
#endif #endif