1 /* 2 * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <poll.h> 8 9 #include <errno.h> 10 #include <pthread.h> 11 12 #include <syscall_utils.h> 13 14 #include <errno_private.h> 15 #include <syscalls.h> 16 #include <time_private.h> 17 18 19 extern "C" int __ppoll(struct pollfd *fds, nfds_t numfds, const struct timespec *tv, 20 const sigset_t *sigMask); 21 22 int 23 poll(struct pollfd *fds, nfds_t numfds, int timeout) 24 { 25 RETURN_AND_SET_ERRNO_TEST_CANCEL(_kern_poll(fds, numfds, timeout * 1000LL, 26 NULL)); 27 } 28 29 30 int 31 __ppoll(struct pollfd *fds, nfds_t numfds, const struct timespec *tv, 32 const sigset_t *sigMask) 33 { 34 int status; 35 bigtime_t timeout = -1LL; 36 if (tv != NULL && !timespec_to_bigtime(*tv, timeout)) 37 RETURN_AND_SET_ERRNO_TEST_CANCEL(EINVAL); 38 39 status = _kern_poll(fds, numfds, timeout, sigMask); 40 41 RETURN_AND_SET_ERRNO_TEST_CANCEL(status); 42 } 43 44 45 B_DEFINE_WEAK_ALIAS(__ppoll, ppoll); 46