Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/runtime/runtime_nintendoswitch.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,18 @@ func ticks() timeUnit {
return timeUnit(ticksToNanoseconds(timeUnit(getArmSystemTick())))
}

var stdoutBuffer = make([]byte, 0, 120)
var stdoutBuffer = make([]byte, 120)
var position = 0

func putchar(c byte) {
if c == '\n' || len(stdoutBuffer)+1 >= 120 {
NxOutputString(string(stdoutBuffer))
stdoutBuffer = stdoutBuffer[:0]
if c == '\n' || position > len(stdoutBuffer) {
nxOutputString(&stdoutBuffer[0], uint64(position))
position = 0
return
}

stdoutBuffer = append(stdoutBuffer, c)
}

func usleep(usec uint) int {
sleepThread(uint64(usec) * 1000)
return 0
stdoutBuffer[position] = c
position++
}

func abort() {
Expand Down
8 changes: 1 addition & 7 deletions src/runtime/runtime_nintendoswitch_heap.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@

package runtime

import "unsafe"

const heapSize = 0x2000000 * 16 // Default by libnx

//go:extern _stack_top
var stackTopSymbol [0]byte

var (
heapStart = uintptr(0)
heapEnd = uintptr(0)
stackTop = uintptr(unsafe.Pointer(&stackTopSymbol))
)

//export setHeapSize
Expand All @@ -24,7 +18,7 @@ func preinit() {
setHeapSize(&heapStart, heapSize)

if heapStart == 0 {
panic("failed to allocate heap")
runtimePanic("failed to allocate heap")
}

heapEnd = heapStart + heapSize
Expand Down