Skip to content

Commit bb51dfe

Browse files
aescolarDashingR
authored andcommitted
Revert "posix: device_io: implement pselect()"
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]>
1 parent bd58694 commit bb51dfe

File tree

6 files changed

+10
-28
lines changed

6 files changed

+10
-28
lines changed

include/zephyr/net/socket_select.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,9 @@ typedef struct zvfs_fd_set zsock_fd_set;
5151
static inline int zsock_select(int nfds, zsock_fd_set *readfds, zsock_fd_set *writefds,
5252
zsock_fd_set *exceptfds, struct zsock_timeval *timeout)
5353
{
54-
struct timespec to = {
55-
.tv_sec = (timeout == NULL) ? 0 : timeout->tv_sec,
56-
.tv_nsec = (long)((timeout == NULL) ? 0 : timeout->tv_usec * NSEC_PER_USEC)};
54+
struct timeval;
5755

58-
return zvfs_select(nfds, (struct zvfs_fd_set *)readfds, (struct zvfs_fd_set *)writefds,
59-
(struct zvfs_fd_set *)exceptfds, (timeout == NULL) ? NULL : &to, NULL);
56+
return zvfs_select(nfds, readfds, writefds, exceptfds, (struct timeval *)timeout);
6057
}
6158

6259
/** Number of file descriptors which can be added to zsock_fd_set */

include/zephyr/posix/sys/select.h

-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ extern "C" {
2020

2121
struct timeval;
2222

23-
int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
24-
const struct timespec *timeout, const void *sigmask);
2523
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout);
2624
void FD_CLR(int fd, fd_set *fdset);
2725
int FD_ISSET(int fd, fd_set *fdset);

include/zephyr/sys/fdtable.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ struct timespec;
223223
__syscall int zvfs_select(int nfds, struct zvfs_fd_set *ZRESTRICT readfds,
224224
struct zvfs_fd_set *ZRESTRICT writefds,
225225
struct zvfs_fd_set *ZRESTRICT errorfds,
226-
const struct timespec *ZRESTRICT timeout, const void *ZRESTRICT sigmask);
226+
const struct timeval *ZRESTRICT timeout);
227227

228228
/**
229229
* Request codes for fd_op_vtable.ioctl().

lib/os/zvfs/zvfs_select.c

+5-7
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void ZVFS_FD_SET(int fd, struct zvfs_fd_set *set)
7777
int z_impl_zvfs_select(int nfds, struct zvfs_fd_set *ZRESTRICT readfds,
7878
struct zvfs_fd_set *ZRESTRICT writefds,
7979
struct zvfs_fd_set *ZRESTRICT exceptfds,
80-
const struct timespec *ZRESTRICT timeout, const void *ZRESTRICT sigmask)
80+
const struct timeval *ZRESTRICT timeout)
8181
{
8282
struct zvfs_pollfd pfds[CONFIG_ZVFS_POLL_MAX];
8383
k_timeout_t poll_timeout;
@@ -142,8 +142,7 @@ int z_impl_zvfs_select(int nfds, struct zvfs_fd_set *ZRESTRICT readfds,
142142
if (timeout == NULL) {
143143
poll_timeout = K_FOREVER;
144144
} else {
145-
poll_timeout =
146-
K_USEC(timeout->tv_sec * USEC_PER_SEC + timeout->tv_nsec / NSEC_PER_USEC);
145+
poll_timeout = K_USEC(timeout->tv_sec * USEC_PER_SEC + timeout->tv_usec);
147146
}
148147

149148
res = zvfs_poll_internal(pfds, num_pfds, poll_timeout);
@@ -221,11 +220,10 @@ int z_impl_zvfs_select(int nfds, struct zvfs_fd_set *ZRESTRICT readfds,
221220
static int z_vrfy_zvfs_select(int nfds, struct zvfs_fd_set *ZRESTRICT readfds,
222221
struct zvfs_fd_set *ZRESTRICT writefds,
223222
struct zvfs_fd_set *ZRESTRICT exceptfds,
224-
const struct timespec *ZRESTRICT timeout,
225-
const void *ZRESTRICT sigmask)
223+
const struct timeval *ZRESTRICT timeout)
226224
{
227225
struct zvfs_fd_set *readfds_copy = NULL, *writefds_copy = NULL, *exceptfds_copy = NULL;
228-
struct timespec *to = NULL;
226+
struct timeval *to = NULL;
229227
int ret = -1;
230228

231229
if (readfds) {
@@ -263,7 +261,7 @@ static int z_vrfy_zvfs_select(int nfds, struct zvfs_fd_set *ZRESTRICT readfds,
263261
}
264262
}
265263

266-
ret = z_impl_zvfs_select(nfds, readfds_copy, writefds_copy, exceptfds_copy, to, sigmask);
264+
ret = z_impl_zvfs_select(nfds, readfds_copy, writefds_copy, exceptfds_copy, to);
267265

268266
if (ret >= 0) {
269267
if (readfds_copy) {

lib/posix/options/device_io.c

+1-12
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,6 @@ ssize_t pread(int fd, void *buf, size_t count, off_t offset)
7171
return zvfs_read(fd, buf, count, (size_t *)&off);
7272
}
7373

74-
int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
75-
const struct timespec *timeout, const void *sigmask)
76-
{
77-
return zvfs_select(nfds, readfds, writefds, exceptfds, timeout, sigmask);
78-
}
79-
8074
ssize_t pwrite(int fd, void *buf, size_t count, off_t offset)
8175
{
8276
size_t off = (size_t)offset;
@@ -99,12 +93,7 @@ FUNC_ALIAS(read, _read, ssize_t);
9993

10094
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
10195
{
102-
struct timespec to = {
103-
.tv_sec = (timeout == NULL) ? 0 : timeout->tv_sec,
104-
.tv_nsec = (long)((timeout == NULL) ? 0 : timeout->tv_usec * NSEC_PER_USEC)};
105-
106-
return zvfs_select(nfds, readfds, writefds, exceptfds, (timeout == NULL) ? NULL : &to,
107-
NULL);
96+
return zvfs_select(nfds, readfds, writefds, exceptfds, timeout);
10897
}
10998

11099
ssize_t write(int fd, const void *buf, size_t sz)

tests/posix/headers/src/sys_select_h.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ ZTEST(posix_headers, test_sys_select_h)
3030
FD_SET(0, &fds);
3131
FD_ZERO(&fds);
3232

33-
zassert_not_null(pselect);
33+
/* zassert_not_null(pselect); */ /* not implemented */
3434
zassert_not_null(select);
3535
}
3636
}

0 commit comments

Comments
 (0)