Fix nimIoselector define in std/selectors (#25104)

Also added some documentation to the header.

See: https://forum.nim-lang.org/t/13311

> I did try using the flag, but couldn't get it to work. If I do
-d:nimIoSelector, the defined check passes, but the other code fails to
compile because there is no const named nimIoSelector. It seemed like a
bug to me, do you have a working number compiler invocation?

Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
This commit is contained in:
bptato
2025-09-11 23:45:47 +02:00
committed by GitHub
parent 88da5e8cee
commit d60e0211bc

View File

@@ -25,6 +25,10 @@
## Solaris (files, sockets, handles and user events).
## Android (files, sockets, handles and user events).
##
## By default, the implementation is chosen based on the target
## platform; you can pass `-d:nimIoselector=value` to override it.
## Accepted values are "epoll", "kqueue", "poll", and "select".
##
## TODO: `/dev/poll`, `event ports` and filesystem events.
import std/nativesockets
@@ -342,7 +346,9 @@ else:
res = int(fdLim.rlim_cur) - 1
res
when defined(nimIoselector):
const nimIoselector {.strdefine.} = ""
when nimIoselector != "":
when nimIoselector == "epoll":
include ioselects/ioselectors_epoll
elif nimIoselector == "kqueue":