epoll: correct mapping [backport] (#20058)

* epoll: correct mapping

`epoll_data` is a union and `epoll_event` is packed on `amd64`

* names
This commit is contained in:
Jacek Sieka 2022-07-18 21:03:25 +02:00 • committed by GitHub
commit f2e4407306
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,12 +33,21 @@ const
EPOLL_CTL_DEL* = 2 # Remove a file descriptor from the interface. EPOLL_CTL_DEL* = 2 # Remove a file descriptor from the interface.
EPOLL_CTL_MOD* = 3 # Change file descriptor epoll_event structure. EPOLL_CTL_MOD* = 3 # Change file descriptor epoll_event structure.
# https://github.com/torvalds/linux/blob/ff6992735ade75aae3e35d16b17da1008d753d28/include/uapi/linux/eventpoll.h#L77
when defined(linux) and defined(amd64):
{.pragma: epollPacked, packed.}
else:
{.pragma: epollPacked.}
type type
EpollData* {.importc: "union epoll_data", EpollData* {.importc: "epoll_data_t",
header: "<sys/epoll.h>", pure, final.} = object # TODO: This is actually a union. header: "<sys/epoll.h>", pure, final, union.} = object
`ptr`* {.importc: "ptr".}: pointer
fd* {.importc: "fd".}: cint
u32* {.importc: "u32".}: uint32
u64* {.importc: "u64".}: uint64 u64* {.importc: "u64".}: uint64
EpollEvent* {.importc: "struct epoll_event", header: "<sys/epoll.h>", pure, final.} = object EpollEvent* {.importc: "struct epoll_event", header: "<sys/epoll.h>", pure, final, epollPacked.} = object
events*: uint32 # Epoll events events*: uint32 # Epoll events
data*: EpollData # User data variable data*: EpollData # User data variable