diff --git a/include/zephyr/sys/time_units.h b/include/zephyr/sys/time_units.h index 527b7371f23..359d73d8e7d 100644 --- a/include/zephyr/sys/time_units.h +++ b/include/zephyr/sys/time_units.h @@ -89,7 +89,7 @@ static TIME_CONSTEXPR inline int sys_clock_hw_cycles_per_sec(void) * @retval true Use faster algorithm. * @retval false Use algorithm preventing overflow of intermediate value. */ -#define Z_TMCVT_USE_FAST_ALGO(from_hz, to_hz) \ +#define z_tmcvt_use_fast_algo(from_hz, to_hz) \ ((DIV_ROUND_UP(CONFIG_SYS_CLOCK_MAX_TIMEOUT_DAYS * 24ULL * 3600ULL * from_hz, \ UINT32_MAX) * to_hz) <= UINT32_MAX) @@ -111,70 +111,134 @@ static TIME_CONSTEXPR inline int sys_clock_hw_cycles_per_sec(void) * round_up - Return the ceiling of the resulting fraction * round_off - Return the nearest value to the resulting fraction * (pass both round_up/off as false to get "round_down") + * + * All of this must be implemented as expressions so that, when constant, + * the results may be used to initialize global variables. */ -static TIME_CONSTEXPR ALWAYS_INLINE uint64_t z_tmcvt(uint64_t t, uint32_t from_hz, - uint32_t to_hz, bool const_hz, - bool result32, bool round_up, - bool round_off) -{ - bool mul_ratio = const_hz && - (to_hz > from_hz) && ((to_hz % from_hz) == 0U); - bool div_ratio = const_hz && - (from_hz > to_hz) && ((from_hz % to_hz) == 0U); - if (from_hz == to_hz) { - return result32 ? ((uint32_t)t) : t; - } +/* true if the conversion is the identity */ +#define z_tmcvt_is_identity(__from_hz, __to_hz) \ + ((__to_hz) == (__from_hz)) - uint64_t off = 0; +/* true if the conversion requires a simple integer multiply */ +#define z_tmcvt_is_int_mul(__from_hz, __to_hz) \ + ((__to_hz) > (__from_hz) && (__to_hz) % (__from_hz) == 0U) - if (!mul_ratio) { - uint32_t rdivisor = div_ratio ? (from_hz / to_hz) : from_hz; +/* true if the conversion requires a simple integer division */ +#define z_tmcvt_is_int_div(__from_hz, __to_hz) \ + ((__from_hz) > (__to_hz) && (__from_hz) % (__to_hz) == 0U) - if (round_up) { - off = rdivisor - 1U; - } - if (round_off) { - off = rdivisor / 2U; - } - } +/* + * Compute the offset needed to round the result correctly when + * the conversion requires a simple integer division + */ +#define z_tmcvt_off_div(__from_hz, __to_hz, __round_up, __round_off) \ + ((__round_off) ? ((__from_hz) / (__to_hz)) / 2 : \ + (__round_up) ? ((__from_hz) / (__to_hz)) - 1 : \ + 0) - /* Select (at build time!) between three different expressions for - * the same mathematical relationship, each expressed with and - * without truncation to 32 bits (I couldn't find a way to make - * the compiler correctly guess at the 32 bit result otherwise). - */ - if (div_ratio) { - t += off; - if (result32 && (t < BIT64(32))) { - return ((uint32_t)t) / (from_hz / to_hz); - } else { - return t / ((uint64_t)from_hz / to_hz); - } - } else if (mul_ratio) { - if (result32) { - return ((uint32_t)t) * (to_hz / from_hz); - } else { - return t * ((uint64_t)to_hz / from_hz); - } - } else { - if (result32) { - return (uint32_t)((t * to_hz + off) / from_hz); - } else if (const_hz && Z_TMCVT_USE_FAST_ALGO(from_hz, to_hz)) { - /* Faster algorithm but source is first multiplied by target frequency - * and it can overflow even though final result would not overflow. - * Kconfig option shall prevent use of this algorithm when there is a - * risk of overflow. - */ - return ((t * to_hz + off) / from_hz); - } else { - /* Slower algorithm but input is first divided before being multiplied - * which prevents overflow of intermediate value. - */ - return (t / from_hz) * to_hz + ((t % from_hz) * to_hz + off) / from_hz; - } - } -} +/* + * Compute the offset needed to round the result correctly when + * the conversion requires a full mul/div + */ +#define z_tmcvt_off_gen(__from_hz, __to_hz, __round_up, __round_off) \ + ((__round_off) ? (__from_hz) / 2 : \ + (__round_up) ? (__from_hz) - 1 : \ + 0) + +/* Integer division 32-bit conversion */ +#define z_tmcvt_int_div_32(__t, __from_hz, __to_hz, __round_up, __round_off) \ + ((uint64_t) (__t) <= 0xffffffffU - \ + z_tmcvt_off_div(__from_hz, __to_hz, __round_up, __round_off) ? \ + ((uint32_t)((__t) + \ + z_tmcvt_off_div(__from_hz, __to_hz, \ + __round_up, __round_off)) / \ + ((__from_hz) / (__to_hz))) \ + : \ + (uint32_t) (((uint64_t) (__t) + \ + z_tmcvt_off_div(__from_hz, __to_hz, \ + __round_up, __round_off)) / \ + ((__from_hz) / (__to_hz))) \ + ) + +/* Integer multiplication 32-bit conversion */ +#define z_tmcvt_int_mul_32(__t, __from_hz, __to_hz) \ + (uint32_t) (__t)*((__to_hz) / (__from_hz)) + +/* General 32-bit conversion */ +#define z_tmcvt_gen_32(__t, __from_hz, __to_hz, __round_up, __round_off) \ + ((uint32_t) (((uint64_t) (__t)*(__to_hz) + \ + z_tmcvt_off_gen(__from_hz, __to_hz, __round_up, __round_off)) / (__from_hz))) + +/* Integer division 64-bit conversion */ +#define z_tmcvt_int_div_64(__t, __from_hz, __to_hz, __round_up, __round_off) \ + ((uint64_t) (__t) + z_tmcvt_off_div(__from_hz, __to_hz, \ + __round_up, __round_off)) / \ + ((__from_hz) / (__to_hz)) + +/* Integer multiplcation 64-bit conversion */ +#define z_tmcvt_int_mul_64(__t, __from_hz, __to_hz) \ + (uint64_t) (__t)*((__to_hz) / (__from_hz)) + +/* Fast 64-bit conversion. This relies on the multiply not overflowing */ +#define z_tmcvt_gen_64_fast(__t, __from_hz, __to_hz, __round_up, __round_off) \ + (((uint64_t) (__t)*(__to_hz) + \ + z_tmcvt_off_gen(__from_hz, __to_hz, __round_up, __round_off)) / (__from_hz)) + +/* Slow 64-bit conversion. This avoids overflowing the multiply */ +#define z_tmcvt_gen_64_slow(__t, __from_hz, __to_hz, __round_up, __round_off) \ + (((uint64_t) (__t) / (__from_hz))*(__to_hz) + \ + (((uint64_t) (__t) % (__from_hz))*(__to_hz) + \ + z_tmcvt_off_gen(__from_hz, __to_hz, __round_up, __round_off)) / (__from_hz)) + +/* General 64-bit conversion. Uses one of the two above macros */ +#define z_tmcvt_gen_64(__t, __from_hz, __to_hz, __round_up, __round_off) \ + (z_tmcvt_use_fast_algo(__from_hz, __to_hz) ? \ + z_tmcvt_gen_64_fast(__t, __from_hz, __to_hz, __round_up, __round_off) : \ + z_tmcvt_gen_64_slow(__t, __from_hz, __to_hz, __round_up, __round_off)) + +/* Convert, generating a 32-bit result */ +#define z_tmcvt_32(__t, __from_hz, __to_hz, __const_hz, __round_up, __round_off) \ + ((__const_hz) ? \ + ( \ + z_tmcvt_is_identity(__from_hz, __to_hz) ? \ + (uint32_t) (__t) \ + : \ + z_tmcvt_is_int_div(__from_hz, __to_hz) ? \ + z_tmcvt_int_div_32(__t, __from_hz, __to_hz, __round_up, __round_off) \ + : \ + z_tmcvt_is_int_mul(__from_hz, __to_hz) ? \ + z_tmcvt_int_mul_32(__t, __from_hz, __to_hz) \ + : \ + z_tmcvt_gen_32(__t, __from_hz, __to_hz, __round_up, __round_off) \ + ) \ + : \ + z_tmcvt_gen_32(__t, __from_hz, __to_hz, __round_up, __round_off) \ + ) + +/* Convert, generating a 64-bit result */ +#define z_tmcvt_64(__t, __from_hz, __to_hz, __const_hz, __round_up, __round_off) \ + ((__const_hz) ? \ + ( \ + z_tmcvt_is_identity(__from_hz, __to_hz) ? \ + (uint64_t) (__t) \ + : \ + z_tmcvt_is_int_div(__from_hz, __to_hz) ? \ + z_tmcvt_int_div_64(__t, __from_hz, __to_hz, __round_up, __round_off) \ + : \ + z_tmcvt_is_int_mul(__from_hz, __to_hz) ? \ + z_tmcvt_int_mul_64(__t, __from_hz, __to_hz) \ + : \ + z_tmcvt_gen_64(__t, __from_hz, __to_hz, __round_up, __round_off) \ + ) \ + : \ + z_tmcvt_gen_64_slow(__t, __from_hz, __to_hz, __round_up, __round_off) \ + ) + +#define z_tmcvt(__t, __from_hz, __to_hz, __const_hz, __result32, __round_up, __round_off) \ + ((__result32) ? \ + z_tmcvt_32(__t, __from_hz, __to_hz, __const_hz, __round_up, __round_off) : \ + z_tmcvt_64(__t, __from_hz, __to_hz, __const_hz, __round_up, __round_off)) /* The following code is programmatically generated using this perl * code, which enumerates all possible combinations of units, rounding @@ -194,6 +258,9 @@ static TIME_CONSTEXPR ALWAYS_INLINE uint64_t z_tmcvt(uint64_t t, uint32_t from_h * "ns" => "nanoseconds", * "cyc" => "hardware cycles", * "ticks" => "ticks"); + * my %human_round = ("ceil" => "Rounds up", + * "near" => "Round nearest", + * "floor" => "Truncates"); * * sub big { return $_[0] eq "us" || $_[0] eq "ns"; } * sub prefix { return $_[0] eq "ms" || $_[0] eq "us" || $_[0] eq "ns"; } @@ -206,16 +273,17 @@ static TIME_CONSTEXPR ALWAYS_INLINE uint64_t z_tmcvt(uint64_t t, uint32_t from_h * for(my $big=0; $big <= 1; $big++) { * my $sz = $big ? 64 : 32; * my $sym = "k_${from_unit}_to_${to_unit}_$round$sz"; - * my $type = "u${sz}_t"; + * my $type = "uint${sz}_t"; * my $const_hz = ($from_unit eq "cyc" || $to_unit eq "cyc") * ? "Z_CCYC" : "true"; - * my $ret32 = $big ? "false" : "true"; + * my $ret32 = $big ? "64" : "32"; * my $rup = $round eq "ceil" ? "true" : "false"; * my $roff = $round eq "near" ? "true" : "false"; * * my $hfrom = $human{$from_unit}; * my $hto = $human{$to_unit}; - * print "/", "** \@brief Convert $hfrom to $hto\n"; + * my $hround = $human_round{$round}; + * print "/", "** \@brief Convert $hfrom to $hto. $ret32 bits. $hround.\n"; * print " *\n"; * print " * Converts time values in $hfrom to $hto.\n"; * print " * Computes result in $sz bit precision.\n"; @@ -227,14 +295,16 @@ static TIME_CONSTEXPR ALWAYS_INLINE uint64_t z_tmcvt(uint64_t t, uint32_t from_h * print " * Truncates to the next lowest output unit.\n"; * } * print " *\n"; - * print " * \@return The converted time value\n"; + * print " * \@param t Source time in $hfrom. uint64_t\n"; + * print " *\n"; + * print " * \@return The converted time value in $hto. $type\n"; * print " *", "/\n"; * - * print "static TIME_CONSTEXPR inline $type $sym($type t)\n{\n\t"; - * print "/", "* Generated. Do not edit. See above. *", "/\n\t"; - * print "return z_tmcvt(t, Z_HZ_$from_unit, Z_HZ_$to_unit,"; - * print " $const_hz, $ret32, $rup, $roff);\n"; - * print "}\n\n"; + * print "/", "* Generated. Do not edit. See above. *", "/\n"; + * print "#define $sym(t) \\\n"; + * print "\tz_tmcvt_$ret32(t, Z_HZ_$from_unit, Z_HZ_$to_unit,"; + * print " $const_hz, $rup, $roff)\n"; + * print "\n\n"; * } * } * } @@ -251,1181 +321,1264 @@ static TIME_CONSTEXPR ALWAYS_INLINE uint64_t z_tmcvt(uint64_t t, uint32_t from_h #define Z_HZ_ticks CONFIG_SYS_CLOCK_TICKS_PER_SEC #define Z_CCYC (!IS_ENABLED(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)) -/** @brief Convert milliseconds to hardware cycles +/** @brief Convert milliseconds to hardware cycles. 32 bits. Truncates. * * Converts time values in milliseconds to hardware cycles. * Computes result in 32 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in milliseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ms_to_cyc_floor32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_ms_to_cyc_floor32(t) \ + z_tmcvt_32(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, false) -/** @brief Convert milliseconds to hardware cycles + +/** @brief Convert milliseconds to hardware cycles. 64 bits. Truncates. * * Converts time values in milliseconds to hardware cycles. * Computes result in 64 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in milliseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ms_to_cyc_floor64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_ms_to_cyc_floor64(t) \ + z_tmcvt_64(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, false) -/** @brief Convert milliseconds to hardware cycles + +/** @brief Convert milliseconds to hardware cycles. 32 bits. Round nearest. * * Converts time values in milliseconds to hardware cycles. * Computes result in 32 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in milliseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ms_to_cyc_near32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_ms_to_cyc_near32(t) \ + z_tmcvt_32(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, true) -/** @brief Convert milliseconds to hardware cycles + +/** @brief Convert milliseconds to hardware cycles. 64 bits. Round nearest. * * Converts time values in milliseconds to hardware cycles. * Computes result in 64 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in milliseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ms_to_cyc_near64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_ms_to_cyc_near64(t) \ + z_tmcvt_64(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, true) -/** @brief Convert milliseconds to hardware cycles + +/** @brief Convert milliseconds to hardware cycles. 32 bits. Rounds up. * * Converts time values in milliseconds to hardware cycles. * Computes result in 32 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in milliseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ms_to_cyc_ceil32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_ms_to_cyc_ceil32(t) \ + z_tmcvt_32(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, false) -/** @brief Convert milliseconds to hardware cycles + +/** @brief Convert milliseconds to hardware cycles. 64 bits. Rounds up. * * Converts time values in milliseconds to hardware cycles. * Computes result in 64 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in milliseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ms_to_cyc_ceil64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_ms_to_cyc_ceil64(t) \ + z_tmcvt_64(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, false) -/** @brief Convert milliseconds to ticks + +/** @brief Convert milliseconds to ticks. 32 bits. Truncates. * * Converts time values in milliseconds to ticks. * Computes result in 32 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in milliseconds. uint64_t + * + * @return The converted time value in ticks. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ms_to_ticks_floor32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, true, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_ms_to_ticks_floor32(t) \ + z_tmcvt_32(t, Z_HZ_ms, Z_HZ_ticks, true, false, false) -/** @brief Convert milliseconds to ticks + +/** @brief Convert milliseconds to ticks. 64 bits. Truncates. * * Converts time values in milliseconds to ticks. * Computes result in 64 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in milliseconds. uint64_t + * + * @return The converted time value in ticks. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ms_to_ticks_floor64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, false, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_ms_to_ticks_floor64(t) \ + z_tmcvt_64(t, Z_HZ_ms, Z_HZ_ticks, true, false, false) -/** @brief Convert milliseconds to ticks + +/** @brief Convert milliseconds to ticks. 32 bits. Round nearest. * * Converts time values in milliseconds to ticks. * Computes result in 32 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in milliseconds. uint64_t + * + * @return The converted time value in ticks. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ms_to_ticks_near32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, true, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_ms_to_ticks_near32(t) \ + z_tmcvt_32(t, Z_HZ_ms, Z_HZ_ticks, true, false, true) -/** @brief Convert milliseconds to ticks + +/** @brief Convert milliseconds to ticks. 64 bits. Round nearest. * * Converts time values in milliseconds to ticks. * Computes result in 64 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in milliseconds. uint64_t + * + * @return The converted time value in ticks. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ms_to_ticks_near64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, false, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_ms_to_ticks_near64(t) \ + z_tmcvt_64(t, Z_HZ_ms, Z_HZ_ticks, true, false, true) -/** @brief Convert milliseconds to ticks + +/** @brief Convert milliseconds to ticks. 32 bits. Rounds up. * * Converts time values in milliseconds to ticks. * Computes result in 32 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in milliseconds. uint64_t + * + * @return The converted time value in ticks. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ms_to_ticks_ceil32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, true, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_ms_to_ticks_ceil32(t) \ + z_tmcvt_32(t, Z_HZ_ms, Z_HZ_ticks, true, true, false) -/** @brief Convert milliseconds to ticks + +/** @brief Convert milliseconds to ticks. 64 bits. Rounds up. * * Converts time values in milliseconds to ticks. * Computes result in 64 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in milliseconds. uint64_t + * + * @return The converted time value in ticks. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ms_to_ticks_ceil64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, false, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_ms_to_ticks_ceil64(t) \ + z_tmcvt_64(t, Z_HZ_ms, Z_HZ_ticks, true, true, false) -/** @brief Convert microseconds to hardware cycles + +/** @brief Convert microseconds to hardware cycles. 32 bits. Truncates. * * Converts time values in microseconds to hardware cycles. * Computes result in 32 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in microseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_us_to_cyc_floor32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_us_to_cyc_floor32(t) \ + z_tmcvt_32(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false) -/** @brief Convert microseconds to hardware cycles + +/** @brief Convert microseconds to hardware cycles. 64 bits. Truncates. * * Converts time values in microseconds to hardware cycles. * Computes result in 64 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in microseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_us_to_cyc_floor64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_us_to_cyc_floor64(t) \ + z_tmcvt_64(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false) -/** @brief Convert microseconds to hardware cycles + +/** @brief Convert microseconds to hardware cycles. 32 bits. Round nearest. * * Converts time values in microseconds to hardware cycles. * Computes result in 32 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in microseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_us_to_cyc_near32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_us_to_cyc_near32(t) \ + z_tmcvt_32(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, true) -/** @brief Convert microseconds to hardware cycles + +/** @brief Convert microseconds to hardware cycles. 64 bits. Round nearest. * * Converts time values in microseconds to hardware cycles. * Computes result in 64 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in microseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_us_to_cyc_near64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_us_to_cyc_near64(t) \ + z_tmcvt_64(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, true) -/** @brief Convert microseconds to hardware cycles + +/** @brief Convert microseconds to hardware cycles. 32 bits. Rounds up. * * Converts time values in microseconds to hardware cycles. * Computes result in 32 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in microseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_us_to_cyc_ceil32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_us_to_cyc_ceil32(t) \ + z_tmcvt_32(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false) -/** @brief Convert microseconds to hardware cycles + +/** @brief Convert microseconds to hardware cycles. 64 bits. Rounds up. * * Converts time values in microseconds to hardware cycles. * Computes result in 64 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in microseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_us_to_cyc_ceil64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_us_to_cyc_ceil64(t) \ + z_tmcvt_64(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false) -/** @brief Convert microseconds to ticks + +/** @brief Convert microseconds to ticks. 32 bits. Truncates. * * Converts time values in microseconds to ticks. * Computes result in 32 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in microseconds. uint64_t + * + * @return The converted time value in ticks. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_us_to_ticks_floor32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, true, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_us_to_ticks_floor32(t) \ + z_tmcvt_32(t, Z_HZ_us, Z_HZ_ticks, true, false, false) -/** @brief Convert microseconds to ticks + +/** @brief Convert microseconds to ticks. 64 bits. Truncates. * * Converts time values in microseconds to ticks. * Computes result in 64 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in microseconds. uint64_t + * + * @return The converted time value in ticks. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_us_to_ticks_floor64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, false, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_us_to_ticks_floor64(t) \ + z_tmcvt_64(t, Z_HZ_us, Z_HZ_ticks, true, false, false) -/** @brief Convert microseconds to ticks + +/** @brief Convert microseconds to ticks. 32 bits. Round nearest. * * Converts time values in microseconds to ticks. * Computes result in 32 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in microseconds. uint64_t + * + * @return The converted time value in ticks. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_us_to_ticks_near32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, true, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_us_to_ticks_near32(t) \ + z_tmcvt_32(t, Z_HZ_us, Z_HZ_ticks, true, false, true) -/** @brief Convert microseconds to ticks + +/** @brief Convert microseconds to ticks. 64 bits. Round nearest. * * Converts time values in microseconds to ticks. * Computes result in 64 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in microseconds. uint64_t + * + * @return The converted time value in ticks. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_us_to_ticks_near64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, false, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_us_to_ticks_near64(t) \ + z_tmcvt_64(t, Z_HZ_us, Z_HZ_ticks, true, false, true) -/** @brief Convert microseconds to ticks + +/** @brief Convert microseconds to ticks. 32 bits. Rounds up. * * Converts time values in microseconds to ticks. * Computes result in 32 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in microseconds. uint64_t + * + * @return The converted time value in ticks. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_us_to_ticks_ceil32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, true, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_us_to_ticks_ceil32(t) \ + z_tmcvt_32(t, Z_HZ_us, Z_HZ_ticks, true, true, false) -/** @brief Convert microseconds to ticks + +/** @brief Convert microseconds to ticks. 64 bits. Rounds up. * * Converts time values in microseconds to ticks. * Computes result in 64 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in microseconds. uint64_t + * + * @return The converted time value in ticks. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_us_to_ticks_ceil64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, false, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_us_to_ticks_ceil64(t) \ + z_tmcvt_64(t, Z_HZ_us, Z_HZ_ticks, true, true, false) -/** @brief Convert nanoseconds to hardware cycles + +/** @brief Convert nanoseconds to hardware cycles. 32 bits. Truncates. * * Converts time values in nanoseconds to hardware cycles. * Computes result in 32 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in nanoseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ns_to_cyc_floor32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_ns_to_cyc_floor32(t) \ + z_tmcvt_32(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false) -/** @brief Convert nanoseconds to hardware cycles + +/** @brief Convert nanoseconds to hardware cycles. 64 bits. Truncates. * * Converts time values in nanoseconds to hardware cycles. * Computes result in 64 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in nanoseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ns_to_cyc_floor64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_ns_to_cyc_floor64(t) \ + z_tmcvt_64(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false) -/** @brief Convert nanoseconds to hardware cycles + +/** @brief Convert nanoseconds to hardware cycles. 32 bits. Round nearest. * * Converts time values in nanoseconds to hardware cycles. * Computes result in 32 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in nanoseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ns_to_cyc_near32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_ns_to_cyc_near32(t) \ + z_tmcvt_32(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, true) -/** @brief Convert nanoseconds to hardware cycles + +/** @brief Convert nanoseconds to hardware cycles. 64 bits. Round nearest. * * Converts time values in nanoseconds to hardware cycles. * Computes result in 64 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in nanoseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ns_to_cyc_near64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_ns_to_cyc_near64(t) \ + z_tmcvt_64(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, true) -/** @brief Convert nanoseconds to hardware cycles + +/** @brief Convert nanoseconds to hardware cycles. 32 bits. Rounds up. * * Converts time values in nanoseconds to hardware cycles. * Computes result in 32 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in nanoseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ns_to_cyc_ceil32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_ns_to_cyc_ceil32(t) \ + z_tmcvt_32(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false) -/** @brief Convert nanoseconds to hardware cycles + +/** @brief Convert nanoseconds to hardware cycles. 64 bits. Rounds up. * * Converts time values in nanoseconds to hardware cycles. * Computes result in 64 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in nanoseconds. uint64_t + * + * @return The converted time value in hardware cycles. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ns_to_cyc_ceil64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_ns_to_cyc_ceil64(t) \ + z_tmcvt_64(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false) -/** @brief Convert nanoseconds to ticks + +/** @brief Convert nanoseconds to ticks. 32 bits. Truncates. * * Converts time values in nanoseconds to ticks. * Computes result in 32 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in nanoseconds. uint64_t + * + * @return The converted time value in ticks. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ns_to_ticks_floor32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, true, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_ns_to_ticks_floor32(t) \ + z_tmcvt_32(t, Z_HZ_ns, Z_HZ_ticks, true, false, false) -/** @brief Convert nanoseconds to ticks + +/** @brief Convert nanoseconds to ticks. 64 bits. Truncates. * * Converts time values in nanoseconds to ticks. * Computes result in 64 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in nanoseconds. uint64_t + * + * @return The converted time value in ticks. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ns_to_ticks_floor64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, false, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_ns_to_ticks_floor64(t) \ + z_tmcvt_64(t, Z_HZ_ns, Z_HZ_ticks, true, false, false) -/** @brief Convert nanoseconds to ticks + +/** @brief Convert nanoseconds to ticks. 32 bits. Round nearest. * * Converts time values in nanoseconds to ticks. * Computes result in 32 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in nanoseconds. uint64_t + * + * @return The converted time value in ticks. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ns_to_ticks_near32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, true, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_ns_to_ticks_near32(t) \ + z_tmcvt_32(t, Z_HZ_ns, Z_HZ_ticks, true, false, true) -/** @brief Convert nanoseconds to ticks + +/** @brief Convert nanoseconds to ticks. 64 bits. Round nearest. * * Converts time values in nanoseconds to ticks. * Computes result in 64 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in nanoseconds. uint64_t + * + * @return The converted time value in ticks. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ns_to_ticks_near64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, false, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_ns_to_ticks_near64(t) \ + z_tmcvt_64(t, Z_HZ_ns, Z_HZ_ticks, true, false, true) -/** @brief Convert nanoseconds to ticks + +/** @brief Convert nanoseconds to ticks. 32 bits. Rounds up. * * Converts time values in nanoseconds to ticks. * Computes result in 32 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in nanoseconds. uint64_t + * + * @return The converted time value in ticks. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ns_to_ticks_ceil32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, true, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_ns_to_ticks_ceil32(t) \ + z_tmcvt_32(t, Z_HZ_ns, Z_HZ_ticks, true, true, false) -/** @brief Convert nanoseconds to ticks + +/** @brief Convert nanoseconds to ticks. 64 bits. Rounds up. * * Converts time values in nanoseconds to ticks. * Computes result in 64 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in nanoseconds. uint64_t + * + * @return The converted time value in ticks. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ns_to_ticks_ceil64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, false, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_ns_to_ticks_ceil64(t) \ + z_tmcvt_64(t, Z_HZ_ns, Z_HZ_ticks, true, true, false) -/** @brief Convert hardware cycles to milliseconds + +/** @brief Convert hardware cycles to milliseconds. 32 bits. Truncates. * * Converts time values in hardware cycles to milliseconds. * Computes result in 32 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in milliseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_cyc_to_ms_floor32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ms_floor32(t) \ + z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, false) -/** @brief Convert hardware cycles to milliseconds + +/** @brief Convert hardware cycles to milliseconds. 64 bits. Truncates. * * Converts time values in hardware cycles to milliseconds. * Computes result in 64 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in milliseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_cyc_to_ms_floor64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ms_floor64(t) \ + z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, false) -/** @brief Convert hardware cycles to milliseconds + +/** @brief Convert hardware cycles to milliseconds. 32 bits. Round nearest. * * Converts time values in hardware cycles to milliseconds. * Computes result in 32 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in milliseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_cyc_to_ms_near32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ms_near32(t) \ + z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, true) -/** @brief Convert hardware cycles to milliseconds + +/** @brief Convert hardware cycles to milliseconds. 64 bits. Round nearest. * * Converts time values in hardware cycles to milliseconds. * Computes result in 64 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in milliseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_cyc_to_ms_near64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ms_near64(t) \ + z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, true) -/** @brief Convert hardware cycles to milliseconds + +/** @brief Convert hardware cycles to milliseconds. 32 bits. Rounds up. * * Converts time values in hardware cycles to milliseconds. * Computes result in 32 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in milliseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_cyc_to_ms_ceil32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ms_ceil32(t) \ + z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, false) -/** @brief Convert hardware cycles to milliseconds + +/** @brief Convert hardware cycles to milliseconds. 64 bits. Rounds up. * * Converts time values in hardware cycles to milliseconds. * Computes result in 64 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in milliseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_cyc_to_ms_ceil64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ms_ceil64(t) \ + z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, false) -/** @brief Convert hardware cycles to microseconds + +/** @brief Convert hardware cycles to microseconds. 32 bits. Truncates. * * Converts time values in hardware cycles to microseconds. * Computes result in 32 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in microseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_cyc_to_us_floor32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_us_floor32(t) \ + z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false) -/** @brief Convert hardware cycles to microseconds + +/** @brief Convert hardware cycles to microseconds. 64 bits. Truncates. * * Converts time values in hardware cycles to microseconds. * Computes result in 64 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in microseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_cyc_to_us_floor64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_us_floor64(t) \ + z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false) -/** @brief Convert hardware cycles to microseconds + +/** @brief Convert hardware cycles to microseconds. 32 bits. Round nearest. * * Converts time values in hardware cycles to microseconds. * Computes result in 32 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in microseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_cyc_to_us_near32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_us_near32(t) \ + z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, true) -/** @brief Convert hardware cycles to microseconds + +/** @brief Convert hardware cycles to microseconds. 64 bits. Round nearest. * * Converts time values in hardware cycles to microseconds. * Computes result in 64 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in microseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_cyc_to_us_near64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_us_near64(t) \ + z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, true) -/** @brief Convert hardware cycles to microseconds + +/** @brief Convert hardware cycles to microseconds. 32 bits. Rounds up. * * Converts time values in hardware cycles to microseconds. * Computes result in 32 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in microseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_cyc_to_us_ceil32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_us_ceil32(t) \ + z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false) -/** @brief Convert hardware cycles to microseconds + +/** @brief Convert hardware cycles to microseconds. 64 bits. Rounds up. * * Converts time values in hardware cycles to microseconds. * Computes result in 64 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in microseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_cyc_to_us_ceil64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_us_ceil64(t) \ + z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false) -/** @brief Convert hardware cycles to nanoseconds + +/** @brief Convert hardware cycles to nanoseconds. 32 bits. Truncates. * * Converts time values in hardware cycles to nanoseconds. * Computes result in 32 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in nanoseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_cyc_to_ns_floor32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ns_floor32(t) \ + z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false) -/** @brief Convert hardware cycles to nanoseconds + +/** @brief Convert hardware cycles to nanoseconds. 64 bits. Truncates. * * Converts time values in hardware cycles to nanoseconds. * Computes result in 64 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in nanoseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_cyc_to_ns_floor64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ns_floor64(t) \ + z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false) -/** @brief Convert hardware cycles to nanoseconds + +/** @brief Convert hardware cycles to nanoseconds. 32 bits. Round nearest. * * Converts time values in hardware cycles to nanoseconds. * Computes result in 32 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in nanoseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_cyc_to_ns_near32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ns_near32(t) \ + z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, true) -/** @brief Convert hardware cycles to nanoseconds + +/** @brief Convert hardware cycles to nanoseconds. 64 bits. Round nearest. * * Converts time values in hardware cycles to nanoseconds. * Computes result in 64 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in nanoseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_cyc_to_ns_near64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ns_near64(t) \ + z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, true) -/** @brief Convert hardware cycles to nanoseconds + +/** @brief Convert hardware cycles to nanoseconds. 32 bits. Rounds up. * * Converts time values in hardware cycles to nanoseconds. * Computes result in 32 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in nanoseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_cyc_to_ns_ceil32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ns_ceil32(t) \ + z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false) -/** @brief Convert hardware cycles to nanoseconds + +/** @brief Convert hardware cycles to nanoseconds. 64 bits. Rounds up. * * Converts time values in hardware cycles to nanoseconds. * Computes result in 64 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in nanoseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_cyc_to_ns_ceil64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ns_ceil64(t) \ + z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false) -/** @brief Convert hardware cycles to ticks + +/** @brief Convert hardware cycles to ticks. 32 bits. Truncates. * * Converts time values in hardware cycles to ticks. * Computes result in 32 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in ticks. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_cyc_to_ticks_floor32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ticks_floor32(t) \ + z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, false) -/** @brief Convert hardware cycles to ticks + +/** @brief Convert hardware cycles to ticks. 64 bits. Truncates. * * Converts time values in hardware cycles to ticks. * Computes result in 64 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in ticks. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_cyc_to_ticks_floor64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ticks_floor64(t) \ + z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, false) -/** @brief Convert hardware cycles to ticks + +/** @brief Convert hardware cycles to ticks. 32 bits. Round nearest. * * Converts time values in hardware cycles to ticks. * Computes result in 32 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in ticks. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_cyc_to_ticks_near32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ticks_near32(t) \ + z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, true) -/** @brief Convert hardware cycles to ticks + +/** @brief Convert hardware cycles to ticks. 64 bits. Round nearest. * * Converts time values in hardware cycles to ticks. * Computes result in 64 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in ticks. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_cyc_to_ticks_near64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ticks_near64(t) \ + z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, true) -/** @brief Convert hardware cycles to ticks + +/** @brief Convert hardware cycles to ticks. 32 bits. Rounds up. * * Converts time values in hardware cycles to ticks. * Computes result in 32 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in ticks. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_cyc_to_ticks_ceil32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ticks_ceil32(t) \ + z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, false) -/** @brief Convert hardware cycles to ticks + +/** @brief Convert hardware cycles to ticks. 64 bits. Rounds up. * * Converts time values in hardware cycles to ticks. * Computes result in 64 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in hardware cycles. uint64_t + * + * @return The converted time value in ticks. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_cyc_to_ticks_ceil64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_cyc_to_ticks_ceil64(t) \ + z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, false) -/** @brief Convert ticks to milliseconds + +/** @brief Convert ticks to milliseconds. 32 bits. Truncates. * * Converts time values in ticks to milliseconds. * Computes result in 32 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in milliseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ticks_to_ms_floor32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, true, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_ms_floor32(t) \ + z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ms, true, false, false) -/** @brief Convert ticks to milliseconds + +/** @brief Convert ticks to milliseconds. 64 bits. Truncates. * * Converts time values in ticks to milliseconds. * Computes result in 64 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in milliseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ticks_to_ms_floor64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, false, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_ms_floor64(t) \ + z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ms, true, false, false) -/** @brief Convert ticks to milliseconds + +/** @brief Convert ticks to milliseconds. 32 bits. Round nearest. * * Converts time values in ticks to milliseconds. * Computes result in 32 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in milliseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ticks_to_ms_near32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, true, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_ms_near32(t) \ + z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ms, true, false, true) -/** @brief Convert ticks to milliseconds + +/** @brief Convert ticks to milliseconds. 64 bits. Round nearest. * * Converts time values in ticks to milliseconds. * Computes result in 64 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in milliseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ticks_to_ms_near64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, false, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_ms_near64(t) \ + z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ms, true, false, true) -/** @brief Convert ticks to milliseconds + +/** @brief Convert ticks to milliseconds. 32 bits. Rounds up. * * Converts time values in ticks to milliseconds. * Computes result in 32 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in milliseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ticks_to_ms_ceil32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, true, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_ms_ceil32(t) \ + z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ms, true, true, false) -/** @brief Convert ticks to milliseconds + +/** @brief Convert ticks to milliseconds. 64 bits. Rounds up. * * Converts time values in ticks to milliseconds. * Computes result in 64 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in milliseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ticks_to_ms_ceil64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, false, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_ms_ceil64(t) \ + z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ms, true, true, false) -/** @brief Convert ticks to microseconds + +/** @brief Convert ticks to microseconds. 32 bits. Truncates. * * Converts time values in ticks to microseconds. * Computes result in 32 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in microseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ticks_to_us_floor32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, true, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_us_floor32(t) \ + z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_us, true, false, false) -/** @brief Convert ticks to microseconds + +/** @brief Convert ticks to microseconds. 64 bits. Truncates. * * Converts time values in ticks to microseconds. * Computes result in 64 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in microseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ticks_to_us_floor64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, false, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_us_floor64(t) \ + z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_us, true, false, false) -/** @brief Convert ticks to microseconds + +/** @brief Convert ticks to microseconds. 32 bits. Round nearest. * * Converts time values in ticks to microseconds. * Computes result in 32 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in microseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ticks_to_us_near32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, true, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_us_near32(t) \ + z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_us, true, false, true) -/** @brief Convert ticks to microseconds + +/** @brief Convert ticks to microseconds. 64 bits. Round nearest. * * Converts time values in ticks to microseconds. * Computes result in 64 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in microseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ticks_to_us_near64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, false, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_us_near64(t) \ + z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_us, true, false, true) -/** @brief Convert ticks to microseconds + +/** @brief Convert ticks to microseconds. 32 bits. Rounds up. * * Converts time values in ticks to microseconds. * Computes result in 32 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in microseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ticks_to_us_ceil32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, true, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_us_ceil32(t) \ + z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_us, true, true, false) -/** @brief Convert ticks to microseconds + +/** @brief Convert ticks to microseconds. 64 bits. Rounds up. * * Converts time values in ticks to microseconds. * Computes result in 64 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in microseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ticks_to_us_ceil64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, false, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_us_ceil64(t) \ + z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_us, true, true, false) -/** @brief Convert ticks to nanoseconds + +/** @brief Convert ticks to nanoseconds. 32 bits. Truncates. * * Converts time values in ticks to nanoseconds. * Computes result in 32 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in nanoseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ticks_to_ns_floor32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, true, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_ns_floor32(t) \ + z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ns, true, false, false) -/** @brief Convert ticks to nanoseconds + +/** @brief Convert ticks to nanoseconds. 64 bits. Truncates. * * Converts time values in ticks to nanoseconds. * Computes result in 64 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in nanoseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ticks_to_ns_floor64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, false, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_ns_floor64(t) \ + z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ns, true, false, false) -/** @brief Convert ticks to nanoseconds + +/** @brief Convert ticks to nanoseconds. 32 bits. Round nearest. * * Converts time values in ticks to nanoseconds. * Computes result in 32 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in nanoseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ticks_to_ns_near32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, true, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_ns_near32(t) \ + z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ns, true, false, true) -/** @brief Convert ticks to nanoseconds + +/** @brief Convert ticks to nanoseconds. 64 bits. Round nearest. * * Converts time values in ticks to nanoseconds. * Computes result in 64 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in nanoseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ticks_to_ns_near64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, false, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_ns_near64(t) \ + z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ns, true, false, true) -/** @brief Convert ticks to nanoseconds + +/** @brief Convert ticks to nanoseconds. 32 bits. Rounds up. * * Converts time values in ticks to nanoseconds. * Computes result in 32 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in nanoseconds. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ticks_to_ns_ceil32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, true, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_ns_ceil32(t) \ + z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ns, true, true, false) -/** @brief Convert ticks to nanoseconds + +/** @brief Convert ticks to nanoseconds. 64 bits. Rounds up. * * Converts time values in ticks to nanoseconds. * Computes result in 64 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in nanoseconds. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ticks_to_ns_ceil64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, false, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_ns_ceil64(t) \ + z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ns, true, true, false) -/** @brief Convert ticks to hardware cycles + +/** @brief Convert ticks to hardware cycles. 32 bits. Truncates. * * Converts time values in ticks to hardware cycles. * Computes result in 32 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in hardware cycles. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ticks_to_cyc_floor32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_cyc_floor32(t) \ + z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, false) -/** @brief Convert ticks to hardware cycles + +/** @brief Convert ticks to hardware cycles. 64 bits. Truncates. * * Converts time values in ticks to hardware cycles. * Computes result in 64 bit precision. * Truncates to the next lowest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in hardware cycles. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ticks_to_cyc_floor64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, false, false); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_cyc_floor64(t) \ + z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, false) -/** @brief Convert ticks to hardware cycles + +/** @brief Convert ticks to hardware cycles. 32 bits. Round nearest. * * Converts time values in ticks to hardware cycles. * Computes result in 32 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in hardware cycles. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ticks_to_cyc_near32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_cyc_near32(t) \ + z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, true) -/** @brief Convert ticks to hardware cycles + +/** @brief Convert ticks to hardware cycles. 64 bits. Round nearest. * * Converts time values in ticks to hardware cycles. * Computes result in 64 bit precision. * Rounds to the nearest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in hardware cycles. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ticks_to_cyc_near64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, false, true); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_cyc_near64(t) \ + z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, true) -/** @brief Convert ticks to hardware cycles + +/** @brief Convert ticks to hardware cycles. 32 bits. Rounds up. * * Converts time values in ticks to hardware cycles. * Computes result in 32 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in hardware cycles. uint32_t */ -static TIME_CONSTEXPR inline uint32_t k_ticks_to_cyc_ceil32(uint32_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_cyc_ceil32(t) \ + z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, false) -/** @brief Convert ticks to hardware cycles + +/** @brief Convert ticks to hardware cycles. 64 bits. Rounds up. * * Converts time values in ticks to hardware cycles. * Computes result in 64 bit precision. * Rounds up to the next highest output unit. * - * @return The converted time value + * @param t Source time in ticks. uint64_t + * + * @return The converted time value in hardware cycles. uint64_t */ -static TIME_CONSTEXPR inline uint64_t k_ticks_to_cyc_ceil64(uint64_t t) -{ - /* Generated. Do not edit. See above. */ - return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, true, false); -} +/* Generated. Do not edit. See above. */ +#define k_ticks_to_cyc_ceil64(t) \ + z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, false) #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME) #include diff --git a/lib/os/timeutil.c b/lib/os/timeutil.c index 4a3b8428f71..18c173acc8d 100644 --- a/lib/os/timeutil.c +++ b/lib/os/timeutil.c @@ -13,6 +13,7 @@ #include #include #include +#include #include /** Convert a civil (proleptic Gregorian) date to days relative to