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

C++ INIT_HLIST_NODE函数代码示例

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

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



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

示例1: init_idle_pids

static inline void init_idle_pids(struct pid_link *links)
{
	enum pid_type type;

	for (type = PIDTYPE_PID; type < PIDTYPE_MAX; ++type) {
		INIT_HLIST_NODE(&links[type].node); /* not really needed */
		links[type].pid = &init_struct_pid;
	}
}
开发者ID:curbthepain,项目名称:revkernel_s5,代码行数:9,代码来源:fork.c


示例2: msm_pmem_table_add

static int msm_pmem_table_add(struct hlist_head *ptype,
	struct msm_pmem_info *info)
{
	struct file *file;
	unsigned long paddr;
#ifdef CONFIG_ANDROID_PMEM
	unsigned long kvstart;
	int rc;
#endif
	unsigned long len;
	struct msm_pmem_region *region;
#ifdef CONFIG_ANDROID_PMEM
	rc = get_pmem_file(info->fd, &paddr, &kvstart, &len, &file);
	if (rc < 0) {
		pr_err("%s: get_pmem_file fd %d error %d\n",
						__func__,
						info->fd, rc);
		return rc;
	}
	if (!info->len)
		info->len = len;

	rc = check_pmem_info(info, len);
	if (rc < 0)
		return rc;
#else
	paddr = 0;
	file = NULL;
#endif
	paddr += info->offset;
	len = info->len;

	if (check_overlap(ptype, paddr, len) < 0)
		return -EINVAL;

	CDBG("%s: type %d, active flag %d, paddr 0x%lx, vaddr 0x%lx\n",
		__func__, info->type, info->active, paddr,
		(unsigned long)info->vaddr);

	region = kmalloc(sizeof(struct msm_pmem_region), GFP_KERNEL);
	if (!region)
		return -ENOMEM;

	INIT_HLIST_NODE(&region->list);

	region->paddr = paddr;
	region->len = len;
	region->file = file;
	memcpy(&region->info, info, sizeof(region->info));
	D("%s Adding region to list with type %d\n", __func__,
						region->info.type);
	D("%s pmem_stats address is 0x%p\n", __func__, ptype);
	hlist_add_head(&(region->list), ptype);

	return 0;
}
开发者ID:Kra1o5,项目名称:android_kernel_huawei_u8815-gb,代码行数:56,代码来源:msm_mem.c


示例3: instance_create

static struct nfulnl_instance *
instance_create(struct net *net, u_int16_t group_num,
		u32 portid, struct user_namespace *user_ns)
{
	struct nfulnl_instance *inst;
	struct nfnl_log_net *log = nfnl_log_pernet(net);
	int err;

	spin_lock_bh(&log->instances_lock);
	if (__instance_lookup(log, group_num)) {
		err = -EEXIST;
		goto out_unlock;
	}

	inst = kzalloc(sizeof(*inst), GFP_ATOMIC);
	if (!inst) {
		err = -ENOMEM;
		goto out_unlock;
	}

	if (!try_module_get(THIS_MODULE)) {
		kfree(inst);
		err = -EAGAIN;
		goto out_unlock;
	}

	INIT_HLIST_NODE(&inst->hlist);
	spin_lock_init(&inst->lock);
	/* needs to be two, since we _put() after creation */
	refcount_set(&inst->use, 2);

	timer_setup(&inst->timer, nfulnl_timer, 0);

	inst->net = get_net(net);
	inst->peer_user_ns = user_ns;
	inst->peer_portid = portid;
	inst->group_num = group_num;

	inst->qthreshold 	= NFULNL_QTHRESH_DEFAULT;
	inst->flushtimeout 	= NFULNL_TIMEOUT_DEFAULT;
	inst->nlbufsiz 		= NFULNL_NLBUFSIZ_DEFAULT;
	inst->copy_mode 	= NFULNL_COPY_PACKET;
	inst->copy_range 	= NFULNL_COPY_RANGE_MAX;

	hlist_add_head_rcu(&inst->hlist,
		       &log->instance_table[instance_hashfn(group_num)]);


	spin_unlock_bh(&log->instances_lock);

	return inst;

out_unlock:
	spin_unlock_bh(&log->instances_lock);
	return ERR_PTR(err);
}
开发者ID:SantoshShilimkar,项目名称:linux,代码行数:56,代码来源:nfnetlink_log.c


