| /* |
| * Copyright (c) 2014 The Native Client Authors. All rights reserved. |
| * Use of this source code is governed by a BSD-style license that can be |
| * found in the LICENSE file. |
| */ |
| #ifndef IRT_POLL_H |
| #define IRT_POLL_H |
| |
| #include <stdarg.h> |
| #include <stddef.h> |
| #include <sys/types.h> |
| |
| #if defined(__cplusplus) |
| extern "C" { |
| #endif |
| |
| struct NaClPollFD { |
| int fd; |
| short events; |
| short revents; |
| }; |
| |
| struct NaClFDSet { |
| unsigned long fd_bits; |
| }; |
| |
| typedef union NaClEpollData { |
| void *ptr; |
| int fd; |
| uint32_t u32; |
| uint64_t u64; |
| } NaClEpollData_t; |
| |
| struct NaClEpollEvent { |
| uint32_t events; /* Epoll events */ |
| NaClEpollData_t data; /* User data variable */ |
| }; |
| |
| |
| /* |
| * The "irt-dev-poll" provides socket functionality for polling functions |
| * such as poll, select, epoll_XXX. |
| */ |
| #define NACL_IRT_DEV_POLL_v0_1 "nacl-irt-dev-poll-0.1" |
| struct nacl_irt_dev_poll { |
| int (*poll)(struct NaClPollFD* fds, size_t nfds, int timeout, int* cnt); |
| int (*select)(size_t nfds, struct NaClFDSet* readfds, |
| struct NaClFDSet* writefds, struct NaClFDSet* exceptfds, |
| struct timeval* timeout); |
| int (*epoll_create)(int size, int* newfd); |
| int (*epoll_ctl)(int epfd, int op, int fd, struct epoll_event* event); |
| int (*epoll_wait)(int epfd, struct epoll_event* events, int maxevents, |
| int timeout); |
| }; |
| |
| #if defined(__cplusplus) |
| } |
| #endif |
| |
| #endif /* IRT_POLL_H */ |