mirror of
https://github.com/golang/go
synced 2024-11-23 07:40:04 -07:00
time: add wasip1 support
Fixes #58141 Co-authored-by: Richard Musiol <neelance@gmail.com> Co-authored-by: Achille Roussel <achille.roussel@gmail.com> Co-authored-by: Julien Fabre <ju.pryz@gmail.com> Co-authored-by: Evan Phoenix <evan@phx.io> Change-Id: I51dabbf17b8f5540c964f90223d18457f6f9fbef Reviewed-on: https://go-review.googlesource.com/c/go/+/483236 Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
ee591c8414
commit
f7f0d39569
@ -2,18 +2,26 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build unix || (js && wasm)
|
//go:build unix || (js && wasm) || wasip1
|
||||||
|
|
||||||
package time
|
package time
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
// for testing: whatever interrupts a sleep
|
// for testing: whatever interrupts a sleep
|
||||||
func interrupt() {
|
func interrupt() {
|
||||||
syscall.Kill(syscall.Getpid(), syscall.SIGCHLD)
|
// There is no mechanism in wasi to interrupt the call to poll_oneoff
|
||||||
|
// used to implement runtime.usleep so this function does nothing, which
|
||||||
|
// somewhat defeats the purpose of TestSleep but we are still better off
|
||||||
|
// validating that time elapses when the process calls time.Sleep than
|
||||||
|
// skipping the test altogether.
|
||||||
|
if runtime.GOOS != "wasip1" {
|
||||||
|
syscall.Kill(syscall.Getpid(), syscall.SIGCHLD)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func open(name string) (uintptr, error) {
|
func open(name string) (uintptr, error) {
|
||||||
|
12
src/time/zoneinfo_wasip1.go
Normal file
12
src/time/zoneinfo_wasip1.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Copyright 2023 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package time
|
||||||
|
|
||||||
|
// in wasip1 zoneinfo is managed by the runtime.
|
||||||
|
var platformZoneSources = []string{}
|
||||||
|
|
||||||
|
func initLocal() {
|
||||||
|
localLoc.name = "Local"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user