Skip to content

Commit

Permalink
Fix: nintendoswitch compilation (nim-lang#21368)
Browse files Browse the repository at this point in the history
* Fix: make nintendoswitch someGcc, remove symlink support for nintendoswitch, add getAppFilename for nintendoswitch

* Fix: use getApplHeuristic on nintendoswitch
  • Loading branch information
dkgitdev authored and bung87 committed Jul 29, 2023
1 parent 89dacbf commit 9fb00f4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
8 changes: 6 additions & 2 deletions lib/posix/posix.nim
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,8 @@ proc pread*(a1: cint, a2: pointer, a3: int, a4: Off): int {.
proc pwrite*(a1: cint, a2: pointer, a3: int, a4: Off): int {.
importc, header: "<unistd.h>".}
proc read*(a1: cint, a2: pointer, a3: int): int {.importc, header: "<unistd.h>".}
proc readlink*(a1, a2: cstring, a3: int): int {.importc, header: "<unistd.h>".}
when not defined(nintendoswitch):
proc readlink*(a1, a2: cstring, a3: int): int {.importc, header: "<unistd.h>".}
proc ioctl*(f: FileHandle, device: uint): int {.importc: "ioctl",
header: "<sys/ioctl.h>", varargs, tags: [WriteIOEffect].}
## A system call for device-specific input/output operations and other
Expand All @@ -603,7 +604,10 @@ proc setsid*(): Pid {.importc, header: "<unistd.h>".}
proc setuid*(a1: Uid): cint {.importc, header: "<unistd.h>".}
proc sleep*(a1: cint): cint {.importc, header: "<unistd.h>".}
proc swab*(a1, a2: pointer, a3: int) {.importc, header: "<unistd.h>".}
proc symlink*(a1, a2: cstring): cint {.importc, header: "<unistd.h>".}
when not defined(nintendoswitch):
proc symlink*(a1, a2: cstring): cint {.importc, header: "<unistd.h>".}
else:
proc symlink*(a1, a2: cstring): cint = -1
proc sync*() {.importc, header: "<unistd.h>".}
proc sysconf*(a1: cint): int {.importc, header: "<unistd.h>".}
proc tcgetpgrp*(a1: cint): Pid {.importc, header: "<unistd.h>".}
Expand Down
4 changes: 3 additions & 1 deletion lib/pure/os.nim
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ proc findExe*(exe: string, followSymlinks: bool = true;
for ext in extensions:
var x = addFileExt(x, ext)
if fileExists(x):
when not defined(windows):
when not (defined(windows) or defined(nintendoswitch)):
while followSymlinks: # doubles as if here
if x.symlinkExists:
var r = newString(maxSymlinkLen)
Expand Down Expand Up @@ -702,6 +702,8 @@ proc getAppFilename*(): string {.rtl, extern: "nos$1", tags: [ReadIOEffect], noW
result = getApplHaiku()
elif defined(openbsd):
result = getApplOpenBsd()
elif defined(nintendoswitch):
result = ""

# little heuristic that may work on other POSIX-like systems:
if result.len == 0:
Expand Down
2 changes: 1 addition & 1 deletion lib/std/private/ossymlinks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ proc expandSymlink*(symlinkPath: string): string {.noWeirdTarget.} =
##
## See also:
## * `createSymlink proc`_
when defined(windows):
when defined(windows) or defined(nintendoswitch):
result = symlinkPath
else:
result = newString(maxSymlinkLen)
Expand Down
2 changes: 1 addition & 1 deletion lib/std/sysatomics.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ when defined(nimPreviewSlimSystem):

const
hasThreadSupport = compileOption("threads") and not defined(nimscript)
const someGcc = defined(gcc) or defined(llvm_gcc) or defined(clang)
const someGcc = defined(gcc) or defined(llvm_gcc) or defined(clang) or defined(nintendoswitch)
const someVcc = defined(vcc) or defined(clang_cl)

type
Expand Down

0 comments on commit 9fb00f4

Please sign in to comment.