1 // Copyright 2011 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.
5 //go:build unix || (js && wasm) || wasip1
15 // for testing: whatever interrupts a sleep
17 // There is no mechanism in wasi to interrupt the call to poll_oneoff
18 // used to implement runtime.usleep so this function does nothing, which
19 // somewhat defeats the purpose of TestSleep but we are still better off
20 // validating that time elapses when the process calls time.Sleep than
21 // skipping the test altogether.
22 if runtime.GOOS != "wasip1" {
23 syscall.Kill(syscall.Getpid(), syscall.SIGCHLD)
27 func open(name string) (uintptr, error) {
28 fd, err := syscall.Open(name, syscall.O_RDONLY, 0)
32 return uintptr(fd), nil
35 func read(fd uintptr, buf []byte) (int, error) {
36 return syscall.Read(int(fd), buf)
39 func closefd(fd uintptr) {
40 syscall.Close(int(fd))
43 func preadn(fd uintptr, buf []byte, off int) error {
48 if _, err := syscall.Seek(int(fd), int64(off), whence); err != nil {
52 m, err := syscall.Read(int(fd), buf)
55 return errors.New("short read")