kernel/kheap: move to timepoint API
Remove sys_clock_timeout_end_calc() usage. Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit is contained in:
parent
3c9249cedc
commit
77b7eb1199
1 changed files with 4 additions and 7 deletions
|
@ -64,11 +64,9 @@ SYS_INIT_NAMED(statics_init_post, statics_init, POST_KERNEL, 0);
|
|||
void *k_heap_aligned_alloc(struct k_heap *h, size_t align, size_t bytes,
|
||||
k_timeout_t timeout)
|
||||
{
|
||||
int64_t now, end = sys_clock_timeout_end_calc(timeout);
|
||||
k_timepoint_t end = sys_timepoint_calc(timeout);
|
||||
void *ret = NULL;
|
||||
|
||||
end = K_TIMEOUT_EQ(timeout, K_FOREVER) ? INT64_MAX : end;
|
||||
|
||||
k_spinlock_key_t key = k_spin_lock(&h->lock);
|
||||
|
||||
SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_heap, aligned_alloc, h, timeout);
|
||||
|
@ -80,9 +78,8 @@ void *k_heap_aligned_alloc(struct k_heap *h, size_t align, size_t bytes,
|
|||
while (ret == NULL) {
|
||||
ret = sys_heap_aligned_alloc(&h->heap, align, bytes);
|
||||
|
||||
now = sys_clock_tick_get();
|
||||
if (!IS_ENABLED(CONFIG_MULTITHREADING) ||
|
||||
(ret != NULL) || ((end - now) <= 0)) {
|
||||
(ret != NULL) || K_TIMEOUT_EQ(timeout, K_NO_WAIT)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -96,8 +93,8 @@ void *k_heap_aligned_alloc(struct k_heap *h, size_t align, size_t bytes,
|
|||
*/
|
||||
}
|
||||
|
||||
(void) z_pend_curr(&h->lock, key, &h->wait_q,
|
||||
K_TICKS(end - now));
|
||||
timeout = sys_timepoint_timeout(end);
|
||||
(void) z_pend_curr(&h->lock, key, &h->wait_q, timeout);
|
||||
key = k_spin_lock(&h->lock);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue