diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-04-26 10:14:29 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-04-26 10:14:29 +0200 |
| commit | 56766df719c8f969e1f5969470f58c8cad1a2755 (patch) | |
| tree | f000ec668ab1356a0e5f250d5a43575895340f16 /src/libtools | |
| parent | e505e5e466be8e7d5e9e102b4b9395d3ce94d5f0 (diff) | |
| download | box64-56766df719c8f969e1f5969470f58c8cad1a2755.tar.gz box64-56766df719c8f969e1f5969470f58c8cad1a2755.zip | |
Aligned struct epoll
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; + } +} |