clock: renmae z_timeout_end_calc -> sys_clock_timeout_end_calc
Do not use z_ for internal APIs, z_ is for private APIs within one subsystem only. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
fe0872c0ab
commit
a518f48796
11 changed files with 24 additions and 24 deletions
|
@ -313,7 +313,7 @@ code. For example, consider this design:
|
||||||
|
|
||||||
This code requires that the timeout value be inspected, which is no
|
This code requires that the timeout value be inspected, which is no
|
||||||
longer possible. For situations like this, the new API provides an
|
longer possible. For situations like this, the new API provides an
|
||||||
internal :c:func:`z_timeout_end_calc` routine that converts an
|
internal :c:func:`sys_clock_timeout_end_calc` routine that converts an
|
||||||
arbitrary timeout to the uptime value in ticks at which it will
|
arbitrary timeout to the uptime value in ticks at which it will
|
||||||
expire. So such a loop might look like:
|
expire. So such a loop might look like:
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ expire. So such a loop might look like:
|
||||||
void my_wait_for_event(struct my_subsys *obj, k_timeout_t timeout_in_ms)
|
void my_wait_for_event(struct my_subsys *obj, k_timeout_t timeout_in_ms)
|
||||||
{
|
{
|
||||||
/* Compute the end time from the timeout */
|
/* Compute the end time from the timeout */
|
||||||
uint64_t end = z_timeout_end_calc(timeout_in_ms);
|
uint64_t end = sys_clock_timeout_end_calc(timeout_in_ms);
|
||||||
|
|
||||||
while (end > k_uptime_ticks()) {
|
while (end > k_uptime_ticks()) {
|
||||||
if (is_event_complete(obj)) {
|
if (is_event_complete(obj)) {
|
||||||
|
@ -335,7 +335,7 @@ expire. So such a loop might look like:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Note that :c:func:`z_timeout_end_calc` returns values in units of
|
Note that :c:func:`sys_clock_timeout_end_calc` returns values in units of
|
||||||
ticks, to prevent conversion aliasing, is always presented at 64 bit
|
ticks, to prevent conversion aliasing, is always presented at 64 bit
|
||||||
uptime precision to prevent rollover bugs, handles special
|
uptime precision to prevent rollover bugs, handles special
|
||||||
:c:macro:`K_FOREVER` naturally (as ``UINT64_MAX``), and works
|
:c:macro:`K_FOREVER` naturally (as ``UINT64_MAX``), and works
|
||||||
|
@ -344,7 +344,7 @@ identically for absolute timeouts as well as conventional ones.
|
||||||
But some care is still required for subsystems that use it. Note that
|
But some care is still required for subsystems that use it. Note that
|
||||||
delta timeouts need to be interpreted relative to a "current time",
|
delta timeouts need to be interpreted relative to a "current time",
|
||||||
and obviously that time is the time of the call to
|
and obviously that time is the time of the call to
|
||||||
:c:func:`z_timeout_end_calc`. But the user expects that the time is
|
:c:func:`sys_clock_timeout_end_calc`. But the user expects that the time is
|
||||||
the time they passed the timeout to you. Care must be taken to call
|
the time they passed the timeout to you. Care must be taken to call
|
||||||
this function just once, as synchronously as possible to the timeout
|
this function just once, as synchronously as possible to the timeout
|
||||||
creation in user code. It should not be used on a "stored" timeout
|
creation in user code. It should not be used on a "stored" timeout
|
||||||
|
|
|
@ -157,7 +157,7 @@ static int w5500_writebuf(const struct device *dev, uint16_t offset, uint8_t *bu
|
||||||
static int w5500_command(const struct device *dev, uint8_t cmd)
|
static int w5500_command(const struct device *dev, uint8_t cmd)
|
||||||
{
|
{
|
||||||
uint8_t reg;
|
uint8_t reg;
|
||||||
uint64_t end = z_timeout_end_calc(K_MSEC(100));
|
uint64_t end = sys_clock_timeout_end_calc(K_MSEC(100));
|
||||||
|
|
||||||
w5500_spi_write(dev, W5500_S0_CR, &cmd, 1);
|
w5500_spi_write(dev, W5500_S0_CR, &cmd, 1);
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -191,7 +191,7 @@ int64_t sys_clock_tick_get(void);
|
||||||
#define sys_clock_tick_get_32() (0)
|
#define sys_clock_tick_get_32() (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint64_t z_timeout_end_calc(k_timeout_t timeout);
|
uint64_t sys_clock_timeout_end_calc(k_timeout_t timeout);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ SYS_INIT(statics_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS);
|
||||||
void *k_heap_aligned_alloc(struct k_heap *h, size_t align, size_t bytes,
|
void *k_heap_aligned_alloc(struct k_heap *h, size_t align, size_t bytes,
|
||||||
k_timeout_t timeout)
|
k_timeout_t timeout)
|
||||||
{
|
{
|
||||||
int64_t now, end = z_timeout_end_calc(timeout);
|
int64_t now, end = sys_clock_timeout_end_calc(timeout);
|
||||||
void *ret = NULL;
|
void *ret = NULL;
|
||||||
k_spinlock_key_t key = k_spin_lock(&h->lock);
|
k_spinlock_key_t key = k_spin_lock(&h->lock);
|
||||||
|
|
||||||
|
|
|
@ -302,7 +302,7 @@ static inline int64_t z_vrfy_k_uptime_ticks(void)
|
||||||
* synchronously with the user passing a new timeout value. It should
|
* synchronously with the user passing a new timeout value. It should
|
||||||
* not be used iteratively to adjust a timeout.
|
* not be used iteratively to adjust a timeout.
|
||||||
*/
|
*/
|
||||||
uint64_t z_timeout_end_calc(k_timeout_t timeout)
|
uint64_t sys_clock_timeout_end_calc(k_timeout_t timeout)
|
||||||
{
|
{
|
||||||
k_ticks_t dt;
|
k_ticks_t dt;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ void zperf_tcp_upload(const struct shell *shell,
|
||||||
unsigned int packet_size,
|
unsigned int packet_size,
|
||||||
struct zperf_results *results)
|
struct zperf_results *results)
|
||||||
{
|
{
|
||||||
int64_t duration = z_timeout_end_calc(K_MSEC(duration_in_ms));
|
int64_t duration = sys_clock_timeout_end_calc(K_MSEC(duration_in_ms));
|
||||||
int64_t start_time, last_print_time, end_time, remaining;
|
int64_t start_time, last_print_time, end_time, remaining;
|
||||||
uint32_t nb_packets = 0U, nb_errors = 0U;
|
uint32_t nb_packets = 0U, nb_errors = 0U;
|
||||||
uint32_t alloc_errors = 0U;
|
uint32_t alloc_errors = 0U;
|
||||||
|
|
|
@ -167,8 +167,8 @@ void zperf_udp_upload(const struct shell *shell,
|
||||||
{
|
{
|
||||||
uint32_t packet_duration = ((uint32_t)packet_size * 8U * USEC_PER_SEC) /
|
uint32_t packet_duration = ((uint32_t)packet_size * 8U * USEC_PER_SEC) /
|
||||||
(rate_in_kbps * 1024U);
|
(rate_in_kbps * 1024U);
|
||||||
uint64_t duration = z_timeout_end_calc(K_MSEC(duration_in_ms));
|
uint64_t duration = sys_clock_timeout_end_calc(K_MSEC(duration_in_ms));
|
||||||
int64_t print_interval = z_timeout_end_calc(K_SECONDS(1));
|
int64_t print_interval = sys_clock_timeout_end_calc(K_SECONDS(1));
|
||||||
uint64_t delay = packet_duration;
|
uint64_t delay = packet_duration;
|
||||||
uint32_t nb_packets = 0U;
|
uint32_t nb_packets = 0U;
|
||||||
int64_t start_time, end_time;
|
int64_t start_time, end_time;
|
||||||
|
@ -275,7 +275,7 @@ void zperf_udp_upload(const struct shell *shell,
|
||||||
"nb_packets=%u\tdelay=%u\tadjust=%d\n",
|
"nb_packets=%u\tdelay=%u\tadjust=%d\n",
|
||||||
nb_packets, (unsigned int)delay,
|
nb_packets, (unsigned int)delay,
|
||||||
(int)adjust);
|
(int)adjust);
|
||||||
print_interval = z_timeout_end_calc(K_SECONDS(1));
|
print_interval = sys_clock_timeout_end_calc(K_SECONDS(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
remaining = duration - k_uptime_ticks();
|
remaining = duration - k_uptime_ticks();
|
||||||
|
|
|
@ -230,7 +230,7 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
|
||||||
k_timeout_t timeout)
|
k_timeout_t timeout)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
uint64_t end = z_timeout_end_calc(timeout);
|
uint64_t end = sys_clock_timeout_end_calc(timeout);
|
||||||
struct net_buf *buf;
|
struct net_buf *buf;
|
||||||
unsigned int key;
|
unsigned int key;
|
||||||
|
|
||||||
|
@ -574,7 +574,7 @@ struct net_buf *net_buf_ref(struct net_buf *buf)
|
||||||
|
|
||||||
struct net_buf *net_buf_clone(struct net_buf *buf, k_timeout_t timeout)
|
struct net_buf *net_buf_clone(struct net_buf *buf, k_timeout_t timeout)
|
||||||
{
|
{
|
||||||
int64_t end = z_timeout_end_calc(timeout);
|
int64_t end = sys_clock_timeout_end_calc(timeout);
|
||||||
struct net_buf_pool *pool;
|
struct net_buf_pool *pool;
|
||||||
struct net_buf *clone;
|
struct net_buf *clone;
|
||||||
|
|
||||||
|
|
|
@ -857,7 +857,7 @@ static struct net_buf *pkt_alloc_buffer(struct net_buf_pool *pool,
|
||||||
size_t size, k_timeout_t timeout)
|
size_t size, k_timeout_t timeout)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
uint64_t end = z_timeout_end_calc(timeout);
|
uint64_t end = sys_clock_timeout_end_calc(timeout);
|
||||||
struct net_buf *first = NULL;
|
struct net_buf *first = NULL;
|
||||||
struct net_buf *current = NULL;
|
struct net_buf *current = NULL;
|
||||||
|
|
||||||
|
@ -1103,7 +1103,7 @@ int net_pkt_alloc_buffer(struct net_pkt *pkt,
|
||||||
k_timeout_t timeout)
|
k_timeout_t timeout)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
uint64_t end = z_timeout_end_calc(timeout);
|
uint64_t end = sys_clock_timeout_end_calc(timeout);
|
||||||
struct net_buf_pool *pool = NULL;
|
struct net_buf_pool *pool = NULL;
|
||||||
size_t alloc_len = 0;
|
size_t alloc_len = 0;
|
||||||
size_t hdr_len = 0;
|
size_t hdr_len = 0;
|
||||||
|
@ -1375,7 +1375,7 @@ pkt_alloc_with_buffer(struct k_mem_slab *slab,
|
||||||
k_timeout_t timeout)
|
k_timeout_t timeout)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
uint64_t end = z_timeout_end_calc(timeout);
|
uint64_t end = sys_clock_timeout_end_calc(timeout);
|
||||||
struct net_pkt *pkt;
|
struct net_pkt *pkt;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|
|
@ -592,7 +592,7 @@ ssize_t zsock_sendto_ctx(struct net_context *ctx, const void *buf, size_t len,
|
||||||
timeout = K_NO_WAIT;
|
timeout = K_NO_WAIT;
|
||||||
} else {
|
} else {
|
||||||
net_context_get_option(ctx, NET_OPT_SNDTIMEO, &timeout, NULL);
|
net_context_get_option(ctx, NET_OPT_SNDTIMEO, &timeout, NULL);
|
||||||
buf_timeout = z_timeout_end_calc(MAX_WAIT_BUFS);
|
buf_timeout = sys_clock_timeout_end_calc(MAX_WAIT_BUFS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register the callback before sending in order to receive the response
|
/* Register the callback before sending in order to receive the response
|
||||||
|
@ -1065,7 +1065,7 @@ static inline ssize_t zsock_recv_stream(struct net_context *ctx,
|
||||||
net_context_get_option(ctx, NET_OPT_RCVTIMEO, &timeout, NULL);
|
net_context_get_option(ctx, NET_OPT_RCVTIMEO, &timeout, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
end = z_timeout_end_calc(timeout);
|
end = sys_clock_timeout_end_calc(timeout);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
struct net_pkt *pkt;
|
struct net_pkt *pkt;
|
||||||
|
@ -1325,7 +1325,7 @@ int z_impl_zsock_poll(struct zsock_pollfd *fds, int nfds, int poll_timeout)
|
||||||
timeout = K_MSEC(poll_timeout);
|
timeout = K_MSEC(poll_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
end = z_timeout_end_calc(timeout);
|
end = sys_clock_timeout_end_calc(timeout);
|
||||||
|
|
||||||
pev = poll_events;
|
pev = poll_events;
|
||||||
for (pfd = fds, i = nfds; i--; pfd++) {
|
for (pfd = fds, i = nfds; i--; pfd++) {
|
||||||
|
|
|
@ -335,7 +335,7 @@ void test_timer_add_timeout(void)
|
||||||
ztest_test_pass();
|
ztest_test_pass();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern uint64_t z_timeout_end_calc(k_timeout_t timeout);
|
extern uint64_t sys_clock_timeout_end_calc(k_timeout_t timeout);
|
||||||
extern void sys_clock_announce(int32_t ticks);
|
extern void sys_clock_announce(int32_t ticks);
|
||||||
void test_timeout_end_calc(void)
|
void test_timeout_end_calc(void)
|
||||||
{
|
{
|
||||||
|
@ -343,15 +343,15 @@ void test_timeout_end_calc(void)
|
||||||
k_timeout_t timeout;
|
k_timeout_t timeout;
|
||||||
|
|
||||||
timeout = K_MSEC(DURATION);
|
timeout = K_MSEC(DURATION);
|
||||||
ret = z_timeout_end_calc(timeout);
|
ret = sys_clock_timeout_end_calc(timeout);
|
||||||
zassert_true(ret, "---timeout end calc---");
|
zassert_true(ret, "---timeout end calc---");
|
||||||
|
|
||||||
timeout.ticks = TEST_TIMEOUT;
|
timeout.ticks = TEST_TIMEOUT;
|
||||||
ret = z_timeout_end_calc(timeout);
|
ret = sys_clock_timeout_end_calc(timeout);
|
||||||
zassert_true(ret, "timeout end calc error");
|
zassert_true(ret, "timeout end calc error");
|
||||||
|
|
||||||
timeout = K_FOREVER;
|
timeout = K_FOREVER;
|
||||||
ret = z_timeout_end_calc(timeout);
|
ret = sys_clock_timeout_end_calc(timeout);
|
||||||
zassert_true(ret, "timeout end calc forever");
|
zassert_true(ret, "timeout end calc forever");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue