Changeset View
Changeset View
Standalone View
Standalone View
src/npth.c
Context not available. | |||||
#ifndef HAVE_PSELECT | #ifndef HAVE_PSELECT | ||||
# include <signal.h> | # include <signal.h> | ||||
#endif | #endif | ||||
#ifdef HAVE_POLL_H | |||||
#include <poll.h> | |||||
#endif | |||||
#include "npth.h" | #include "npth.h" | ||||
Context not available. | |||||
} | } | ||||
int | |||||
npth_poll (struct pollfd *fds, unsigned long nfds, int timeout) | |||||
{ | |||||
int res; | |||||
ENTER(); | |||||
res = poll (fds, (nfds_t)nfds, timeout); | |||||
LEAVE(); | |||||
return res; | |||||
} | |||||
int | |||||
npth_ppoll (struct pollfd *fds, unsigned long nfds, | |||||
const struct timespec *timeout, const sigset_t *sigmask) | |||||
{ | |||||
int res; | |||||
ENTER(); | |||||
#ifdef HAVE_PSELECT | |||||
res = ppoll (fds, (nfds_t)nfds, timeout, sigmask); | |||||
#else /*!HAVE_PSELECT*/ | |||||
{ | |||||
# ifdef __GNUC__ | |||||
# warning Using a non race free ppoll emulation. | |||||
# endif | |||||
int t; | |||||
if (!timeout) | |||||
t = -1; | |||||
else if (timeout->tv_nsec >= 0 && timeout->tv_nsec < 1000000000) | |||||
t = timeout->tv_sec * 1000 + (timeout->tv_nsec + 999999) / 1000000; | |||||
else | |||||
{ | |||||
errno = EINVAL; | |||||
res = -1; | |||||
goto leave; | |||||
} | |||||
if (sigmask) | |||||
{ | |||||
int save_errno; | |||||
sigset_t savemask; | |||||
pthread_sigmask (SIG_SETMASK, sigmask, &savemask); | |||||
res = poll (fds, (nfds_t)nfds, timeout); | |||||
save_errno = errno; | |||||
pthread_sigmask (SIG_SETMASK, &savemask, NULL); | |||||
errno = save_errno; | |||||
} | |||||
else | |||||
res = poll (fds, (nfds_t)nfds, timeout); | |||||
leave: | |||||
; | |||||
} | |||||
#endif | |||||
LEAVE(); | |||||
return res; | |||||
} | |||||
ssize_t | ssize_t | ||||
npth_read(int fd, void *buf, size_t nbytes) | npth_read(int fd, void *buf, size_t nbytes) | ||||
{ | { | ||||
Context not available. |