• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ LIST_FIRST函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中LIST_FIRST函数的典型用法代码示例。如果您正苦于以下问题:C++ LIST_FIRST函数的具体用法?C++ LIST_FIRST怎么用?C++ LIST_FIRST使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了LIST_FIRST函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: g_mbr_ioctl

static int
g_mbr_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td)
{
	struct g_geom *gp;
	struct g_mbr_softc *ms;
	struct g_slicer *gsp;
	struct g_consumer *cp;
	int error, opened;

	gp = pp->geom;
	gsp = gp->softc;
	ms = gsp->softc;

	opened = 0;
	error = 0;
	switch(cmd) {
	case DIOCSMBR: {
		if (!(fflag & FWRITE))
			return (EPERM);
		DROP_GIANT();
		g_topology_lock();
		cp = LIST_FIRST(&gp->consumer);
		if (cp->acw == 0) {
			error = g_access(cp, 0, 1, 0);
			if (error == 0)
				opened = 1;
		}
		if (!error)
			error = g_mbr_modify(gp, ms, data, 512);
		if (!error)
			error = g_write_data(cp, 0, data, 512);
		if (opened)
			g_access(cp, 0, -1 , 0);
		g_topology_unlock();
		PICKUP_GIANT();
		return(error);
	}
	default:
		return (ENOIOCTL);
	}
}
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:41,代码来源:geom_mbr.c


示例2: g_bsd_writelabel

static int
g_bsd_writelabel(struct g_geom *gp, u_char *bootcode)
{
	off_t secoff;
	u_int secsize;
	struct g_consumer *cp;
	struct g_slicer *gsp;
	struct g_bsd_softc *ms;
	u_char *buf;
	uint64_t sum;
	int error, i;

	gsp = gp->softc;
	ms = gsp->softc;
	cp = LIST_FIRST(&gp->consumer);
	/* Get sector size, we need it to read data. */
	secsize = cp->provider->sectorsize;
	secoff = ms->labeloffset % secsize;
	if (bootcode == NULL) {
		buf = g_read_data(cp, ms->labeloffset - secoff, secsize, &error);
		if (buf == NULL)
			return (error);
		bcopy(ms->label, buf + secoff, sizeof(ms->label));
	} else {
		buf = bootcode;
		bcopy(ms->label, buf + ms->labeloffset, sizeof(ms->label));
	}
	if (ms->labeloffset == ALPHA_LABEL_OFFSET) {
		sum = 0;
		for (i = 0; i < 63; i++)
			sum += le64dec(buf + i * 8);
		le64enc(buf + 504, sum);
	}
	if (bootcode == NULL) {
		error = g_write_data(cp, ms->labeloffset - secoff, buf, secsize);
		g_free(buf);
	} else {
		error = g_write_data(cp, 0, bootcode, BBSIZE);
	}
	return(error);
}
开发者ID:coyizumi,项目名称:cs111,代码行数:41,代码来源:geom_bsd.c


示例3: svr4_elf32_probe

int
svr4_elf32_probe(
    struct lwp *l,
    struct exec_package *epp,
    void *eh,
    char *itp,
    vaddr_t *pos
)
{
	struct proc *p = l->l_proc;
	int error;

	if (itp) {
		if ((error = emul_find_interp(LIST_FIRST(&p->p_lwps), epp, itp)))
			return error;
	}
#ifdef SVR4_INTERP_ADDR
	*pos = SVR4_INTERP_ADDR;
#endif
	return 0;
}
开发者ID:Tommmster,项目名称:netbsd-avr32,代码行数:21,代码来源:svr4_exec_elf32.c


示例4: LIST_FIRST

struct atom *builtin_if(struct atom *expr, struct env *env)
{
    struct list *list = expr->list;
    struct atom *op = LIST_FIRST(list);
    struct atom *predicate = CDR(op);
    struct atom *true_case = CDR(predicate);
    struct atom *false_case = CDR(true_case);

    if (!predicate || !true_case || !false_case)
    {
        printf("error: if takes 3 arguments\n");
        return &nil_atom;
    }

    predicate = eval(predicate, env);

    if (IS_TRUE(predicate))
        return eval(true_case, env);

    return eval(false_case, env);
}
开发者ID:oswjk,项目名称:lispish,代码行数:21,代码来源:eval.c


示例5: GTIMER_FCN

void
GTIMER_FCN(mtimer_arm_abs)
  (GTIMER_TRACEID_ mtimer_t *mti, mti_callback_t *callback, void *opaque, int64_t when)
{
  lock_assert(&global_lock);

  if (mti->mti_callback != NULL)
    LIST_REMOVE(mti, mti_link);

  mti->mti_callback = callback;
  mti->mti_opaque   = opaque;
  mti->mti_expire   = when;
#if ENABLE_GTIMER_CHECK
  mti->mti_id       = id;
#endif

  LIST_INSERT_SORTED(&mtimers, mti, mti_link, mtimercmp);

  if (LIST_FIRST(&mtimers) == mti)
    tvh_cond_signal(&mtimer_cond, 0); // force timer re-check
}
开发者ID:Glenn-1990,项目名称:tvheadend,代码行数:21,代码来源:main.c


示例6: pp_cb

static void
pp_cb(void *opaque, prop_event_t event, ...)
{
  proppage_t *pp = opaque;
  openpage_t *op;

  if(event != PROP_DESTROYED) 
    return;

  while((op = LIST_FIRST(&pp->pp_pages)) != NULL) {
    LIST_REMOVE(op, op_link);
    op->op_pp = NULL;
    prop_set_int(prop_create(op->op_root, "close"), 1);
  }

  LIST_REMOVE(pp, pp_link);
  prop_ref_dec(pp->pp_model);
  prop_unsubscribe(pp->pp_model_sub);
  rstr_release(pp->pp_url);
  free(pp);
}
开发者ID:Allba,项目名称:showtime,代码行数:21,代码来源:backend_prop.c


示例7: mii_mediachg

/*
 * Media changed; notify all PHYs.
 */
int
mii_mediachg(struct mii_data *mii)
{
	struct mii_softc *child;
	int rv;

	mii->mii_media_status = 0;
	mii->mii_media_active = IFM_NONE;

	for (child = LIST_FIRST(&mii->mii_phys); child != NULL;
	     child = LIST_NEXT(child, mii_list)) {
		rv = (*child->mii_service)(child, mii, MII_MEDIACHG);
		if (rv) {
			return (rv);
		} else {
			/* Reset autonegotiation timer. */
			child->mii_ticks = 0;
		}
	}
	return (0);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:24,代码来源:mii.c


示例8: common_physmem_page_alloc

physmem_error_t common_physmem_page_alloc(struct physmem *_phys, 
    uint8 node VAR_UNUSED, physaddr_t *address) {

  struct physmem_page * newpage = NULL;

  if (_phys->free_pages <= 0) { 
    return PHYSMEM_ERR_OOM;
  }

  _phys->free_pages--;

  assert(!LIST_EMPTY(&_phys->freelist));

  newpage = LIST_FIRST(&_phys->freelist);
  LIST_REMOVE(newpage, pages);


  *address = physmem_page_to_phys(_phys, newpage);

  return PHYSMEM_SUCCESS;
}
开发者ID:via,项目名称:akaris-ng,代码行数:21,代码来源:physmem.c


示例9: adv_clear_state_really

static void
adv_clear_state_really(struct adv_softc *adv, union ccb* ccb)
{
	if ((adv->state & ADV_BUSDMA_BLOCK_CLEARED) != 0)
		adv->state &= ~(ADV_BUSDMA_BLOCK_CLEARED|ADV_BUSDMA_BLOCK);
	if ((adv->state & ADV_RESOURCE_SHORTAGE) != 0) {
		int openings;

		openings = adv->max_openings - adv->cur_active - ADV_MIN_FREE_Q;
		if (openings >= adv->openings_needed) {
			adv->state &= ~ADV_RESOURCE_SHORTAGE;
			adv->openings_needed = 0;
		}
	}
		
	if ((adv->state & ADV_IN_TIMEOUT) != 0) {
		struct adv_ccb_info *cinfo;

		cinfo = (struct adv_ccb_info *)ccb->ccb_h.ccb_cinfo_ptr;
		if ((cinfo->state & ACCB_RECOVERY_CCB) != 0) {
			struct ccb_hdr *ccb_h;

			/*
			 * We now traverse our list of pending CCBs
			 * and reinstate their timeouts.
			 */
			ccb_h = LIST_FIRST(&adv->pending_ccbs);
			while (ccb_h != NULL) {
				ccb_h->timeout_ch =
				    timeout(adv_timeout, (caddr_t)ccb_h,
					    (ccb_h->timeout * hz) / 1000);
				ccb_h = LIST_NEXT(ccb_h, sim_links.le);
			}
			adv->state &= ~ADV_IN_TIMEOUT;
			printf("%s: No longer in timeout\n", adv_name(adv));
		}
	}
	if (adv->state == 0)
		ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
}
开发者ID:oza,项目名称:FreeBSD-7.3-dyntick,代码行数:40,代码来源:advansys.c


示例10: dev_data_insert

/*
 * Insert a dev_data into the provided list, sorted by select code.
 */
static void
dev_data_insert(struct dev_data *dd, ddlist_t *ddlist)
{
	struct dev_data *de;

#ifdef DIAGNOSTIC
	if (dd->dd_scode < 0 || dd->dd_scode > 255) {
		printf("bogus select code for %s\n", dd->dd_dev->dv_xname);
		panic("dev_data_insert");
	}
#endif

	de = LIST_FIRST(ddlist);

	/*
	 * Just insert at head if list is empty.
	 */
	if (de == NULL) {
		LIST_INSERT_HEAD(ddlist, dd, dd_clist);
		return;
	}

	/*
	 * Traverse the list looking for a device who's select code
	 * is greater than ours.  When we find it, insert ourselves
	 * into the list before it.
	 */
	for (; LIST_NEXT(de, dd_clist) != NULL; de = LIST_NEXT(de, dd_clist)) {
		if (de->dd_scode > dd->dd_scode) {
			LIST_INSERT_BEFORE(de, dd, dd_clist);
			return;
		}
	}

	/*
	 * Our select code is greater than everyone else's.  We go
	 * onto the end.
	 */
	LIST_INSERT_AFTER(de, dd, dd_clist);
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:43,代码来源:autoconf.c


示例11: ax88190_media_init

void
ax88190_media_init(struct dp8390_softc *sc)
{
	struct ifnet *ifp = &sc->sc_arpcom.ac_if;

	sc->sc_mii.mii_ifp = ifp;
	sc->sc_mii.mii_readreg = ax88190_mii_readreg;
	sc->sc_mii.mii_writereg = ax88190_mii_writereg;
	sc->sc_mii.mii_statchg = ax88190_mii_statchg;
	ifmedia_init(&sc->sc_mii.mii_media, 0, dp8390_mediachange,
	    dp8390_mediastatus);

	mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
	    MII_OFFSET_ANY, 0);

	if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
		ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0,
		    NULL);
		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE);
	} else
		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:22,代码来源:ax88190.c


示例12: open_notify

int open_notify(enum access_type at, const char *pathname)
{
	/* For the parser: manually keep track of file accesses, since we
	 * don't run the UDP server for the parsing stage in win32.
	 */
	if(!LIST_EMPTY(&finfo_list_head)) {
		struct finfo_list *flist;
		struct stat buf;
		char fullpath[PATH_MAX];
		int cwdlen;
		int pathlen;

		if(getcwd(fullpath, sizeof(fullpath)) != fullpath) {
			perror("getcwd");
			return -1;
		}
		cwdlen = strlen(fullpath);
		pathlen = strlen(pathname);
		if(cwdlen + pathlen + 2 >= (signed)sizeof(fullpath)) {
			fprintf(stderr, "tup internal error: max pathname exceeded.\n");
			return -1;
		}
		fullpath[cwdlen] = PATH_SEP;
		memcpy(fullpath + cwdlen + 1, pathname, pathlen);
		fullpath[cwdlen + pathlen + 1] = 0;

		/* If the stat fails, or if the stat works and we know it
		 * is a directory, don't actually add the dependency. We
		 * want failed stats for ghost nodes, and all successful
		 * file accesses.
		 */
		if(stat(pathname, &buf) < 0 || !S_ISDIR(buf.st_mode)) {
			flist = LIST_FIRST(&finfo_list_head);
			if(handle_open_file(at, fullpath, flist->finfo) < 0)
				return -1;
		}
	}
	return 0;
}
开发者ID:CodeFred,项目名称:tup,代码行数:39,代码来源:open_notify.c


示例13: alq_load_handler

static int
alq_load_handler(module_t mod, int what, void *arg)
{
	int ret;
	
	ret = 0;

	switch (what) {
	case MOD_LOAD:
	case MOD_SHUTDOWN:
		break;

	case MOD_QUIESCE:
		ALD_LOCK();
		/* Only allow unload if there are no open queues. */
		if (LIST_FIRST(&ald_queues) == NULL) {
			ald_shutingdown = 1;
			ALD_UNLOCK();
			ald_shutdown(NULL, 0);
			mtx_destroy(&ald_mtx);
		} else {
			ALD_UNLOCK();
			ret = EBUSY;
		}
		break;

	case MOD_UNLOAD:
		/* If MOD_QUIESCE failed we must fail here too. */
		if (ald_shutingdown == 0)
			ret = EBUSY;
		break;

	default:
		ret = EINVAL;
		break;
	}

	return (ret);
}
开发者ID:ornarium,项目名称:freebsd,代码行数:39,代码来源:kern_alq.c


示例14: test_list

