• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ poll_wait函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中poll_wait函数的典型用法代码示例。如果您正苦于以下问题:C++ poll_wait函数的具体用法?C++ poll_wait怎么用?C++ poll_wait使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了poll_wait函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: mei_poll

/**
 * mei_poll - the poll function
 *
 * @file: pointer to file structure
 * @wait: pointer to poll_table structure
 *
 * Return: poll mask
 */
static unsigned int mei_poll(struct file *file, poll_table *wait)
{
	unsigned long req_events = poll_requested_events(wait);
	struct mei_cl *cl = file->private_data;
	struct mei_device *dev;
	unsigned int mask = 0;

	if (WARN_ON(!cl || !cl->dev))
		return POLLERR;

	dev = cl->dev;

	mutex_lock(&dev->device_lock);


	if (dev->dev_state != MEI_DEV_ENABLED ||
	    !mei_cl_is_connected(cl)) {
		mask = POLLERR;
		goto out;
	}

	if (cl == &dev->iamthif_cl) {
		mask = mei_amthif_poll(dev, file, wait);
		goto out;
	}

	if (req_events & (POLLIN | POLLRDNORM)) {
		poll_wait(file, &cl->rx_wait, wait);

		if (!list_empty(&cl->rd_completed))
			mask |= POLLIN | POLLRDNORM;
		else
			mei_cl_read_start(cl, 0, file);
	}

out:
	mutex_unlock(&dev->device_lock);
	return mask;
}
开发者ID:lovejavaee,项目名称:linux-2,代码行数:47,代码来源:main.c


示例2: datagram_poll

/**
 * 	datagram_poll - generic datagram poll
 *	@file: file struct
 *	@sock: socket
 *	@wait: poll table
 *
 *	Datagram poll: Again totally generic. This also handles
 *	sequenced packet sockets providing the socket receive queue
 *	is only ever holding data ready to receive.
 *
 *	Note: when you _don't_ use this routine for this protocol,
 *	and you use a different write policy from sock_writeable()
 *	then please supply your own write_space callback.
 */
unsigned int datagram_poll(struct file *file, struct socket *sock,
			   poll_table *wait)
{
	struct sock *sk = sock->sk;
	unsigned int mask;

	poll_wait(file, sk->sk_sleep, wait);
	mask = 0;

	/* exceptional events? */
	if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
		mask |= POLLERR;
	if (sk->sk_shutdown & RCV_SHUTDOWN)
		mask |= POLLRDHUP;
	if (sk->sk_shutdown == SHUTDOWN_MASK)
		mask |= POLLHUP;

	/* readable? */
	if (!skb_queue_empty(&sk->sk_receive_queue) ||
	    (sk->sk_shutdown & RCV_SHUTDOWN))
		mask |= POLLIN | POLLRDNORM;

	/* Connection-based need to check for termination and startup */
	if (connection_based(sk)) {
		if (sk->sk_state == TCP_CLOSE)
			mask |= POLLHUP;
		/* connection hasn't started yet? */
		if (sk->sk_state == TCP_SYN_SENT)
			return mask;
	}

	/* writable? */
	if (sock_writeable(sk))
		mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
	else
		set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);

	return mask;
}
开发者ID:ruigulala,项目名称:helgrind_uml,代码行数:53,代码来源:datagram.c


示例3: vb2_poll

unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
{
	unsigned long flags;
	unsigned int ret;
	struct vb2_buffer *vb = NULL;

	if (q->num_buffers == 0 && q->fileio == NULL) {
		if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ)) {
			ret = __vb2_init_fileio(q, 1);
			if (ret)
				return POLLERR;
		}
		if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE)) {
			ret = __vb2_init_fileio(q, 0);
			if (ret)
				return POLLERR;
			return POLLOUT | POLLWRNORM;
		}
	}

	if (list_empty(&q->queued_list))
		return POLLERR;

	poll_wait(file, &q->done_wq, wait);

	spin_lock_irqsave(&q->done_lock, flags);
	if (!list_empty(&q->done_list))
		vb = list_first_entry(&q->done_list, struct vb2_buffer,
					done_entry);
	spin_unlock_irqrestore(&q->done_lock, flags);

	if (vb && (vb->state == VB2_BUF_STATE_DONE
			|| vb->state == VB2_BUF_STATE_ERROR)) {
		return (V4L2_TYPE_IS_OUTPUT(q->type)) ? POLLOUT | POLLWRNORM :
			POLLIN | POLLRDNORM;
	}
	return 0;
}
开发者ID:InvisiSource,项目名称:Haunted,代码行数:38,代码来源:videobuf2-core.c


示例4: microdia_queue_poll

/**
 * @brief Poll the video queue.
 *
 * @param queue
 * @param file
 * @param wait
 *
 * This function implements video queue polling and is intended to be used by
 * the device poll handler.
 */
unsigned int microdia_queue_poll(struct microdia_video_queue *queue,
	struct file *file, poll_table *wait)
{
	struct microdia_buffer *buf;
	unsigned int mask = 0;

	mutex_lock(&queue->mutex);
	if (list_empty(&queue->mainqueue)) {
		mask |= POLLERR;
		goto done;
	}
	buf = list_first_entry(&queue->mainqueue, struct microdia_buffer,
			       stream);

	poll_wait(file, &buf->wait, wait);
	if (buf->state == MICRODIA_BUF_STATE_DONE ||
	    buf->state == MICRODIA_BUF_STATE_ERROR)
		mask |= POLLIN | POLLRDNORM;

done:
	mutex_unlock(&queue->mutex);
	return mask;
}
开发者ID:BotBallARDroneAPI,项目名称:CBC_Library,代码行数:33,代码来源:microdia-queue.c


示例5: dvb_demux_poll

static unsigned int dvb_demux_poll (struct file *file, poll_table *wait)
{
	struct dmxdev_filter *dmxdevfilter = dvb_dmxdev_file_to_filter(file);
	unsigned int mask = 0;

	if (!dmxdevfilter)
		return -EINVAL;

	poll_wait(file, &dmxdevfilter->buffer.queue, wait);

	if (dmxdevfilter->state != DMXDEV_STATE_GO &&
	    dmxdevfilter->state != DMXDEV_STATE_DONE &&
	    dmxdevfilter->state != DMXDEV_STATE_TIMEDOUT)
		return 0;

	if (dmxdevfilter->buffer.error)
		mask |= (POLLIN | POLLRDNORM | POLLPRI | POLLERR);

	if (dmxdevfilter->buffer.pread != dmxdevfilter->buffer.pwrite)
		mask |= (POLLIN | POLLRDNORM | POLLPRI);

	return mask;
}
开发者ID:ChakaZulu,项目名称:tuxbox_driver,代码行数:23,代码来源:dmxdev.c


示例6: goldfish_pipe_poll

static __poll_t goldfish_pipe_poll(struct file *filp, poll_table *wait)
{
	struct goldfish_pipe *pipe = filp->private_data;
	__poll_t mask = 0;
	int status;

	poll_wait(filp, &pipe->wake_queue, wait);

	status = goldfish_pipe_cmd(pipe, PIPE_CMD_POLL);
	if (status < 0)
		return -ERESTARTSYS;

	if (status & PIPE_POLL_IN)
		mask |= EPOLLIN | EPOLLRDNORM;
	if (status & PIPE_POLL_OUT)
		mask |= EPOLLOUT | EPOLLWRNORM;
	if (status & PIPE_POLL_HUP)
		mask |= EPOLLHUP;
	if (test_bit(BIT_CLOSED_ON_HOST, &pipe->flags))
		mask |= EPOLLERR;

	return mask;
}
开发者ID:austriancoder,项目名称:linux,代码行数:23,代码来源:goldfish_pipe.c


示例7: chardev_poll

/**
 *	@brief poll handler for char dev
 *
 *	@param filp	pointer to structure file
 *	@param wait		pointer to poll_table structure
 *	@return			mask
 */
static unsigned int
chardev_poll(struct file *filp, poll_table * wait)
{
	unsigned int mask;
	struct char_dev *dev = (struct char_dev *)filp->private_data;
	struct m_dev *m_dev = NULL;
	ENTER();
	if (!dev || !dev->m_dev) {
		LEAVE();
		return -ENXIO;
	}

	m_dev = dev->m_dev;
	poll_wait(filp, &m_dev->req_wait_q, wait);
	mask = POLLOUT | POLLWRNORM;
	if (skb_peek(&m_dev->rx_q))
		mask |= POLLIN | POLLRDNORM;
	if (!test_bit(HCI_UP, &(m_dev->flags)))
		mask |= POLLHUP;
	PRINTM(INFO, "poll mask=0x%x\n", mask);
	LEAVE();
	return mask;
}
开发者ID:1ee7,项目名称:linux_l4t_tx1,代码行数:30,代码来源:mbt_char.c


示例8: co_os_manager_poll

static
unsigned int co_os_manager_poll(struct file *file, struct poll_table_struct *pollts)
{
	co_manager_open_desc_t opened = (typeof(opened))(file->private_data);
        unsigned int mask = POLLOUT | POLLWRNORM, size;
	co_queue_t *queue;

	co_os_mutex_acquire(opened->lock);
	queue = &opened->out_queue;
	size = co_queue_size(queue);
	co_os_mutex_release(opened->lock);

        poll_wait(file, &opened->os->waitq, pollts);

        if (size)
                mask |= POLLIN | POLLRDNORM;

	if (!opened->active)
		mask |= POLLHUP;

        return mask;

}
开发者ID:matt81093,项目名称:Original-Colinux,代码行数:23,代码来源:manager.c


示例9: plog_poll

// We need to support this function if we want the select() call to behave
// properly on this file.
static unsigned int plog_poll(struct file *file, poll_table * wait)
{
    unsigned int  readable;
    plog_reader   *s = (plog_reader*) file->private_data;
    monotonic_ptr file_rp = s->read_ptr;
    unsigned long flags;

    poll_wait(file, &plog_wait, wait);

    spin_lock_irqsave(&s_lock, flags);
    
    readable = plog_readable(file_rp);

    spin_unlock_irqrestore(&s_lock, flags);

    // If there is 4096 bytes, you can read data.
    if (readable >= 4096) 
    {
        return POLLIN | POLLRDNORM;
    }

    return 0;
}
开发者ID:jameshilliard,项目名称:20-4-4,代码行数:25,代码来源:plog.c


示例10: proc_sys_poll

static unsigned int proc_sys_poll(struct file *filp, poll_table *wait)
{
	struct inode *inode = filp->f_path.dentry->d_inode;
	struct ctl_table *table = PROC_I(inode)->sysctl_entry;
	unsigned long event = (unsigned long)filp->private_data;
	unsigned int ret = DEFAULT_POLLMASK;

	if (!table->proc_handler)
		goto out;

	if (!table->poll)
		goto out;

	poll_wait(filp, &table->poll->wait, wait);

	if (event != atomic_read(&table->poll->event)) {
		filp->private_data = proc_sys_poll_event(table->poll);
		ret = POLLIN | POLLRDNORM | POLLERR | POLLPRI;
	}

out:
	return ret;
}
开发者ID:nos1609,项目名称:Chrono_Kernel-1,代码行数:23,代码来源:proc_sysctl.c


示例11: normal_poll

static unsigned int normal_poll(struct tty_struct * tty, struct file * file, poll_table *wait)
{
	unsigned int mask = 0;

	poll_wait(file, &tty->poll_wait, wait);
	if (input_available_p(tty, TIME_CHAR(tty) ? 0 : MIN_CHAR(tty)))
		mask |= POLLIN | POLLRDNORM;
	if (tty->packet && tty->link->ctrl_status)
		mask |= POLLPRI | POLLIN | POLLRDNORM;
	if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
		mask |= POLLHUP;
	if (tty_hung_up_p(file))
		mask |= POLLHUP;
	if (!(mask & (POLLHUP | POLLIN | POLLRDNORM))) {
		if (MIN_CHAR(tty) && !TIME_CHAR(tty))
			tty->minimum_to_wake = MIN_CHAR(tty);
		else
			tty->minimum_to_wake = 1;
	}
	if (tty->driver.chars_in_buffer(tty) < WAKEUP_CHARS)
		mask |= POLLOUT | POLLWRNORM;
	return mask;
}
开发者ID:chinnyannieb,项目名称:empeg-hijack,代码行数:23,代码来源:n_tty.c


示例12: dvb_demux_poll

static unsigned int dvb_demux_poll(struct file *file, poll_table *wait)
{
    struct dmxdev_filter *dmxdevfilter = file->private_data;
    unsigned int mask = 0;

    if (!dmxdevfilter)
        return -EINVAL;

    poll_wait(file, &dmxdevfilter->buffer.queue, wait);

    if (dmxdevfilter->state != DMXDEV_STATE_GO &&
        dmxdevfilter->state != DMXDEV_STATE_DONE &&
        dmxdevfilter->state != DMXDEV_STATE_TIMEDOUT)
        return 0;

    if (dmxdevfilter->buffer.error)
        mask |= (POLLIN | POLLRDNORM | POLLPRI | POLLERR);

    if (!dvb_ringbuffer_empty(&dmxdevfilter->buffer))
        mask |= (POLLIN | POLLRDNORM | POLLPRI);

    return mask;
}
开发者ID:274914765,项目名称:C,代码行数:23,代码来源:dmxdev.c


示例13: rawchip_fops_poll

static unsigned int rawchip_fops_poll(struct file *filp,
	struct poll_table_struct *pll_table)
{
	int rc = 0;
	unsigned long flags;

	poll_wait(filp, &yushan_int.yushan_wait, pll_table);

	spin_lock_irqsave(&yushan_int.yushan_spin_lock, flags);
	if (atomic_read(&interrupt)) {
		atomic_set(&interrupt, 0);
		atomic_set(&rawchipCtrl->check_intr0, 1);
		rc = POLLIN | POLLRDNORM;
	}
	if (atomic_read(&interrupt2)) {
		atomic_set(&interrupt2, 0);
		atomic_set(&rawchipCtrl->check_intr1, 1);
		rc = POLLIN | POLLRDNORM;
	}
	spin_unlock_irqrestore(&yushan_int.yushan_spin_lock, flags);

	return rc;
}
开发者ID:talnoah,项目名称:Lemur_cm-11.0,代码行数:23,代码来源:rawchip.c


示例14: avSync_device_poll

static unsigned int avSync_device_poll(struct file *file, struct poll_table_struct *wait)
{
    isil_avSync_dev_t	*dev;
    unsigned int mask = 0;

    dev = (isil_avSync_dev_t*)file->private_data;
    if (dev == NULL) {
        printk("[%s]:video_dev is null\n", __FUNCTION__);
        return -ENODEV;
    }
    down(&dev->sem);
    if(atomic_read(&dev->opened_flags)) {
        poll_wait(file, &dev->wait_poll, wait);
        if(dev->avSync_frame_queue.op->get_curr_queue_entry_number(&dev->avSync_frame_queue)){
            mask = POLLIN | POLLRDNORM;
        }
    } else {
        printk("%s:%s have not been opened\n", __FUNCTION__, dev->name);
        mask = POLLOUT | POLLWRNORM | POLLIN | POLLRDNORM;
    }
    up(&dev->sem);
    return mask;
}
开发者ID:github188,项目名称:isil5864,代码行数:23,代码来源:isil_avSync_device.c


示例15: rmnet_ctl_poll

static unsigned int rmnet_ctl_poll(struct file *file, poll_table *wait)
{
	unsigned int		mask = 0;
	struct rmnet_ctrl_dev	*dev;

	dev = file->private_data;
	if (!dev)
		return POLLERR;

	poll_wait(file, &dev->read_wait_queue, wait);
	if (!is_dev_connected(dev)) {
		dev_dbg(dev->devicep, "%s: Device not connected\n",
			__func__);
		return POLLERR;
	}

	if (!list_empty(&dev->rx_list)) {
		poll_time = cpu_clock(smp_processor_id());
		rd_poll_delta_time = poll_time - rd_cb_time;
		mask |= POLLIN | POLLRDNORM;
	}
	return mask;
}
开发者ID:devil1210,项目名称:EvilKernel,代码行数:23,代码来源:rmnet_usb_ctrl.c


示例16: sysfs_poll

/* Sysfs attribute files are pollable.  The idea is that you read
 * the content and then you use 'poll' or 'select' to wait for
 * the content to change.  When the content changes (assuming the
 * manager for the kobject supports notification), poll will
 * return POLLERR|POLLPRI, and select will return the fd whether
 * it is waiting for read, write, or exceptions.
 * Once poll/select indicates that the value has changed, you
 * need to close and re-open the file, as simply seeking and reading
 * again will not get new data, or reset the state of 'poll'.
 * Reminder: this only works for attributes which actively support
 * it, and it is not possible to test an attribute from userspace
 * to see if it supports poll (Nether 'poll' or 'select' return
 * an appropriate error code).  When in doubt, set a suitable timeout value.
 */
static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
{
	struct sysfs_buffer * buffer = filp->private_data;
	struct sysfs_dirent *attr_sd = filp->f_path.dentry->d_fsdata;
	struct kobject *kobj = attr_sd->s_parent->s_elem.dir.kobj;

	/* need parent for the kobj, grab both */
	if (!sysfs_get_active_two(attr_sd))
		goto trigger;

	poll_wait(filp, &kobj->poll, wait);

	sysfs_put_active_two(attr_sd);

	if (buffer->event != atomic_read(&attr_sd->s_event))
		goto trigger;

	return 0;

 trigger:
	buffer->needs_read_fill = 1;
	return POLLERR|POLLPRI;
}
开发者ID:cilynx,项目名称:dd-wrt,代码行数:37,代码来源:file.c


示例17: sysfs_poll

/* Sysfs attribute files are pollable.  The idea is that you read
 * the content and then you use 'poll' or 'select' to wait for
 * the content to change.  When the content changes (assuming the
 * manager for the kobject supports notification), poll will
 * return POLLERR|POLLPRI, and select will return the fd whether
 * it is waiting for read, write, or exceptions.
 * Once poll/select indicates that the value has changed, you
 * need to close and re-open the file, or seek to 0 and read again.
 * Reminder: this only works for attributes which actively support
 * it, and it is not possible to test an attribute from userspace
 * to see if it supports poll (Neither 'poll' nor 'select' return
 * an appropriate error code).  When in doubt, set a suitable timeout value.
 */
static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
{
	struct sysfs_buffer * buffer = filp->private_data;
	struct sysfs_dirent *attr_sd = filp->f_path.dentry->d_fsdata;
	struct sysfs_open_dirent *od = attr_sd->s_attr.open;

	/* need parent for the kobj, grab both */
	if (!sysfs_get_active(attr_sd))
		goto trigger;

	poll_wait(filp, &od->poll, wait);

	sysfs_put_active(attr_sd);

	if (buffer->event != atomic_read_unchecked(&od->event))
		goto trigger;

	return DEFAULT_POLLMASK;

 trigger:
	buffer->needs_read_fill = 1;
	return DEFAULT_POLLMASK|POLLERR|POLLPRI;
}
开发者ID:novic,项目名称:AniDroid-Hardened-Kernel,代码行数:36,代码来源:file.c


示例18: r3964_poll

/* Called without the kernel lock held - fine */
static unsigned int r3964_poll(struct tty_struct *tty, struct file *file,
			struct poll_table_struct *wait)
{
	struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data;
	struct r3964_client_info *pClient;
	struct r3964_message *pMsg = NULL;
	unsigned long flags;
	int result = POLLOUT;

	TRACE_L("POLL");

	pClient = findClient(pInfo, task_pid(current));
	if (pClient) {
		poll_wait(file, &pInfo->read_wait, wait);
		spin_lock_irqsave(&pInfo->lock, flags);
		pMsg = pClient->first_msg;
		spin_unlock_irqrestore(&pInfo->lock, flags);
		if (pMsg)
			result |= POLLIN | POLLRDNORM;
	} else {
		result = -EINVAL;
	}
	return result;
}
开发者ID:ManiacTwister,项目名称:linux-hnd,代码行数:25,代码来源:n_r3964.c


示例19: qti_ctrl_poll

static unsigned int qti_ctrl_poll(struct file *file, poll_table *wait)
{
	struct qti_ctrl_port *port = container_of(file->private_data,
						struct qti_ctrl_port,
						ctrl_device);
	unsigned long flags;
	unsigned int mask = 0;

	if (!port) {
		pr_err("%s on a NULL device\n", __func__);
		return POLLERR;
	}

	poll_wait(file, &port->read_wq, wait);

	spin_lock_irqsave(&port->lock, flags);
	if (!list_empty(&port->cpkt_req_q)) {
		mask |= POLLIN | POLLRDNORM;
		pr_debug("%s sets POLLIN for rmnet_ctrl_qti_port\n", __func__);
	}
	spin_unlock_irqrestore(&port->lock, flags);

	return mask;
}
开发者ID:Menpiko,项目名称:SnaPKernel-N6P,代码行数:24,代码来源:u_ctrl_qti.c


示例20: bus1_fop_poll

static unsigned int bus1_fop_poll(struct file *file,
				  struct poll_table_struct *wait)
{
	struct bus1_peer *peer = file->private_data;
	struct bus1_peer_info *peer_info;
	unsigned int mask;

	poll_wait(file, &peer->waitq, wait);

	/*
	 * If the peer is still in state NEW, then CONNECT hasn't been called
	 * and the peer is unused. Return no event at all.
	 */
	if (bus1_active_is_new(&peer->active))
		return 0;

	/*
	 * We now dereference the peer object (which is rcu-protected). It
	 * might be NULL during a racing DISCONNECT. If it is non-NULL *and*
	 * the peer has not been deactivated, then the peer is live and thus
	 * writable. If data is queued, it is readable as well.
	 */
	rcu_read_lock();
	peer_info = rcu_dereference(peer->info);
	if (!peer_info || bus1_active_is_deactivated(&peer->active)) {
		mask = POLLERR | POLLHUP;
	} else {
		mask = POLLOUT | POLLWRNORM;
		if (bus1_queue_is_readable(&peer_info->queue) ||
		    atomic_read(&peer_info->n_dropped) > 0)
			mask |= POLLIN | POLLRDNORM;
	}
	rcu_read_unlock();

	return mask;
}
开发者ID:OpenDZ,项目名称:bus1,代码行数:36,代码来源:main.c



注:本文中的poll_wait函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ poly函数代码示例发布时间:2022-05-30
下一篇:
C++ pollBalanceChanged函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap