unix/modtime: Implement ticks_ms(), ticks_us() and ticks_diff().
All of these functions return positive small int, thus range is 2 bits less
than word size (30 bit on 32-bit systems, 62 bit on 64-bit systems).
diff --git a/py/smallint.h b/py/smallint.h
index 7bdf405..19b5209 100644
--- a/py/smallint.h
+++ b/py/smallint.h
@@ -36,11 +36,15 @@
#define MP_SMALL_INT_MIN ((mp_int_t)(((mp_int_t)WORD_MSBIT_HIGH) >> 1))
#define MP_SMALL_INT_FITS(n) ((((n) ^ ((n) << 1)) & WORD_MSBIT_HIGH) == 0)
+// Mask to truncate mp_int_t to positive value
+#define MP_SMALL_INT_POSITIVE_MASK ~(WORD_MSBIT_HIGH | (WORD_MSBIT_HIGH >> 1))
#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B
#define MP_SMALL_INT_MIN ((mp_int_t)(((mp_int_t)WORD_MSBIT_HIGH) >> 2))
#define MP_SMALL_INT_FITS(n) ((((n) & MP_SMALL_INT_MIN) == 0) || (((n) & MP_SMALL_INT_MIN) == MP_SMALL_INT_MIN))
+// Mask to truncate mp_int_t to positive value
+#define MP_SMALL_INT_POSITIVE_MASK ~(WORD_MSBIT_HIGH | (WORD_MSBIT_HIGH >> 1) | (WORD_MSBIT_HIGH >> 2))
#endif