Fixup another level of compiler warnings, add _U() definition
This commit is contained in:
@ -76,4 +76,6 @@ typedef struct {
|
||||
int8_t sec; ///< 0..59
|
||||
} datetime_t;
|
||||
|
||||
#define bool_to_bit(x) ((uint)!!(x))
|
||||
|
||||
#endif
|
||||
|
@ -11,7 +11,7 @@ static_assert(sizeof(critical_section_t) == 8, "");
|
||||
#endif
|
||||
|
||||
void critical_section_init(critical_section_t *critsec) {
|
||||
critical_section_init_with_lock_num(critsec, spin_lock_claim_unused(true));
|
||||
critical_section_init_with_lock_num(critsec, (uint)spin_lock_claim_unused(true));
|
||||
}
|
||||
|
||||
void critical_section_init_with_lock_num(critical_section_t *critsec, uint lock_num) {
|
||||
|
@ -23,7 +23,7 @@ void __time_critical_func(mutex_enter_blocking)(mutex_t *mtx) {
|
||||
do {
|
||||
uint32_t save = spin_lock_blocking(mtx->core.spin_lock);
|
||||
if (mtx->owner < 0) {
|
||||
mtx->owner = get_core_num();
|
||||
mtx->owner = (int8_t)get_core_num();
|
||||
block = false;
|
||||
}
|
||||
spin_unlock(mtx->core.spin_lock, save);
|
||||
@ -37,10 +37,10 @@ bool __time_critical_func(mutex_try_enter)(mutex_t *mtx, uint32_t *owner_out) {
|
||||
bool entered;
|
||||
uint32_t save = spin_lock_blocking(mtx->core.spin_lock);
|
||||
if (mtx->owner < 0) {
|
||||
mtx->owner = get_core_num();
|
||||
mtx->owner = (int8_t)get_core_num();
|
||||
entered = true;
|
||||
} else {
|
||||
if (owner_out) *owner_out = mtx->owner;
|
||||
if (owner_out) *owner_out = (uint32_t) mtx->owner;
|
||||
entered = false;
|
||||
}
|
||||
spin_unlock(mtx->core.spin_lock, save);
|
||||
@ -57,7 +57,7 @@ bool __time_critical_func(mutex_enter_block_until)(mutex_t *mtx, absolute_time_t
|
||||
do {
|
||||
uint32_t save = spin_lock_blocking(mtx->core.spin_lock);
|
||||
if (mtx->owner < 0) {
|
||||
mtx->owner = get_core_num();
|
||||
mtx->owner = (int8_t)get_core_num();
|
||||
block = false;
|
||||
}
|
||||
spin_unlock(mtx->core.spin_lock, save);
|
||||
|
@ -63,7 +63,7 @@ bool __time_critical_func(sem_release)(semaphore_t *sem) {
|
||||
uint32_t save = spin_lock_blocking(sem->core.spin_lock);
|
||||
int32_t count = sem->permits;
|
||||
if (count < sem->max_permits) {
|
||||
sem->permits = count + 1;
|
||||
sem->permits = (int16_t)(count + 1);
|
||||
__sev();
|
||||
rc = true;
|
||||
} else {
|
||||
|
@ -152,7 +152,7 @@ static inline absolute_time_t make_timeout_time_ms(uint32_t ms) {
|
||||
* in case of overflow)
|
||||
*/
|
||||
static inline int64_t absolute_time_diff_us(absolute_time_t from, absolute_time_t to) {
|
||||
return to_us_since_boot(to) - to_us_since_boot(from);
|
||||
return (int64_t)(to_us_since_boot(to) - to_us_since_boot(from));
|
||||
}
|
||||
|
||||
/*! \brief The timestamp representing the end of time; no timestamp is after this
|
||||
|
@ -71,12 +71,12 @@ bool timer_pool_entry_comparator(void *user_data, pheap_node_id_t a, pheap_node_
|
||||
}
|
||||
|
||||
static inline alarm_id_t make_public_id(uint8_t id_high, pheap_node_id_t id) {
|
||||
return ((uint)id_high << 8u * sizeof(id)) | id;
|
||||
return (alarm_id_t)(((uint)id_high << 8u * sizeof(id)) | id);
|
||||
}
|
||||
|
||||
static alarm_id_t add_alarm_under_lock(alarm_pool_t *pool, absolute_time_t time, alarm_callback_t callback,
|
||||
void *user_data, alarm_id_t reuse_id, bool create_if_past, bool *missed) {
|
||||
alarm_id_t id;
|
||||
static pheap_node_id_t add_alarm_under_lock(alarm_pool_t *pool, absolute_time_t time, alarm_callback_t callback,
|
||||
void *user_data, pheap_node_id_t reuse_id, bool create_if_past, bool *missed) {
|
||||
pheap_node_id_t id;
|
||||
if (reuse_id) {
|
||||
assert(!ph_contains(pool->heap, reuse_id));
|
||||
id = reuse_id;
|
||||
@ -137,10 +137,10 @@ static void alarm_pool_alarm_callback(uint alarm_num) {
|
||||
// todo think more about whether we want to keep calling
|
||||
if (repeat < 0 && pool->alarm_in_progress) {
|
||||
assert(pool->alarm_in_progress == make_public_id(id_high, next_id));
|
||||
add_alarm_under_lock(pool, delayed_by_us(target, -repeat), callback, user_data, next_id, true, NULL);
|
||||
add_alarm_under_lock(pool, delayed_by_us(target, (uint64_t)-repeat), callback, user_data, next_id, true, NULL);
|
||||
} else if (repeat > 0 && pool->alarm_in_progress) {
|
||||
assert(pool->alarm_in_progress == make_public_id(id_high, next_id));
|
||||
add_alarm_under_lock(pool, delayed_by_us(get_absolute_time(), repeat), callback, user_data, next_id,
|
||||
add_alarm_under_lock(pool, delayed_by_us(get_absolute_time(), (uint64_t)repeat), callback, user_data, next_id,
|
||||
true, NULL);
|
||||
} else {
|
||||
// need to return the id to the heap
|
||||
@ -164,7 +164,7 @@ alarm_pool_t *alarm_pool_create(uint hardware_alarm_num, uint max_timers) {
|
||||
pool->heap = ph_create(max_timers, timer_pool_entry_comparator, pool);
|
||||
pool->entries = (alarm_pool_entry_t *)calloc(max_timers, sizeof(alarm_pool_entry_t));
|
||||
pool->entry_ids_high = (uint8_t *)calloc(max_timers, sizeof(uint8_t));
|
||||
pool->hardware_alarm_num = hardware_alarm_num;
|
||||
pool->hardware_alarm_num = (uint8_t)hardware_alarm_num;
|
||||
pools[hardware_alarm_num] = pool;
|
||||
return pool;
|
||||
}
|
||||
@ -185,7 +185,7 @@ alarm_id_t alarm_pool_add_alarm_at(alarm_pool_t *pool, absolute_time_t time, ala
|
||||
void *user_data, bool fire_if_past) {
|
||||
bool missed = false;
|
||||
|
||||
uint public_id;
|
||||
alarm_id_t public_id;
|
||||
do {
|
||||
uint8_t id_high = 0;
|
||||
uint32_t save = spin_lock_blocking(pool->lock);
|
||||
@ -205,9 +205,9 @@ alarm_id_t alarm_pool_add_alarm_at(alarm_pool_t *pool, absolute_time_t time, ala
|
||||
public_id = 0;
|
||||
break;
|
||||
} else if (repeat < 0) {
|
||||
time = delayed_by_us(time, -repeat);
|
||||
time = delayed_by_us(time, (uint64_t)-repeat);
|
||||
} else {
|
||||
time = delayed_by_us(get_absolute_time(), repeat);
|
||||
time = delayed_by_us(get_absolute_time(), (uint64_t)repeat);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
@ -270,7 +270,8 @@ bool alarm_pool_add_repeating_timer_us(alarm_pool_t *pool, int64_t delay_us, rep
|
||||
out->callback = callback;
|
||||
out->delay_us = delay_us;
|
||||
out->user_data = user_data;
|
||||
out->alarm_id = alarm_pool_add_alarm_at(pool, make_timeout_time_us(delay_us >= 0 ? delay_us : -delay_us), repeating_timer_callback, out, true);
|
||||
out->alarm_id = alarm_pool_add_alarm_at(pool, make_timeout_time_us((uint64_t)(delay_us >= 0 ? delay_us : -delay_us)),
|
||||
repeating_timer_callback, out, true);
|
||||
return out->alarm_id > 0;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ static inline uint queue_get_level_unsafe(queue_t *q) {
|
||||
if (rc < 0) {
|
||||
rc += + q->element_count + 1;
|
||||
}
|
||||
return rc;
|
||||
return (uint)rc;
|
||||
}
|
||||
|
||||
/*! \brief Check of level of the specified queue.
|
||||
|
@ -11,7 +11,7 @@
|
||||
pheap_t *ph_create(uint max_nodes, pheap_comparator comparator, void *user_data) {
|
||||
invalid_params_if(PHEAP, !max_nodes || max_nodes >= (1u << sizeof(pheap_node_id_t)));
|
||||
pheap_t *heap = calloc(1, sizeof(pheap_t));
|
||||
heap->max_nodes = max_nodes;
|
||||
heap->max_nodes = (pheap_node_id_t) max_nodes;
|
||||
heap->comparator = comparator;
|
||||
heap->nodes = calloc(max_nodes, sizeof(pheap_node_t));
|
||||
heap->user_data = user_data;
|
||||
@ -23,8 +23,8 @@ void ph_clear(pheap_t *heap) {
|
||||
heap->root_id = 0;
|
||||
heap->free_head_id = 1;
|
||||
heap->free_tail_id = heap->max_nodes;
|
||||
for(uint i = 1; i < heap->max_nodes; i++) {
|
||||
ph_get_node(heap, i)->sibling = i + 1;
|
||||
for(pheap_node_id_t i = 1; i < heap->max_nodes; i++) {
|
||||
ph_get_node(heap, i)->sibling = (pheap_node_id_t)(i + 1);
|
||||
}
|
||||
ph_get_node(heap, heap->max_nodes)->sibling = 0;
|
||||
}
|
||||
|
@ -11,8 +11,8 @@
|
||||
void queue_init_with_spinlock(queue_t *q, uint element_size, uint element_count, uint spinlock_num) {
|
||||
q->lock = spin_lock_instance(spinlock_num);
|
||||
q->data = (uint8_t *)calloc(element_count + 1, element_size);
|
||||
q->element_count = element_count;
|
||||
q->element_size = element_size;
|
||||
q->element_count = (uint16_t)element_count;
|
||||
q->element_size = (uint16_t)element_size;
|
||||
q->wptr = 0;
|
||||
q->rptr = 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user