Skip to content

Commit 8017a1a

Browse files
committed
ports/unix VARIANT=coverage fixes
1 parent fdfc442 commit 8017a1a

File tree

8 files changed

+20
-39
lines changed

8 files changed

+20
-39
lines changed

extmod/modhashlib.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ STATIC mp_obj_t hashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args
136136
}
137137

138138
STATIC mp_obj_t hashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg) {
139+
check_not_unicode(arg);
139140
mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in);
140141
hashlib_ensure_not_final(self);
141142
mp_buffer_info_t bufinfo;

ports/unix/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,6 @@ SRC_C += \
200200
unix_mphal.c \
201201
mpthreadport.c \
202202
input.c \
203-
modtime.c \
204-
moduselect.c \
205203
alloc.c \
206204
fatfs_port.c \
207205
supervisor/stub/filesystem.c \
@@ -211,6 +209,10 @@ SRC_C += \
211209
$(SRC_MOD) \
212210
$(wildcard $(VARIANT_DIR)/*.c)
213211

212+
# CIRCUITPY-CHANGE
213+
# CircuitPython doesn't use extmod/modtime.c, but ports/unix/extmod.c depends on it.
214+
SRC_EXTMOD_C += extmod/modtime.c
215+
214216
$(BUILD)/supervisor/shared/translate/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/compressed_translations.generated.h
215217

216218
SHARED_SRC_C += $(addprefix shared/,\

ports/unix/modos.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,4 @@ STATIC mp_obj_t mp_os_errno(size_t n_args, const mp_obj_t *args) {
147147
errno = mp_obj_get_int(args[0]);
148148
return mp_const_none;
149149
}
150-
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_uos_errno_obj, 0, 1, mp_uos_errno);
150+
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_os_errno_obj, 0, 1, mp_os_errno);

ports/unix/modtime.c

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ STATIC mp_obj_t mp_time_time_get(void) {
7171
return mp_obj_new_int((mp_int_t)time(NULL));
7272
#endif
7373
}
74-
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_time_time_obj, mod_time_time);
7574

7675
// Note: this is deprecated since CPy3.3, but pystone still uses it.
7776
STATIC mp_obj_t mod_time_clock(void) {
@@ -125,7 +124,6 @@ STATIC mp_obj_t mp_time_sleep(mp_obj_t arg) {
125124
#endif
126125
return mp_const_none;
127126
}
128-
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_time_sleep_obj, mod_time_sleep);
129127

130128
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)) {
131129
time_t t;
@@ -202,31 +200,8 @@ STATIC mp_obj_t mod_time_mktime(mp_obj_t tuple) {
202200
}
203201
MP_DEFINE_CONST_FUN_OBJ_1(mod_time_mktime_obj, mod_time_mktime);
204202

205-
STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = {
206-
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time) },
207-
{ MP_ROM_QSTR(MP_QSTR_clock), MP_ROM_PTR(&mod_time_clock_obj) },
208-
{ MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&mod_time_sleep_obj) },
209-
{ MP_ROM_QSTR(MP_QSTR_sleep_ms), MP_ROM_PTR(&mp_time_sleep_ms_obj) },
210-
{ MP_ROM_QSTR(MP_QSTR_sleep_us), MP_ROM_PTR(&mp_time_sleep_us_obj) },
211-
{ MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&mod_time_time_obj) },
212-
{ MP_ROM_QSTR(MP_QSTR_ticks_ms), MP_ROM_PTR(&mp_time_ticks_ms_obj) },
213-
{ MP_ROM_QSTR(MP_QSTR_ticks_us), MP_ROM_PTR(&mp_time_ticks_us_obj) },
214-
{ MP_ROM_QSTR(MP_QSTR_ticks_cpu), MP_ROM_PTR(&mp_time_ticks_cpu_obj) },
215-
{ MP_ROM_QSTR(MP_QSTR_ticks_add), MP_ROM_PTR(&mp_time_ticks_add_obj) },
216-
{ MP_ROM_QSTR(MP_QSTR_ticks_diff), MP_ROM_PTR(&mp_time_ticks_diff_obj) },
217-
{ MP_ROM_QSTR(MP_QSTR_time_ns), MP_ROM_PTR(&mp_time_time_ns_obj) },
218-
{ MP_ROM_QSTR(MP_QSTR_gmtime), MP_ROM_PTR(&mod_time_gmtime_obj) },
219-
{ MP_ROM_QSTR(MP_QSTR_localtime), MP_ROM_PTR(&mod_time_localtime_obj) },
203+
#define MICROPY_PY_TIME_EXTRA_GLOBALS \
204+
{ MP_ROM_QSTR(MP_QSTR_clock), MP_ROM_PTR(&mod_time_clock_obj) }, \
205+
{ MP_ROM_QSTR(MP_QSTR_gmtime), MP_ROM_PTR(&mod_time_gmtime_obj) }, \
206+
{ MP_ROM_QSTR(MP_QSTR_localtime), MP_ROM_PTR(&mod_time_localtime_obj) }, \
220207
{ MP_ROM_QSTR(MP_QSTR_mktime), MP_ROM_PTR(&mod_time_mktime_obj) },
221-
};
222-
223-
STATIC MP_DEFINE_CONST_DICT(mp_module_time_globals, mp_module_time_globals_table);
224-
225-
const mp_obj_module_t mp_module_time = {
226-
.base = { &mp_type_module },
227-
.globals = (mp_obj_dict_t *)&mp_module_time_globals,
228-
};
229-
230-
MP_REGISTER_MODULE(MP_QSTR_time, mp_module_time);
231-
232-
#endif // MICROPY_PY_TIME

ports/unix/mphalport.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
#define CHAR_CTRL_C (3)
3232
#endif
3333

34-
void mp_hal_set_interrupt_char(char c);
34+
// CIRCUITPY-CHANGE: mp_hal_set_interrupt_char(int) instead of char
35+
void mp_hal_set_interrupt_char(int c);
3536
bool mp_hal_is_interrupted(void);
3637

3738
#define mp_hal_stdio_poll unused // this is not implemented, nor needed

ports/unix/unix_mphal.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ STATIC void sighandler(int signum) {
7272
}
7373
#endif
7474

75-
void mp_hal_set_interrupt_char(char c) {
75+
// CIRCUITPY-CHANGE: mp_hal_set_interrupt_char(int) instead of char
76+
void mp_hal_set_interrupt_char(int c) {
7677
// configure terminal settings to (not) let ctrl-C through
7778
if (c == CHAR_CTRL_C) {
7879
#ifndef _WIN32

ports/unix/variants/coverage/mpconfigvariant.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,3 @@
4646
#define MICROPY_PY_CRYPTOLIB (0)
4747
#define MICROPY_PY_CRYPTOLIB_CTR (0)
4848
#define MICROPY_PY_STRUCT (0) // uses shared-bindings struct
49-
#define MICROPY_GC_SPLIT_HEAP (0)

py/gc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,16 @@ STATIC bool gc_try_add_heap(size_t failed_alloc) {
338338

339339
#endif
340340

341+
#if !MICROPY_GC_SPLIT_HEAP
341342
// CIRCUITPY-CHANGE
342-
// TODO FOR MERGE: fix this for multiple areas??
343+
// TODO FOR MERGE: fix this for split heap
343344
void gc_deinit(void) {
344345
// Run any finalisers before we stop using the heap.
345346
gc_sweep_all();
346-
MP_STATIC_ASSERT(!MICROPY_GC_SPLIT_HEAP);
347+
/// MP_STATIC_ASSERT(!MICROPY_GC_SPLIT_HEAP);
347348
memset(&MP_STATE_MEM(area), 0, sizeof(MP_STATE_MEM(area)));
348349
}
350+
#endif
349351

350352
void gc_lock(void) {
351353
// This does not need to be atomic or have the GC mutex because:
@@ -958,12 +960,12 @@ void gc_free(void *ptr) {
958960
mp_state_mem_area_t *area;
959961
#if MICROPY_GC_SPLIT_HEAP
960962
area = gc_get_ptr_area(ptr);
963+
// assert(area);
964+
#else
961965
// CIRCUITPY-CHANGE: extra checking
962966
if (MP_STATE_MEM(gc_pool_start) == 0) {
963967
reset_into_safe_mode(SAFE_MODE_GC_ALLOC_OUTSIDE_VM);
964968
}
965-
// assert(area);
966-
#else
967969
assert(VERIFY_PTR(ptr));
968970
area = &MP_STATE_MEM(area);
969971
#endif

0 commit comments

Comments
 (0)