summary refs log tree commit diff stats
path: root/lib/posix/epoll.nim
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2017-11-22 14:43:10 +0000
committerAndreas Rumpf <rumpf_a@web.de>2017-11-22 15:43:10 +0100
commitd3394be5559c324da1c6b576d0ae9bfa966698d9 (patch)
tree72698b80e6045f35f783abe55405500b19808475 /lib/posix/epoll.nim
parent2c584cdb3d71f0cd811e3774c49db34735040032 (diff)
downloadNim-d3394be5559c324da1c6b576d0ae9bfa966698d9.tar.gz
Async upcoming (#6585)
* Merge upcoming async with current.
* Various improvements to selectors (mostly docs).

Two changes to highlight:

* Renamed ``setEvent`` to ``trigger``
* Reused setBlocking from nativesockets.
* Various changes/fixes to asyncdispatch after upcoming merge.
* Make some attempts to be compatible with older selectors.
* Reuse epoll module in ioselectors_epoll.
Diffstat (limited to 'lib/posix/epoll.nim')
-rw-r--r--lib/posix/epoll.nim19
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/posix/epoll.nim b/lib/posix/epoll.nim
index 86b977576..c5ed1a873 100644
--- a/lib/posix/epoll.nim
+++ b/lib/posix/epoll.nim
@@ -35,18 +35,13 @@ const
   EPOLL_CTL_MOD* = 3          # Change file descriptor epoll_event structure.
 
 type
-  epoll_data* {.importc: "union epoll_data",
+  EpollData* {.importc: "union epoll_data",
       header: "<sys/epoll.h>", pure, final.} = object # TODO: This is actually a union.
-    #thePtr* {.importc: "ptr".}: pointer
-    fd* {.importc: "fd".}: cint
-    when defined(linux) and defined(amd64):
-      u32: uint32 # this field ensures that binary size is right - it cannot be
-                  # used because its offset is wrong
-    #u64*: uint64
+    u64* {.importc: "u64".}: uint64
 
-  epoll_event* {.importc: "struct epoll_event", header: "<sys/epoll.h>", pure, final.} = object
+  EpollEvent* {.importc: "struct epoll_event", header: "<sys/epoll.h>", pure, final.} = object
     events*: uint32 # Epoll events
-    data*: epoll_data # User data variable
+    data*: EpollData # User data variable
 
 proc epoll_create*(size: cint): cint {.importc: "epoll_create",
     header: "<sys/epoll.h>".}
@@ -60,7 +55,7 @@ proc epoll_create1*(flags: cint): cint {.importc: "epoll_create1",
   ## Same as epoll_create but with an FLAGS parameter.  The unused SIZE
   ##   parameter has been dropped.
 
-proc epoll_ctl*(epfd: cint; op: cint; fd: cint | SocketHandle; event: ptr epoll_event): cint {.
+proc epoll_ctl*(epfd: cint; op: cint; fd: cint | SocketHandle; event: ptr EpollEvent): cint {.
     importc: "epoll_ctl", header: "<sys/epoll.h>".}
   ## Manipulate an epoll instance "epfd". Returns 0 in case of success,
   ##   -1 in case of error ( the "errno" variable will contain the
@@ -69,7 +64,7 @@ proc epoll_ctl*(epfd: cint; op: cint; fd: cint | SocketHandle; event: ptr epoll_
   ##   operation. The "event" parameter describes which events the caller
   ##   is interested in and any associated user data.
 
-proc epoll_wait*(epfd: cint; events: ptr epoll_event; maxevents: cint;
+proc epoll_wait*(epfd: cint; events: ptr EpollEvent; maxevents: cint;
                  timeout: cint): cint {.importc: "epoll_wait",
     header: "<sys/epoll.h>".}
   ## Wait for events on an epoll instance "epfd". Returns the number of
@@ -84,7 +79,7 @@ proc epoll_wait*(epfd: cint; events: ptr epoll_event; maxevents: cint;
   ##   __THROW.
 
 
-#proc epoll_pwait*(epfd: cint; events: ptr epoll_event; maxevents: cint;
+#proc epoll_pwait*(epfd: cint; events: ptr EpollEvent; maxevents: cint;
 #                  timeout: cint; ss: ptr sigset_t): cint {.
 #    importc: "epoll_pwait", header: "<sys/epoll.h>".}
 # Same as epoll_wait, but the thread's signal mask is temporarily