Skip to content

Commit 3077302

Browse files
committed
Fill in missing functions for plan9 port
1 parent 5e40747 commit 3077302

File tree

5 files changed

+58
-7
lines changed

5 files changed

+58
-7
lines changed

src/runtime/os_plan9.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -587,10 +587,3 @@ func nanotime1() int64 {
587587
// fall back to unix time
588588
return int64(frombe(t[0]))
589589
}
590-
591-
//go:nosplit
592-
func walltime() (sec int64, nsec int32) {
593-
var t [1]uint64
594-
readtime(&t[0], 1, 1)
595-
return timesplit(frombe(t[0]))
596-
}

src/runtime/os_plan9_386.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2025 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+
package runtime
6+
7+
//go:nosplit
8+
func walltime() (sec int64, nsec int32) {
9+
var t [1]uint64
10+
readtime(&t[0], 1, 1)
11+
return timesplit(frombe(t[0]))
12+
}

src/runtime/os_plan9_amd64.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2025 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+
package runtime
6+
7+
//go:nosplit
8+
func walltime() (sec int64, nsec int32) {
9+
var t [1]uint64
10+
readtime(&t[0], 1, 1)
11+
return timesplit(frombe(t[0]))
12+
}

src/runtime/os_plan9_arm.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@ func cputicks() int64 {
1313
// runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
1414
return nanotime()
1515
}
16+
17+
//go:nosplit
18+
func walltime() (sec int64, nsec int32) {
19+
var t [1]uint64
20+
readtime(&t[0], 1, 1)
21+
return timesplit(frombe(t[0]))
22+
}

src/runtime/sys_plan9_arm64.s

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ TEXT runtime·closefd(SB),NOSPLIT,$0-12
101101
MOVWU R0, ret+8(FP)
102102
RET
103103

104+
//func dupfd(old, new int32) int32
105+
TEXT runtime·dupfd(SB),NOSPLIT,$0-12
106+
MOVD $SYS_DUP, R0
107+
SVC $0
108+
MOVWU R0, ret+8(FP)
109+
RET
110+
104111
//func exits(msg *byte)
105112
TEXT runtime·exits(SB),NOSPLIT,$0-8
106113
MOVD $SYS_EXITS, R0
@@ -135,6 +142,26 @@ TEXT runtime·plan9_tsemacquire(SB),NOSPLIT,$0-20
135142
MOVWU R0, ret+16(FP)
136143
RET
137144

145+
// func timesplit(u uint64) (sec int64, nsec int32)
146+
TEXT runtime·timesplit(SB),NOSPLIT,$0-16
147+
// load u (nanoseconds)
148+
MOVD u+0(FP), R0
149+
150+
// compute sec = u / 1e9
151+
MOVD R0, R1
152+
MOVD $1000000000, R2
153+
UDIV R2, R1 // R1 = R1 / R2 -> seconds
154+
155+
// compute rem = u - sec * 1e9
156+
MOVD R1, R3
157+
MUL R3, R2 // R2 = sec * 1e9
158+
SUB R2, R0 // R0 = u - (sec*1e9) -> remainder (nsec)
159+
160+
// store results
161+
MOVD R1, sec+0(FP)
162+
MOVWU R0, nsec+8(FP)
163+
RET
164+
138165
//func nsec(*int64) int64
139166
TEXT runtime·nsec(SB),NOSPLIT|NOFRAME,$0-16
140167
MOVD $SYS_NSEC, R0

0 commit comments

Comments
 (0)