• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2014, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _EPOLL_PORTABLE_H_
18 #define _EPOLL_PORTABLE_H_
19 
20 #include <portability.h>
21 #include <signal.h>
22 #include <stdint.h>
23 #include <sys/epoll.h>
24 
25 struct epoll_event_portable
26 {
27   uint32_t events;
28   uint8_t __padding[4];
29   epoll_data_t data;
30 };
31 
32 
WRAP(epoll_ctl)33 int WRAP(epoll_ctl)(int epfd, int op, int fd, struct epoll_event_portable *event)
34 {
35     struct epoll_event machine_epoll_event;
36 
37     machine_epoll_event.events = event->events;
38     machine_epoll_event.data = event->data;
39 
40     return REAL(epoll_ctl)(epfd, op, fd, &machine_epoll_event);
41 }
42 
WRAP(epoll_wait)43 int WRAP(epoll_wait)(int epfd, struct epoll_event_portable *events, int max, int timeout)
44 {
45     struct epoll_event machine_epoll_event;
46     int ret = REAL(epoll_wait)(epfd, &machine_epoll_event, max, timeout);
47 
48     events->events = machine_epoll_event.events;
49     events->data = machine_epoll_event.data;
50 
51     return ret;
52 }
53 
WRAP(epoll_pwait)54 int WRAP(epoll_pwait)(int fd, struct epoll_event_portable* events, int max_events, int timeout, const sigset_t* ss)
55 {
56     struct epoll_event machine_epoll_event;
57     int ret = REAL(epoll_pwait)(fd, &machine_epoll_event, max_events, timeout, ss);
58 
59     events->events = machine_epoll_event.events;
60     events->data = machine_epoll_event.data;
61 
62     return ret;
63 }
64 
65 #endif /* _EPOLL_PORTABLE_H */
66