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