mirror of
https://github.com/status-im/nim-chronos.git
synced 2025-03-03 12:20:32 +00:00
Fix RangeError defect being happened using android toolchain. (#538)
* Fix RangeError defect being happened using android toolchain. * Set proper type for `Tnfds`. * Update comment.
This commit is contained in:
parent
bb96f02ae8
commit
72f560f049
@ -220,7 +220,10 @@ proc selectInto2*[T](s: Selector[T], timeout: int,
|
|||||||
verifySelectParams(timeout, -1, int(high(cint)))
|
verifySelectParams(timeout, -1, int(high(cint)))
|
||||||
|
|
||||||
let
|
let
|
||||||
maxEventsCount = min(len(s.pollfds), len(readyKeys))
|
maxEventsCount = culong(min(len(s.pollfds), len(readyKeys)))
|
||||||
|
# Without `culong` conversion, this code could fail with RangeError
|
||||||
|
# defect on explicit Tnfds(integer) conversion (probably related to
|
||||||
|
# combination of nim+clang (android toolchain)).
|
||||||
eventsCount =
|
eventsCount =
|
||||||
if maxEventsCount > 0:
|
if maxEventsCount > 0:
|
||||||
let res = handleEintr(poll(addr(s.pollfds[0]), Tnfds(maxEventsCount),
|
let res = handleEintr(poll(addr(s.pollfds[0]), Tnfds(maxEventsCount),
|
||||||
|
@ -965,7 +965,7 @@ elif defined(macos) or defined(macosx):
|
|||||||
events*: cshort
|
events*: cshort
|
||||||
revents*: cshort
|
revents*: cshort
|
||||||
|
|
||||||
Tnfds* {.importc: "nfds_t", header: "<poll.h>".} = cuint
|
Tnfds* {.importc: "nfds_t", header: "<poll.h>".} = culong
|
||||||
|
|
||||||
const
|
const
|
||||||
POLLIN* = 0x0001
|
POLLIN* = 0x0001
|
||||||
|
Loading…
x
Reference in New Issue
Block a user