FAR sigpendq_t *sig_removependingsignal(FAR struct tcb_s *stcb, int signo) { FAR struct task_group_s *group = stcb->group; FAR sigpendq_t *currsig; FAR sigpendq_t *prevsig; irqstate_t saved_state; DEBUGASSERT(group); saved_state = irqsave(); for (prevsig = NULL, currsig = (FAR sigpendq_t*)group->sigpendingq.head; (currsig && currsig->info.si_signo != signo); prevsig = currsig, currsig = currsig->flink); if (currsig) { if (prevsig) { sq_remafter((FAR sq_entry_t*)prevsig, &group->sigpendingq); } else { sq_remfirst(&group->sigpendingq); } } irqrestore(saved_state); return currsig; }
FAR sigpendq_t *sig_removependingsignal(FAR struct tcb_s *stcb, int signo) { FAR struct task_group_s *group = stcb->group; FAR sigpendq_t *currsig; FAR sigpendq_t *prevsig; irqstate_t flags; DEBUGASSERT(group); flags = enter_critical_section(); for (prevsig = NULL, currsig = (FAR sigpendq_t *)group->tg_sigpendingq.head; (currsig && currsig->info.si_signo != signo); prevsig = currsig, currsig = currsig->flink); if (currsig) { if (prevsig) { sq_remafter((FAR sq_entry_t *)prevsig, &group->tg_sigpendingq); } else { sq_remfirst(&group->tg_sigpendingq); } } leave_critical_section(flags); return currsig; }
void sq_rem(FAR sq_entry_t *node, sq_queue_t *queue) { if (queue->head && node) { if (node == queue->head) { queue->head = node->flink; if (node == queue->tail) { queue->tail = NULL; } } else { FAR sq_entry_t *prev; for(prev = (FAR sq_entry_t*)queue->head; prev && prev->flink != node; prev = prev->flink); if (prev) { sq_remafter(prev, queue); } } } }
int uip_backlogdelete(FAR struct uip_conn *conn, FAR struct uip_conn *blconn) { FAR struct uip_backlog_s *bls; FAR struct uip_blcontainer_s *blc; FAR struct uip_blcontainer_s *prev; nllvdbg("conn=%p blconn=%p\n", conn, blconn); #ifdef CONFIG_DEBUG if (!conn) { return -EINVAL; } #endif bls = conn->backlog; if (bls) { /* Find the container hold the connection */ for (blc = (FAR struct uip_blcontainer_s *)sq_peek(&bls->bl_pending), prev = NULL; blc; prev = blc, blc = (FAR struct uip_blcontainer_s *)sq_next(&blc->bc_node)) { if (blc->bc_conn == blconn) { if (prev) { /* Remove the a container from the middle of the list of * pending connections */ (void)sq_remafter(&prev->bc_node, &bls->bl_pending); } else { /* Remove the a container from the head of the list of * pending connections */ (void)sq_remfirst(&bls->bl_pending); } /* Put container in the free list */ blc->bc_conn = NULL; sq_addlast(&blc->bc_node, &bls->bl_free); return OK; } } nlldbg("Failed to find pending connection\n"); return -EINVAL; } return OK; }
static int net_match(FAR struct net_route_s *route, FAR void *arg) { FAR struct route_match_s *match = ( FAR struct route_match_s *)arg; /* To match, the masked target address must be the same, and the masks * must be the same. */ if (net_ipv4addr_maskcmp(route->target, match->target, match->netmask) && net_ipv4addr_cmp(route->netmask, match->netmask)) { /* They match.. Remove the entry from the routing table */ if (match->prev) { (void)sq_remafter((FAR sq_entry_t *)match->prev, (FAR sq_queue_t *)&g_routes); } else { (void)sq_remfirst((FAR sq_queue_t *)&g_routes); } /* And free the routing table entry by adding it to the free list */ net_freeroute(route); /* Return a non-zero value to terminate the traversal */ return 1; } /* Next time we are here, this will be the previous entry */ match->prev = route; return 0; }
int wd_cancel (WDOG_ID wdid) { wdog_t *curr; wdog_t *prev; irqstate_t saved_state; int ret = ERROR; /* Prohibit timer interactions with the timer queue until the * cancellation is complete */ saved_state = irqsave(); /* Make sure that the watchdog is initialed (non-NULL) and is still active */ if (wdid && wdid->active) { /* Search the g_wdactivelist for the target FCB. We can't use sq_rem * to do this because there are additional operations that need to be * done. */ prev = NULL; curr = (wdog_t*)g_wdactivelist.head; while((curr) && (curr != wdid)) { prev = curr; curr = curr->next; } /* Check if the watchdog was found in the list. If not, then an OS * error has occurred because the watchdog is marked active! */ if (!curr) { PANIC(OSERR_WDOGNOTFOUND); } else { /* If there is a watchdog in the timer queue after the one that * is being canceled, then it inherits the remaining ticks. */ if (curr->next) { curr->next->lag += curr->lag; } /* Now, remove the watchdog from the timer queue */ if (prev) { (void)sq_remafter((FAR sq_entry_t*)prev, &g_wdactivelist); } else { (void)sq_remfirst(&g_wdactivelist); } wdid->next = NULL; /* Return success */ ret = OK; } /* Mark the watchdog inactive */ wdid->active = false; } irqrestore(saved_state); return ret; }