Commit 881dc1fa authored by Chris Friedt's avatar Chris Friedt Committed by Henrik Brix Andersen
Browse files

net: sockets: move poll implementation to zvfs



Move the implementation of zsock_poll to zvfs_poll. This allows
other types of file descriptors to also make use of poll()
functionality even when the network subsystem is not enabled.

Additionally, it partially removes a dependency cycle between
posix and networking by moving functionality into a mutual
dependency.

Signed-off-by: default avatarChris Friedt <cfriedt@tenstorrent.com>
parent 5ccbaeff
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -629,7 +629,10 @@ static inline int zsock_ioctl_wrapper(int sock, unsigned long request, ...)
 * it may conflict with generic POSIX ``poll()`` function).
 * @endrst
 */
__syscall int zsock_poll(struct zsock_pollfd *fds, int nfds, int timeout);
static inline int zsock_poll(struct zsock_pollfd *fds, int nfds, int timeout)
{
	return zvfs_poll(fds, nfds, timeout);
}

/**
 * @brief Get various socket options
+6 −0
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@
#ifndef ZEPHYR_INCLUDE_NET_SOCKET_POLL_H_
#define ZEPHYR_INCLUDE_NET_SOCKET_POLL_H_

#include <zephyr/sys/fdtable.h>

/* Setting for pollfd to avoid circular inclusion */

/**
@@ -20,6 +22,7 @@
extern "C" {
#endif

#ifdef __DOXYGEN__
/**
 * @brief Definition of the monitored socket/file descriptor.
 *
@@ -30,6 +33,9 @@ struct zsock_pollfd {
	short events;  /**< Requested events */
	short revents; /**< Returned events */
};
#else
#define zsock_pollfd zvfs_pollfd
#endif

#ifdef __cplusplus
}
+15 −0
Original line number Diff line number Diff line
@@ -27,6 +27,13 @@
#define ZVFS_MODE_IFLNK  0120000
#define ZVFS_MODE_IFSOCK 0140000

#define ZVFS_POLLIN   BIT(0)
#define ZVFS_POLLPRI  BIT(1)
#define ZVFS_POLLOUT  BIT(2)
#define ZVFS_POLLERR  BIT(3)
#define ZVFS_POLLHUP  BIT(4)
#define ZVFS_POLLNVAL BIT(5)

#ifdef __cplusplus
extern "C" {
#endif
@@ -192,6 +199,14 @@ static inline int zvfs_fdtable_call_ioctl(const struct fd_op_vtable *vtable, voi
	return res;
}

struct zvfs_pollfd {
	int fd;
	short events;
	short revents;
};

__syscall int zvfs_poll(struct zvfs_pollfd *fds, int nfds, int poll_timeout);

/**
 * Request codes for fd_op_vtable.ioctl().
 *
+3 −0
Original line number Diff line number Diff line
@@ -12,6 +12,9 @@ zephyr_sources(
  )

zephyr_sources_ifdef(CONFIG_FDTABLE fdtable.c)
zephyr_syscall_header_ifdef(CONFIG_FDTABLE
  ${ZEPHYR_BASE}/include/zephyr/sys/fdtable.h
)

zephyr_sources_ifdef(CONFIG_CBPRINTF_COMPLETE cbprintf_complete.c)
zephyr_sources_ifdef(CONFIG_CBPRINTF_NANO cbprintf_nano.c)
+1 −0
Original line number Diff line number Diff line
@@ -2,3 +2,4 @@

zephyr_library()
zephyr_library_sources_ifdef(CONFIG_ZVFS_EVENTFD zvfs_eventfd.c)
zephyr_library_sources_ifdef(CONFIG_ZVFS_POLL zvfs_poll.c)
Loading