Zephyr API Documentation  3.0.0
A Scalable Open Source RTOS
3.0.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
time_units.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_TIME_UNITS_H_
8#define ZEPHYR_INCLUDE_TIME_UNITS_H_
9
10#include <toolchain.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
23#define SYS_FOREVER_MS (-1)
24
29#define SYS_FOREVER_US (-1)
30
33#define SYS_TIMEOUT_MS(ms) ((ms) == SYS_FOREVER_MS ? K_FOREVER : K_MSEC(ms))
34
35/* Exhaustively enumerated, highly optimized time unit conversion API */
36
37#if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
38__syscall int sys_clock_hw_cycles_per_sec_runtime_get(void);
39
40static inline int z_impl_sys_clock_hw_cycles_per_sec_runtime_get(void)
41{
42 extern int z_clock_hw_cycles_per_sec;
43
44 return z_clock_hw_cycles_per_sec;
45}
46#endif /* CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME */
47
48#if defined(__cplusplus) && __cplusplus >= 201402L
49 #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
50 #define TIME_CONSTEXPR
51 #else
52 #define TIME_CONSTEXPR constexpr
53 #endif
54#else
55 #define TIME_CONSTEXPR
56#endif
57
59{
60#if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
61 return sys_clock_hw_cycles_per_sec_runtime_get();
62#else
64#endif
65}
66
78#define Z_TMCVT_USE_FAST_ALGO(from_hz, to_hz) \
79 ((ceiling_fraction(CONFIG_SYS_CLOCK_MAX_TIMEOUT_DAYS * 24ULL * 3600ULL * from_hz, \
80 UINT32_MAX) * to_hz) <= UINT32_MAX)
81
82/* Time converter generator gadget. Selects from one of three
83 * conversion algorithms: ones that take advantage when the
84 * frequencies are an integer ratio (in either direction), or a full
85 * precision conversion. Clever use of extra arguments causes all the
86 * selection logic to be optimized out, and the generated code even
87 * reduces to 32 bit only if a ratio conversion is available and the
88 * result is 32 bits.
89 *
90 * This isn't intended to be used directly, instead being wrapped
91 * appropriately in a user-facing API. The boolean arguments are:
92 *
93 * const_hz - The hz arguments are known to be compile-time
94 * constants (because otherwise the modulus test would
95 * have to be done at runtime)
96 * result32 - The result will be truncated to 32 bits on use
97 * round_up - Return the ceiling of the resulting fraction
98 * round_off - Return the nearest value to the resulting fraction
99 * (pass both round_up/off as false to get "round_down")
100 */
102 uint32_t to_hz, bool const_hz,
103 bool result32, bool round_up,
104 bool round_off)
105{
106 bool mul_ratio = const_hz &&
107 (to_hz > from_hz) && ((to_hz % from_hz) == 0U);
108 bool div_ratio = const_hz &&
109 (from_hz > to_hz) && ((from_hz % to_hz) == 0U);
110
111 if (from_hz == to_hz) {
112 return result32 ? ((uint32_t)t) : t;
113 }
114
115 uint64_t off = 0;
116
117 if (!mul_ratio) {
118 uint32_t rdivisor = div_ratio ? (from_hz / to_hz) : from_hz;
119
120 if (round_up) {
121 off = rdivisor - 1U;
122 }
123 if (round_off) {
124 off = rdivisor / 2U;
125 }
126 }
127
128 /* Select (at build time!) between three different expressions for
129 * the same mathematical relationship, each expressed with and
130 * without truncation to 32 bits (I couldn't find a way to make
131 * the compiler correctly guess at the 32 bit result otherwise).
132 */
133 if (div_ratio) {
134 t += off;
135 if (result32 && (t < BIT64(32))) {
136 return ((uint32_t)t) / (from_hz / to_hz);
137 } else {
138 return t / ((uint64_t)from_hz / to_hz);
139 }
140 } else if (mul_ratio) {
141 if (result32) {
142 return ((uint32_t)t) * (to_hz / from_hz);
143 } else {
144 return t * ((uint64_t)to_hz / from_hz);
145 }
146 } else {
147 if (result32) {
148 return (uint32_t)((t * to_hz + off) / from_hz);
149 } else if (const_hz && Z_TMCVT_USE_FAST_ALGO(from_hz, to_hz)) {
150 /* Faster algorithm but source is first multiplied by target frequency
151 * and it can overflow even though final result would not overflow.
152 * Kconfig option shall prevent use of this algorithm when there is a
153 * risk of overflow.
154 */
155 return ((t * to_hz + off) / from_hz);
156 } else {
157 /* Slower algorithm but input is first divided before being multiplied
158 * which prevents overflow of intermediate value.
159 */
160 return (t / from_hz) * to_hz + ((t % from_hz) * to_hz + off) / from_hz;
161 }
162 }
163}
164
165/* The following code is programmatically generated using this perl
166 * code, which enumerates all possible combinations of units, rounding
167 * modes and precision. Do not edit directly.
168 *
169 * Note that nano/microsecond conversions are only defined with 64 bit
170 * precision. These units conversions were not available in 32 bit
171 * variants historically, and doing 32 bit math with units that small
172 * has precision traps that we probably don't want to support in an
173 * official API.
174 *
175 * #!/usr/bin/perl -w
176 * use strict;
177 *
178 * my %human = ("ms" => "milliseconds",
179 * "us" => "microseconds",
180 * "ns" => "nanoseconds",
181 * "cyc" => "hardware cycles",
182 * "ticks" => "ticks");
183 *
184 * sub big { return $_[0] eq "us" || $_[0] eq "ns"; }
185 * sub prefix { return $_[0] eq "ms" || $_[0] eq "us" || $_[0] eq "ns"; }
186 *
187 * for my $from_unit ("ms", "us", "ns", "cyc", "ticks") {
188 * for my $to_unit ("ms", "us", "ns", "cyc", "ticks") {
189 * next if $from_unit eq $to_unit;
190 * next if prefix($from_unit) && prefix($to_unit);
191 * for my $round ("floor", "near", "ceil") {
192 * for(my $big=0; $big <= 1; $big++) {
193 * my $sz = $big ? 64 : 32;
194 * my $sym = "k_${from_unit}_to_${to_unit}_$round$sz";
195 * my $type = "u${sz}_t";
196 * my $const_hz = ($from_unit eq "cyc" || $to_unit eq "cyc")
197 * ? "Z_CCYC" : "true";
198 * my $ret32 = $big ? "false" : "true";
199 * my $rup = $round eq "ceil" ? "true" : "false";
200 * my $roff = $round eq "near" ? "true" : "false";
201 *
202 * my $hfrom = $human{$from_unit};
203 * my $hto = $human{$to_unit};
204 * print "/", "** \@brief Convert $hfrom to $hto\n";
205 * print " *\n";
206 * print " * Converts time values in $hfrom to $hto.\n";
207 * print " * Computes result in $sz bit precision.\n";
208 * if ($round eq "ceil") {
209 * print " * Rounds up to the next highest output unit.\n";
210 * } elsif ($round eq "near") {
211 * print " * Rounds to the nearest output unit.\n";
212 * } else {
213 * print " * Truncates to the next lowest output unit.\n";
214 * }
215 * print " *\n";
216 * print " * \@return The converted time value\n";
217 * print " *", "/\n";
218 *
219 * print "static TIME_CONSTEXPR inline $type $sym($type t)\n{\n\t";
220 * print "/", "* Generated. Do not edit. See above. *", "/\n\t";
221 * print "return z_tmcvt(t, Z_HZ_$from_unit, Z_HZ_$to_unit,";
222 * print " $const_hz, $ret32, $rup, $roff);\n";
223 * print "}\n\n";
224 * }
225 * }
226 * }
227 * }
228 */
229
230/* Some more concise declarations to simplify the generator script and
231 * save bytes below
232 */
233#define Z_HZ_ms 1000
234#define Z_HZ_us 1000000
235#define Z_HZ_ns 1000000000
236#define Z_HZ_cyc sys_clock_hw_cycles_per_sec()
237#define Z_HZ_ticks CONFIG_SYS_CLOCK_TICKS_PER_SEC
238#define Z_CCYC (!IS_ENABLED(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME))
239
249{
250 /* Generated. Do not edit. See above. */
251 return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, false, false);
252}
253
263{
264 /* Generated. Do not edit. See above. */
265 return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, false, false);
266}
267
277{
278 /* Generated. Do not edit. See above. */
279 return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, false, true);
280}
281
291{
292 /* Generated. Do not edit. See above. */
293 return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, false, true);
294}
295
305{
306 /* Generated. Do not edit. See above. */
307 return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, true, false);
308}
309
319{
320 /* Generated. Do not edit. See above. */
321 return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, true, false);
322}
323
333{
334 /* Generated. Do not edit. See above. */
335 return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, true, false, false);
336}
337
347{
348 /* Generated. Do not edit. See above. */
349 return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, false, false, false);
350}
351
361{
362 /* Generated. Do not edit. See above. */
363 return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, true, false, true);
364}
365
375{
376 /* Generated. Do not edit. See above. */
377 return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, false, false, true);
378}
379
389{
390 /* Generated. Do not edit. See above. */
391 return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, true, true, false);
392}
393
403{
404 /* Generated. Do not edit. See above. */
405 return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, false, true, false);
406}
407
417{
418 /* Generated. Do not edit. See above. */
419 return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false, false);
420}
421
431{
432 /* Generated. Do not edit. See above. */
433 return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false, false);
434}
435
445{
446 /* Generated. Do not edit. See above. */
447 return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false, true);
448}
449
459{
460 /* Generated. Do not edit. See above. */
461 return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false, true);
462}
463
473{
474 /* Generated. Do not edit. See above. */
475 return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, true, false);
476}
477
487{
488 /* Generated. Do not edit. See above. */
489 return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, true, false);
490}
491
501{
502 /* Generated. Do not edit. See above. */
503 return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, true, false, false);
504}
505
515{
516 /* Generated. Do not edit. See above. */
517 return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, false, false, false);
518}
519
529{
530 /* Generated. Do not edit. See above. */
531 return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, true, false, true);
532}
533
543{
544 /* Generated. Do not edit. See above. */
545 return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, false, false, true);
546}
547
557{
558 /* Generated. Do not edit. See above. */
559 return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, true, true, false);
560}
561
571{
572 /* Generated. Do not edit. See above. */
573 return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, false, true, false);
574}
575
585{
586 /* Generated. Do not edit. See above. */
587 return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false, false);
588}
589
599{
600 /* Generated. Do not edit. See above. */
601 return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false, false);
602}
603
613{
614 /* Generated. Do not edit. See above. */
615 return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false, true);
616}
617
627{
628 /* Generated. Do not edit. See above. */
629 return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false, true);
630}
631
641{
642 /* Generated. Do not edit. See above. */
643 return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, true, false);
644}
645
655{
656 /* Generated. Do not edit. See above. */
657 return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, true, false);
658}
659
669{
670 /* Generated. Do not edit. See above. */
671 return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, true, false, false);
672}
673
683{
684 /* Generated. Do not edit. See above. */
685 return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, false, false, false);
686}
687
697{
698 /* Generated. Do not edit. See above. */
699 return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, true, false, true);
700}
701
711{
712 /* Generated. Do not edit. See above. */
713 return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, false, false, true);
714}
715
725{
726 /* Generated. Do not edit. See above. */
727 return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, true, true, false);
728}
729
739{
740 /* Generated. Do not edit. See above. */
741 return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, false, true, false);
742}
743
753{
754 /* Generated. Do not edit. See above. */
755 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, false, false);
756}
757
767{
768 /* Generated. Do not edit. See above. */
769 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, false, false);
770}
771
781{
782 /* Generated. Do not edit. See above. */
783 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, false, true);
784}
785
795{
796 /* Generated. Do not edit. See above. */
797 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, false, true);
798}
799
809{
810 /* Generated. Do not edit. See above. */
811 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, true, false);
812}
813
823{
824 /* Generated. Do not edit. See above. */
825 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, true, false);
826}
827
837{
838 /* Generated. Do not edit. See above. */
839 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false, false);
840}
841
851{
852 /* Generated. Do not edit. See above. */
853 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false, false);
854}
855
865{
866 /* Generated. Do not edit. See above. */
867 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false, true);
868}
869
879{
880 /* Generated. Do not edit. See above. */
881 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false, true);
882}
883
893{
894 /* Generated. Do not edit. See above. */
895 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, true, false);
896}
897
907{
908 /* Generated. Do not edit. See above. */
909 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, true, false);
910}
911
921{
922 /* Generated. Do not edit. See above. */
923 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false, false);
924}
925
935{
936 /* Generated. Do not edit. See above. */
937 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false, false);
938}
939
949{
950 /* Generated. Do not edit. See above. */
951 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false, true);
952}
953
963{
964 /* Generated. Do not edit. See above. */
965 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false, true);
966}
967
977{
978 /* Generated. Do not edit. See above. */
979 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, true, false);
980}
981
991{
992 /* Generated. Do not edit. See above. */
993 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, true, false);
994}
995
1005{
1006 /* Generated. Do not edit. See above. */
1007 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, false, false);
1008}
1009
1019{
1020 /* Generated. Do not edit. See above. */
1021 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, false, false);
1022}
1023
1033{
1034 /* Generated. Do not edit. See above. */
1035 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, false, true);
1036}
1037
1047{
1048 /* Generated. Do not edit. See above. */
1049 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, false, true);
1050}
1051
1061{
1062 /* Generated. Do not edit. See above. */
1063 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, true, false);
1064}
1065
1075{
1076 /* Generated. Do not edit. See above. */
1077 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, true, false);
1078}
1079
1089{
1090 /* Generated. Do not edit. See above. */
1091 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, true, false, false);
1092}
1093
1103{
1104 /* Generated. Do not edit. See above. */
1105 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, false, false, false);
1106}
1107
1117{
1118 /* Generated. Do not edit. See above. */
1119 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, true, false, true);
1120}
1121
1131{
1132 /* Generated. Do not edit. See above. */
1133 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, false, false, true);
1134}
1135
1145{
1146 /* Generated. Do not edit. See above. */
1147 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, true, true, false);
1148}
1149
1159{
1160 /* Generated. Do not edit. See above. */
1161 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, false, true, false);
1162}
1163
1173{
1174 /* Generated. Do not edit. See above. */
1175 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, true, false, false);
1176}
1177
1187{
1188 /* Generated. Do not edit. See above. */
1189 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, false, false, false);
1190}
1191
1201{
1202 /* Generated. Do not edit. See above. */
1203 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, true, false, true);
1204}
1205
1215{
1216 /* Generated. Do not edit. See above. */
1217 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, false, false, true);
1218}
1219
1229{
1230 /* Generated. Do not edit. See above. */
1231 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, true, true, false);
1232}
1233
1243{
1244 /* Generated. Do not edit. See above. */
1245 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, false, true, false);
1246}
1247
1257{
1258 /* Generated. Do not edit. See above. */
1259 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, true, false, false);
1260}
1261
1271{
1272 /* Generated. Do not edit. See above. */
1273 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, false, false, false);
1274}
1275
1285{
1286 /* Generated. Do not edit. See above. */
1287 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, true, false, true);
1288}
1289
1299{
1300 /* Generated. Do not edit. See above. */
1301 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, false, false, true);
1302}
1303
1313{
1314 /* Generated. Do not edit. See above. */
1315 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, true, true, false);
1316}
1317
1327{
1328 /* Generated. Do not edit. See above. */
1329 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, false, true, false);
1330}
1331
1341{
1342 /* Generated. Do not edit. See above. */
1343 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, false, false);
1344}
1345
1355{
1356 /* Generated. Do not edit. See above. */
1357 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, false, false);
1358}
1359
1369{
1370 /* Generated. Do not edit. See above. */
1371 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, false, true);
1372}
1373
1383{
1384 /* Generated. Do not edit. See above. */
1385 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, false, true);
1386}
1387
1397{
1398 /* Generated. Do not edit. See above. */
1399 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, true, false);
1400}
1401
1411{
1412 /* Generated. Do not edit. See above. */
1413 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, true, false);
1414}
1415
1416#if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
1417#include <syscalls/time_units.h>
1418#endif
1419
1420#undef TIME_CONSTEXPR
1421
1422#ifdef __cplusplus
1423} /* extern "C" */
1424#endif
1425
1426#endif /* ZEPHYR_INCLUDE_TIME_UNITS_H_ */
irp nz macro MOVR cc s mov cc s endm endr irp aw macro LDR aa off
Definition: asm-macro-32-bit-gnu.h:17
#define ALWAYS_INLINE
Definition: common.h:124
#define BIT64(_n)
64-bit unsigned integer with bit position _n set.
Definition: util_macro.h:49
struct k_thread t
Definition: kobject.c:1321
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT64_TYPE__ uint64_t
Definition: stdint.h:61
static uint32_t k_ms_to_cyc_floor32(uint32_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:248
static uint64_t k_cyc_to_ns_near64(uint64_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:962
static uint64_t k_ticks_to_ns_floor64(uint64_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1270
static uint64_t k_ms_to_cyc_near64(uint64_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:290
static uint64_t k_ms_to_cyc_ceil64(uint64_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:318
static uint32_t k_ticks_to_ms_near32(uint32_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1116
static uint32_t k_ns_to_cyc_floor32(uint32_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:584
static uint32_t k_ticks_to_ns_near32(uint32_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1284
static uint32_t k_us_to_ticks_near32(uint32_t t)
Convert microseconds to ticks.
Definition: time_units.h:528
static uint32_t k_ns_to_ticks_floor32(uint32_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:668
static uint64_t k_ns_to_ticks_ceil64(uint64_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:738
static uint64_t k_cyc_to_ticks_floor64(uint64_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:1018
static int sys_clock_hw_cycles_per_sec(void)
Definition: time_units.h:58
static uint64_t k_ticks_to_ns_near64(uint64_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1298
static uint64_t k_cyc_to_ms_floor64(uint64_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:766
static uint64_t k_us_to_cyc_ceil64(uint64_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:486
static uint64_t k_ns_to_cyc_floor64(uint64_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:598
static uint64_t k_us_to_ticks_floor64(uint64_t t)
Convert microseconds to ticks.
Definition: time_units.h:514
static uint32_t k_cyc_to_us_ceil32(uint32_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:892
static uint32_t k_cyc_to_ns_floor32(uint32_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:920
static uint64_t k_ms_to_ticks_floor64(uint64_t t)
Convert milliseconds to ticks.
Definition: time_units.h:346
static uint64_t k_cyc_to_ms_ceil64(uint64_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:822
static uint32_t k_us_to_cyc_ceil32(uint32_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:472
#define TIME_CONSTEXPR
Definition: time_units.h:55
static uint32_t k_ticks_to_ms_ceil32(uint32_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1144
static uint32_t k_ticks_to_cyc_floor32(uint32_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1340
static uint64_t k_ticks_to_cyc_ceil64(uint64_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1410
static uint32_t k_us_to_ticks_floor32(uint32_t t)
Convert microseconds to ticks.
Definition: time_units.h:500
static uint32_t k_ns_to_ticks_near32(uint32_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:696
static uint64_t k_ns_to_ticks_floor64(uint64_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:682
static uint64_t k_ms_to_ticks_near64(uint64_t t)
Convert milliseconds to ticks.
Definition: time_units.h:374
static uint32_t k_ticks_to_ns_ceil32(uint32_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1312
static uint64_t k_us_to_cyc_near64(uint64_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:458
static uint32_t k_ns_to_cyc_near32(uint32_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:612
static uint64_t k_us_to_cyc_floor64(uint64_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:430
static uint32_t k_ticks_to_ns_floor32(uint32_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1256
static uint64_t k_cyc_to_ms_near64(uint64_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:794
static uint32_t k_us_to_cyc_near32(uint32_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:444
static uint64_t k_ticks_to_ms_floor64(uint64_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1102
static uint32_t k_ns_to_ticks_ceil32(uint32_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:724
static uint32_t k_cyc_to_ms_near32(uint32_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:780
static uint32_t k_cyc_to_ms_ceil32(uint32_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:808
static uint64_t k_ns_to_ticks_near64(uint64_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:710
static uint64_t k_ticks_to_us_near64(uint64_t t)
Convert ticks to microseconds.
Definition: time_units.h:1214
static uint32_t k_cyc_to_ticks_ceil32(uint32_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:1060
static uint64_t k_ns_to_cyc_ceil64(uint64_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:654
static uint32_t k_ms_to_cyc_ceil32(uint32_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:304
static uint32_t k_ticks_to_ms_floor32(uint32_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1088
static uint32_t k_ms_to_ticks_floor32(uint32_t t)
Convert milliseconds to ticks.
Definition: time_units.h:332
static uint64_t k_cyc_to_ticks_near64(uint64_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:1046
static uint64_t k_ticks_to_us_floor64(uint64_t t)
Convert ticks to microseconds.
Definition: time_units.h:1186
static uint64_t k_cyc_to_ns_floor64(uint64_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:934
static uint32_t k_cyc_to_ns_ceil32(uint32_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:976
static uint32_t k_cyc_to_us_floor32(uint32_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:836
static uint64_t k_cyc_to_us_floor64(uint64_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:850
static uint32_t k_us_to_cyc_floor32(uint32_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:416
static uint64_t k_ms_to_ticks_ceil64(uint64_t t)
Convert milliseconds to ticks.
Definition: time_units.h:402
static uint32_t k_us_to_ticks_ceil32(uint32_t t)
Convert microseconds to ticks.
Definition: time_units.h:556
static uint32_t k_ticks_to_us_near32(uint32_t t)
Convert ticks to microseconds.
Definition: time_units.h:1200
static uint32_t k_cyc_to_ticks_floor32(uint32_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:1004
static uint32_t k_ticks_to_us_ceil32(uint32_t t)
Convert ticks to microseconds.
Definition: time_units.h:1228
static uint32_t k_ms_to_ticks_near32(uint32_t t)
Convert milliseconds to ticks.
Definition: time_units.h:360
static uint64_t k_cyc_to_ns_ceil64(uint64_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:990
static uint32_t k_ns_to_cyc_ceil32(uint32_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:640
static uint32_t k_ticks_to_cyc_ceil32(uint32_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1396
static uint64_t k_cyc_to_us_ceil64(uint64_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:906
static uint32_t k_ms_to_cyc_near32(uint32_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:276
static uint32_t k_ticks_to_us_floor32(uint32_t t)
Convert ticks to microseconds.
Definition: time_units.h:1172
static uint32_t k_cyc_to_ms_floor32(uint32_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:752
static uint64_t k_ticks_to_ms_near64(uint64_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1130
static uint64_t k_ticks_to_us_ceil64(uint64_t t)
Convert ticks to microseconds.
Definition: time_units.h:1242
static uint64_t k_us_to_ticks_near64(uint64_t t)
Convert microseconds to ticks.
Definition: time_units.h:542
static uint32_t k_cyc_to_ns_near32(uint32_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:948
static uint32_t k_ticks_to_cyc_near32(uint32_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1368
static uint64_t k_cyc_to_ticks_ceil64(uint64_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:1074
static uint32_t k_ms_to_ticks_ceil32(uint32_t t)
Convert milliseconds to ticks.
Definition: time_units.h:388
static uint64_t k_ticks_to_ms_ceil64(uint64_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1158
static uint64_t k_ticks_to_cyc_floor64(uint64_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1354
static uint64_t k_cyc_to_us_near64(uint64_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:878
static uint64_t k_ticks_to_cyc_near64(uint64_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1382
static uint64_t k_ms_to_cyc_floor64(uint64_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:262
static uint64_t k_ticks_to_ns_ceil64(uint64_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1326
static uint32_t k_cyc_to_ticks_near32(uint32_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:1032
static uint64_t k_ns_to_cyc_near64(uint64_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:626
static uint64_t k_us_to_ticks_ceil64(uint64_t t)
Convert microseconds to ticks.
Definition: time_units.h:570
static uint32_t k_cyc_to_us_near32(uint32_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:864
Macros to abstract toolchain specific capabilities.
#define CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC
Definition: ztest.h:40