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:
patacongo
2008-11-17 20:24:28 +00:00
parent efff6fa8d2
commit 68ec2ba098
6 changed files with 235 additions and 10 deletions
+27 -2
View File
@@ -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
****************************************************************************/