Add support for NuttX RTOS. (#21372)

* Add support for NuttX RTOS.

Signed-off-by: Takeyoshi Kikuchi <kikuchi@centurysys.co.jp>

* lib: pure: asyncdispatch: assign to result.

Signed-off-by: Takeyoshi Kikuchi <kikuchi@centurysys.co.jp>

* lib: std: typedthreads: add support for parameters to adjust Thread Stack Size.

Like FreeRTOS/Zephyr, add support for following configurations.

  -d:nimThreadStackSize=xxxxx
  -d:nimThreadStackGuard=yyyy

Signed-off-by: Takeyoshi Kikuchi <kikuchi@centurysys.co.jp>

---------

Signed-off-by: Takeyoshi Kikuchi <kikuchi@centurysys.co.jp>
This commit is contained in:
Century Systems 2023-02-16 21:47:52 +09:00 • committed by GitHub
commit 3b9e9fd7b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 52 additions and 17 deletions

View file

@ -37,7 +37,7 @@ const hasThreadSupport = compileOption("threads") and defined(threadsafe)
const ioselSupportedPlatform* = defined(macosx) or defined(freebsd) or
defined(netbsd) or defined(openbsd) or
defined(dragonfly) or
defined(dragonfly) or defined(nuttx) or
(defined(linux) and not defined(android) and not defined(emscripten))
## This constant is used to determine whether the destination platform is
## fully supported by `ioselectors` module.
@ -328,7 +328,7 @@ else:
doAssert(timeout >= -1, "Cannot select with a negative value, got: " & $timeout)
when defined(linux) or defined(windows) or defined(macosx) or defined(bsd) or
defined(solaris) or defined(zephyr) or defined(freertos):
defined(solaris) or defined(zephyr) or defined(freertos) or defined(nuttx):
template maxDescriptors*(): int =
## Returns the maximum number of active file descriptors for the current
## process. This involves a system call. For now `maxDescriptors` is
@ -337,6 +337,9 @@ else:
16_700_000
elif defined(zephyr) or defined(freertos):
FD_MAX
elif defined(nuttx):
# The maximum number of concurrently active UDP and TCP ports.
NACTIVESOCKETS
else:
var fdLim: RLimit
var res = int(getrlimit(RLIMIT_NOFILE, fdLim))
@ -360,5 +363,7 @@ else:
include ioselects/ioselectors_select
elif defined(zephyr):
include ioselects/ioselectors_poll
elif defined(nuttx):
include ioselects/ioselectors_epoll
else:
include ioselects/ioselectors_poll