/*
 * test_list - Do some basic list manipulations and output to log for
 * script comparison. Only testing the macros we use.
 */
static void
test_list(void)
{
	PTEST_LIST_NODE pNode = NULL;
	struct TestList head = LIST_HEAD_INITIALIZER(head);

	LIST_INIT(&head);
	UT_ASSERT_rt(LIST_EMPTY(&head));

	pNode = MALLOC(sizeof(struct TEST_LIST_NODE));
	pNode->dummy = 0;
	LIST_INSERT_HEAD(&head, pNode, ListEntry);
	UT_ASSERTeq_rt(1, get_list_count(&head));
	dump_list(&head);

	/* Remove one node */
	LIST_REMOVE(pNode, ListEntry);
	UT_ASSERTeq_rt(0, get_list_count(&head));
	dump_list(&head);
	free(pNode);

	/* Add a bunch of nodes */
	for (int i = 1; i < 10; i++) {
		pNode = MALLOC(sizeof(struct TEST_LIST_NODE));
		pNode->dummy = i;
		LIST_INSERT_HEAD(&head, pNode, ListEntry);
	}
	UT_ASSERTeq_rt(9, get_list_count(&head));
	dump_list(&head);

	/* Remove all of them */
	while (!LIST_EMPTY(&head)) {
		pNode = (PTEST_LIST_NODE)LIST_FIRST(&head);
		LIST_REMOVE(pNode, ListEntry);
		free(pNode);
	}
	UT_ASSERTeq_rt(0, get_list_count(&head));
	dump_list(&head);
}
开发者ID:GBuella,项目名称:nvml,代码行数:43,代码来源:win_lists.c


示例15: __dbclear_child

/*
 * RECURSIVE FUNCTION.  We need to clear/free any number of levels of nested
 * layers.
 */
static void
__dbclear_child(ct_entry *parent)
{
	ct_entry *ctp, *nextctp;

	for (ctp = LIST_FIRST(&__dbsrv_head); ctp != NULL;
	    ctp = nextctp) {
		nextctp = LIST_NEXT(ctp, entries);
		if (ctp->ct_type == 0)
			continue;
		if (ctp->ct_parent == parent) {
			__dbclear_child(ctp);
			/*
			 * Need to do this here because le_next may
			 * have changed with the recursive call and we
			 * don't want to point to a removed entry.
			 */
			nextctp = LIST_NEXT(ctp, entries);
			__dbclear_ctp(ctp);
		}
	}
}
开发者ID:dmeister,项目名称:kbdb,代码行数:26,代码来源:db_server_cxxutil.cpp


示例16: pgmounts_read

/**
 * Free the list of known pgmounts and re-build the list from
 * /proc/mounts.
 *
 * @param None.
 * @return None.
 */
static void
pgmounts_read(void)
{
	FILE		*file;
	char		 line[512];
	int		 i;
	char		*prefix;

	/* First free old list of mounted file systems. */
	while (!LIST_EMPTY(&pgmounts)) {
		struct pgmount		*mnt = LIST_FIRST(&pgmounts);

		LIST_REMOVE(mnt, next);
		if (mnt->prefix)
			free(mnt->prefix);
		if (mnt->dirfd >= 0)
			close(mnt->dirfd);
		free(mnt);
	}
	file = fopen("/proc/mounts", "r");
	if (!file)
		return;
	while (fgets(line, sizeof(line), file)) {
		i=0;
		while (line[i] && !isspace(line[i]))
			i++;
		if (!isspace(line[i]))
			continue;
		i++;
		prefix = line+i;
		if (*prefix != '/')
			continue;
		while (line[i] && !isspace(line[i]))
			i++;
		line[i] = 0;
		pgmounts_readone(prefix);
	}
	fclose(file);
}
开发者ID:genua,项目名称:anoubis,代码行数:46,代码来源:playground_files.c


示例17: miibus_mediainit

