本文整理汇总了C++中LIST_HEAD_INITIALIZER函数的典型用法代码示例。如果您正苦于以下问题:C++ LIST_HEAD_INITIALIZER函数的具体用法?C++ LIST_HEAD_INITIALIZER怎么用?C++ LIST_HEAD_INITIALIZER使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LIST_HEAD_INITIALIZER函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: __P
int ifqmaxlen = IFQ_MAXLEN;
struct ifnethead ifnet; /* depend on static init XXX */
#ifdef INET6
/*
* XXX: declare here to avoid to include many inet6 related files..
* should be more generalized?
*/
extern void nd6_setmtu __P((struct ifnet *));
#endif
struct if_clone *if_clone_lookup __P((const char *, int *));
int if_clone_list __P((struct if_clonereq *));
LIST_HEAD(, if_clone) if_cloners = LIST_HEAD_INITIALIZER(if_cloners);
int if_cloners_count;
/*
* Network interface utility routines.
*
* Routines with ifa_ifwith* names take sockaddr *'s as
* parameters.
*/
/* ARGSUSED*/
void
ifinit(dummy)
void *dummy;
{
#ifdef DEBUG_IFINIT
struct ifnet *ifp;
示例3: LIST_HEAD
#include <sys/conf.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/queue.h>
#include <sys/fbio.h>
#include <machine/bus.h>
#include <dev/vt/vt.h>
#include <dev/vt/hw/fb/vt_fb.h>
#include "fb_if.h"
LIST_HEAD(fb_list_head_t, fb_list_entry) fb_list_head =
LIST_HEAD_INITIALIZER(fb_list_head);
struct fb_list_entry {
struct fb_info *fb_info;
struct cdev *fb_si;
LIST_ENTRY(fb_list_entry) fb_list;
};
struct fbd_softc {
device_t sc_dev;
struct fb_info *sc_info;
};
static void fbd_evh_init(void *);
/* SI_ORDER_SECOND, just after EVENTHANDLERs initialized. */
SYSINIT(fbd_evh_init, SI_SUB_CONFIGURE, SI_ORDER_SECOND, fbd_evh_init, NULL);
示例4: job_callback
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include "tmux.h"
/*
* Job scheduling. Run queued commands in the background and record their
* output.
*/
void job_callback(struct bufferevent *, short, void *);
/* All jobs list. */
struct joblist all_jobs = LIST_HEAD_INITIALIZER(all_jobs);
/* Start a job running, if it isn't already. */
struct job *
job_run(const char *cmd,
void (*callbackfn)(struct job *), void (*freefn)(void *), void *data)
{
struct job *job;
struct environ env;
pid_t pid;
int nullfd, out[2];
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, out) != 0)
return (NULL);
environ_init(&env);
示例5: DECLARE_GEOM_CLASS
};
struct g_class g_md_class = {
.name = "MD",
.version = G_VERSION,
.init = g_md_init,
.fini = g_md_fini,
.start = g_md_start,
.access = g_md_access,
.dumpconf = g_md_dumpconf,
};
DECLARE_GEOM_CLASS(g_md_class, g_md);
static LIST_HEAD(, md_s) md_softc_list = LIST_HEAD_INITIALIZER(md_softc_list);
#define NINDIR (PAGE_SIZE / sizeof(uintptr_t))
#define NMASK (NINDIR-1)
static int nshift;
static int md_vnode_pbuf_freecnt;
struct indir {
uintptr_t *array;
u_int total;
u_int used;
u_int shift;
};
struct md_s {
示例6: disk_probe
static void disk_probe(struct disk *dp, int reprobe);
static void _setdiskinfo(struct disk *disk, struct disk_info *info);
static void bioqwritereorder(struct bio_queue_head *bioq);
static void disk_cleanserial(char *serno);
static int disk_debug(int, char *, ...) __printflike(2, 3);
static cdev_t _disk_create_named(const char *name, int unit, struct disk *dp,
struct dev_ops *raw_ops, int clone);
static d_open_t diskopen;
static d_close_t diskclose;
static d_ioctl_t diskioctl;
static d_strategy_t diskstrategy;
static d_psize_t diskpsize;
static d_dump_t diskdump;
static LIST_HEAD(, disk) disklist = LIST_HEAD_INITIALIZER(&disklist);
static struct lwkt_token disklist_token;
static struct dev_ops disk_ops = {
{ "disk", 0, D_DISK | D_MPSAFE | D_TRACKCLOSE },
.d_open = diskopen,
.d_close = diskclose,
.d_read = physread,
.d_write = physwrite,
.d_ioctl = diskioctl,
.d_strategy = diskstrategy,
.d_dump = diskdump,
.d_psize = diskpsize,
};
static struct objcache *disk_msg_cache;
示例7: LIST_ENTRY
/*
* The vnode of the system's root (/ in the filesystem, without chroot
* active.)
*/
struct vnode *rootvnode;
char *rootdevnames[2] = {NULL, NULL};
struct root_hold_token {
const char *who;
LIST_ENTRY(root_hold_token) list;
};
static LIST_HEAD(, root_hold_token) root_holds =
LIST_HEAD_INITIALIZER(root_holds);
enum action {
A_CONTINUE,
A_PANIC,
A_REBOOT,
A_RETRY
};
static enum action root_mount_onfail = A_CONTINUE;
static int root_mount_mddev;
static int root_mount_complete;
/* By default wait up to 3 seconds for devices to appear. */
static int root_mount_timeout = 3;
示例8: MALLOC_DEFINE
* allocate more.
*/
#define SNOOP_MAXLEN (64*1024) /* This one also,64K enough
* If we grow more,something
* really bad in this world..
*/
static MALLOC_DEFINE(M_SNP, "snp", "Snoop device data");
/*
* The number of the "snoop" line discipline. This gets determined at
* module load time.
*/
static int snooplinedisc;
static LIST_HEAD(, snoop) snp_sclist = LIST_HEAD_INITIALIZER(&snp_sclist);
static struct tty *snpdevtotty (cdev_t dev);
static int snp_detach (struct snoop *snp);
static int snp_down (struct snoop *snp);
static int snp_in (struct snoop *snp, char *buf, int n);
static int snp_modevent (module_t mod, int what, void *arg);
static int
snplclose(struct tty *tp, int flag)
{
struct snoop *snp;
int error;
lwkt_gettoken(&tty_token);
snp = tp->t_sc;
示例9: return
return (NULL);
return (strcpy(xalloc(strlen(s) + 1), s));
}
/************************************************************
*
* Input stack
*/
struct input {
FILE *fp;
u_int lno;
char *fname;
char *path;
LIST_ENTRY(input) link;
};
LIST_HEAD(, input) inputs = LIST_HEAD_INITIALIZER(inputs);
struct input *input = NULL;
int pbchar = -1;
#if !defined(MAX_PATHS)
#define MAX_PATHS 100
#endif
static const char *paths[MAX_PATHS + 1] = {
#if defined(DEFSDIR)
DEFSDIR,
#endif
#if defined(LOCAL_DEFSDIR)
LOCAL_DEFSDIR,
#endif
NULL
示例10: US_PER_S
#include <eal_private.h>
#define NS_PER_US 1000
#define US_PER_MS 1000
#define MS_PER_S 1000
#define US_PER_S (US_PER_MS * MS_PER_S)
struct alarm_entry {
LIST_ENTRY(alarm_entry) next;
struct timeval time;
rte_eal_alarm_callback cb_fn;
void *cb_arg;
volatile int executing;
};
static LIST_HEAD(alarm_list, alarm_entry) alarm_list = LIST_HEAD_INITIALIZER();
static rte_spinlock_t alarm_list_lk = RTE_SPINLOCK_INITIALIZER;
static struct rte_intr_handle intr_handle = {.fd = -1 };
static int handler_registered = 0;
static void eal_alarm_callback(struct rte_intr_handle *hdl, void *arg);
int
rte_eal_alarm_init(void)
{
intr_handle.type = RTE_INTR_HANDLE_ALARM;
/* create a timerfd file descriptor */
intr_handle.fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
if (intr_handle.fd == -1)
goto error;
示例11: LIST_ENTRY
#include <compat/ndis/pe_var.h>
#include <compat/ndis/cfg_var.h>
#include <compat/ndis/resource_var.h>
#include <compat/ndis/ntoskrnl_var.h>
#include <compat/ndis/ndis_var.h>
#include <compat/ndis/hal_var.h>
#include <compat/ndis/usbd_var.h>
#ifdef __amd64__
struct fpu_cc_ent {
struct fpu_kern_ctx *ctx;
LIST_ENTRY(fpu_cc_ent) entries;
};
static LIST_HEAD(fpu_ctx_free, fpu_cc_ent) fpu_free_head =
LIST_HEAD_INITIALIZER(fpu_free_head);
static LIST_HEAD(fpu_ctx_busy, fpu_cc_ent) fpu_busy_head =
LIST_HEAD_INITIALIZER(fpu_busy_head);
static struct mtx fpu_free_mtx;
static struct mtx fpu_busy_mtx;
#endif
static struct mtx drvdb_mtx;
static STAILQ_HEAD(drvdb, drvdb_ent) drvdb_head;
static driver_object fake_pci_driver; /* serves both PCI and cardbus */
static driver_object fake_pccard_driver;
#ifdef __i386__
static void x86_oldldt(void *);
static void x86_newldt(void *);
示例12: LIST_ENTRY
#include <sys/param.h>
#include <sys/device.h>
#include <sys/ioctl.h>
#include <sys/malloc.h>
#include <sys/queue.h>
#include <sys/systm.h>
#include <dev/biovar.h>
struct bio_mapping {
LIST_ENTRY(bio_mapping) bm_link;
struct device *bm_dev;
int (*bm_ioctl)(struct device *, u_long, caddr_t);
};
LIST_HEAD(, bio_mapping) bios = LIST_HEAD_INITIALIZER(bios);
void bioattach(int);
int bioclose(dev_t, int, int, struct proc *);
int bioioctl(dev_t, u_long, caddr_t, int, struct proc *);
int bioopen(dev_t, int, int, struct proc *);
int bio_delegate_ioctl(struct bio_mapping *, u_long, caddr_t);
struct bio_mapping *bio_lookup(char *);
int bio_validate(void *);
void
bioattach(int nunits)
{
}
示例13: LIST_HEAD_INITIALIZER
static db_cmdfcn_t db_halt;
static db_cmdfcn_t db_kill;
static db_cmdfcn_t db_reset;
static db_cmdfcn_t db_stack_trace;
static db_cmdfcn_t db_stack_trace_all;
static db_cmdfcn_t db_watchdog;
/*
* 'show' commands
*/
static struct command db_show_all_cmds[] = {
{ "trace", db_stack_trace_all, 0, 0 },
};
struct command_table db_show_all_table =
LIST_HEAD_INITIALIZER(db_show_all_table);
static struct command db_show_cmds[] = {
{ "all", 0, 0, &db_show_all_table },
{ "registers", db_show_regs, 0, 0 },
{ "breaks", db_listbreak_cmd, 0, 0 },
{ "threads", db_show_threads, 0, 0 },
};
struct command_table db_show_table = LIST_HEAD_INITIALIZER(db_show_table);
static struct command db_cmds[] = {
{ "print", db_print_cmd, 0, 0 },
{ "p", db_print_cmd, 0, 0 },
{ "examine", db_examine_cmd, CS_SET_DOT, 0 },
{ "x", db_examine_cmd, CS_SET_DOT, 0 },
{ "search", db_search_cmd, CS_OWN|CS_SET_DOT, 0 },
示例14: pud_putter_waitcount
static size_t pud_putter_waitcount(void *);
static int pud_putter_close(void *);
struct putter_ops pud_putter = {
.pop_getout = pud_putter_getout,
.pop_releaseout = pud_putter_releaseout,
.pop_waitcount = pud_putter_waitcount,
.pop_dispatch = pud_putter_dispatch,
.pop_close = pud_putter_close,
};
extern struct bdevsw pud_bdevsw;
extern struct cdevsw pud_cdevsw;
kmutex_t pud_mtx;
static LIST_HEAD(, pud_dev) pudlist = LIST_HEAD_INITIALIZER(pudlist);
static uint64_t
nextreq(struct pud_dev *pd)
{
uint64_t rv;
mutex_enter(&pd->pd_mtx);
rv = pd->pd_nextreq++;
mutex_exit(&pd->pd_mtx);
return rv;
}
static int
pud_putter_getout(void *this, size_t maxsize, int nonblock,
示例15: LIST_ENTRY
* be at least 'sizeof(struct fl)', so that blocks can be used as structures
* when on the free list.
*/
/*
* Memory lists.
*/
struct ml {
unsigned size;
LIST_ENTRY(ml) list;
};
/* XXX - this is from NetBSD */
#define LIST_HEAD_INITIALIZER(head) { NULL }
LIST_HEAD(, ml) freelist = LIST_HEAD_INITIALIZER(freelist);
LIST_HEAD(, ml) allocatedlist = LIST_HEAD_INITIALIZER(allocatedlist);
#define OVERHEAD ALIGN(sizeof (struct ml)) /* shorthand */
void *
alloc(size)
unsigned size;
{
struct ml *f, *bestf;
unsigned bestsize = 0xffffffff; /* greater than any real size */
char *help;
int failed;
#ifdef ALLOC_TRACE
printf("alloc(%u)", size);