src/dpdk/lib/librte_timer/rte_timer.c
static void
timer_add(struct rte_timer *tim, unsigned int tim_lcore,
	  struct priv_timer *priv_timer)
{
	unsigned lvl;
	struct rte_timer *prev[MAX_SKIPLIST_DEPTH+1];

	/* find where exactly this element goes in the list of elements
	 * for each depth. */
	timer_get_prev_entries(tim->expire, tim_lcore, prev, priv_timer);

	/* now assign it a new level and add at that level */
	const unsigned tim_level = timer_get_skiplist_level(
			priv_timer[tim_lcore].curr_skiplist_depth);
	if (tim_level == priv_timer[tim_lcore].curr_skiplist_depth)
		priv_timer[tim_lcore].curr_skiplist_depth++;

	lvl = tim_level;
	while (lvl > 0) {
		tim->sl_next[lvl] = prev[lvl]->sl_next[lvl];
		prev[lvl]->sl_next[lvl] = tim;
		lvl--;
	}
	tim->sl_next[0] = prev[0]->sl_next[0];
	prev[0]->sl_next[0] = tim;

	/* save the lowest list entry into the expire field of the dummy hdr
	 * NOTE: this is not atomic on 32-bit*/
	priv_timer[tim_lcore].pending_head.expire = priv_timer[tim_lcore].\
			pending_head.sl_next[0]->expire;
}
/* call with lock held as necessary
 * add in list
 * timer must be in config state
 * timer must not be in a list
 */
call with lock held as necessary
add in list
timer must be in config state
timer must not be in a list
call with lock held as necessary add in list timer must be in config state timer must not be in a list
static void
timer_add(struct rte_timer *tim, unsigned int tim_lcore,
	  struct priv_timer *priv_timer)
{
	unsigned lvl;
	struct rte_timer *prev[MAX_SKIPLIST_DEPTH+1];
	timer_get_prev_entries(tim->expire, tim_lcore, prev, priv_timer);
	const unsigned tim_level = timer_get_skiplist_level(
			priv_timer[tim_lcore].curr_skiplist_depth);
	if (tim_level == priv_timer[tim_lcore].curr_skiplist_depth)
		priv_timer[tim_lcore].curr_skiplist_depth++;
	lvl = tim_level;
	while (lvl > 0) {
		tim->sl_next[lvl] = prev[lvl]->sl_next[lvl];
		prev[lvl]->sl_next[lvl] = tim;
		lvl--;
	}
	tim->sl_next[0] = prev[0]->sl_next[0];
	prev[0]->sl_next[0] = tim;
	priv_timer[tim_lcore].pending_head.expire = priv_timer[tim_lcore].\
			pending_head.sl_next[0]->expire;
}
static void timer_add ( struct rte_timer * tim , unsigned int tim_lcore , struct priv_timer * priv_timer ) { unsigned lvl ; struct rte_timer * prev [ MAX_SKIPLIST_DEPTH + 1 ] ; timer_get_prev_entries ( tim -> expire , tim_lcore , prev , priv_timer ) ; const unsigned tim_level = timer_get_skiplist_level ( priv_timer [ tim_lcore ] . curr_skiplist_depth ) ; if ( tim_level == priv_timer [ tim_lcore ] . curr_skiplist_depth ) priv_timer [ tim_lcore ] . curr_skiplist_depth ++ ; lvl = tim_level ; while ( lvl > 0 ) { tim -> sl_next [ lvl ] = prev [ lvl ] -> sl_next [ lvl ] ; prev [ lvl ] -> sl_next [ lvl ] = tim ; lvl -- ; } tim -> sl_next [ 0 ] = prev [ 0 ] -> sl_next [ 0 ] ; prev [ 0 ] -> sl_next [ 0 ] = tim ; priv_timer [ tim_lcore ] . pending_head . expire = priv_timer [ tim_lcore ] . pending_head . sl_next [ 0 ] -> expire ; }
call with lock held as necessary
 add in list
 timer must be in config state
 timer must not be in a list
call with lock held as necessary add in list timer must be in config state timer must not be in a list
/* find where exactly this element goes in the list of elements
	 * for each depth. */ /* now assign it a new level and add at that level */ /* save the lowest list entry into the expire field of the dummy hdr
	 * NOTE: this is not atomic on 32-bit*/