diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 3bc87728b..90c52657c 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -819,7 +819,8 @@ iterator walkDir*(dir: string; relative=false): tuple[kind: PathComponent, path: y = dir / y var k = pcFile - when defined(linux) or defined(macosx) or defined(bsd) or defined(genode): + when defined(linux) or defined(macosx) or + defined(bsd) or defined(genode) or defined(nintendoswitch): if x.d_type != DT_UNKNOWN: if x.d_type == DT_DIR: k = pcDir if x.d_type == DT_LNK: @@ -1285,7 +1286,7 @@ elif defined(windows): elif not defined(createNimRtl) and not(defined(posix) and appType == "lib") and - not defined(genode): + not defined(genode) and not defined(nintendoswitch): # On Posix, there is no portable way to get the command line from a DLL. var cmdCount {.importc: "cmdCount".}: cint @@ -1439,7 +1440,7 @@ 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): + elif defined(genode) or defined(nintendoswitch): raiseOSError(OSErrorCode(-1), "POSIX command line not supported") elif defined(freebsd) or defined(dragonfly): result = getApplFreebsd() diff --git a/lib/pure/selectors.nim b/lib/pure/selectors.nim index 640df8282..935250e08 100644 --- a/lib/pure/selectors.nim +++ b/lib/pure/selectors.nim @@ -312,6 +312,8 @@ else: include ioselects/ioselectors_poll # need to replace it with event ports elif defined(genode): include ioselects/ioselectors_select # TODO: use the native VFS layer + elif defined(nintendoswitch): + include ioselects/ioselectors_select else: include ioselects/ioselectors_poll diff --git a/lib/system/ansi_c.nim b/lib/system/ansi_c.nim index 0bac979e7..52cb15e39 100644 --- a/lib/system/ansi_c.nim +++ b/lib/system/ansi_c.nim @@ -45,7 +45,7 @@ when defined(windows): SIGTERM = cint(15) elif defined(macosx) or defined(linux) or defined(freebsd) or defined(openbsd) or defined(netbsd) or defined(solaris) or - defined(dragonfly): + defined(dragonfly) or defined(nintendoswitch): const SIGABRT = cint(6) SIGFPE = cint(8) diff --git a/lib/system/dyncalls.nim b/lib/system/dyncalls.nim index f1ff307da..8fb694829 100644 --- a/lib/system/dyncalls.nim +++ b/lib/system/dyncalls.nim @@ -167,6 +167,24 @@ elif defined(genode): proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr {. error: "nimGetProcAddr not implemented".} +elif defined(nintendoswitch): + proc nimUnloadLibrary(lib: LibHandle) = + stderr.rawWrite("nimUnLoadLibrary not implemented") + stderr.rawWrite("\n") + quit(1) + + proc nimLoadLibrary(path: string): LibHandle = + stderr.rawWrite("nimLoadLibrary not implemented") + stderr.rawWrite("\n") + quit(1) + + + proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr = + stderr.rawWrite("nimGetProAddr not implemented") + stderr.write(name) + stderr.rawWrite("\n") + quit(1) + else: {.error: "no implementation for dyncalls".} diff --git a/lib/system/platforms.nim b/lib/system/platforms.nim index b561cd3ba..aab270312 100644 --- a/lib/system/platforms.nim +++ b/lib/system/platforms.nim @@ -31,13 +31,14 @@ type vm, ## Some Virtual machine: Nim's VM or JavaScript avr, ## AVR based processor msp430, ## TI MSP430 microcontroller - riscv64 ## RISC-V 64-bit processor + riscv64, ## RISC-V 64-bit processor + armv8a57 ## Arm Cortex A57 64-bit processor for Nintendo Switch OsPlatform* {.pure.} = enum ## the OS this program will run on. none, dos, windows, os2, linux, morphos, skyos, solaris, irix, netbsd, freebsd, openbsd, aix, palmos, qnx, amiga, atari, netware, macos, macosx, haiku, android, js, nimVM, - standalone + standalone, nintendoswitch const targetOS* = when defined(windows): OsPlatform.windows @@ -64,6 +65,7 @@ const elif defined(js): OsPlatform.js elif defined(nimVM): OsPlatform.nimVM elif defined(standalone): OsPlatform.standalone + elif defined(nintendoswitch): OsPlatform.nintendoswitch else: OsPlatform.none ## the OS this program will run on. @@ -86,5 +88,6 @@ const elif defined(avr): CpuPlatform.avr elif defined(msp430): CpuPlatform.msp430 elif defined(riscv64): CpuPlatform.riscv64 + elif defined(armv8a57): CpuPlatform.armv8a57 else: CpuPlatform.none ## the CPU this program will run on. diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim index 86b290230..f3a576be0 100644 --- a/lib/system/sysio.nim +++ b/lib/system/sysio.nim @@ -419,7 +419,7 @@ proc setStdIoUnbuffered() = when declared(stdout): proc echoBinSafe(args: openArray[string]) {.compilerProc.} = # flockfile deadlocks some versions of Android 5.x.x - when not defined(windows) and not defined(android): + when not defined(windows) and not defined(android) and not defined(nintendoswitch): proc flockfile(f: File) {.importc, noDecl.} proc funlockfile(f: File) {.importc, noDecl.} flockfile(stdout) @@ -428,7 +428,7 @@ when declared(stdout): const linefeed = "\n" # can be 1 or more chars discard c_fwrite(linefeed.cstring, linefeed.len, 1, stdout) discard c_fflush(stdout) - when not defined(windows) and not defined(android): + when not defined(windows) and not defined(android) and not defined(nintendoswitch): funlockfile(stdout) {.pop.} diff --git a/lib/system/threads.nim b/lib/system/threads.nim index c8ea03f92..350fe5d0c 100644 --- a/lib/system/threads.nim +++ b/lib/system/threads.nim @@ -185,6 +185,14 @@ else: abi: array[56 div sizeof(clong), clong] ThreadVarSlot {.importc: "pthread_key_t", header: "".} = distinct cuint + elif defined(nintendoswitch): + type + SysThread* {.importc: "pthread_t", + header: "" .} = distinct cuint + Pthread_attr {.importc: "pthread_attr_t", + header: "".} = object + ThreadVarSlot {.importc: "pthread_key_t", + header: "".} = distinct cuint else: type SysThread* {.importc: "pthread_t", header: "".} = object