1// Copyright 2018 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//go:build js && wasm
6
7package runtime
8
9import (
10	"unsafe"
11)
12
13func exit(code int32)
14
15func write1(fd uintptr, p unsafe.Pointer, n int32) int32 {
16	if fd > 2 {
17		throw("runtime.write to fd > 2 is unsupported")
18	}
19	wasmWrite(fd, p, n)
20	return n
21}
22
23//go:wasmimport gojs runtime.wasmWrite
24//go:noescape
25func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)
26
27func usleep(usec uint32) {
28	// TODO(neelance): implement usleep
29}
30
31//go:wasmimport gojs runtime.getRandomData
32//go:noescape
33func getRandomData(r []byte)
34
35func readRandom(r []byte) int {
36	getRandomData(r)
37	return len(r)
38}
39
40func goenvs() {
41	goenvs_unix()
42}
43