示例4: from_cblock

/*
 * This assumes the cblock hasn't already been allocated.
 */
static struct entry *alloc_particular_entry(struct entry_pool *ep, dm_cblock_t cblock)
{
	struct entry *e = ep->entries + from_cblock(cblock);

	list_del_init(&e->list);
	INIT_HLIST_NODE(&e->hlist);
	ep->nr_allocated++;

	return e;
}
开发者ID:vmayoral,项目名称:ubuntu-vivid,代码行数:13,代码来源:dm-cache-policy-mq.c


示例5: gfs2_init_glock_once

static void gfs2_init_glock_once(void *foo)
{
	struct gfs2_glock *gl = foo;

	INIT_HLIST_NODE(&gl->gl_list);
	spin_lock_init(&gl->gl_spin);
	INIT_LIST_HEAD(&gl->gl_holders);
	INIT_LIST_HEAD(&gl->gl_lru);
	INIT_LIST_HEAD(&gl->gl_ail_list);
	atomic_set(&gl->gl_ail_count, 0);
}
开发者ID:12rafael,项目名称:jellytimekernel,代码行数:11,代码来源:main.c


示例6: nfs4_init_deviceid_node

void
nfs4_init_deviceid_node(struct nfs4_deviceid_node *d,
			const struct pnfs_layoutdriver_type *ld,
			const struct nfs_client *nfs_client,
			const struct nfs4_deviceid *id)
{
	INIT_HLIST_NODE(&d->node);
	d->ld = ld;
	d->nfs_client = nfs_client;
	d->deviceid = *id;
	atomic_set(&d->ref, 1);
}
开发者ID:macbury,项目名称:linux-2.6,代码行数:12,代码来源:pnfs_dev.c


示例7: hmap_entry_init

static inline int hmap_entry_init(struct hash_entry *e, const char *key_str,
                                  unsigned int len)
{
    INIT_HLIST_NODE(&(e->head));
    if (key_str) {
        if ((e->key = (char *)malloc(len+1)) == NULL)
            return -1;
        strcpy((char *)e->key, (char *)key_str);
        /*		memcpy(e->key, key_str, len); */
        e->keylen = len;
    }
    return 0;
}
开发者ID:gpalma,项目名称:annsim,代码行数:13,代码来源:hash_map.c


示例8: list_entry

static struct entry *alloc_entry(struct entry_pool *ep)
{
	struct entry *e;

	if (list_empty(&ep->free))
		return NULL;

	e = list_entry(list_pop(&ep->free), struct entry, list);
	INIT_LIST_HEAD(&e->list);
	INIT_HLIST_NODE(&e->hlist);
	ep->nr_allocated++;

	return e;
}
开发者ID:vmayoral,项目名称:ubuntu-vivid,代码行数:14,代码来源:dm-cache-policy-mq.c


示例9: gfs2_init_glock_once

static void gfs2_init_glock_once(void *foo)
{
	struct gfs2_glock *gl = foo;

	INIT_HLIST_NODE(&gl->gl_list);
	spin_lock_init(&gl->gl_spin);
	INIT_LIST_HEAD(&gl->gl_holders);
	INIT_LIST_HEAD(&gl->gl_waiters1);
	INIT_LIST_HEAD(&gl->gl_waiters3);
	gl->gl_lvb = NULL;
	atomic_set(&gl->gl_lvb_count, 0);
	INIT_LIST_HEAD(&gl->gl_reclaim);
	INIT_LIST_HEAD(&gl->gl_ail_list);
	atomic_set(&gl->gl_ail_count, 0);
}
开发者ID:Mr-Aloof,项目名称:wl500g,代码行数:15,代码来源:main.c


示例10: BUG_ON

/*
 * Allocates a new entry structure.  The memory is allocated in one lump,
 * so we just handing it out here.  Returns NULL if all entries have
 * already been allocated.  Cannot fail otherwise.
 */
static struct entry *alloc_entry(struct mq_policy *mq)
{
	struct entry *e;

	if (mq->nr_entries_allocated >= mq->nr_entries) {
		BUG_ON(!list_empty(&mq->free));
		return NULL;
	}

	e = list_entry(list_pop(&mq->free), struct entry, list);
	INIT_LIST_HEAD(&e->list);
	INIT_HLIST_NODE(&e->hlist);

