void k_queue_merge_slist(struct k_queue *queue, sys_slist_t *list) { __ASSERT(!sys_slist_is_empty(list), "list must not be empty"); /* * note: this works as long as: * - the slist implementation keeps the next pointer as the first * field of the node object type * - list->tail->next = NULL. */ k_queue_append_list(queue, list->head, list->tail); sys_slist_init(list); }
static void _gpio_sch_manage_callback(struct device *dev) { struct gpio_sch_data *gpio = dev->driver_data; /* Start the thread only when relevant */ if (!sys_slist_is_empty(&gpio->callbacks) && gpio->cb_enabled) { if (!gpio->poll) { LOG_DBG("Starting SCH GPIO polling thread"); gpio->poll = 1U; k_thread_create(&gpio->polling_thread, gpio->polling_stack, GPIO_SCH_POLLING_STACK_SIZE, (k_thread_entry_t)gpio_sch_poll_status, dev, NULL, NULL, K_PRIO_COOP(1), 0, 0); } } else { gpio->poll = 0U; } }
static void tcp_retry_expired(struct k_timer *timer) { struct net_tcp *tcp = CONTAINER_OF(timer, struct net_tcp, retry_timer); struct net_pkt *pkt; /* Double the retry period for exponential backoff and resent * the first (only the first!) unack'd packet. */ if (!sys_slist_is_empty(&tcp->sent_list)) { tcp->retry_timeout_shift++; if (tcp->retry_timeout_shift > CONFIG_NET_TCP_RETRY_COUNT) { abort_connection(tcp); return; } k_timer_start(&tcp->retry_timer, retry_timeout(tcp), 0); pkt = CONTAINER_OF(sys_slist_peek_head(&tcp->sent_list), struct net_pkt, sent_list); if (net_pkt_sent(pkt)) { do_ref_if_needed(tcp, pkt); net_pkt_set_sent(pkt, false); } net_pkt_set_queued(pkt, true); if (net_tcp_send_pkt(pkt) < 0 && !is_6lo_technology(pkt)) { NET_DBG("[%p] pkt %p send failed", tcp, pkt); net_pkt_unref(pkt); } else { NET_DBG("[%p] sent pkt %p", tcp, pkt); if (IS_ENABLED(CONFIG_NET_STATISTICS_TCP) && !is_6lo_technology(pkt)) { net_stats_update_tcp_seg_rexmit(); } } } else if (IS_ENABLED(CONFIG_NET_TCP_TIME_WAIT)) {
void *k_queue_get(struct k_queue *queue, s32_t timeout) { unsigned int key; void *data; key = irq_lock(); if (likely(!sys_slist_is_empty(&queue->data_q))) { data = sys_slist_get_not_empty(&queue->data_q); irq_unlock(key); return data; } if (timeout == K_NO_WAIT) { irq_unlock(key); return NULL; } _pend_current_thread(&queue->wait_q, timeout); return _Swap(key) ? NULL : _current->base.swap_data; }
static inline bool verify_content_amount(sys_slist_t *list, int amount) { sys_snode_t *node; sys_snode_t *s_node; int count; if (sys_slist_is_empty(list)) { return false; } if (!sys_slist_peek_head(list)) { return false; } if (!sys_slist_peek_tail(list)) { return false; } count = 0; SYS_SLIST_FOR_EACH_NODE(list, node) { count++; } if (count != amount) { return false; } count = 0; SYS_SLIST_FOR_EACH_NODE_SAFE(list, node, s_node) { count++; } if (count != amount) { return false; } return true; }