Commit a518f487 authored by Anas Nashif's avatar Anas Nashif
Browse files

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: default avatarAnas Nashif <anas.nashif@intel.com>
parent fe0872c0
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -313,7 +313,7 @@ code. For example, consider this design:

This code requires that the timeout value be inspected, which is no
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
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)
    {
        /* 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()) {
            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
uptime precision to prevent rollover bugs, handles special
: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
delta timeouts need to be interpreted relative to a "current time",
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
this function just once, as synchronously as possible to the timeout
creation in user code.  It should not be used on a "stored" timeout
+1 −1
Original line number Diff line number Diff line
@@ -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)
{
	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);
	do {
+1 −1
Original line number Diff line number Diff line
@@ -191,7 +191,7 @@ int64_t sys_clock_tick_get(void);
#define sys_clock_tick_get_32() (0)
#endif

uint64_t z_timeout_end_calc(k_timeout_t timeout);
uint64_t sys_clock_timeout_end_calc(k_timeout_t timeout);

#ifdef __cplusplus
}
+1 −1
Original line number Diff line number Diff line
@@ -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,
			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;
	k_spinlock_key_t key = k_spin_lock(&h->lock);

+1 −1
Original line number Diff line number Diff line
@@ -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
 * 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;

Loading