0 | module System.Linux.Epoll.Struct
 1 |
 2 | import Data.C.Ptr
 3 | import Derive.Prelude
 4 |
 5 | import System.Linux.Epoll.Flags
 6 | import System.Posix.File.FileDesc
 7 | import System.Posix.File.ReadRes
 8 | import public System.Posix.Poll.Struct
 9 |
10 | %default total
11 | %language ElabReflection
12 |
13 | %foreign "C:get_epoll_event_events, linux-idris"
14 | prim__get_epoll_event_events : AnyPtr -> PrimIO Bits32
15 |
16 | %foreign "C:get_epoll_event_fd, linux-idris"
17 | prim__get_epoll_event_fd : AnyPtr -> PrimIO Bits32
18 |
19 | ||| A file descriptor used for monitoring other file descriptors in
20 | ||| calls to `epoll_ctl` and `epoll_wait`.
21 | export
22 | record Epollfd where
23 |   constructor EFD
24 |   fd : Bits32
25 |
26 | export %inline
27 | Cast Epollfd Fd where cast = MkFd . fd
28 |
29 | export %inline
30 | Cast CInt Epollfd where cast = EFD . cast
31 |
32 | ||| Wrapper around a pointer of an `epoll_event` value.
33 | export
34 | record SSEpollEvent (s : Type) where
35 |   constructor SE
36 |   ptr : AnyPtr
37 |
38 | export %inline
39 | Struct SSEpollEvent where
40 |   swrap   = SE
41 |   sunwrap = ptr
42 |
43 | public export
44 | 0 SEpollEvent : Type
45 | SEpollEvent = SSEpollEvent World
46 |
47 | export %inline
48 | SizeOf (SSEpollEvent s) where sizeof_ = epoll_event_size
49 |
50 | export
51 | pollPair : SSEpollEvent s -> F1 s PollPair
52 | pollPair (SE p) t =
53 |   let fd # t := ffi (prim__get_epoll_event_fd p) t
54 |       ev # t := ffi (prim__get_epoll_event_events p) t
55 |    in PP (cast fd) (PE ev) # t
56 |
57 | export %inline %hint
58 | convEpollEvent : Convert PollPair
59 | convEpollEvent = convStruct SSEpollEvent pollPair
60 |