MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / sys_poll

Function sys_poll

components/lwp/lwp_syscall.c:895–930  ·  view source on GitHub ↗

* @brief Monitors multiple file descriptors to see if they are ready for I/O. * * This system call monitors the file descriptors specified in `fds` for any * I/O events such as readiness for reading, writing, or exceptional conditions. * It waits up to the specified timeout and returns with information about which * file descriptors are ready for the requested operations. * * @param fds An

Source from the content-addressed store, hash-verified

893 * @see sys_select(), poll(), select()
894 */
895sysret_t sys_poll(struct pollfd *fds, nfds_t nfds, int timeout)
896{
897 int ret = -1;
898#ifdef ARCH_MM_MMU
899 struct pollfd *kfds = RT_NULL;
900
901 if (!lwp_user_accessable((void *)fds, nfds * sizeof *fds))
902 {
903 return -EFAULT;
904 }
905
906 kfds = (struct pollfd *)kmem_get(nfds * sizeof *kfds);
907 if (!kfds)
908 {
909 return -ENOMEM;
910 }
911
912 lwp_get_from_user(kfds, fds, nfds * sizeof *kfds);
913
914 ret = poll(kfds, nfds, timeout);
915 if (ret > 0)
916 {
917 lwp_put_to_user(fds, kfds, nfds * sizeof *kfds);
918 }
919
920 kmem_put(kfds);
921 return ret;
922#else
923 if (!lwp_user_accessable((void *)fds, nfds * sizeof *fds))
924 {
925 return -EFAULT;
926 }
927 ret = poll(fds, nfds, timeout);
928 return ret;
929#endif /* ARCH_MM_MMU */
930}
931
932/**
933 * @brief Monitors multiple file descriptors for readiness to perform I/O operations.

Callers

nothing calls this directly

Calls 6

lwp_user_accessableFunction · 0.85
kmem_getFunction · 0.85
lwp_get_from_userFunction · 0.85
pollFunction · 0.85
lwp_put_to_userFunction · 0.85
kmem_putFunction · 0.85

Tested by

no test coverage detected