runtime: wrap nanotime, walltime, and write

In preparation for general faketime support, this renames the existing
nanotime, walltime, and write functions to nanotime1, walltime1, and
write1 and wraps them with trivial Go functions. This will let us
inject different implementations on all platforms when faketime is
enabled.

Updates #30439.

Change-Id: Ice5ccc513a32a6d89ea051638676d3ee05b00418
Reviewed-on: https://go-review.googlesource.com/c/go/+/192738
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Austin Clements 2019-09-01 10:37:44 -04:00
parent 6719d889e1
commit 4af3c17f8c
43 changed files with 164 additions and 133 deletions

View file

@ -393,11 +393,11 @@ func munmap(addr unsafe.Pointer, n uintptr) {
sysvicall2(&libc_munmap, uintptr(addr), uintptr(n))
}
func nanotime1()
func nanotime2()
//go:nosplit
func nanotime() int64 {
return int64(sysvicall0((*libcFunc)(unsafe.Pointer(funcPC(nanotime1)))))
func nanotime1() int64 {
return int64(sysvicall0((*libcFunc)(unsafe.Pointer(funcPC(nanotime2)))))
}
//go:nosplit
@ -499,7 +499,7 @@ func usleep(µs uint32) {
}
//go:nosplit
func write(fd uintptr, buf unsafe.Pointer, nbyte int32) int32 {
func write1(fd uintptr, buf unsafe.Pointer, nbyte int32) int32 {
return int32(sysvicall3(&libc_write, uintptr(fd), uintptr(buf), uintptr(nbyte)))
}