本文整理汇总了C++中LIST_EMPTY函数的典型用法代码示例。如果您正苦于以下问题:C++ LIST_EMPTY函数的具体用法?C++ LIST_EMPTY怎么用?C++ LIST_EMPTY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LIST_EMPTY函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vbds_alloc
int
vbds_alloc(xsis_vbds_t *vbds, xsis_flts_t *domids, xsis_flts_t *vbdids){
// Local variables
DIR *dp = NULL; // dir pointer
struct dirent *dirp; // dirent pointer
xsis_vbd_t *vbd; // Temporary VBD pointer
uint32_t domid; // Temporary DOM ID
uint32_t vbdid; // Temporary VBD ID
int err = 0; // Return code
// Open VBD3 base dir
if (!(dp = opendir(XSIS_VBD3_DIR))){
perror("opendir");
goto err;
}
// Scan for valid VBD entries
while ((dirp = readdir(dp))){
// Skip irrelevant entries and fetch DOM/VBD ids
if (sscanf(dirp->d_name, XSIS_VBD3_BASEFMT, &domid, &vbdid) != 2)
continue;
// Filter domids and vbdids
if (!LIST_EMPTY(domids))
if (!flt_isset(domids, domid))
continue;
if (!LIST_EMPTY(vbdids))
if (!flt_isset(vbdids, vbdid))
continue;
// Do not add repeated entries
LIST_FOREACH(vbd, vbds, vbds)
if ((vbd->domid == domid) && (vbd->vbdid == vbdid))
break;
if (vbd)
continue;
// Allocate VBD entry
if (vbd_open(&vbd, domid, vbdid))
continue;
// Insert new VBD in list
LIST_INSERT_HEAD(vbds, vbd, vbds);
}
out:
// Close VBD3 base dir
if (dp)
closedir(dp);
// Return
return(err);
err:
err = 1;
goto out;
}
示例2: ies_task_main
/*****************************************************************************
* FUNCTION
* ies_task_main
* DESCRIPTION
* image viewer daemon task main function & MSG loop
* PARAMETERS
* *task_entry_ptr [IN] task entry structure
* RETURNS
* void
*****************************************************************************/
static void ies_task_main(task_entry_struct *task_entry_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
ilm_struct current_ilm;
kal_uint32 msg_count;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
kal_set_active_module_id(MOD_IES);
while(1)
{
/* peek and check command */
msg_count = msg_get_extq_messages();
while(msg_count > 0)
{
msg_receive_extq_for_stack(¤t_ilm);
_ies_task_dispatch_message(¤t_ilm);
destroy_ilm(¤t_ilm);
// consume ext queue eagerly
msg_count = msg_get_extq_messages();
}
if(!g_ies_task_context.pJob)
{
// At this point, there may be pending jobs.
_ies_task_job_handle_queue();
if (!g_ies_task_context.pJob)
{
// We still have nothing to do
if ((LIST_EMPTY(&(g_ies_task_context.normal))) &&
(LIST_EMPTY(&(g_ies_task_context.lowest))))
{
msg_receive_extq_for_stack(¤t_ilm);
_ies_task_dispatch_message(¤t_ilm);
destroy_ilm(¤t_ilm);
}
}
}
else
{
/* after processed all commands,
perform job iteration if there are active jobs. */
if(_ies_task_job_handle_start(g_ies_task_context.pJob))
{
// job finished
g_ies_task_context.pJob = NULL;
_ies_task_job_handle_queue();
}
}
}
}
示例3: destroy_sa_qp
/** ========================================================================= */
static void destroy_sa_qp(struct oib_port *port)
{
int i;
// if the user just unregistered trap messages those messages may still
// be on this list, wait 5 seconds for the thread to handle the response.
for (i = 0; i < 5000; i++) {
if (!LIST_EMPTY(&port->pending_reg_msg_head)) {
usleep(1000);
}
else {
DBGPRINT("destroy_sa_qp: wait %d ms for LIST_EMPTY\n", i);
break;
}
}
stop_ud_cq_monitor(port);
join_port_thread(port);
/* Free any remaining unregistration messages */
if (!LIST_EMPTY(&port->pending_reg_msg_head)) {
OUTPUT_ERROR("Ignoring Pending Notice un-registation requests\n");
oib_sa_remove_all_pending_reg_msgs(port);
}
if (port->sa_ah)
ibv_destroy_ah(port->sa_ah);
if (port->sa_qp)
ibv_destroy_qp(port->sa_qp);
for (i = 0; i<port->num_userspace_recv_buf; i++)
if (port->recv_bufs)
ibv_dereg_mr(port->recv_bufs[i].mr);
if (port->sa_qp_pd)
ibv_dealloc_pd(port->sa_qp_pd);
if (port->sa_qp_cq)
ibv_destroy_cq(port->sa_qp_cq);
if (port->recv_bufs) {
free(port->recv_bufs);
port->recv_bufs = NULL;
}
if (port->sa_qp_comp_channel)
ibv_destroy_comp_channel(port->sa_qp_comp_channel);
}
示例4: kore_pool_get
void *
kore_pool_get(struct kore_pool *pool)
{
u_int8_t *ptr;
struct kore_pool_entry *entry;
if (LIST_EMPTY(&(pool->freelist))) {
kore_log(LOG_NOTICE, "pool %s is exhausted (%d/%d)",
pool->name, pool->inuse, pool->elms);
pool_region_create(pool, pool->elms);
}
entry = LIST_FIRST(&(pool->freelist));
if (entry->state != POOL_ELEMENT_FREE)
fatal("%s: element %p was not free", pool->name, entry);
LIST_REMOVE(entry, list);
entry->state = POOL_ELEMENT_BUSY;
ptr = (u_int8_t *)entry + sizeof(struct kore_pool_entry);
pool->inuse++;
return (ptr);
}
示例5: DEBUG_PRINT
int Sched::addtoactive(Task &task)
{
Task *pos;
uint8_t task_priority;
task_priority = task.Task_GetSchedPriority();
DEBUG_PRINT("addtoactive:task_priority:%d\n",task_priority);
task.Task_SetState(TSTATE_TASK_READYTORUN);
if (LIST_EMPTY(task_active)) { // furtherm
LIST_ADD(task_active, task);
DEBUG_PRINT("LIST_EMPTY:LIST_ADD to task_active OK\n");
Sched_SetCurrentTask(task);
DEBUG_PRINT("It's the first task.\n");
return OK;
}else {
if (LIST_LAST_ENTRY(task_active).Task_GetSchedPriority() > task_priority) {
LIST_ADD_TAIL(task_active, task);
}else {
LIST_FOR_EACH_ENTRY(task_active, pos) {
if (pos->Task_GetSchedPriority() <= task_priority) {
LIST_ADD_BEFORE(task_active, task, (*pos));
}
}
if (!Sched_locked() && IS_LIST_FIRST_ENTRY(task_active, task)) {
return OK;
}
}
}
return NO;
}
示例6: pflog_modevent
static int
pflog_modevent(module_t mod, int type, void *data)
{
int error = 0;
switch (type) {
case MOD_LOAD:
LIST_INIT(&pflog_list);
if_clone_attach(&pflog_cloner);
break;
case MOD_UNLOAD:
if_clone_detach(&pflog_cloner);
while (!LIST_EMPTY(&pflog_list))
pflog_clone_destroy(
&LIST_FIRST(&pflog_list)->sc_if);
break;
default:
error = EINVAL;
break;
}
return error;
}
示例7: cpu_switch_prepare
/*
* Prepare context switch from oldlwp to newlwp.
* This code is shared by cpu_switch and cpu_switchto.
*/
struct lwp *
cpu_switch_prepare(struct lwp *oldlwp, struct lwp *newlwp)
{
newlwp->l_stat = LSONPROC;
if (newlwp != oldlwp) {
struct proc *p = newlwp->l_proc;
curpcb = newlwp->l_md.md_pcb;
pmap_activate(newlwp);
/* Check for Restartable Atomic Sequences. */
if (!LIST_EMPTY(&p->p_raslist)) {
caddr_t pc;
pc = ras_lookup(p,
(caddr_t)newlwp->l_md.md_regs->tf_spc);
if (pc != (caddr_t) -1)
newlwp->l_md.md_regs->tf_spc = (int) pc;
}
}
curlwp = newlwp;
return (newlwp);
}
示例8: acquire_locks
/* Used in fork case, to avoid deadlocks.
* The fork caller acquires all locks before fork and release them
* after because the child will have only a thread. If one lock is
* taken by another thread than, in the child process, nobody will
* release it.
*/
static void
acquire_locks(void) {
struct entries_list *list;
struct hashentry *tmp;
struct shm_data *data;
struct semid_pool *semaptr;
int i;
SYSV_MUTEX_LOCK(&lock_undo);
SYSV_MUTEX_LOCK(&lock_resources);
//pthread_rwlock_wrlock(&rwlock_addrs);
for (i=0; i<get_hash_size(MAXSIZE); i++) {
list = &shmaddrs->entries[i];
if (LIST_EMPTY(list))
continue;
LIST_FOREACH(tmp, list, entry_link) {
data = (struct shm_data*)tmp->value;
if (data->type == SEMGET) {
semaptr = (struct semid_pool *)data->internal;
#ifdef SYSV_RWLOCK
#ifdef SYSV_SEMS
/* There is no need to acquire the mutexes from
* each semaphore in the group. It is enough
* to acquire the group lock in write mode.
*/
#endif
sysv_rwlock_wrlock(&semaptr->rwlock);
#else
sysv_mutex_lock(&semaptr->mutex);
#endif
}
}
}
示例9: destroy_timer
/**
* Destroy the timer list.
*
* @return 0 means ok, the other means fail.
*/
int destroy_timer(void)
{
struct timer *node = NULL;
if ((signal(SIGALRM, timer_list.old_sigfunc)) == SIG_ERR) {
return -1;
}
if((setitimer(ITIMER_REAL, &timer_list.ovalue, &timer_list.value)) < 0) {
return -1;
}
while (!LIST_EMPTY(&timer_list.header)) {/* Delete. */
node = LIST_FIRST(&timer_list.header);
LIST_REMOVE(node, entries);
/* Free node */
printf("Remove id %d\n", node->id);
free(node->user_data);
free(node);
}
memset(&timer_list, 0, sizeof(struct timer_list));
return 0;
}
示例10: isrdispatch_autovec
/*
* This is the dispatcher called by the low-level
* assembly language autovectored interrupt routine.
*/
void
isrdispatch_autovec(int ipl)
{
struct isr_autovec *isr;
isr_autovec_list_t *list;
int rc, handled = 0;
static int straycount, unexpected;
#ifdef DIAGNOSTIC
if (ipl < 0 || ipl >= NISRAUTOVEC)
panic("isrdispatch_autovec: bad ipl 0x%d\n", ipl);
#endif
intrcnt[ipl]++;
#if 0 /* XXX: already counted in machdep.c */
uvmexp.intrs++;
#endif
list = &isr_autovec[ipl];
if (LIST_EMPTY(list)) {
printf("isrdispatch_autovec: ipl %d unexpected\n", ipl);
if (++unexpected > 10)
panic("too many unexpected interrupts");
return;
}
/* Give all the handlers a chance. */
LIST_FOREACH(isr, list, isr_link) {
rc = (*isr->isr_func)(isr->isr_arg);
if (rc != 0)
isr->isr_count.ec_count++;
handled |= rc;
}
示例11: session_free
static void
session_free(obfsproxyssh_client_session_t *session)
{
obfsproxyssh_client_t *client = session->client;
assert(NULL == session->ssh_session);
assert(NULL == session->ssh_channel);
bdestroy(session->hostkey_rsa);
bdestroy(session->hostkey_dss);
bdestroy(session->user);
bdestroy(session->privkey_pem);
free_rsa_private_key(session->privkey);
if (NULL !=session->ssh_ev)
bufferevent_free(session->ssh_ev);
bufferevent_free(session->socks_ev);
bdestroy(session->ssh_addr);
bdestroy(session->socks_addr);
LIST_REMOVE(session, entries);
free(session);
/*
* Assuming that we are shutting down, ensure that we break out of the
* event loop if this is the last session. (Not needed?)
*/
if (NULL == client->listener && LIST_EMPTY(&client->sessions))
event_base_loopbreak(client->state->base);
}
示例12: t_dump
void t_dump (void)
{
Topic *tp;
if (LIST_EMPTY (topics)) {
printf ("No topics discovered.\r\n");
return;
}
printf ("Active #rd #wr #msgs #disp #no_w Topic\r\n");
printf ("------ --- --- ----- ----- ----- -----\r\n");
lock_take (topic_lock);
LIST_FOREACH (topics, tp) {
if (tp->active)
printf (" * ");
else
printf (" ");
printf ("%6u %6u %7lu %7lu %7lu %s/%s\r\n",
nendpoints (tp->writers),
nendpoints (tp->readers),
tp->ndata,
tp->ndispose,
tp->nnowriter,
tp->topic_name,
tp->type_name);
}
lock_release (topic_lock);
}
示例13: assign_job
static void
assign_job(struct scan_peer *peer)
{
size_t job_len;
uint16_t net_job_len;
peer->job = clients_started ? get_job() : NULL;
if (peer->job == NULL) {
LIST_INSERT_HEAD(&inactive_peers, peer, peer_link);
if (LIST_EMPTY(&active_peers) && clients_started)
shutdown_master();
return;
}
LIST_INSERT_HEAD(&active_peers, peer, peer_link);
peer->job->scan_output = NULL;
job_len = strlen(peer->job->pkg_location);
if (job_len > 0xffff)
errx(1, "Location inside pkgsrc tree too long");
net_job_len = htons(job_len);
(void)memcpy(peer->tmp_buf, &net_job_len, 2);
deferred_write(peer->fd, peer->tmp_buf, 2, peer, send_job_path,
kill_peer);
}
示例14: ng_ksocket_shutdown
/*
* Destroy node
*/
static int
ng_ksocket_shutdown(node_p node)
{
const priv_p priv = NG_NODE_PRIVATE(node);
priv_p embryo;
/* Close our socket (if any) */
if (priv->so != NULL) {
atomic_clear_int(&priv->so->so_rcv.ssb_flags, SSB_UPCALL);
atomic_clear_int(&priv->so->so_snd.ssb_flags, SSB_UPCALL);
priv->so->so_upcall = NULL;
soclose(priv->so, FNONBLOCK);
priv->so = NULL;
}
/* If we are an embryo, take ourselves out of the parent's list */
if (priv->flags & KSF_EMBRYONIC) {
LIST_REMOVE(priv, siblings);
priv->flags &= ~KSF_EMBRYONIC;
}
/* Remove any embryonic children we have */
while (!LIST_EMPTY(&priv->embryos)) {
embryo = LIST_FIRST(&priv->embryos);
ng_rmnode_self(embryo->node);
}
/* Take down netgraph node */
bzero(priv, sizeof(*priv));
kfree(priv, M_NETGRAPH);
NG_NODE_SET_PRIVATE(node, NULL);
NG_NODE_UNREF(node); /* let the node escape */
return (0);
}
示例15: handle_pending_hsrs
void handle_pending_hsrs(void)
{
extern int32_t sched_lock;
int nr;
list_head_t *list, *node;
hsr_t *hsr;
if (sched_lock > 0)
return;
// just only to prevent hisrs to schedule
++sched_lock;
while (1) {
nr = HAL_FIND_FIRST_SET(hsr_bitmap);
if (nr < 0)
break;
list = hsr_array + nr;
node = LIST_FIRST(list);
BUG_ON(NULL == node);
hsr = LIST_ENTRY(node, hsr_t, node);
hsr->function(hsr->data);
HAL_DISABLE_INTERRUPTS();
--hsr->count;
if (hsr->count <= 0)
LIST_DEL(node);
if (LIST_EMPTY(list))
hsr_bitmap &= ~(1 << nr);
HAL_ENABLE_INTERRUPTS();
}
--sched_lock;
}