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.
10 "runtime/internal/atomic"
16 func write1(fd uintptr, p unsafe.Pointer, n int32) int32 {
18 throw("runtime.write to fd > 2 is unsupported")
24 // Stubs so tests can link correctly. These should never be called.
25 func open(name *byte, mode, perm int32) int32 { panic("not implemented") }
26 func closefd(fd int32) int32 { panic("not implemented") }
27 func read(fd int32, p unsafe.Pointer, n int32) int32 { panic("not implemented") }
29 //go:wasmimport gojs runtime.wasmWrite
31 func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)
33 func usleep(usec uint32)
36 func usleep_no_g(usec uint32) {
40 func exitThread(wait *atomic.Uint32)
56 throw("unexpected signal during runtime execution")
59 // js only invokes the exception handler for memory faults.
66 // Called to initialize a new m (including the bootstrap m).
67 // Called on the parent thread (main thread in case of bootstrap), can allocate memory.
68 func mpreinit(mp *m) {
69 mp.gsignal = malg(32 * 1024)
74 func sigsave(p *sigset) {
78 func msigrestore(sigmask sigset) {
82 //go:nowritebarrierrec
83 func clearSignalHandlers() {
87 func sigblock(exiting bool) {
90 // Called to initialize a new m (including the bootstrap m).
91 // Called on the new thread, cannot allocate memory.
95 // Called from dropm to undo the effect of an minit.
99 // Called from exitm, but not from drop, to undo the effect of thread-owned
100 // resources in minit, semacreate, or elsewhere. Do not take locks after calling this.
101 func mdestroy(mp *m) {
107 physPageSize = 64 * 1024
110 // wasm has no signals
113 func signame(sig uint32) string {
121 //go:wasmimport gojs runtime.getRandomData
122 func getRandomData(r []byte)
128 func initsig(preinit bool) {
131 // May run with m.p==nil, so write barriers are not allowed.
134 func newosproc(mp *m) {
135 throw("newosproc: not implemented")
138 func setProcessCPUProfiler(hz int32) {}
139 func setThreadCPUProfiler(hz int32) {}
140 func sigdisable(uint32) {}
141 func sigenable(uint32) {}
142 func sigignore(uint32) {}
144 //go:linkname os_sigpipe os.sigpipe
146 throw("too many writes on closed pipe")
150 func cputicks() int64 {
151 // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand().
152 // runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
156 //go:linkname syscall_now syscall.now
157 func syscall_now() (sec int64, nsec int32) {
158 sec, nsec, _ = time_now()
162 // gsignalStack is unused on js.
163 type gsignalStack struct{}
165 const preemptMSupported = false
167 func preemptM(mp *m) {
168 // No threads, so nothing to do.