Commit 3272afe5 authored by stijn's avatar stijn
Browse files

windows: Implement mp_hal_ticks_cpu in terms of QueryPerformanceCounter

parent 0b9ed550
......@@ -152,6 +152,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(&mp_utime_ticks_ms_obj) },
{ MP_ROM_QSTR(MP_QSTR_ticks_us), MP_ROM_PTR(&mp_utime_ticks_us_obj) },
{ MP_ROM_QSTR(MP_QSTR_ticks_cpu), MP_ROM_PTR(&mp_utime_ticks_cpu_obj) },
{ MP_ROM_QSTR(MP_QSTR_ticks_add), MP_ROM_PTR(&mp_utime_ticks_add_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) },
......
......@@ -217,3 +217,13 @@ mp_uint_t mp_hal_ticks_us(void) {
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000000 + tv.tv_usec;
}
mp_uint_t mp_hal_ticks_cpu(void) {
LARGE_INTEGER value;
QueryPerformanceCounter(&value);
#ifdef _WIN64
return value.QuadPart;
#else
return value.LowPart;
#endif
}
......@@ -32,5 +32,5 @@
void mp_hal_move_cursor_back(unsigned int pos);
void mp_hal_erase_line_from_cursor(unsigned int n_chars_to_erase);
// TODO: Implement.
#define mp_hal_ticks_cpu() 0
#undef mp_hal_ticks_cpu
mp_uint_t mp_hal_ticks_cpu(void);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment