mirror of
https://github.com/apache/nuttx.git
synced 2026-09-27 18:58:27 +08:00
Add poll() method
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1262 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
+27
-2
@@ -45,6 +45,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <poll.h>
|
||||
#include <errno.h>
|
||||
#include <nuttx/fs.h>
|
||||
|
||||
@@ -54,6 +55,9 @@
|
||||
|
||||
static ssize_t devnull_read(FAR struct file *, FAR char *, size_t);
|
||||
static ssize_t devnull_write(FAR struct file *, FAR const char *, size_t);
|
||||
#ifndef CONFIG_DISABLE_POLL
|
||||
static int devnull_poll(FAR struct file *filp, FAR struct pollfd *poll);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@@ -66,8 +70,10 @@ static struct file_operations devnull_fops =
|
||||
devnull_read, /* read */
|
||||
devnull_write, /* write */
|
||||
0, /* seek */
|
||||
0, /* ioctl */
|
||||
0 /* poll */
|
||||
0 /* ioctl */
|
||||
#ifndef CONFIG_DISABLE_POLL
|
||||
, devnull_poll /* poll */
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -92,6 +98,25 @@ static ssize_t devnull_write(FAR struct file *filp, FAR const char *buffer, size
|
||||
return len; /* Say that everything was written */
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: devnull_poll
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_DISABLE_POLL
|
||||
static int devnull_poll(FAR struct file *filp, FAR struct pollfd *fds)
|
||||
{
|
||||
if (fds)
|
||||
{
|
||||
fds->revents |= (fds->events & (POLLIN|POLLOUT));
|
||||
if (fds->revents != 0)
|
||||
{
|
||||
sem_post(fds->sem);
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user