diff options
Diffstat (limited to 'src/libtools')
| -rwxr-xr-x | src/libtools/myalign.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/libtools/myalign.c b/src/libtools/myalign.c index a61728c5..58760837 100755 --- a/src/libtools/myalign.c +++ b/src/libtools/myalign.c @@ -691,4 +691,43 @@ void UnalignStat64(const void* source, void* dest) x64st->st_atim = st->st_atim; x64st->st_mtim = st->st_mtim; x64st->st_ctim = st->st_ctim; -} \ No newline at end of file +} + +typedef union __attribute__((packed)) x64_epoll_data { + void *ptr; + int fd; + uint32_t u32; + uint64_t u64; +} x64_epoll_data_t; + +struct __attribute__((packed)) x64_epoll_event { + uint32_t events; + x64_epoll_data_t data; +}; +// Arm -> x64 +void UnalignEpollEvent(void* dest, void* source, int nbr) +{ + struct x64_epoll_event *x64_struct = (struct x64_epoll_event*)dest; + struct epoll_event *arm_struct = (struct epoll_event*)source; + while(nbr) { + x64_struct->events = arm_struct->events; + x64_struct->data.u64 = arm_struct->data.u64; + ++x64_struct; + ++arm_struct; + --nbr; + } +} + +// x64 -> Arm +void AlignEpollEvent(void* dest, void* source, int nbr) +{ + struct x64_epoll_event *x64_struct = (struct x64_epoll_event*)source; + struct epoll_event *arm_struct = (struct epoll_event*)dest; + while(nbr) { + arm_struct->events = x64_struct->events; + arm_struct->data.u64 = x64_struct->data.u64; + ++x64_struct; + ++arm_struct; + --nbr; + } +} |