summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorJaremy Creechley <creechley@gmail.com>2020-08-31 03:48:54 -0600
committerGitHub <noreply@github.com>2020-08-31 11:48:54 +0200
commita76ae8f79584c5a491861daf2efda9908b21e488 (patch)
tree606a21bb285e5f03bf5a93709b151ec0cb34ec92 /lib/system
parentb5424b826e57c791a751bf31b69549c7d8daab0b (diff)
downloadNim-a76ae8f79584c5a491861daf2efda9908b21e488.tar.gz
Changes for FreeRTOS/LwIP Port for the ESP32 (ESP-IDF) (#15250)
* Changes for FreeRTOS/LwIP Port for the ESP32 (ESP-IDF)

Adding FreeRTOS/LwIP to compiler:

* adding freertos option
* dyncalls for freertos
* add freertos to posix os list
* adding lwip option

Setting up networking FreeRTOS/LwIP Port:

* setting up lwip network for freertos
* fixing posix / networking for freertos
* disable setInheritable for freerots
* using lwip for net control items

* Fix builds by ignoring lib/posix/posix_freertos_consts.nim similar to lib/posix/posix_other_consts.nim
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/dyncalls.nim2
-rw-r--r--lib/system/io.nim12
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/system/dyncalls.nim b/lib/system/dyncalls.nim
index a15d9267f..1b0a3e64c 100644
--- a/lib/system/dyncalls.nim
+++ b/lib/system/dyncalls.nim
@@ -179,7 +179,7 @@ elif defined(genode):
   proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr {.
     error: "nimGetProcAddr not implemented".}
 
-elif defined(nintendoswitch):
+elif defined(nintendoswitch) or defined(freertos):
   proc nimUnloadLibrary(lib: LibHandle) =
     cstderr.rawWrite("nimUnLoadLibrary not implemented")
     cstderr.rawWrite("\n")
diff --git a/lib/system/io.nim b/lib/system/io.nim
index 3d5cf981a..c3b2976fb 100644
--- a/lib/system/io.nim
+++ b/lib/system/io.nim
@@ -269,7 +269,7 @@ when SupportIoctlInheritCtl:
 
   proc c_ioctl(fd: cint, request: cint): cint {.
     importc: "ioctl", header: "<sys/ioctl.h>", varargs.}
-elif defined(posix) and not defined(nimscript):
+elif defined(posix) and not defined(lwip) and not defined(nimscript):
   var
     F_GETFD {.importc, header: "<fcntl.h>".}: cint
     F_SETFD {.importc, header: "<fcntl.h>".}: cint
@@ -336,6 +336,8 @@ when defined(nimdoc) or (defined(posix) and not defined(nimscript)) or defined(w
     ## availability with `declared() <system.html#declared,untyped>`.
     when SupportIoctlInheritCtl:
       result = c_ioctl(f, if inheritable: FIONCLEX else: FIOCLEX) != -1
+    elif defined(freertos):
+      result = true
     elif defined(posix):
       var flags = c_fcntl(f, F_GETFD)
       if flags == -1:
@@ -767,6 +769,10 @@ when declared(stdout):
     var echoLock: SysLock
     initSysLock echoLock
 
+  const stdOutLock = not defined(windows) and not defined(android) and
+                     not defined(nintendoswitch) and not defined(freertos) and
+                     hostOS != "any"
+
   proc echoBinSafe(args: openArray[string]) {.compilerproc.} =
     when defined(androidNDK):
       var s = ""
@@ -775,7 +781,7 @@ when declared(stdout):
       android_log_print(ANDROID_LOG_VERBOSE, "nim", s)
     else:
       # flockfile deadlocks some versions of Android 5.x.x
-      when not defined(windows) and not defined(android) and not defined(nintendoswitch) and hostOS != "any":
+      when stdOutLock:
         proc flockfile(f: File) {.importc, nodecl.}
         proc funlockfile(f: File) {.importc, nodecl.}
         flockfile(stdout)
@@ -789,7 +795,7 @@ when declared(stdout):
       const linefeed = "\n"
       discard c_fwrite(linefeed.cstring, linefeed.len, 1, stdout)
       discard c_fflush(stdout)
-      when not defined(windows) and not defined(android) and not defined(nintendoswitch) and hostOS != "any":
+      when stdOutLock:
         funlockfile(stdout)
       when defined(windows) and compileOption("threads"):
         releaseSys echoLock