1
0
mirror of https://github.com/golang/go synced 2024-11-23 04:20:03 -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:
Johan Brandhorst-Satzkorn 2023-04-07 18:26:50 -07:00 committed by Gopher Robot
parent ee591c8414
commit f7f0d39569
2 changed files with 22 additions and 2 deletions

View File

@ -2,18 +2,26 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build unix || (js && wasm)
//go:build unix || (js && wasm) || wasip1
package time
import (
"errors"
"runtime"
"syscall"
)
// for testing: whatever interrupts a sleep
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) {

View 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"
}