diff options
author | Emery Hemingway <githubjunk@spam.works> | 2017-03-31 16:13:06 -0500 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-03-31 23:13:06 +0200 |
commit | 7e351fc7fa96b4d560c5a51118bab22abb590585 (patch) | |
tree | e0f5dd4deb394e86d95244317b0a328bb970842d /lib/pure/os.nim | |
parent | 57246cbcec2f747d5af33ebf4c8c0e0a531eba02 (diff) | |
download | Nim-7e351fc7fa96b4d560c5a51118bab22abb590585.tar.gz |
support for the Genode OS framework (#5560)
Diffstat (limited to 'lib/pure/os.nim')
-rw-r--r-- | lib/pure/os.nim | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim index a7f7116ef..82acb2a59 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -825,16 +825,16 @@ proc putEnv*(key, val: string) {.tags: [WriteEnvEffect].} = else: add environment, (key & '=' & val) indx = high(environment) - when defined(unix): - if c_putenv(environment[indx]) != 0'i32: - raiseOSError(osLastError()) - else: + when defined(windows): when useWinUnicode: var k = newWideCString(key) var v = newWideCString(val) if setEnvironmentVariableW(k, v) == 0'i32: raiseOSError(osLastError()) else: if setEnvironmentVariableA(key, val) == 0'i32: raiseOSError(osLastError()) + else: + if c_putenv(environment[indx]) != 0'i32: + raiseOSError(osLastError()) iterator envPairs*(): tuple[key, value: TaintedString] {.tags: [ReadEnvEffect].} = ## Iterate over all `environments variables`:idx:. In the first component @@ -1091,7 +1091,7 @@ proc rawCreateDir(dir: string): bool = result = false else: raiseOSError(osLastError()) - elif defined(unix): + elif defined(posix): let res = mkdir(dir, 0o777) if res == 0'i32: result = true @@ -1452,7 +1452,9 @@ elif defined(windows): if isNil(ownArgv): ownArgv = parseCmdLine($getCommandLine()) return TaintedString(ownArgv[i]) -elif not defined(createNimRtl) and not(defined(posix) and appType == "lib"): +elif not defined(createNimRtl) and + not(defined(posix) and appType == "lib") and + not defined(genode): # On Posix, there is no portable way to get the command line from a DLL. var cmdCount {.importc: "cmdCount".}: cint @@ -1606,6 +1608,8 @@ proc getAppFilename*(): string {.rtl, extern: "nos$1", tags: [ReadIOEffect].} = result = getApplAux("/proc/self/exe") elif defined(solaris): result = getApplAux("/proc/" & $getpid() & "/path/a.out") + elif defined(genode): + raiseOSError("POSIX command line not supported") elif defined(freebsd) or defined(dragonfly): result = getApplFreebsd() # little heuristic that may work on other POSIX-like systems: |