	mq->nr_entries_allocated++;
	return e;
}
开发者ID:03199618,项目名称:linux,代码行数:21,代码来源:dm-cache-policy-mq.c


示例11: create_io_context

/**
 * ioc_create_icq - create and link io_cq
 * @q: request_queue of interest
 * @gfp_mask: allocation mask
 *
 * Make sure io_cq linking %current->io_context and @q exists.  If either
 * io_context and/or icq don't exist, they will be created using @gfp_mask.
 *
 * The caller is responsible for ensuring @ioc won't go away and @q is
 * alive and will stay alive until this function returns.
 */
struct io_cq *ioc_create_icq(struct request_queue *q, gfp_t gfp_mask)
{
	struct elevator_type *et = q->elevator->type;
	struct io_context *ioc;
	struct io_cq *icq;

	/* allocate stuff */
	ioc = create_io_context(current, gfp_mask, q->node);
	if (!ioc)
		return NULL;

	icq = kmem_cache_alloc_node(et->icq_cache, gfp_mask | __GFP_ZERO,
				    q->node);
	if (!icq)
		return NULL;

	if (radix_tree_preload(gfp_mask) < 0) {
		kmem_cache_free(et->icq_cache, icq);
		return NULL;
	}

	icq->ioc = ioc;
	icq->q = q;
	INIT_LIST_HEAD(&icq->q_node);
	INIT_HLIST_NODE(&icq->ioc_node);

	/* lock both q and ioc and try to link @icq */
	spin_lock_irq(q->queue_lock);
	spin_lock(&ioc->lock);

	if (likely(!radix_tree_insert(&ioc->icq_tree, q->id, icq))) {
		hlist_add_head(&icq->ioc_node, &ioc->icq_list);
		list_add(&icq->q_node, &q->icq_list);
		if (et->ops.elevator_init_icq_fn)
			et->ops.elevator_init_icq_fn(icq);
	} else {
		kmem_cache_free(et->icq_cache, icq);
		icq = ioc_lookup_icq(ioc, q);
		if (!icq)
			printk(KERN_ERR "cfq: icq link failed!\n");
	}

	spin_unlock(&ioc->lock);
	spin_unlock_irq(q->queue_lock);
	radix_tree_preload_end();
	return icq;
}
开发者ID:DevSwift,项目名称:LT22-kernel,代码行数:58,代码来源:blk-ioc.c


示例12: buffer_alloc

static struct buffer_head *
buffer_alloc(int dev,uint32_t block)
{
	struct buffer_head *buf;
	buf = kmalloc(sizeof(struct buffer_head));

	if (!buf)
		return NULL;

	memset(buf,0x0,sizeof(struct buffer_head));
	buf->b_blocknr = block;
	buf->b_dev = dev;
	SPIN_LOCK_INIT(&buf->b_lock);
	INIT_HLIST_NODE(&buf->list_free);

	return buf;
}
开发者ID:bingone,项目名称:fuckOS,代码行数:17,代码来源:buffer.c


示例13: gfs2_init_glock_once

static void gfs2_init_glock_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
{
	struct gfs2_glock *gl = foo;
	if (flags & SLAB_CTOR_CONSTRUCTOR) {
		INIT_HLIST_NODE(&gl->gl_list);
		spin_lock_init(&gl->gl_spin);
		INIT_LIST_HEAD(&gl->gl_holders);
		INIT_LIST_HEAD(&gl->gl_waiters1);
		INIT_LIST_HEAD(&gl->gl_waiters2);
		INIT_LIST_HEAD(&gl->gl_waiters3);
		gl->gl_lvb = NULL;
		atomic_set(&gl->gl_lvb_count, 0);
		INIT_LIST_HEAD(&gl->gl_reclaim);
		INIT_LIST_HEAD(&gl->gl_ail_list);
		atomic_set(&gl->gl_ail_count, 0);
	}
}
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:17,代码来源:main.c


示例14: __uproc_create

static uproc_dentry_t* __uproc_create(uproc_ctx_t *ctx,
                                      const char *name,
                                      mode_t mode,
                                      uproc_dentry_t **parent) {
    const char *lp;
    uproc_dentry_t *new_entry = NULL;
    size_t namelen;
    if (!name || !strlen(name)) {
        if (ctx->dbg)
            fprintf(stderr, "uproc: empty pathname!\n");
        goto out;
    }

    if (__find_last_part(ctx, name, parent, &lp)) {
        if (ctx->dbg)
            fprintf(stderr, "uproc: some parts of \"%s\" does not exist!\n", name);
        goto out;
    }

    if (!*lp) {
        if (ctx->dbg)
            fprintf(stderr, "uproc: invalid pathname \"%s\"\n", name);
        goto out;
    }

    namelen = strlen(lp);
    new_entry = malloc(sizeof(*new_entry) + namelen + 1);
    if (!new_entry) {
        if (ctx->dbg)
            fprintf(stderr, "uproc: memory shortage, can't allocate memory for entry \"%s\"\n", name);
        goto out;
    }

    memset(new_entry, 0, sizeof(*new_entry) + namelen + 1);
    new_entry->name = (char *)new_entry + sizeof(*new_entry);
    memcpy(new_entry->name, lp, namelen);
    new_entry->namelen = namelen;
    new_entry->uid = getuid();
    new_entry->gid = getgid();
    new_entry->mode = mode;
    INIT_HLIST_NODE(&new_entry->hlink);
out:
    return new_entry;
}
开发者ID:zxjcarrot,项目名称:uproc,代码行数:44,代码来源:uproc.c


示例15: ptlrpc_connection_get

struct ptlrpc_connection *
ptlrpc_connection_get(struct lnet_process_id peer, lnet_nid_t self,
		      struct obd_uuid *uuid)
{
	struct ptlrpc_connection *conn, *conn2;
	ENTRY;

	peer.nid = LNetPrimaryNID(peer.nid);
	conn = cfs_hash_lookup(conn_hash, &peer);
	if (conn)
		GOTO(out, conn);

	OBD_ALLOC_PTR(conn);
	if (!conn)
		RETURN(NULL);

	conn->c_peer = peer;
	conn->c_self = self;
	INIT_HLIST_NODE(&conn->c_hash);
	atomic_set(&conn->c_refcount, 1);
	if (uuid)
		obd_str2uuid(&conn->c_remote_uuid, uuid->uuid);

	/*
	 * Add the newly created conn to the hash, on key collision we
	 * lost a racing addition and must destroy our newly allocated
	 * connection.	The object which exists in the hash will be
	 * returned and may be compared against out object.
	 */
	/* In the function below, .hs_keycmp resolves to
	 * conn_keycmp() */
	/* coverity[overrun-buffer-val] */
	conn2 = cfs_hash_findadd_unique(conn_hash, &peer, &conn->c_hash);
	if (conn != conn2) {
		OBD_FREE_PTR(conn);
		conn = conn2;
	}
	EXIT;
out:
	CDEBUG(D_INFO, "conn=%p refcount %d to %s\n",
	       conn, atomic_read(&conn->c_refcount),
	       libcfs_nid2str(conn->c_peer.nid));
	return conn;
}
开发者ID:Xyratex,项目名称:lustre-stable,代码行数:44,代码来源:connection.c


示例16: __get_new_ipc_port

static struct shim_ipc_port * __get_new_ipc_port (PAL_HANDLE hdl)
{
    struct shim_ipc_port * port =
                get_mem_obj_from_mgr_enlarge(port_mgr,
                                             size_align_up(PORT_MGR_ALLOC));

    if (!port)
        return NULL;

    memset(port, 0, sizeof(struct shim_ipc_port));
    port->pal_handle = hdl;
    port->update = true;
    INIT_HLIST_NODE(&port->hlist);
    INIT_LIST_HEAD(&port->list);
    INIT_LIST_HEAD(&port->msgs);
    REF_SET(port->ref_count, 1);
    create_lock(port->msgs_lock);
    return port;
}
开发者ID:gsmadhusudan,项目名称:graphene,代码行数:19,代码来源:shim_ipc_helper.c


示例17: blk_rq_init

void blk_rq_init(struct request_queue *q, struct request *rq)
{
	memset(rq, 0, sizeof(*rq));

	INIT_LIST_HEAD(&rq->queuelist);
	INIT_LIST_HEAD(&rq->timeout_list);
	rq->cpu = -1;
	rq->q = q;
	rq->__sector = (sector_t) -1;
	INIT_HLIST_NODE(&rq->hash);
	RB_CLEAR_NODE(&rq->rb_node);
	rq->cmd = rq->__cmd;
	rq->cmd_len = BLK_MAX_CDB;
	rq->tag = -1;
	rq->ref_count = 1;
	rq->start_time = jiffies;
	set_start_time_ns(rq);
	rq->part = NULL;
}
开发者ID:CaptainThrowback,项目名称:android_kernel_htc_hiae,代码行数:19,代码来源:blk-core.c


