本文整理汇总了C++中LIST_HEAD函数的典型用法代码示例。如果您正苦于以下问题:C++ LIST_HEAD函数的具体用法?C++ LIST_HEAD怎么用?C++ LIST_HEAD使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LIST_HEAD函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: list_test
static void list_test(void)
{
int i ;
struct data *node,*next;
LIST_HEAD(lhead);
for(i = 0; i < MAX_LIST; i++)
{
struct data *pdata;
pdata = kmalloc(sizeof(struct data),GFP_KERNEL);
pdata->i = i;
if(!pdata)
goto clean;
list_add(&pdata->list,&lhead);
}
list_for_each_entry(node,&lhead,list)
printk("list entry:%d\n",node->i);
clean:
list_for_each_entry_safe(node,next,&lhead,list)
kfree(node);
}
开发者ID:lyq628,项目名称:exercises,代码行数:20,代码来源:listhead.c
示例2: svr_checker_up
/* Test if realserver is marked UP for a specific checker */
int
svr_checker_up(checker_id_t cid, real_server_t *rs)
{
element e;
list l = rs->failed_checkers;
checker_id_t *id;
/*
* We assume there is not too much checker per
* real server, so we consider this lookup as
* o(1).
*/
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
id = ELEMENT_DATA(e);
if (*id == cid)
return 0;
}
return 1;
}
开发者ID:dyhjgl,项目名称:keepalived,代码行数:21,代码来源:ipwrapper.c
示例3: __linkwatch_run_queue
static void __linkwatch_run_queue(int urgent_only)
{
struct net_device *dev;
LIST_HEAD(wrk);
/*
*/
if (!urgent_only)
linkwatch_nextevent = jiffies + HZ;
/* */
else if (time_after(linkwatch_nextevent, jiffies + HZ))
linkwatch_nextevent = jiffies;
clear_bit(LW_URGENT, &linkwatch_flags);
spin_lock_irq(&lweventlist_lock);
list_splice_init(&lweventlist, &wrk);
while (!list_empty(&wrk)) {
dev = list_first_entry(&wrk, struct net_device, link_watch_list);
list_del_init(&dev->link_watch_list);
if (urgent_only && !linkwatch_urgent_event(dev)) {
list_add_tail(&dev->link_watch_list, &lweventlist);
continue;
}
spin_unlock_irq(&lweventlist_lock);
linkwatch_do_dev(dev);
spin_lock_irq(&lweventlist_lock);
}
if (!list_empty(&lweventlist))
linkwatch_schedule_work(0);
spin_unlock_irq(&lweventlist_lock);
}
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:41,代码来源:link_watch.c
示例4: distdb_fetch_result_remote
/**
* 获得远程返回的结果,
*/
int distdb_fetch_result_remote(struct DISTDB_SQL_RESULT * reslt,
char ** table[], int ifpeek)
{
int i;
struct sql_result_plain_text * ptext;
pthread_mutex_lock(&reslt->lock);
if (LIST_ISEMPTY(reslt->sql_result))
{
if (reslt->ref && !ifpeek) //还有结果会陆续进来,呵呵
{
pthread_cond_wait(&reslt->waitcond, &reslt->lock);
}
else if (reslt->ref && ifpeek)
{
pthread_mutex_unlock(&reslt->lock);
return 1;
}
else if( reslt->ref ==0)
{
pthread_mutex_unlock(&reslt->lock);
return -1;
}
}
if (reslt->ref == 0)
return -1;
if (reslt->last)
free(reslt->last);
ptext = LIST_HEAD(reslt->sql_result.head,sql_result_plain_text,resultlist);
LIST_DELETE_AT(&ptext->resultlist);
reslt->last = ptext;
for (i = 0; i < reslt->colums; ++i)
{
reslt ->last_table[i] = ptext->plaindata + ptext->strings[i].offset;
}
pthread_mutex_unlock(&reslt->lock);
return 0;
}
开发者ID:kikidong,项目名称:distdb,代码行数:44,代码来源:database.c
示例5: vrrp_print_stats
void
vrrp_print_stats(void)
{
FILE *file;
file = fopen ("/tmp/keepalived.stats","w");
list l = vrrp_data->vrrp;
element e;
vrrp_t *vrrp;
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
vrrp = ELEMENT_DATA(e);
fprintf(file, "VRRP Instance: %s\n", vrrp->iname);
fprintf(file, " Advertisements:\n");
fprintf(file, " Received: %d\n", vrrp->stats->advert_rcvd);
fprintf(file, " Sent: %d\n", vrrp->stats->advert_sent);
fprintf(file, " Became master: %d\n", vrrp->stats->become_master);
fprintf(file, " Released master: %d\n",
vrrp->stats->release_master);
fprintf(file, " Packet Errors:\n");
fprintf(file, " Length: %d\n", vrrp->stats->packet_len_err);
fprintf(file, " TTL: %d\n", vrrp->stats->ip_ttl_err);
fprintf(file, " Invalid Type: %d\n",
vrrp->stats->invalid_type_rcvd);
fprintf(file, " Advertisement Interval: %d\n",
vrrp->stats->advert_interval_err);
fprintf(file, " Address List: %d\n",
vrrp->stats->addr_list_err);
fprintf(file, " Authentication Errors:\n");
fprintf(file, " Invalid Type: %d\n",
vrrp->stats->invalid_authtype);
fprintf(file, " Type Mismatch: %d\n",
vrrp->stats->authtype_mismatch);
fprintf(file, " Failure: %d\n",
vrrp->stats->auth_failure);
fprintf(file, " Priority Zero:\n");
fprintf(file, " Received: %d\n", vrrp->stats->pri_zero_rcvd);
fprintf(file, " Sent: %d\n", vrrp->stats->pri_zero_sent);
}
fclose(file);
}
开发者ID:jwalzer,项目名称:keepalived,代码行数:41,代码来源:vrrp_print.c
示例6: print_processes_backwards
static int __init print_processes_backwards(void)
{
LIST_HEAD(data_stack);
int result = 0; // OK
stack_entry_t *task_entry = NULL;
struct task_struct *task = NULL;
char *task_name = NULL;
for_each_process (task) {
task_name = kmalloc(TASK_COMM_LEN, GFP_KERNEL);
if (task_name) {
task_entry = create_stack_entry(task_name);
if (task_entry) {
task_name = get_task_comm(task_name, task);
stack_push(&data_stack, task_entry);
} else {
kfree(task_name);
result = -ENOMEM;
break;
}
} else {
result = -ENOMEM;
break;
}
}
while (!stack_empty(&data_stack)) {
task_entry = stack_pop(&data_stack);
task_name = STACK_ENTRY_DATA(task_entry, char*);
delete_stack_entry(task_entry);
if (result != -ENOMEM) {
printk(KERN_ALERT "task name = %s\n", task_name);
}
kfree(task_name);
}
return result;
}
开发者ID:GolovanovSrg,项目名称:au-linux-kernel-spring-2016,代码行数:41,代码来源:module.c
示例7: nfs_flushd
static void
nfs_flushd(struct rpc_task *task)
{
struct nfs_server *server;
struct nfs_reqlist *cache;
LIST_HEAD(head);
dprintk("NFS: %4d flushd starting\n", task->tk_pid);
server = (struct nfs_server *) task->tk_calldata;
cache = server->rw_requests;
for(;;) {
spin_lock(&nfs_wreq_lock);
if (nfs_scan_lru_dirty_timeout(server, &head)) {
spin_unlock(&nfs_wreq_lock);
nfs_flush_list(&head, server->wpages, FLUSH_AGING);
continue;
}
if (nfs_scan_lru_read_timeout(server, &head)) {
spin_unlock(&nfs_wreq_lock);
nfs_pagein_list(&head, server->rpages);
continue;
}
#ifdef CONFIG_NFS_V3
if (nfs_scan_lru_commit_timeout(server, &head)) {
spin_unlock(&nfs_wreq_lock);
nfs_commit_list(&head, FLUSH_AGING);
continue;
}
#endif
spin_unlock(&nfs_wreq_lock);
break;
}
dprintk("NFS: %4d flushd back to sleep\n", task->tk_pid);
if (task->tk_action) {
task->tk_timeout = NFS_FLUSHD_TIMEOUT;
cache->runat = jiffies + task->tk_timeout;
rpc_sleep_on(&flushd_queue, task, NULL, NULL);
}
}
开发者ID:iwangv,项目名称:edimax-br-6528n,代码行数:41,代码来源:flushd.c
示例8: pcibios_init
/*
* Initialization. Try all known PCI access methods. Note that we support
* using both PCI BIOS and direct access: in such cases, we use I/O ports
* to access config space, but we still keep BIOS order of cards to be
* compatible with 2.0.X. This should go away some day.
*/
static int __init pcibios_init(void)
{
resource_size_t io_offset, mem_offset;
LIST_HEAD(resources);
struct pci_bus *bus;
ioport_resource.start = 0xA0000000;
ioport_resource.end = 0xDFFFFFFF;
iomem_resource.start = 0xA0000000;
iomem_resource.end = 0xDFFFFFFF;
if (insert_resource(&iomem_resource, &pci_iomem_resource) < 0)
panic("Unable to insert PCI IOMEM resource\n");
if (insert_resource(&ioport_resource, &pci_ioport_resource) < 0)
panic("Unable to insert PCI IOPORT resource\n");
if (!pci_probe)
return 0;
if (pci_check_direct() < 0) {
printk(KERN_WARNING "PCI: No PCI bus detected\n");
return 0;
}
printk(KERN_INFO "PCI: Probing PCI hardware [mempage %08x]\n",
MEM_PAGING_REG);
io_offset = pci_ioport_resource.start -
(pci_ioport_resource.start & 0x00ffffff);
mem_offset = pci_iomem_resource.start -
((pci_iomem_resource.start & 0x03ffffff) | MEM_PAGING_REG);
pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset);
pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset);
bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources);
if (!bus)
return 0;
pcibios_resource_survey();
pci_bus_add_devices(bus);
return 0;
}
开发者ID:skdwriting,项目名称:kbase,代码行数:47,代码来源:pci.c
示例9: __linkwatch_run_queue
static void __linkwatch_run_queue(int urgent_only)
{
struct net_device *dev;
LIST_HEAD(wrk);
/*
* Limit the number of linkwatch events to one
* per second so that a runaway driver does not
* cause a storm of messages on the netlink
* socket. This limit does not apply to up events
* while the device qdisc is down.
*/
if (!urgent_only)
linkwatch_nextevent = jiffies + HZ;
/* Limit wrap-around effect on delay. */
else if (time_after(linkwatch_nextevent, jiffies + HZ))
linkwatch_nextevent = jiffies;
clear_bit(LW_URGENT, &linkwatch_flags);
spin_lock_irq(&lweventlist_lock);
list_splice_init(&lweventlist, &wrk);
while (!list_empty(&wrk)) {
dev = list_first_entry(&wrk, struct net_device, link_watch_list);
list_del_init(&dev->link_watch_list);
if (urgent_only && !linkwatch_urgent_event(dev)) {
list_add_tail(&dev->link_watch_list, &lweventlist);
continue;
}
spin_unlock_irq(&lweventlist_lock);
linkwatch_do_dev(dev);
spin_lock_irq(&lweventlist_lock);
}
if (!list_empty(&lweventlist))
linkwatch_schedule_work(0);
spin_unlock_irq(&lweventlist_lock);
}
开发者ID:A2109devs,项目名称:lenovo_a2109a_kernel,代码行数:41,代码来源:link_watch.c
示例10: expand_single_string
static int expand_single_string(struct token *tok, struct token *next,
struct string **string_ret)
{
int ret;
LIST_HEAD(string_list);
ret = expand_params_and_word_split(tok, next, &string_list);
if (ret)
goto out_free_string_list;
ret = glue_strings(&string_list);
if (ret)
goto out_free_string_list;
if (!mysh_filename_expansion_disabled) {
ret = do_filename_expansion(&string_list);
if (ret)
goto out_free_string_list;
}
if (list_empty(&string_list))
*string_ret = NULL;
else if (list_is_singular(&string_list))
*string_ret = list_entry(string_list.next, struct string, list);
else {
开发者ID:ebiggers,项目名称:mysh,代码行数:21,代码来源:mysh_parse.c
示例11: main
int main()
{
LIST_HEAD(list);
append_node(&list);
append_node(&list);
struct node *pos;
list_for_each_entry(pos, &list, embedded_head)
___sl_plot(NULL);
___sl_plot(NULL);
// insane -- better to use list_for_each_entry_safe()
while (&list != list.prev) {
list.next = list.prev->prev;
free(list_entry(list.prev, struct node, embedded_head));
list.prev = list.next;
}
return 0;
}
开发者ID:jpokorny,项目名称:predator,代码行数:21,代码来源:test-0139.c
示例12: vrrp_timer_vrid_timeout
static int
vrrp_timer_vrid_timeout(const int fd)
{
vrrp_rt *vrrp;
element e;
list l = &vrrp_data->vrrp_index_fd[fd%1024 + 1];
TIMEVAL timer;
int vrid = 0;
/* Multiple instances on the same interface */
TIMER_RESET(timer);
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
vrrp = ELEMENT_DATA(e);
if (timer_cmp(vrrp->sands, timer) < 0 ||
TIMER_ISNULL(timer)) {
timer = timer_dup(vrrp->sands);
vrid = vrrp->vrid;
}
}
return vrid;
}
开发者ID:jsouthworth,项目名称:keepalived,代码行数:21,代码来源:vrrp_scheduler.c
示例13: take_over_work
static void take_over_work(struct ehca_comp_pool *pool, int cpu)
{
struct ehca_cpu_comp_task *cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu);
LIST_HEAD(list);
struct ehca_cq *cq;
unsigned long flags_cct;
spin_lock_irqsave(&cct->task_lock, flags_cct);
list_splice_init(&cct->cq_list, &list);
while (!list_empty(&list)) {
cq = list_entry(cct->cq_list.next, struct ehca_cq, entry);
list_del(&cq->entry);
__queue_comp_task(cq, this_cpu_ptr(pool->cpu_comp_tasks));
}
spin_unlock_irqrestore(&cct->task_lock, flags_cct);
}
开发者ID:MrJwiz,项目名称:UBER-M,代码行数:21,代码来源:ehca_irq.c
示例14: draw_battle_target
static void draw_battle_target(
BATTLE *battle,
BATTLE_ACTOR *ba
)
{
int x, y;
STEP_POINT *p;
for (p = (STEP_POINT *) LIST_HEAD(&ba->targetList);
p != NULL;
p = (STEP_POINT *) LIST_NEXT(&p->listNode)) {
x = p->i * BMARKER_WIDTH - battle->world->x;
y = p->j * BMARKER_HEIGHT - battle->world->y;
draw_sprite(x, y,
TARGET_MARKER, battle->bmarker,
0, 0, window_width, window_height);
}
}
开发者ID:phoboz,项目名称:yz,代码行数:21,代码来源:battle.c
示例15: rpc_timeout_upcall_queue
static void
rpc_timeout_upcall_queue(struct work_struct *work)
{
LIST_HEAD(free_list);
struct rpc_pipe *pipe =
container_of(work, struct rpc_pipe, queue_timeout.work);
void (*destroy_msg)(struct rpc_pipe_msg *);
struct dentry *dentry;
spin_lock(&pipe->lock);
destroy_msg = pipe->ops->destroy_msg;
if (pipe->nreaders == 0) {
list_splice_init(&pipe->pipe, &free_list);
pipe->pipelen = 0;
}
dentry = dget(pipe->dentry);
spin_unlock(&pipe->lock);
rpc_purge_list(dentry ? &RPC_I(dentry->d_inode)->waitq : NULL,
&free_list, destroy_msg, -ETIMEDOUT);
dput(dentry);
}
开发者ID:7799,项目名称:linux,代码行数:21,代码来源:rpc_pipe.c
示例16: kmem_cache_reap
void kmem_cache_reap(struct kmem_cache *cache)
{
LIST_HEAD(list);
const bool enabled = spin_lock_irqsave(&cache->lock);
list_splice(&cache->free_list, &list);
spin_unlock_irqrestore(&cache->lock, enabled);
for (struct list_head *ptr = list.next; ptr != &list;) {
struct kmem_slab *slab =
LIST_ENTRY(ptr, struct kmem_slab, link);
struct page *pages = slab->pages;
ptr = ptr->next;
if (cache->ops->destroy)
cache->ops->destroy(cache, slab);
free_pages(pages, cache->order);
}
}
开发者ID:krinkinmu,项目名称:64bit,代码行数:21,代码来源:kmem_cache.c
示例17: hashinit
/*
* General routine to allocate a hash table.
*/
void *
hashinit(int elements, int type, u_long *hashmask)
{
long hashsize;
LIST_HEAD(generic, generic) *hashtbl;
int i;
if (elements <= 0)
panic("hashinit: bad cnt");
for (hashsize = 1; hashsize <= elements; hashsize <<= 1)
continue;
hashsize >>= 1;
MALLOC(hashtbl, struct generic *,
(u_long)hashsize * sizeof(*hashtbl), type, M_WAITOK|M_ZERO);
if (hashtbl != NULL) {
for (i = 0; i < hashsize; i++)
LIST_INIT(&hashtbl[i]);
*hashmask = hashsize - 1;
}
return (hashtbl);
}
开发者ID:MACasuba,项目名称:MACasuba-Utils-git,代码行数:24,代码来源:kern_subr.c
示例18: main
int main()
{
// NOTE: two nodes should be enough to trigger DLS abstraction by default
// and consequently the spurious memory leak in the end
LIST_HEAD(list);
append_node(&list);
append_node(&list);
// plot heap in each iteration
struct node *pos;
list_for_each_entry(pos, &list, embedded_head)
___sl_plot(NULL);
// plot heap after list_for_each_entry() -- an off-value should be there
___sl_plot(NULL);
// use list_entry()
free(list_entry(list.next, struct node, embedded_head));
free(list_entry(list.prev, struct node, embedded_head));
return 0;
}
开发者ID:jpokorny,项目名称:predator,代码行数:21,代码来源:test-0140.c
示例19: phashinit
/*
* General routine to allocate a prime number sized hash table.
*/
void *
phashinit(int elements, struct malloc_type *type, u_long *nentries)
{
long hashsize;
LIST_HEAD(generic, generic) *hashtbl;
int i;
KASSERT(elements > 0, ("%s: bad elements", __func__));
for (i = 1, hashsize = primes[1]; hashsize <= elements;) {
i++;
if (i == NPRIMES)
break;
hashsize = primes[i];
}
hashsize = primes[i - 1];
hashtbl = malloc((u_long)hashsize * sizeof(*hashtbl), type, M_WAITOK);
for (i = 0; i < hashsize; i++)
LIST_INIT(&hashtbl[i]);
*nentries = hashsize;
return (hashtbl);
}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:24,代码来源:subr_hash.c
示例20: netlink_rtlist
/* Add/Delete a list of IP routes */
void
netlink_rtlist(list rt_list, int cmd)
{
ip_route_t *iproute;
element e;
/* No routes to add */
if (LIST_ISEMPTY(rt_list))
return;
for (e = LIST_HEAD(rt_list); e; ELEMENT_NEXT(e)) {
iproute = ELEMENT_DATA(e);
if ((cmd == IPROUTE_ADD && !iproute->set) ||
(cmd == IPROUTE_DEL && iproute->set)) {
if (netlink_route(iproute, cmd) > 0)
iproute->set = (cmd == IPROUTE_ADD);
else
iproute->set = false;
}
}
}
开发者ID:Zex,项目名称:keepalived,代码行数:22,代码来源:vrrp_iproute.c
注:本文中的LIST_HEAD函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论