unix/modtime: Use ticks_diff() implementation from extmod/utime_mphal.c.
This commit is contained in:
parent
aee6483536
commit
e381efed4a
@ -37,6 +37,7 @@
|
||||
#include "py/runtime.h"
|
||||
#include "py/smallint.h"
|
||||
#include "py/mphal.h"
|
||||
#include "extmod/utime_mphal.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
static inline int msec_sleep_tv(struct timeval *tv) {
|
||||
@ -92,13 +93,6 @@ STATIC mp_obj_t mod_time_ticks_ms(void) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_time_ticks_ms_obj, mod_time_ticks_ms);
|
||||
|
||||
STATIC mp_obj_t mod_time_ticks_diff(mp_obj_t oldval, mp_obj_t newval) {
|
||||
mp_uint_t old = MP_OBJ_SMALL_INT_VALUE(oldval);
|
||||
mp_uint_t new = MP_OBJ_SMALL_INT_VALUE(newval);
|
||||
return MP_OBJ_NEW_SMALL_INT((new - old) & MP_SMALL_INT_POSITIVE_MASK);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_time_ticks_diff_obj, mod_time_ticks_diff);
|
||||
|
||||
// Note: this is deprecated since CPy3.3, but pystone still uses it.
|
||||
STATIC mp_obj_t mod_time_clock(void) {
|
||||
#if MICROPY_PY_BUILTINS_FLOAT
|
||||
@ -190,7 +184,7 @@ STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&mod_time_time_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ticks_ms), MP_ROM_PTR(&mod_time_ticks_ms_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ticks_us), MP_ROM_PTR(&mod_time_ticks_us_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ticks_diff), MP_ROM_PTR(&mod_time_ticks_diff_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ticks_diff), MP_ROM_PTR(&mp_utime_ticks_diff_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_strftime), MP_ROM_PTR(&mod_time_strftime_obj) },
|
||||
};
|
||||
|
||||
|
@ -106,6 +106,7 @@
|
||||
|
||||
#define MICROPY_PY_OS_STATVFS (1)
|
||||
#define MICROPY_PY_UTIME (1)
|
||||
#define MICROPY_PY_UTIME_MP_HAL (1)
|
||||
#define MICROPY_PY_UERRNO (1)
|
||||
#define MICROPY_PY_UCTYPES (1)
|
||||
#define MICROPY_PY_UZLIB (1)
|
||||
|
Loading…
Reference in New Issue
Block a user