Skip to content

Commit 2a2234a

Browse files
committed
align GOOS=tamago support to go1.14
1 parent 5e437af commit 2a2234a

30 files changed

+617
-51
lines changed

src/cmd/dist/build.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1556,10 +1556,10 @@ var cgoEnabled = map[string]bool{
15561556
"plan9/amd64": false,
15571557
"plan9/arm": false,
15581558
"solaris/amd64": true,
1559+
"tamago/arm": true,
15591560
"windows/386": true,
15601561
"windows/amd64": true,
15611562
"windows/arm": false,
1562-
"tamago/arm": true,
15631563
}
15641564

15651565
// List of platforms which are supported but not complete yet. These get

src/cmd/dist/util.go

+4
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,10 @@ func xsamefile(f1, f2 string) bool {
383383
}
384384

385385
func xgetgoarm() string {
386+
if goos == "tamago" {
387+
// tamago guarantees VFPv3 and is always cross-compiled.
388+
return "7"
389+
}
386390
if goos == "darwin" || goos == "android" {
387391
// Assume all darwin/arm and android devices have VFPv3.
388392
// These ports are also mostly cross-compiled, so it makes little

src/internal/poll/fcntl_tamago.go

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2019 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build tamago
6+
7+
package poll
8+
9+
import "syscall"
10+
11+
// fcntl not supported on tamago
12+
func fcntl(fd int, cmd int, arg int) (int, error) {
13+
return 0, syscall.ENOSYS
14+
}

src/os/stat_js.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build js,wasm tamago
5+
// +build js,wasm
66

77
package os
88

src/os/stat_tamago.go

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2009 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build tamago
6+
7+
package os
8+
9+
import (
10+
"syscall"
11+
"time"
12+
)
13+
14+
func fillFileStatFromSys(fs *fileStat, name string) {
15+
fs.name = basename(name)
16+
fs.size = fs.sys.Size
17+
fs.modTime = timespecToTime(fs.sys.Mtime, fs.sys.MtimeNsec)
18+
fs.mode = FileMode(fs.sys.Mode & 0777)
19+
switch fs.sys.Mode & syscall.S_IFMT {
20+
case syscall.S_IFBLK:
21+
fs.mode |= ModeDevice
22+
case syscall.S_IFCHR:
23+
fs.mode |= ModeDevice | ModeCharDevice
24+
case syscall.S_IFDIR:
25+
fs.mode |= ModeDir
26+
case syscall.S_IFIFO:
27+
fs.mode |= ModeNamedPipe
28+
case syscall.S_IFLNK:
29+
fs.mode |= ModeSymlink
30+
case syscall.S_IFREG:
31+
// nothing to do
32+
case syscall.S_IFSOCK:
33+
fs.mode |= ModeSocket
34+
}
35+
if fs.sys.Mode&syscall.S_ISGID != 0 {
36+
fs.mode |= ModeSetgid
37+
}
38+
if fs.sys.Mode&syscall.S_ISUID != 0 {
39+
fs.mode |= ModeSetuid
40+
}
41+
if fs.sys.Mode&syscall.S_ISVTX != 0 {
42+
fs.mode |= ModeSticky
43+
}
44+
}
45+
46+
func timespecToTime(sec, nsec int64) time.Time {
47+
return time.Unix(sec, nsec)
48+
}
49+
50+
// For testing.
51+
func atime(fi FileInfo) time.Time {
52+
st := fi.Sys().(*syscall.Stat_t)
53+
return timespecToTime(st.Atime, st.AtimeNsec)
54+
}

src/runtime/alg.go

-3
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,6 @@ func alginit() {
331331
initAlgAES()
332332
return
333333
}
334-
if GOOS == "tamago" {
335-
initRNG()
336-
}
337334
getRandomData((*[len(hashkey) * sys.PtrSize]byte)(unsafe.Pointer(&hashkey))[:])
338335
hashkey[0] |= 1 // make sure these numbers are odd
339336
hashkey[1] |= 1

src/runtime/internal/sys/zgoos_aix.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/internal/sys/zgoos_android.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/internal/sys/zgoos_darwin.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/internal/sys/zgoos_dragonfly.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/internal/sys/zgoos_freebsd.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/internal/sys/zgoos_hurd.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/internal/sys/zgoos_illumos.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/internal/sys/zgoos_js.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/internal/sys/zgoos_linux.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/internal/sys/zgoos_netbsd.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/internal/sys/zgoos_openbsd.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/internal/sys/zgoos_plan9.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/internal/sys/zgoos_solaris.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/internal/sys/zgoos_tamago.go

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/internal/sys/zgoos_windows.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/internal/sys/zgoos_zos.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/lock_tamago.go

+3-21
Original file line numberDiff line numberDiff line change
@@ -142,27 +142,9 @@ func checkTimeouts() {
142142
}
143143
}
144144

145-
var returnedEventHandler *g
146-
147-
func init() {
148-
// At the toplevel we need an extra goroutine that handles asynchronous events.
149-
initg := getg()
150-
go func() {
151-
returnedEventHandler = getg()
152-
goready(initg, 1)
153-
154-
gopark(nil, nil, waitReasonZero, traceEvNone, 1)
155-
returnedEventHandler = nil
156-
}()
157-
gopark(nil, nil, waitReasonZero, traceEvNone, 1)
158-
}
159-
160145
// beforeIdle gets called by the scheduler if no goroutine is awake.
161-
// We resume the event handler (if available) which will pause the execution.
162-
func beforeIdle() bool {
163-
if returnedEventHandler != nil {
164-
goready(returnedEventHandler, 1)
165-
return true
166-
}
146+
// If we are not already handling an event, then we pause for an async event.
147+
// If an event handler returned, we resume it and it will pause the execution.
148+
func beforeIdle(delay int64) bool {
167149
return false
168150
}

src/runtime/mem_tamago.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func sysReserve(v unsafe.Pointer, n uintptr) unsafe.Pointer {
196196
// so try to extend the address space.
197197
p = sbrk(n)
198198
}
199-
if p == nil {
199+
if p == nil && v == nil {
200200
p = memAlloc(n)
201201
memCheck()
202202
}

src/runtime/os_tamago_arm.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ func initRNG()
5050

5151
// the following functions must be provided externally
5252
// (but are already stubbed somewhere else in the runtime)
53-
//func initRNG()
54-
//func nanotime() int64
53+
//func nanotime1() int64
5554

5655
// the following functions are defined in sys_tamago_arm.s
5756
func set_vbar(addr unsafe.Pointer)
@@ -356,7 +355,7 @@ func syscall(number, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
356355
}
357356

358357
//go:nosplit
359-
func write(fd uintptr, buf unsafe.Pointer, count int32) int32 {
358+
func write1(fd uintptr, buf unsafe.Pointer, count int32) int32 {
360359
if fd != 1 && fd != 2 {
361360
throw("unexpected fd, only stdout/stderr are supported")
362361
}
@@ -378,7 +377,7 @@ func syscall_now() (sec int64, nsec int32) {
378377
}
379378

380379
//go:nosplit
381-
func walltime() (sec int64, nsec int32) {
380+
func walltime1() (sec int64, nsec int32) {
382381
// TODO: probably better implement this in sys_tamago_arm.s for better
383382
// performance
384383
nano := nanotime()
@@ -409,3 +408,11 @@ func exitThread(wait *uint32) {
409408
// We should never reach exitThread
410409
throw("exitThread: not implemented")
411410
}
411+
412+
const preemptMSupported = false
413+
414+
func preemptM(mp *m) {
415+
// Not currently supported.
416+
//
417+
// TODO: Use a note like we use signals on POSIX OSes
418+
}

src/runtime/proc.go

+3
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,9 @@ func mcommoninit(mp *m) {
651651
var fastrandseed uintptr
652652

653653
func fastrandinit() {
654+
if GOOS == "tamago" {
655+
initRNG()
656+
}
654657
s := (*[unsafe.Sizeof(fastrandseed)]byte)(unsafe.Pointer(&fastrandseed))[:]
655658
getRandomData(s)
656659
}

0 commit comments

Comments
 (0)