本文整理汇总了C++中LIST_INIT函数的典型用法代码示例。如果您正苦于以下问题:C++ LIST_INIT函数的具体用法?C++ LIST_INIT怎么用?C++ LIST_INIT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LIST_INIT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LIST_INIT
* Implement search in an external script. The results are streamed
* back into a local listing.
*/
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include "debug.h"
#include "excrate.h"
#include "rig.h"
#include "status.h"
static struct list excrates = LIST_INIT(excrates);
static int excrate_init(struct excrate *e, const char *script,
const char *search, struct listing *storage)
{
pid_t pid;
fprintf(stderr, "External scan '%s'...\n", search);
pid = fork_pipe_nb(&e->fd, script, "scan", search, NULL);
if (pid == -1)
return -1;
e->pid = pid;
e->pe = NULL;
e->terminated = false;
示例2: dhcp6_timer_init
void
dhcp6_timer_init()
{
LIST_INIT(&timer_head);
tm_sentinel = tm_max;
}
示例3: main
/* process HTTP or SSDP requests */
int
main(int argc, char **argv)
{
int ret, i;
int sudp = -1, shttpl = -1;
int smonitor = -1;
LIST_HEAD(httplisthead, upnphttp) upnphttphead;
struct upnphttp * e = 0;
struct upnphttp * next;
fd_set readset; /* for select() */
fd_set writeset;
struct timeval timeout, timeofday, lastnotifytime = {0, 0};
time_t lastupdatetime = 0;
int max_fd = -1;
int last_changecnt = 0;
pid_t scanner_pid = 0;
pthread_t inotify_thread = 0;
#ifdef TIVO_SUPPORT
uint8_t beacon_interval = 5;
int sbeacon = -1;
struct sockaddr_in tivo_bcast;
struct timeval lastbeacontime = {0, 0};
#endif
for (i = 0; i < L_MAX; i++)
log_level[i] = E_WARN;
#ifdef ENABLE_NLS
setlocale(LC_MESSAGES, "");
setlocale(LC_CTYPE, "en_US.utf8");
DPRINTF(E_DEBUG, L_GENERAL, "Using locale dir %s\n", bindtextdomain("minidlna", getenv("TEXTDOMAINDIR")));
textdomain("minidlna");
#endif
ret = init(argc, argv);
if (ret != 0)
return 1;
DPRINTF(E_WARN, L_GENERAL, "Starting " SERVER_NAME " version " MINIDLNA_VERSION ".\n");
if (sqlite3_libversion_number() < 3005001)
{
DPRINTF(E_WARN, L_GENERAL, "SQLite library is old. Please use version 3.5.1 or newer.\n");
}
LIST_INIT(&upnphttphead);
ret = open_db(NULL);
if (ret == 0)
{
updateID = sql_get_int_field(db, "SELECT VALUE from SETTINGS where KEY = 'UPDATE_ID'");
if (updateID == -1)
ret = -1;
}
check_db(db, ret, &scanner_pid);
signal(SIGCHLD, &sigchld);
#ifdef HAVE_INOTIFY
if( GETFLAG(INOTIFY_MASK) )
{
if (!sqlite3_threadsafe() || sqlite3_libversion_number() < 3005001)
DPRINTF(E_ERROR, L_GENERAL, "SQLite library is not threadsafe! "
"Inotify will be disabled.\n");
else if (pthread_create(&inotify_thread, NULL, start_inotify, NULL) != 0)
DPRINTF(E_FATAL, L_GENERAL, "ERROR: pthread_create() failed for start_inotify. EXITING\n");
}
#endif
smonitor = OpenAndConfMonitorSocket();
sudp = OpenAndConfSSDPReceiveSocket();
if (sudp < 0)
{
DPRINTF(E_INFO, L_GENERAL, "Failed to open socket for receiving SSDP. Trying to use MiniSSDPd\n");
if (SubmitServicesToMiniSSDPD(lan_addr[0].str, runtime_vars.port) < 0)
DPRINTF(E_FATAL, L_GENERAL, "Failed to connect to MiniSSDPd. EXITING");
}
/* open socket for HTTP connections. */
shttpl = OpenAndConfHTTPSocket(runtime_vars.port);
if (shttpl < 0)
DPRINTF(E_FATAL, L_GENERAL, "Failed to open socket for HTTP. EXITING\n");
DPRINTF(E_WARN, L_GENERAL, "HTTP listening on port %d\n", runtime_vars.port);
#ifdef TIVO_SUPPORT
if (GETFLAG(TIVO_MASK))
{
DPRINTF(E_WARN, L_GENERAL, "TiVo support is enabled.\n");
/* Add TiVo-specific randomize function to sqlite */
ret = sqlite3_create_function(db, "tivorandom", 1, SQLITE_UTF8, NULL, &TiVoRandomSeedFunc, NULL, NULL);
if (ret != SQLITE_OK)
DPRINTF(E_ERROR, L_TIVO, "ERROR: Failed to add sqlite randomize function for TiVo!\n");
/* open socket for sending Tivo notifications */
sbeacon = OpenAndConfTivoBeaconSocket();
if(sbeacon < 0)
DPRINTF(E_FATAL, L_GENERAL, "Failed to open sockets for sending Tivo beacon notify "
"messages. EXITING\n");
tivo_bcast.sin_family = AF_INET;
tivo_bcast.sin_addr.s_addr = htonl(getBcastAddress());
tivo_bcast.sin_port = htons(2190);
}
else
sbeacon = -1;
#endif
//.........这里部分代码省略.........
示例4: WINE_DEFAULT_DEBUG_CHANNEL
#include "gdi_private.h"
#include "wine/unicode.h"
#include "wine/list.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(driver);
struct graphics_driver
{
struct list entry;
HMODULE module; /* module handle */
DC_FUNCTIONS funcs;
};
static struct list drivers = LIST_INIT( drivers );
static struct graphics_driver *display_driver;
static CRITICAL_SECTION driver_section;
static CRITICAL_SECTION_DEBUG critsect_debug =
{
0, 0, &driver_section,
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": driver_section") }
};
static CRITICAL_SECTION driver_section = { &critsect_debug, -1, 0, 0, 0, 0 };
/**********************************************************************
* create_driver
*
* Allocate and fill the driver structure for a given module.
示例5: dhcp6_timer_init
void dhcp6_timer_init(void)
{
LIST_INIT(&client6_config.timer_head);
client6_config.tm_sentinel = ULLONG_MAX;
}
示例6: scr_hash_new
/* allocates a new hash */
scr_hash* scr_hash_new()
{
scr_hash* hash = (scr_hash*) SCR_MALLOC(sizeof(scr_hash));
LIST_INIT(hash);
return hash;
}
示例7: fork1
/*
* General fork call. Note that another LWP in the process may call exec()
* or exit() while we are forking. It's safe to continue here, because
* neither operation will complete until all LWPs have exited the process.
*/
int
fork1(struct lwp *l1, int flags, int exitsig, void *stack, size_t stacksize,
void (*func)(void *), void *arg, register_t *retval,
struct proc **rnewprocp)
{
struct proc *p1, *p2, *parent;
struct plimit *p1_lim;
uid_t uid;
struct lwp *l2;
int count;
vaddr_t uaddr;
int tnprocs;
int tracefork;
int error = 0;
p1 = l1->l_proc;
uid = kauth_cred_getuid(l1->l_cred);
tnprocs = atomic_inc_uint_nv(&nprocs);
/*
* Although process entries are dynamically created, we still keep
* a global limit on the maximum number we will create.
*/
if (__predict_false(tnprocs >= maxproc))
error = -1;
else
error = kauth_authorize_process(l1->l_cred,
KAUTH_PROCESS_FORK, p1, KAUTH_ARG(tnprocs), NULL, NULL);
if (error) {
static struct timeval lasttfm;
atomic_dec_uint(&nprocs);
if (ratecheck(&lasttfm, &fork_tfmrate))
tablefull("proc", "increase kern.maxproc or NPROC");
if (forkfsleep)
kpause("forkmx", false, forkfsleep, NULL);
return EAGAIN;
}
/*
* Enforce limits.
*/
count = chgproccnt(uid, 1);
if (__predict_false(count > p1->p_rlimit[RLIMIT_NPROC].rlim_cur)) {
if (kauth_authorize_process(l1->l_cred, KAUTH_PROCESS_RLIMIT,
p1, KAUTH_ARG(KAUTH_REQ_PROCESS_RLIMIT_BYPASS),
&p1->p_rlimit[RLIMIT_NPROC], KAUTH_ARG(RLIMIT_NPROC)) != 0) {
(void)chgproccnt(uid, -1);
atomic_dec_uint(&nprocs);
if (forkfsleep)
kpause("forkulim", false, forkfsleep, NULL);
return EAGAIN;
}
}
/*
* Allocate virtual address space for the U-area now, while it
* is still easy to abort the fork operation if we're out of
* kernel virtual address space.
*/
uaddr = uvm_uarea_alloc();
if (__predict_false(uaddr == 0)) {
(void)chgproccnt(uid, -1);
atomic_dec_uint(&nprocs);
return ENOMEM;
}
/*
* We are now committed to the fork. From here on, we may
* block on resources, but resource allocation may NOT fail.
*/
/* Allocate new proc. */
p2 = proc_alloc();
/*
* Make a proc table entry for the new process.
* Start by zeroing the section of proc that is zero-initialized,
* then copy the section that is copied directly from the parent.
*/
memset(&p2->p_startzero, 0,
(unsigned) ((char *)&p2->p_endzero - (char *)&p2->p_startzero));
memcpy(&p2->p_startcopy, &p1->p_startcopy,
(unsigned) ((char *)&p2->p_endcopy - (char *)&p2->p_startcopy));
TAILQ_INIT(&p2->p_sigpend.sp_info);
LIST_INIT(&p2->p_lwps);
LIST_INIT(&p2->p_sigwaiters);
/*
* Duplicate sub-structures as needed.
* Increase reference counts on shared objects.
* Inherit flags we want to keep. The flags related to SIGCHLD
* handling are important in order to keep a consistent behaviour
//.........这里部分代码省略.........
示例8: EXPORT_SYMBOL
* thread.c: thread implementation
* Refered to ReactOS code
*/
#include "mutex.h"
#include "unistr.h"
#include "attach.h"
#include "semaphore.h"
#include "thread.h"
#include "wineserver/lib.h"
#ifdef CONFIG_UNIFIED_KERNEL
POBJECT_TYPE thread_object_type = NULL;
EXPORT_SYMBOL(thread_object_type);
struct list_head thread_list = LIST_INIT(thread_list);
static void thread_close(struct ethread *);
static int thread_signal(struct ethread *, int);
static void thread_exit(struct ethread *, int);
static void thread_execve(struct ethread *);
static void thread_fork(struct ethread *,
struct task_struct *,
struct task_struct *,
unsigned long);
extern void do_exit_task(struct task_struct *tsk, long code);
extern long do_fork_from_task(struct task_struct *ptsk,
unsigned long process_flags,
unsigned long clone_flags,
unsigned long stack_start,
示例9: rsys_init
int rsys_init(struct rsys* rsys, struct rsys_table* table, struct esys* esys)
{
if(rsys->magic == OCN_MAGIC)
return OCN_FAIL;
/* rendersystem table */
rsys->table = *table;
if(rsys->table.win_init != NULL)
if(rsys->table.win_init() != OCN_OK)
return OCN_WINDOW_ERR_CREATE;
if(rsys->table.ctt1_init != NULL)
{
if(rsys->table.ctt1_init() != OCN_OK)
{
if(rsys->table.win_dest != NULL)
rsys->table.win_dest();
return OCN_CONTEXT_ERR_CREATE;
}
}
if(rsys->table.ctt2_init != NULL)
{
if(rsys->table.ctt2_init() != OCN_OK)
{
if(rsys->table.ctt1_dest != NULL)
rsys->table.ctt1_dest();
if(rsys->table.win_dest != NULL)
rsys->table.win_dest();
return OCN_CONTEXT_ERR_CREATE;
}
}
if(rsys->table.glew_init != NULL)
{
if(rsys->table.glew_init() != OCN_OK)
{
if(rsys->table.ctt1_dest != NULL)
rsys->table.ctt1_dest();
if(rsys->table.ctt2_dest != NULL)
rsys->table.ctt2_dest();
if(rsys->table.win_dest != NULL)
rsys->table.win_dest();
return OCN_GLEW_ERR;
}
}
/* render queue */
ocn_spin_init(&rsys->render_reqs_lock);
queue_init (&rsys->render_reqs, OCN_RSYS_BUFFER_SIZE);
/* worker queue */
ocn_spin_init(&rsys->worker_reqs_lock);
queue_init (&rsys->worker_reqs, OCN_RSYS_BUFFER_SIZE);
ocn_thread_create(&rsys->worker_thread, rsys_worker, rsys);
ocn_thread_create(&rsys->render_thread, rsys_render, rsys);
/* ro_assets */
ocn_spin_init(&rsys->ro_assets_lock);
for(uint64_t u = 0lu; u < OCN_MAX_ASSETS; u++)
rsys->ro_assets[u].flags = 0lu;
/* ro_entities */
ocn_spin_init(&rsys->ro_entities_lock);
for(uint64_t u = 0lu; u < OCN_MAX_ENTITIES; u++)
rsys->ro_entities[u].flags = 0lu;
LIST_INIT(&rsys->ros)
frame_init(&rsys->frame);
rsys->bg_red = 0.5f;
rsys->bg_green = 0.5f;
rsys->bg_blue = 0.5f;
rsys->bg_alpha = 1.0f;
rsys->magic = OCN_MAGIC;
return OCN_OK;
}
示例10: LIST_INIT
uint32_t dev_class;
uint32_t reg_base[6];
uint32_t reg_size[6];
uint8_t irq_line;
uint8_t irq_pin;
struct list link;
};
struct pci_bus {
struct pci_func *parent_bridge;
uint32_t busno;
};
static struct list pci_func_list = LIST_INIT(pci_func_list);
static paddr_t pci_map_base = CONFIG_PCI_MMIO_ALLOC_BASE;
static void
pci_conf1_set_addr(uint32_t bus,
uint32_t dev,
uint32_t func,
uint32_t offset)
{
ASSERT(bus < 256);
ASSERT(dev < 32);
ASSERT(func < 8);
ASSERT(offset < 256);
ASSERT((offset & 0x3) == 0);
uint32_t v = (1 << 31) | /* config-space */
示例11: SAMPLE
#include "external.h"
#include "list.h"
#include "realtime.h"
#include "rig.h"
#include "status.h"
#include "track.h"
#define RATE 44100
#define SAMPLE (sizeof(signed short) * TRACK_CHANNELS) /* bytes per sample */
#define TRACK_BLOCK_PCM_BYTES (TRACK_BLOCK_SAMPLES * SAMPLE)
#define _STR(tok) #tok
#define STR(tok) _STR(tok)
static struct list tracks = LIST_INIT(tracks);
static bool use_mlock = false;
/*
* An empty track is used rarely, and is easier than
* continuous checks for NULL throughout the code
*/
static struct track empty = {
.refcount = 1,
.rate = RATE,
.bytes = 0,
.length = 0,
.blocks = 0,
示例12: pppattach
/*
* Called from boot code to establish ppp interfaces.
*/
void
pppattach()
{
LIST_INIT(&ppp_softc_list);
if_clone_attach(&ppp_cloner);
}
示例13: main
int
main(
int argc,
char **argv)
{
extern char *optarg;
CLIENT *cl;
int ch, ret;
char *passwd;
prog = argv[0];
version_check();
/*
* Check whether another server is running or not. There
* is a race condition where two servers could be racing to
* register with the portmapper. The goal of this check is to
* forbid running additional servers (like those started from
* the test suite) if the user is already running one.
*
* XXX
* This does not solve nor prevent two servers from being
* started at the same time and running recovery at the same
* time on the same environments.
*/
if ((cl = clnt_create("localhost",
DB_RPC_SERVERPROG, DB_RPC_SERVERVERS, "tcp")) != NULL) {
fprintf(stderr,
"%s: Berkeley DB RPC server already running.\n", prog);
clnt_destroy(cl);
return (EXIT_FAILURE);
}
LIST_INIT(&__dbsrv_home);
while ((ch = getopt(argc, argv, "h:I:L:P:t:T:Vv")) != EOF)
switch (ch) {
case 'h':
(void)add_home(optarg);
break;
case 'I':
if (__db_getlong(NULL, prog,
optarg, 1, LONG_MAX, &__dbsrv_idleto))
return (EXIT_FAILURE);
break;
case 'L':
logfile = optarg;
break;
case 'P':
passwd = strdup(optarg);
memset(optarg, 0, strlen(optarg));
if (passwd == NULL) {
fprintf(stderr, "%s: strdup: %s\n",
prog, strerror(errno));
return (EXIT_FAILURE);
}
if ((ret = add_passwd(passwd)) != 0) {
fprintf(stderr, "%s: strdup: %s\n",
prog, strerror(ret));
return (EXIT_FAILURE);
}
break;
case 't':
if (__db_getlong(NULL, prog,
optarg, 1, LONG_MAX, &__dbsrv_defto))
return (EXIT_FAILURE);
break;
case 'T':
if (__db_getlong(NULL, prog,
optarg, 1, LONG_MAX, &__dbsrv_maxto))
return (EXIT_FAILURE);
break;
case 'V':
printf("%s\n", db_version(NULL, NULL, NULL));
return (EXIT_SUCCESS);
case 'v':
__dbsrv_verbose = 1;
break;
default:
usage(prog);
}
/*
* Check default timeout against maximum timeout
*/
if (__dbsrv_defto > __dbsrv_maxto)
__dbsrv_defto = __dbsrv_maxto;
/*
* Check default timeout against idle timeout
* It would be bad to timeout environments sooner than txns.
*/
if (__dbsrv_defto > __dbsrv_idleto)
fprintf(stderr,
"%s: WARNING: Idle timeout %ld is less than resource timeout %ld\n",
prog, __dbsrv_idleto, __dbsrv_defto);
LIST_INIT(&__dbsrv_head);
/*
* If a client crashes during an RPC, our reply to it
//.........这里部分代码省略.........
示例14: init_new_proxy
/* Perform the most basic initialization of a proxy :
* memset(), list_init(*), reset_timeouts(*).
* Any new proxy or peer should be initialized via this function.
*/
void init_new_proxy(struct proxy *p)
{
memset(p, 0, sizeof(struct proxy));
LIST_INIT(&p->pendconns);
LIST_INIT(&p->acl);
LIST_INIT(&p->http_req_rules);
LIST_INIT(&p->block_cond);
LIST_INIT(&p->redirect_rules);
LIST_INIT(&p->mon_fail_cond);
LIST_INIT(&p->switching_rules);
LIST_INIT(&p->server_rules);
LIST_INIT(&p->persist_rules);
LIST_INIT(&p->sticking_rules);
LIST_INIT(&p->storersp_rules);
LIST_INIT(&p->tcp_req.inspect_rules);
LIST_INIT(&p->tcp_rep.inspect_rules);
LIST_INIT(&p->tcp_req.l4_rules);
LIST_INIT(&p->req_add);
LIST_INIT(&p->rsp_add);
LIST_INIT(&p->listener_queue);
LIST_INIT(&p->logsrvs);
LIST_INIT(&p->logformat);
LIST_INIT(&p->format_unique_id);
/* Timeouts are defined as -1 */
proxy_reset_timeouts(p);
p->tcp_rep.inspect_delay = TICK_ETERNITY;
}
示例15: vmem_init
vmem_t *
vmem_init(vmem_t *vm, const char *name,
vmem_addr_t base, vmem_size_t size, vmem_size_t quantum,
vmem_import_t *importfn, vmem_release_t *releasefn,
vmem_t *arg, vmem_size_t qcache_max, vm_flag_t flags, int ipl)
{
int i;
KASSERT((flags & (VM_SLEEP|VM_NOSLEEP)) != 0);
KASSERT((~flags & (VM_SLEEP|VM_NOSLEEP)) != 0);
KASSERT(quantum > 0);
#if defined(_KERNEL)
/* XXX: SMP, we get called early... */
if (!vmem_bootstrapped) {
vmem_bootstrap();
}
#endif /* defined(_KERNEL) */
if (vm == NULL) {
vm = xmalloc(sizeof(*vm), flags);
}
if (vm == NULL) {
return NULL;
}
VMEM_CONDVAR_INIT(vm, "vmem");
VMEM_LOCK_INIT(vm, ipl);
vm->vm_flags = flags;
vm->vm_nfreetags = 0;
LIST_INIT(&vm->vm_freetags);
strlcpy(vm->vm_name, name, sizeof(vm->vm_name));
vm->vm_quantum_mask = quantum - 1;
vm->vm_quantum_shift = SIZE2ORDER(quantum);
KASSERT(ORDER2SIZE(vm->vm_quantum_shift) == quantum);
vm->vm_importfn = importfn;
vm->vm_releasefn = releasefn;
vm->vm_arg = arg;
vm->vm_nbusytag = 0;
vm->vm_size = 0;
vm->vm_inuse = 0;
#if defined(QCACHE)
qc_init(vm, qcache_max, ipl);
#endif /* defined(QCACHE) */
TAILQ_INIT(&vm->vm_seglist);
for (i = 0; i < VMEM_MAXORDER; i++) {
LIST_INIT(&vm->vm_freelist[i]);
}
memset(&vm->vm_hash0, 0, sizeof(struct vmem_hashlist));
vm->vm_hashsize = 1;
vm->vm_hashlist = &vm->vm_hash0;
if (size != 0) {
if (vmem_add(vm, base, size, flags) != 0) {
vmem_destroy1(vm);
return NULL;
}
}
#if defined(_KERNEL)
if (flags & VM_BOOTSTRAP) {
bt_refill(vm);
}
mutex_enter(&vmem_list_lock);
LIST_INSERT_HEAD(&vmem_list, vm, vm_alllist);
mutex_exit(&vmem_list_lock);
#endif /* defined(_KERNEL) */
return vm;
}