/* * 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=0e0694ff1a7791274946b7f51bae692da0001a08'>refslogtreecommitdiff
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2016-12-26 14:09:28 -0200
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-12-26 14:09:28 -0200
commit0e0694ff1a7791274946b7f51bae692da0001a08 (patch)
tree53d28f58d793c151aa870f17d38ddec6ac01ec7a /include/rdma/ib_verbs.h
parent65390ea01ce678379da32b01f39fcfac4903f256 (diff)
parentc739c0a7c3c2472d7562b8f802cdce44d2597c8b (diff)
Merge branch 'patchwork' into v4l_for_linus
* patchwork: [media] s5k4ecgx: select CRC32 helper [media] dvb: avoid warning in dvb_net [media] v4l: tvp5150: Don't override output pinmuxing at stream on/off time [media] v4l: tvp5150: Fix comment regarding output pin muxing [media] v4l: tvp5150: Reset device at probe time, not in get/set format handlers [media] pctv452e: move buffer to heap, no mutex [media] media/cobalt: use pci_irq_allocate_vectors [media] cec: fix race between configuring and unconfiguring [media] cec: move cec_report_phys_addr into cec_config_thread_func [media] cec: replace cec_report_features by cec_fill_msg_report_features [media] cec: update log_addr[] before finishing configuration [media] cec: CEC_MSG_GIVE_FEATURES should abort for CEC version < 2 [media] cec: when canceling a message, don't overwrite old status info [media] cec: fix report_current_latency [media] smiapp: Make suspend and resume functions __maybe_unused [media] smiapp: Implement power-on and power-off sequences without runtime PM
Diffstat (limited to 'include/rdma/ib_verbs.h')