| 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 |
|
| 7 |
package runtime |
| 8 |
|
| 9 |
import ( |
| 10 |
"unsafe" |
| 11 |
) |
| 12 |
|
| 13 |
func exit(code int32) |
| 14 |
|
| 15 |
func 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 |
| 25 |
func wasmWrite(fd uintptr, p unsafe.Pointer, n int32) |
| 26 |
|
| 27 |
func usleep(usec uint32) { |
| 28 |
// TODO(neelance): implement usleep |
| 29 |
} |
| 30 |
|
| 31 |
//go:wasmimport gojs runtime.getRandomData |
| 32 |
//go:noescape |
| 33 |
func getRandomData(r []byte) |
| 34 |
|
| 35 |
func readRandom(r []byte) int { |
| 36 |
getRandomData(r) |
| 37 |
return len(r) |
| 38 |
} |
| 39 |
|
| 40 |
func goenvs() { |
| 41 |
goenvs_unix() |
| 42 |
} |