示例18: ptlrpc_connection_get

struct ptlrpc_connection *
ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self,
		      struct obd_uuid *uuid)
{
	struct ptlrpc_connection *conn, *conn2;

	conn = cfs_hash_lookup(conn_hash, &peer);
	if (conn)
		goto out;

	conn = kzalloc(sizeof(*conn), GFP_NOFS);
	if (!conn)
		return NULL;

	conn->c_peer = peer;
	conn->c_self = self;
	INIT_HLIST_NODE(&conn->c_hash);
	atomic_set(&conn->c_refcount, 1);
	if (uuid)
		obd_str2uuid(&conn->c_remote_uuid, uuid->uuid);

	/*
	 * Add the newly created conn to the hash, on key collision we
	 * lost a racing addition and must destroy our newly allocated
	 * connection.  The object which exists in the has will be
	 * returned and may be compared against out object.
	 */
	/* In the function below, .hs_keycmp resolves to
	 * conn_keycmp()
	 */
	/* coverity[overrun-buffer-val] */
	conn2 = cfs_hash_findadd_unique(conn_hash, &peer, &conn->c_hash);
	if (conn != conn2) {
		kfree(conn);
		conn = conn2;
	}
out:
	CDEBUG(D_INFO, "conn=%p refcount %d to %s\n",
	       conn, atomic_read(&conn->c_refcount),
	       libcfs_nid2str(conn->c_peer.nid));
	return conn;
}
开发者ID:acton393,项目名称:linux,代码行数:42,代码来源:connection.c


示例19: pr_debug

struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdreq_tlv(u8 tid, char *uri,
						  size_t uri_len)
{
	struct nfc_llcp_sdp_tlv *sdreq;

	pr_debug("uri: %s, len: %zu\n", uri, uri_len);

	/* sdreq->tlv_len is u8, takes uri_len, + 3 for header, + 1 for NULL */
	if (WARN_ON_ONCE(uri_len > U8_MAX - 4))
		return NULL;

	sdreq = kzalloc(sizeof(struct nfc_llcp_sdp_tlv), GFP_KERNEL);
	if (sdreq == NULL)
		return NULL;

	sdreq->tlv_len = uri_len + 3;

	if (uri[uri_len - 1] == 0)
		sdreq->tlv_len--;

	sdreq->tlv = kzalloc(sdreq->tlv_len + 1, GFP_KERNEL);
	if (sdreq->tlv == NULL) {
		kfree(sdreq);
		return NULL;
	}

	sdreq->tlv[0] = LLCP_TLV_SDREQ;
	sdreq->tlv[1] = sdreq->tlv_len - 2;
	sdreq->tlv[2] = tid;

	sdreq->tid = tid;
	sdreq->uri = sdreq->tlv + 3;
	memcpy(sdreq->uri, uri, uri_len);

	sdreq->time = jiffies;

	INIT_HLIST_NODE(&sdreq->node);

	return sdreq;
}
开发者ID:Anjali05,项目名称:linux,代码行数:40,代码来源:llcp_commands.c


示例20: objhash_add_one

static int objhash_add_one(struct my_obj *obj)
{
	u32 hash_idx;

	if (obj == NULL) {
		pr_err("%s(): Failed, NULL object\n", __func__);
		return 0;
	}

	objhash_cnt++;
	INIT_HLIST_NODE(&obj->node);
	obj->page = virt_to_head_page(obj);

	/* Hash on the page address of the object */
	hash_idx = jhash(&obj->page, 8, 13);
	//pr_info("DEBUG: hash_idx=0x%x [%u] page=0x%p\n",
	//	hash_idx, hash_idx % HASHSZ, obj->page);
	hash_idx = hash_idx % HASHSZ;

	hlist_add_head(&obj->node, &objhash[hash_idx]);

	return 1;
}
开发者ID:MartinMSPedersen,项目名称:prototype-kernel,代码行数:23,代码来源:slab_bulk_test03.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ INIT_I18N函数代码示例发布时间:2022-05-30
下一篇:
C++ INIT_HLIST_HEAD函数代码示例发布时间: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