* @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
| 893 | * @see sys_select(), poll(), select() |
| 894 | */ |
| 895 | sysret_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. |
nothing calls this directly
no test coverage detected