/* * Simple pointer stack * * (c) 2010 Arnaldo Carvalho de Melo */ #include "util.h" #include "pstack.h" #include "debug.h" #include #include struct pstack { unsigned short top; unsigned short max_nr_entries; void *entries[0]; }; struct pstack *pstack__new(unsigned short max_nr_entries) { struct pstack *pstack = zalloc((sizeof(*pstack) + max_nr_entries * sizeof(void *))); if (pstack != NULL) pstack->max_nr_entries = max_nr_entries; return pstack; } void pstack__delete(struct pstack *pstack) { free(pstack); } bool pstack__empty(const struct pstack *pstack) { return pstack->top == 0; } void pstack__remove(struct pstack *pstack, void *key) { unsigned short i = pstack->top, last_index = pstack->top - 1; while (i-- != 0) { if (pstack->entries[i] == key) { if (i < last_index) memmove(pstack->entries + i, pstack->entries + i + 1, (last_index - i) * sizeof(void *)); --pstack->top; return; } } pr_err("%s: %p not on the pstack!\n", __func__, key); } void pstack__push(struct pstack *pstack, void *key) { if (pstack->top == pstack->max_nr_entries) { pr_err("%s: top=%d, overflow!\n", __func__, pstack->top); return; } pstack->entries[pstack->top++] = key; } void *pstack__pop(struct pstack *pstack) { void *ret; if (pstack->top == 0) { pr_err("%s: underflow!\n", __func__); return NULL; } ret = pstack->entries[--pstack->top]; pstack->entries[pstack->top] = NULL; return ret; } void *pstack__peek(struct pstack *pstack) { if (pstack->top == 0) return NULL; return pstack->entries[pstack->top - 1]; } .cgi/linux/net-next.git/refs/?h=nds-private-remove&id=1bae6c99decf9137069646b593d3439171a8a8e2'>refslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-01-30 22:05:52 -0500
committerDavid S. Miller <davem@davemloft.net>2017-01-30 22:05:52 -0500
commit1bae6c99decf9137069646b593d3439171a8a8e2 (patch)
tree431604a568cd2303973470de326bd9731370a025 /tools/objtool/Build
parent63c190429020a9701b42887ac22c28f287f1762f (diff)
parent2b2d3eb41c920b47df2fcedd1489cf748bd09466 (diff)
Merge branch 'sh_eth-E-DMAC-interrupt-mask-cleanups'
Sergei Shtylyov says: ==================== sh_eth: E-DMAC interrupt mask cleanups Here's a set of 3 patches against DaveM's 'net-next.git' repo. The main goal of this set is to stop using the bare numbers for the E-DMAC interrupt masks. [1/3] sh_eth: rename EESIPR bits [2/3] sh_eth: add missing EESIPR bits [3/3] sh_eth: stop using bare numbers for EESIPR values ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/objtool/Build')