本文整理汇总了C++中INIT_HLIST_NODE函数的典型用法代码示例。如果您正苦于以下问题:C++ INIT_HLIST_NODE函数的具体用法?C++ INIT_HLIST_NODE怎么用?C++ INIT_HLIST_NODE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了INIT_HLIST_NODE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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(®ion->list);
region->paddr = paddr;
region->len = len;
region->file = file;
memcpy(®ion->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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}