Skip to content

Commit

Permalink
Revert "posix: device_io: implement pselect()"
Browse files Browse the repository at this point in the history
This reverts commit 305ec62.

PR zephyrproject-rtos#73978 introduced a regression.
Unfortunately this PR cannot be reverted without reverting also
Let's revert both PRs to stabilize main again towards the 3.7 release.

For more details on the issue see
zephyrproject-rtos#75205

Signed-off-by: Alberto Escolar Piedras <[email protected]>
  • Loading branch information
aescolar committed Jul 1, 2024
1 parent 40d2871 commit 75b4255
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 28 deletions.
7 changes: 2 additions & 5 deletions include/zephyr/net/socket_select.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,9 @@ typedef struct zvfs_fd_set zsock_fd_set;
static inline int zsock_select(int nfds, zsock_fd_set *readfds, zsock_fd_set *writefds,
zsock_fd_set *exceptfds, struct zsock_timeval *timeout)
{
struct timespec to = {
.tv_sec = (timeout == NULL) ? 0 : timeout->tv_sec,
.tv_nsec = (long)((timeout == NULL) ? 0 : timeout->tv_usec * NSEC_PER_USEC)};
struct timeval;

return zvfs_select(nfds, (struct zvfs_fd_set *)readfds, (struct zvfs_fd_set *)writefds,
(struct zvfs_fd_set *)exceptfds, (timeout == NULL) ? NULL : &to, NULL);
return zvfs_select(nfds, readfds, writefds, exceptfds, (struct timeval *)timeout);
}

/** Number of file descriptors which can be added to zsock_fd_set */
Expand Down
2 changes: 0 additions & 2 deletions include/zephyr/posix/sys/select.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ extern "C" {

struct timeval;

int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
const struct timespec *timeout, const void *sigmask);
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout);
void FD_CLR(int fd, fd_set *fdset);
int FD_ISSET(int fd, fd_set *fdset);
Expand Down
2 changes: 1 addition & 1 deletion include/zephyr/sys/fdtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ struct timespec;
__syscall int zvfs_select(int nfds, struct zvfs_fd_set *ZRESTRICT readfds,
struct zvfs_fd_set *ZRESTRICT writefds,
struct zvfs_fd_set *ZRESTRICT errorfds,
const struct timespec *ZRESTRICT timeout, const void *ZRESTRICT sigmask);
const struct timeval *ZRESTRICT timeout);

/**
* Request codes for fd_op_vtable.ioctl().
Expand Down
12 changes: 5 additions & 7 deletions lib/os/zvfs/zvfs_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void ZVFS_FD_SET(int fd, struct zvfs_fd_set *set)
int z_impl_zvfs_select(int nfds, struct zvfs_fd_set *ZRESTRICT readfds,
struct zvfs_fd_set *ZRESTRICT writefds,
struct zvfs_fd_set *ZRESTRICT exceptfds,
const struct timespec *ZRESTRICT timeout, const void *ZRESTRICT sigmask)
const struct timeval *ZRESTRICT timeout)
{
struct zvfs_pollfd pfds[CONFIG_ZVFS_POLL_MAX];
k_timeout_t poll_timeout;
Expand Down Expand Up @@ -142,8 +142,7 @@ int z_impl_zvfs_select(int nfds, struct zvfs_fd_set *ZRESTRICT readfds,
if (timeout == NULL) {
poll_timeout = K_FOREVER;
} else {
poll_timeout =
K_USEC(timeout->tv_sec * USEC_PER_SEC + timeout->tv_nsec / NSEC_PER_USEC);
poll_timeout = K_USEC(timeout->tv_sec * USEC_PER_SEC + timeout->tv_usec);
}

res = zvfs_poll_internal(pfds, num_pfds, poll_timeout);
Expand Down Expand Up @@ -221,11 +220,10 @@ int z_impl_zvfs_select(int nfds, struct zvfs_fd_set *ZRESTRICT readfds,
static int z_vrfy_zvfs_select(int nfds, struct zvfs_fd_set *ZRESTRICT readfds,
struct zvfs_fd_set *ZRESTRICT writefds,
struct zvfs_fd_set *ZRESTRICT exceptfds,
const struct timespec *ZRESTRICT timeout,
const void *ZRESTRICT sigmask)
const struct timeval *ZRESTRICT timeout)
{
struct zvfs_fd_set *readfds_copy = NULL, *writefds_copy = NULL, *exceptfds_copy = NULL;
struct timespec *to = NULL;
struct timeval *to = NULL;
int ret = -1;

if (readfds) {
Expand Down Expand Up @@ -263,7 +261,7 @@ static int z_vrfy_zvfs_select(int nfds, struct zvfs_fd_set *ZRESTRICT readfds,
}
}

ret = z_impl_zvfs_select(nfds, readfds_copy, writefds_copy, exceptfds_copy, to, sigmask);
ret = z_impl_zvfs_select(nfds, readfds_copy, writefds_copy, exceptfds_copy, to);

if (ret >= 0) {
if (readfds_copy) {
Expand Down
13 changes: 1 addition & 12 deletions lib/posix/options/device_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ ssize_t pread(int fd, void *buf, size_t count, off_t offset)
return zvfs_read(fd, buf, count, (size_t *)&off);
}

int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
const struct timespec *timeout, const void *sigmask)
{
return zvfs_select(nfds, readfds, writefds, exceptfds, timeout, sigmask);
}

ssize_t pwrite(int fd, void *buf, size_t count, off_t offset)
{
size_t off = (size_t)offset;
Expand All @@ -99,12 +93,7 @@ FUNC_ALIAS(read, _read, ssize_t);

int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
{
struct timespec to = {
.tv_sec = (timeout == NULL) ? 0 : timeout->tv_sec,
.tv_nsec = (long)((timeout == NULL) ? 0 : timeout->tv_usec * NSEC_PER_USEC)};

return zvfs_select(nfds, readfds, writefds, exceptfds, (timeout == NULL) ? NULL : &to,
NULL);
return zvfs_select(nfds, readfds, writefds, exceptfds, timeout);
}

ssize_t write(int fd, const void *buf, size_t sz)
Expand Down
2 changes: 1 addition & 1 deletion tests/posix/headers/src/sys_select_h.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ZTEST(posix_headers, test_sys_select_h)
FD_SET(0, &fds);
FD_ZERO(&fds);

zassert_not_null(pselect);
/* zassert_not_null(pselect); */ /* not implemented */
zassert_not_null(select);
}
}

0 comments on commit 75b4255

Please sign in to comment.