summaryrefslogtreecommitdiffstatshomepage
path: root/ports/unix/modtime.c
diff options
context:
space:
mode:
Diffstat (limited to 'ports/unix/modtime.c')
-rw-r--r--ports/unix/modtime.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ports/unix/modtime.c b/ports/unix/modtime.c
index 126aec30c5..16152152ac 100644
--- a/ports/unix/modtime.c
+++ b/ports/unix/modtime.c
@@ -61,7 +61,7 @@ static inline int msec_sleep_tv(struct timeval *tv) {
#endif
#if defined(MP_CLOCKS_PER_SEC)
-#define CLOCK_DIV (MP_CLOCKS_PER_SEC / 1000.0F)
+#define CLOCK_DIV (MP_CLOCKS_PER_SEC / MICROPY_FLOAT_CONST(1000.0))
#else
#error Unsupported clock() implementation
#endif
@@ -84,7 +84,7 @@ STATIC mp_obj_t mod_time_clock(void) {
// float cannot represent full range of int32 precisely, so we pre-divide
// int to reduce resolution, and then actually do float division hoping
// to preserve integer part resolution.
- return mp_obj_new_float((float)(clock() / 1000) / CLOCK_DIV);
+ return mp_obj_new_float((clock() / 1000) / CLOCK_DIV);
#else
return mp_obj_new_int((mp_int_t)clock());
#endif
@@ -95,8 +95,8 @@ STATIC mp_obj_t mod_time_sleep(mp_obj_t arg) {
#if MICROPY_PY_BUILTINS_FLOAT
struct timeval tv;
mp_float_t val = mp_obj_get_float(arg);
- double ipart;
- tv.tv_usec = round(modf(val, &ipart) * 1000000);
+ mp_float_t ipart;
+ tv.tv_usec = MICROPY_FLOAT_C_FUN(round)(MICROPY_FLOAT_C_FUN(modf)(val, &ipart) * MICROPY_FLOAT_CONST(1000000.));
tv.tv_sec = ipart;
int res;
while (1) {