Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow nintendoswitch target to compile #4648

Merged
merged 2 commits into from
Dec 4, 2024
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
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ endif
@$(MD5SUM) test.hex
$(TINYGO) build -size short -o test.hex -target=pca10040 -serial=rtt examples/echo
@$(MD5SUM) test.hex
$(TINYGO) build -o test.nro -target=nintendoswitch examples/serial
$(TINYGO) build -o test.nro -target=nintendoswitch examples/echo2
@$(MD5SUM) test.nro
$(TINYGO) build -size short -o test.hex -target=pca10040 -opt=0 ./testdata/stdlib.go
@$(MD5SUM) test.hex
Expand Down
2 changes: 1 addition & 1 deletion src/os/dir_other.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build baremetal || js || windows || wasm_unknown
//go:build baremetal || js || windows || wasm_unknown || nintendoswitch

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
Expand Down
2 changes: 1 addition & 1 deletion src/os/dir_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build linux && !baremetal && !wasip1 && !wasip2 && !wasm_unknown
//go:build linux && !baremetal && !wasip1 && !wasip2 && !wasm_unknown && !nintendoswitch

package os

Expand Down
2 changes: 1 addition & 1 deletion src/os/dirent_linux.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !baremetal && !js && !wasip1 && !wasip2 && !wasm_unknown
//go:build !baremetal && !js && !wasip1 && !wasip2 && !wasm_unknown && !nintendoswitch

// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
Expand Down
2 changes: 1 addition & 1 deletion src/os/exec_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build linux && !baremetal && !tinygo.wasm
//go:build linux && !baremetal && !tinygo.wasm && !nintendoswitch

package os

Expand Down
2 changes: 1 addition & 1 deletion src/os/exec_other.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build (!aix && !android && !freebsd && !linux && !netbsd && !openbsd && !plan9 && !solaris) || baremetal || tinygo.wasm
//go:build (!aix && !android && !freebsd && !linux && !netbsd && !openbsd && !plan9 && !solaris) || baremetal || tinygo.wasm || nintendoswitch

package os

Expand Down
2 changes: 1 addition & 1 deletion src/os/file_anyos.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !baremetal && !js && !wasm_unknown
//go:build !baremetal && !js && !wasm_unknown && !nintendoswitch

// Portions copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
Expand Down
2 changes: 1 addition & 1 deletion src/os/file_other.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build baremetal || (tinygo.wasm && !wasip1 && !wasip2)
//go:build baremetal || (tinygo.wasm && !wasip1 && !wasip2) || nintendoswitch

package os

Expand Down
2 changes: 1 addition & 1 deletion src/os/file_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build darwin || (linux && !baremetal && !wasm_unknown) || wasip1 || wasip2
//go:build darwin || (linux && !baremetal && !wasm_unknown && !nintendoswitch) || wasip1 || wasip2

// target wasi sets GOOS=linux and thus the +linux build tag,
// even though it doesn't show up in "tinygo info target -wasi"
Expand Down
2 changes: 1 addition & 1 deletion src/os/osexec.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux && !baremetal && !tinygo.wasm
//go:build linux && !baremetal && !tinygo.wasm && !nintendoswitch

package os

Expand Down
2 changes: 1 addition & 1 deletion src/os/removeall_noat.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !baremetal && !js && !wasip1 && !wasip2 && !wasm_unknown
//go:build !baremetal && !js && !wasip1 && !wasip2 && !wasm_unknown && !nintendoswitch

package os

Expand Down
2 changes: 1 addition & 1 deletion src/os/removeall_other.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build baremetal || js || wasip1 || wasip2 || wasm_unknown
//go:build baremetal || js || wasip1 || wasip2 || wasm_unknown || nintendoswitch

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
Expand Down
2 changes: 1 addition & 1 deletion src/os/stat_linuxlike.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build (linux && !baremetal && !wasm_unknown) || wasip1 || wasip2
//go:build (linux && !baremetal && !wasm_unknown && !nintendoswitch) || wasip1 || wasip2

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
Expand Down
2 changes: 1 addition & 1 deletion src/os/stat_other.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build baremetal || (tinygo.wasm && !wasip1 && !wasip2)
//go:build baremetal || (tinygo.wasm && !wasip1 && !wasip2) || nintendoswitch

// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
Expand Down
2 changes: 1 addition & 1 deletion src/os/stat_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build darwin || (linux && !baremetal && !wasm_unknown) || wasip1 || wasip2
//go:build darwin || (linux && !baremetal && !wasm_unknown && !nintendoswitch) || wasip1 || wasip2

// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
Expand Down
2 changes: 1 addition & 1 deletion src/os/types_anyos.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !baremetal && !js && !wasm_unknown
//go:build !baremetal && !js && !wasm_unknown && !nintendoswitch

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
Expand Down
2 changes: 1 addition & 1 deletion src/os/types_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build darwin || (linux && !baremetal && !wasm_unknown) || wasip1 || wasip2
//go:build darwin || (linux && !baremetal && !wasm_unknown && !nintendoswitch) || wasip1 || wasip2

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/nonhosted.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build baremetal || js || wasm_unknown
//go:build baremetal || js || wasm_unknown || nintendoswitch

package runtime

Expand Down
21 changes: 21 additions & 0 deletions src/runtime/runtime_nintendoswitch.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ func ticks() timeUnit {
return timeUnit(ticksToNanoseconds(timeUnit(getArmSystemTick())))
}

// timeOffset is how long the monotonic clock started after the Unix epoch. It
// should be a positive integer under normal operation or zero when it has not
// been set.
var timeOffset int64

//go:linkname now time.now
func now() (sec int64, nsec int32, mono int64) {
mono = nanotime()
sec = (mono + timeOffset) / (1000 * 1000 * 1000)
nsec = int32((mono + timeOffset) - sec*(1000*1000*1000))
return
}

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

Expand All @@ -98,6 +111,14 @@ func putchar(c byte) {
position++
}

func buffered() int {
return 0
}

func getchar() byte {
return 0
}

func abort() {
for {
exit(1)
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/runtime_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build (darwin || (linux && !baremetal && !wasip1 && !wasm_unknown && !wasip2)) && !nintendoswitch
//go:build darwin || (linux && !baremetal && !wasip1 && !wasm_unknown && !wasip2 && !nintendoswitch)

package runtime

Expand Down
2 changes: 1 addition & 1 deletion src/syscall/proc_emulated.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build baremetal || tinygo.wasm
//go:build baremetal || tinygo.wasm || nintendoswitch

// This file emulates some process-related functions that are only available
// under a real operating system.
Expand Down
2 changes: 1 addition & 1 deletion src/syscall/proc_hosted.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !baremetal && !tinygo.wasm
//go:build !baremetal && !tinygo.wasm && !nintendoswitch

// This file assumes there is a libc available that runs on a real operating
// system.
Expand Down
Loading