static void
miibus_mediainit(device_t dev)
{
	struct mii_data		*mii;
	struct ifmedia_entry	*m;
	int			media = 0;

	/* Poke the parent in case it has any media of its own to add. */
	MIIBUS_MEDIAINIT(device_get_parent(dev));

	mii = device_get_softc(dev);
	for (m = LIST_FIRST(&mii->mii_media.ifm_list); m != NULL;
	     m = LIST_NEXT(m, ifm_list)) {
		media = m->ifm_media;
		if (media == (IFM_ETHER|IFM_AUTO))
			break;
	}

	ifmedia_set(&mii->mii_media, media);

	return;
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:22,代码来源:mii.c


示例18: page_alloc

int
page_alloc(struct Page **pp)
{
	// Fill this function in
	struct Page *ppage_temp;

	ppage_temp = LIST_FIRST(&page_free_list);

	//printf("%x\n",ppage_temp);
	//printf("pages__%x\n",ppage_temp);
	if (ppage_temp != NULL) {
		*pp = ppage_temp;
		LIST_REMOVE(ppage_temp, pp_link);
		page_initpp(*pp);

		bzero((void *)KADDR(page2pa(ppage_temp)), BY2PG);

		return 0;
	}

	return -E_NO_MEM;
}
开发者ID:SivilTaram,项目名称:Jos-mips,代码行数:22,代码来源:pmap.c


示例19: epggrab_channel_updated

/**
 * Parse a <programme> tag from xmltv
 */
static int _xmltv_parse_programme
  (epggrab_module_t *mod, htsmsg_t *body, epggrab_stats_t *stats)
{
  int chsave = 0, save = 0;
  htsmsg_t *attribs, *tags, *subtag;
  const char *s, *chid, *icon = NULL;
  time_t start, stop;
  epggrab_channel_t *ec;
  idnode_list_mapping_t *ilm;

  if(body == NULL) return 0;

  if((attribs = htsmsg_get_map(body,    "attrib"))  == NULL) return 0;
  if((tags    = htsmsg_get_map(body,    "tags"))    == NULL) return 0;
  if((chid    = htsmsg_get_str(attribs, "channel")) == NULL) return 0;
  if((ec      = _xmltv_channel_find(chid, 1, &chsave)) == NULL) return 0;
  if (chsave) {
    epggrab_channel_updated(ec);
    stats->channels.created++;
    stats->channels.modified++;
  }
  if (!LIST_FIRST(&ec->channels)) return 0;
  if((s       = htsmsg_get_str(attribs, "start"))   == NULL) return 0;
  start = _xmltv_str2time(s);
  if((s       = htsmsg_get_str(attribs, "stop"))    == NULL) return 0;
  stop  = _xmltv_str2time(s);

  if((subtag  = htsmsg_get_map(tags,    "icon"))   != NULL &&
     (attribs = htsmsg_get_map(subtag,  "attrib")) != NULL)
    icon = htsmsg_get_str(attribs, "src");

  if(stop <= start || stop <= dispatch_clock) return 0;

  LIST_FOREACH(ilm, &ec->channels, ilm_in2_link)
    save |= _xmltv_parse_programme_tags(mod, (channel_t *)ilm->ilm_in2, tags,
                                        start, stop, icon, stats);
  return save;
}
开发者ID:astrilchuk,项目名称:tvheadend,代码行数:41,代码来源:xmltv.c


示例20: lookup_consider_update_cache

void 
lookup_consider_update_cache(vnode_t dvp, vnode_t vp, struct componentname *cnp, int nc_generation) 
{
	int isdot_or_dotdot;
	isdot_or_dotdot = (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') || (cnp->cn_flags & ISDOTDOT);

	if (vp->v_name == NULL || vp->v_parent == NULLVP) {
		int  update_flags = 0;

		if (isdot_or_dotdot == 0) {
			if (vp->v_name == NULL)
				update_flags |= VNODE_UPDATE_NAME;
			if (dvp != NULLVP && vp->v_parent == NULLVP)
				update_flags |= VNODE_UPDATE_PARENT;

			if (update_flags)
				vnode_update_identity(vp, dvp, cnp->cn_nameptr, cnp->cn_namelen, cnp->cn_hash, update_flags);
		}
	}
	if ( (cnp->cn_flags & MAKEENTRY) && (vp->v_flag & VNCACHEABLE) && LIST_FIRST(&vp->v_nclinks) == NULL) {
		/*
		 * missing from name cache, but should
		 * be in it... this can happen if volfs
		 * causes the vnode to be created or the
		 * name cache entry got recycled but the
		 * vnode didn't...
		 * check to make sure that ni_dvp is valid
		 * cache_lookup_path may return a NULL
		 * do a quick check to see if the generation of the
		 * directory matches our snapshot... this will get
		 * rechecked behind the name cache lock, but if it
		 * already fails to match, no need to go any further
		 */
		if (dvp != NULLVP && (nc_generation == dvp->v_nc_generation) && (!isdot_or_dotdot))
			cache_enter_with_gen(dvp, vp, cnp, nc_generation);
	}

}
开发者ID:Algozjb,项目名称:xnu,代码行数:38,代码来源:vfs_lookup.c



注:本文中的LIST_FIRST函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ LIST_FOREACH函数代码示例发布时间:2022-05-30
下一篇:
C++ LIST_EMPTY函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap