forked from nuttx/nuttx-update
fs: Remove the unused nx_poll to prefer file_poll for kernel
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
aa31648c9f
commit
cf21319d3a
3 changed files with 39 additions and 101 deletions
|
@ -410,21 +410,37 @@ int file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
|
|||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_poll
|
||||
* Name: poll
|
||||
*
|
||||
* Description:
|
||||
* nx_poll() is similar to the standard 'poll' interface except that is
|
||||
* not a cancellation point and it does not modify the errno variable.
|
||||
* poll() waits for one of a set of file descriptors to become ready to
|
||||
* perform I/O. If none of the events requested (and no error) has
|
||||
* occurred for any of the file descriptors, then poll() blocks until
|
||||
* one of the events occurs.
|
||||
*
|
||||
* nx_poll() is an internal NuttX interface and should not be called from
|
||||
* applications.
|
||||
* Input Parameters:
|
||||
* fds - List of structures describing file descriptors to be monitored
|
||||
* nfds - The number of entries in the list
|
||||
* timeout - Specifies an upper limit on the time for which poll() will
|
||||
* block in milliseconds. A negative value of timeout means an infinite
|
||||
* timeout.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success; a negated value is returned on any failure.
|
||||
* On success, the number of structures that have non-zero revents fields.
|
||||
* A value of 0 indicates that the call timed out and no file descriptors
|
||||
* were ready. On error, -1 is returned, and errno is set appropriately:
|
||||
*
|
||||
* EBADF - An invalid file descriptor was given in one of the sets.
|
||||
* EFAULT - The fds address is invalid
|
||||
* EINTR - A signal occurred before any requested event.
|
||||
* EINVAL - The nfds value exceeds a system limit.
|
||||
* ENOMEM - There was no space to allocate internal data structures.
|
||||
* ENOSYS - One or more of the drivers supporting the file descriptor
|
||||
* does not support the poll method.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_poll(FAR struct pollfd *fds, unsigned int nfds, int timeout)
|
||||
int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout)
|
||||
{
|
||||
sem_t sem;
|
||||
int count = 0;
|
||||
|
@ -433,6 +449,10 @@ int nx_poll(FAR struct pollfd *fds, unsigned int nfds, int timeout)
|
|||
|
||||
DEBUGASSERT(nfds == 0 || fds != NULL);
|
||||
|
||||
/* poll() is a cancellation point */
|
||||
|
||||
enter_cancellation_point();
|
||||
|
||||
nxsem_init(&sem, 0, 0);
|
||||
ret = poll_setup(fds, nfds, &sem);
|
||||
if (ret >= 0)
|
||||
|
@ -508,57 +528,15 @@ int nx_poll(FAR struct pollfd *fds, unsigned int nfds, int timeout)
|
|||
}
|
||||
|
||||
nxsem_destroy(&sem);
|
||||
return ret < 0 ? ret : count;
|
||||
}
|
||||
leave_cancellation_point();
|
||||
|
||||
/****************************************************************************
|
||||
* Name: poll
|
||||
*
|
||||
* Description:
|
||||
* poll() waits for one of a set of file descriptors to become ready to
|
||||
* perform I/O. If none of the events requested (and no error) has
|
||||
* occurred for any of the file descriptors, then poll() blocks until
|
||||
* one of the events occurs.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fds - List of structures describing file descriptors to be monitored
|
||||
* nfds - The number of entries in the list
|
||||
* timeout - Specifies an upper limit on the time for which poll() will
|
||||
* block in milliseconds. A negative value of timeout means an infinite
|
||||
* timeout.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, the number of structures that have non-zero revents fields.
|
||||
* A value of 0 indicates that the call timed out and no file descriptors
|
||||
* were ready. On error, -1 is returned, and errno is set appropriately:
|
||||
*
|
||||
* EBADF - An invalid file descriptor was given in one of the sets.
|
||||
* EFAULT - The fds address is invalid
|
||||
* EINTR - A signal occurred before any requested event.
|
||||
* EINVAL - The nfds value exceeds a system limit.
|
||||
* ENOMEM - There was no space to allocate internal data structures.
|
||||
* ENOSYS - One or more of the drivers supporting the file descriptor
|
||||
* does not support the poll method.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* poll() is a cancellation point */
|
||||
|
||||
enter_cancellation_point();
|
||||
|
||||
/* Let nx_poll() do all of the work */
|
||||
|
||||
ret = nx_poll(fds, nfds, timeout);
|
||||
if (ret < 0)
|
||||
{
|
||||
set_errno(-ret);
|
||||
ret = ERROR;
|
||||
return ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
leave_cancellation_point();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -79,21 +79,16 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
|||
FAR fd_set *exceptfds, FAR struct timeval *timeout)
|
||||
{
|
||||
struct pollfd *pollset = NULL;
|
||||
int errcode = OK;
|
||||
int fd;
|
||||
int npfds;
|
||||
int msec;
|
||||
int ndx;
|
||||
int ret;
|
||||
|
||||
/* select() is cancellation point */
|
||||
|
||||
enter_cancellation_point();
|
||||
|
||||
if (nfds < 0)
|
||||
{
|
||||
errcode = EINVAL;
|
||||
goto errout;
|
||||
set_errno(EINVAL);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* How many pollfd structures do we need to allocate? */
|
||||
|
@ -123,8 +118,8 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
|||
|
||||
if (pollset == NULL)
|
||||
{
|
||||
errcode = ENOMEM;
|
||||
goto errout;
|
||||
set_errno(ENOMEM);
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,13 +186,7 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
|||
|
||||
/* Then let poll do all of the real work. */
|
||||
|
||||
ret = nx_poll(pollset, npfds, msec);
|
||||
if (ret < 0)
|
||||
{
|
||||
/* poll() failed! Save the errno value */
|
||||
|
||||
errcode = -ret;
|
||||
}
|
||||
ret = poll(pollset, npfds, msec);
|
||||
|
||||
/* Now set up the return values */
|
||||
|
||||
|
@ -263,17 +252,5 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
|||
}
|
||||
|
||||
kmm_free(pollset);
|
||||
|
||||
/* Did poll() fail above? */
|
||||
|
||||
if (ret >= 0)
|
||||
{
|
||||
leave_cancellation_point();
|
||||
return ret;
|
||||
}
|
||||
|
||||
errout:
|
||||
set_errno(errcode);
|
||||
leave_cancellation_point();
|
||||
return ERROR;
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1354,23 +1354,6 @@ int nx_fcntl(int fd, int cmd, ...);
|
|||
|
||||
int file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_poll
|
||||
*
|
||||
* Description:
|
||||
* nx_poll() is similar to the standard 'poll' interface except that is
|
||||
* not a cancellation point and it does not modify the errno variable.
|
||||
*
|
||||
* nx_poll() is an internal NuttX interface and should not be called from
|
||||
* applications.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success; a negated value is returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_poll(FAR struct pollfd *fds, unsigned int nfds, int timeout);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: file_fstat
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue