本文整理汇总了C++中INIT_LIST函数的典型用法代码示例。如果您正苦于以下问题:C++ INIT_LIST函数的具体用法?C++ INIT_LIST怎么用?C++ INIT_LIST使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了INIT_LIST函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: INIT_LIST
static struct meta_lock *lock_alloc(spdid_t spd)
{
struct meta_lock *l;
struct meta_lock *snd, *lst;
l = (struct meta_lock*)malloc(sizeof(struct meta_lock));
if (!l) return NULL;
l->b_thds.thd_id = 0;
INIT_LIST(&(l->b_thds), next, prev);
/* FIXME: check for lock_id overflow */
l->lock_id = lock_id++;
l->owner = 0;
l->gen_num = 0;
l->spd = spd;
INIT_LIST(l, next, prev);
assert(&locks != l);
snd = FIRST_LIST(&locks, next, prev);
lst = LAST_LIST(&locks, next, prev);
(l)->next = (&locks)->next;
(l)->prev = (&locks);
(&locks)->next = (l);
(l)->next->prev = (l);
assert(FIRST_LIST(&locks, next, prev) == l);
assert(LAST_LIST(l, next, prev) == &locks);
if (lst != &locks) {
assert(LAST_LIST(&locks, next, prev) == lst);
assert(FIRST_LIST(lst, next, prev) == &locks);
}
assert(FIRST_LIST(l, next, prev) == snd && LAST_LIST(snd, next, prev) == l);
// lock_print_all();
return l;
}
示例2: init_spds
static void
init_spds(void)
{
int i, mgr;
for (mgr = 0 ; mgr < NUM_TMEM_MGR ; mgr++) {
INIT_LIST(&components[mgr], next, prev);
for (i = 0 ; i < MAX_NUM_SPDS ; i++) {
struct component *c;
switch (mgr) {
case STK_MGR:
if (-1 == stkmgr_spd_concurrency_estimate(i)) continue;
break;
case CBUF_MGR:
if (-1 == cbufmgr_spd_concurrency_estimate(i)) continue;
break;
default: BUG();
}
c = malloc(sizeof(struct component));
if (!c) BUG();
memset(c, 0, sizeof(struct component));
c->spdid = i;
c->allocated = DEFAULT_TMEM_AMNT;
c->mgr = mgr;
INIT_LIST(c, next, prev);
ADD_LIST(&components[mgr], c, next, prev);
ncomps++;
}
}
}
示例3: rdmm_list_init
/*--------------------------------------*/
static struct rec_data_mm_list *
rdmm_list_init(long id)
{
struct rec_data_mm_list *rdmm_list;
/* FIXME: A BUG here that bitmap will be all 0 */
rdmm_list = cslab_alloc_rdmm_ls();
assert(rdmm_list);
rdmm_list->id = id;
rdmm_list->fcnt = fcounter;
rdmm_list->recordable = 1;
rdmm_list->head = rdmm_list->tail = &rdmm_list->first;
if (cvect_add(&rec_mm_vect, rdmm_list, rdmm_list->id)) {
printc("Cli: can not add list into cvect\n");
return NULL;
}
/* printc("Init a list using id %d (vect @ %p ", id,&rec_mm_vect); */
/* printc("list @ %p)\n", rdmm_list); */
#if (!LAZY_RECOVERY)
INIT_LIST(rdmm_list, next, prev);
if (!all_rdmm_list) {
all_rdmm_list = cslab_alloc_rdmm_ls();
assert(all_rdmm_list);
INIT_LIST(all_rdmm_list, next, prev);
} else {
ADD_LIST(all_rdmm_list, rdmm_list, next, prev);
}
#endif
return rdmm_list;
}
示例4: mpClockComp
MagPipelineManager::MagPipelineManager(MagClock *mpClockComp):
mpClockComp(mpClockComp){
INIT_LIST(&mVideoPipelineHead);
INIT_LIST(&mAudioPipelineHead);
mpClockComp->init();
}
示例5: __sg_sched_block
// track blocked threads here for all clients (on each thread stack)
int __sg_sched_block(spdid_t spdid, int dependency_thd)
{
struct blocked_thd blk_thd;
// add to list
cos_sched_lock_take();
if (unlikely(!bthds[spdid].next)) {
INIT_LIST(&bthds[spdid], next, prev);
}
INIT_LIST(&blk_thd, next, prev);
blk_thd.id = cos_get_thd_id();
blk_thd.dep_thd = dependency_thd;
/* printc("add to the list..... thd %d\n", cos_get_thd_id()); */
ADD_LIST(&bthds[spdid], &blk_thd, next, prev);
cos_sched_lock_release();
sched_block(spdid, dependency_thd);
// remove from list in both normal path and reflect path
cos_sched_lock_take();
/* printc("remove from the list..... thd %d\n", cos_get_thd_id()); */
REM_LIST(&blk_thd, next, prev);
cos_sched_lock_release();
return 0;
}
示例6: main
int main(int argc, char *argv[])
{
#define COUNT (10)
struct mydata data[COUNT];
int i;
struct mydata *pcur, *plast = data;
INIT_LIST(plast);
plast->data1 = -222;
plast->data2 = -999000.0;
for(i=1; i<COUNT; i++) {
pcur = data + i;
INIT_LIST(pcur);
pcur->data1 = i;
pcur->data2 = i + 999300.0;
ADD_AFTER(plast, pcur);
plast = NEXT(plast);
}
struct mydata *ptr = data;
while(ptr) {
printf("data1=%d, data2=%f\n", ptr->data1, ptr->data2);
ptr = NEXT(ptr);
}
ptr = data + COUNT - 1;
while(ptr) {
printf("data1=%d, data2=%f\n", ptr->data1, ptr->data2);
ptr = PREV(ptr);
}
return 0;
}
示例7: isc__task_create
ISC_TASKFUNC_SCOPE isc_result_t
isc__task_create(isc_taskmgr_t *manager0, unsigned int quantum,
isc_task_t **taskp)
{
isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
isc__task_t *task;
isc_boolean_t exiting;
isc_result_t result;
REQUIRE(VALID_MANAGER(manager));
REQUIRE(taskp != NULL && *taskp == NULL);
task = isc_mem_get(manager->mctx, sizeof(*task));
if (task == NULL)
return (ISC_R_NOMEMORY);
XTRACE("isc_task_create");
task->manager = manager;
result = isc_mutex_init(&task->lock);
if (result != ISC_R_SUCCESS) {
isc_mem_put(manager->mctx, task, sizeof(*task));
return (result);
}
task->state = task_state_idle;
task->references = 1;
INIT_LIST(task->events);
INIT_LIST(task->on_shutdown);
task->quantum = quantum;
task->flags = 0;
task->now = 0;
memset(task->name, 0, sizeof(task->name));
task->tag = NULL;
INIT_LINK(task, link);
INIT_LINK(task, ready_link);
INIT_LINK(task, ready_priority_link);
exiting = ISC_FALSE;
LOCK(&manager->lock);
if (!manager->exiting) {
if (task->quantum == 0)
task->quantum = manager->default_quantum;
APPEND(manager->tasks, task, link);
} else
exiting = ISC_TRUE;
UNLOCK(&manager->lock);
if (exiting) {
DESTROYLOCK(&task->lock);
isc_mem_put(manager->mctx, task, sizeof(*task));
return (ISC_R_SHUTTINGDOWN);
}
task->common.methods = (isc_taskmethods_t *)&taskmethods;
task->common.magic = ISCAPI_TASK_MAGIC;
task->common.impmagic = TASK_MAGIC;
*taskp = (isc_task_t *)task;
return (ISC_R_SUCCESS);
}
示例8: addComponentList
static OMX_S32 addComponentList(OMX_PTR hLib,
comp_reg_func_t regFunc,
comp_dereg_func_t deregFunc){
MagOMX_Component_Registration_t *regInfo;
Component_Entry_t *entry;
OMX_U32 u = 0;
regInfo = regFunc();
if (NULL != regInfo){
entry = (Component_Entry_t *)mag_mallocz(sizeof(Component_Entry_t));
MAG_ASSERT(entry != NULL);
INIT_LIST(&entry->node);
entry->regInfo = regInfo;
entry->deregFunc = deregFunc;
entry->libHandle = hLib;
entry->initialized = OMX_FALSE;
AGILE_LOGD("add the component name = %s", regInfo->name);
list_add_tail(&entry->node, &gOmxCore->LoadedCompListHead);
for (u = 0; u < regInfo->roles_num; u++){
gOmxCore->roleToComponentTable->addItem(gOmxCore->roleToComponentTable, entry, regInfo->roles[u]);
AGILE_LOGD("add the component role %d: %s", u, regInfo->roles[u]);
}
gOmxCore->componentToRoleTable->addItem(gOmxCore->componentToRoleTable, entry, regInfo->name);
return 0;
}else{
AGILE_LOGE("failed to do regFunc[%p]()", regFunc);
return -1;
}
}
示例9: ldap_rdatalist_copy
isc_result_t
ldap_rdatalist_copy(isc_mem_t *mctx, ldapdb_rdatalist_t source,
ldapdb_rdatalist_t *target)
{
dns_rdatalist_t *rdlist;
dns_rdatalist_t *new_rdlist;
isc_result_t result;
REQUIRE(mctx != NULL);
REQUIRE(target != NULL);
INIT_LIST(*target);
rdlist = HEAD(source);
while (rdlist != NULL) {
new_rdlist = NULL;
CHECK(rdatalist_clone(mctx, rdlist, &new_rdlist));
APPEND(*target, new_rdlist, link);
rdlist = NEXT(rdlist, link);
}
return ISC_R_SUCCESS;
cleanup:
ldapdb_rdatalist_destroy(mctx, target);
return result;
}
示例10: cos_init
void cos_init(void *arg)
{
lock_static_init(&evt_lock);
cos_map_init_static(&evt_map);
if (mapping_create(NULL) != 0) BUG();
INIT_LIST(&grps, next, prev);
}
示例11: __cbuf_desc_alloc
static struct cbuf_alloc_desc *
__cbuf_desc_alloc(int cbid, int size, void *addr, struct cbuf_meta *cm, int tmem)
{
struct cbuf_alloc_desc *d;
int idx = ((int)addr >> PAGE_ORDER);
assert(addr && cm);
assert(cm->nfo.c.ptr == idx);
assert(__cbuf_alloc_lookup(idx) == NULL);
assert((!tmem && !(cm->nfo.c.flags & CBUFM_TMEM)) ||
(tmem && cm->nfo.c.flags & CBUFM_TMEM));
d = cslab_alloc_desc();
if (!d) return NULL;
d->cbid = cbid;
d->addr = addr;
d->length = size;
d->meta = cm;
d->tmem = tmem;
INIT_LIST(d, next, prev);
//ADD_LIST(&cbuf_alloc_freelists, d, next, prev);
if (tmem) d->flhead = &cbuf_alloc_freelists;
else d->flhead = __cbufp_freelist_get(size);
cvect_add(&alloc_descs, d, idx);
return d;
}
示例12: main
int main(int argc, char *argv[])
{
struct child_st *c1;
struct child_st *c2;
struct child_st *c3;
struct child_st *tmp;
uint8_t s1[] = "The first node";
uint8_t s2[] = "The second node";
uint8_t s3[] = "The third node";
INIT_LIST(parent, p);
p->ops->create(&c1, s1, strlen(s1));
p->ops->add(p, c1);
p->ops->print(p);
p->ops->create(&c2, s2, strlen(s2));
p->ops->add(p, c2);
p->ops->print(p);
p->ops->create(&c3, s3, strlen(s3));
p->ops->add(p, c3);
p->ops->print(p);
tmp = p->ops->get(p, "The third node", 14);
if (tmp)
printf("Get Right? name (%d bytes): %s\n", tmp->nlen, tmp->name);
else
printf("Not found\n");
p->ops->del(p, c2);
p->ops->print(p);
return 0;
}
示例13: rb_init
static void rb_init(rb_meta_t *rbm, ring_buff_t *rb)
{
int i;
for (i = 0 ; i < RB_SIZE ; i++) {
rb->packets[i].status = RB_EMPTY;
}
memset(rbm, 0, sizeof(rb_meta_t));
rbm->rb_head = 0;
rbm->rb_tail = RB_SIZE-1;
rbm->rb = rb;
// rbm->curr_buffs = rbm->max_buffs = 0;
// rbm->tot_principal = rbm->max_principal = 0;
lock_static_init(&rbm->l);
INIT_LIST(&rbm->used_pages, next, prev);
INIT_LIST(&rbm->avail_pages, next, prev);
}
示例14: init_lru
void init_lru(){
lru = zmalloc(sizeof(LRU_list));
lru->head = zmalloc(sizeof(LRU_node));
lru->tail = zmalloc(sizeof(LRU_node));
DUMMYNODE(lru->head);
DUMMYNODE(lru->tail);
INIT_LIST(lru);
}
示例15: INIT_LIST
DWORD InterfaceUtils::INITEX(PDWORD index, const char *reservedAddrString, const char *reservedMaskString) {
INIT_LIST();
ULONG NTEContext;
if (InterfaceAddIPAddress(reservedAddrString, reservedMaskString, *index, &NTEContext) == NO_ERROR) {
AddEntry(NTEContext);
return NO_ERROR;
}
return ERROR_INVALID_ACCESS;
}