Source file
src/runtime/os_wasmx.go
1
2
3
4
5
6
7 package runtime
8
9 import (
10 "internal/goarch"
11 "internal/runtime/atomic"
12 "unsafe"
13 )
14
15 func osinit() {
16
17 physPageSize = 64 * 1024
18 if goarch.IsWasm32 != 0 && firstmoduledata.end > ^uintptr(0)-(physPageSize-1) {
19 throw("initial WebAssembly memory exceeds uintptr range")
20 }
21 initBloc()
22 pages := currentMemory()
23 if pages < 0 {
24 throw("negative WebAssembly memory size")
25 }
26 if goarch.IsWasm32 != 0 && uintptr(pages) > ^uintptr(0)/physPageSize {
27
28 pages = int32(^uintptr(0) / physPageSize)
29 }
30 blocMax = uintptr(pages) * physPageSize
31 numCPUStartup = getCPUCount()
32 getg().m.procid = 2
33 }
34
35 func getCPUCount() int32 {
36 return 1
37 }
38
39 const _SIGSEGV = 0xb
40
41 func sigpanic() {
42 gp := getg()
43 if !canpanic() {
44 throw("unexpected signal during runtime execution")
45 }
46
47
48 gp.sig = _SIGSEGV
49 panicmem()
50 }
51
52
53
54 func exitThread(wait *atomic.Uint32)
55
56 type mOS struct{}
57
58 func osyield()
59
60
61 func osyield_no_g() {
62 osyield()
63 }
64
65 type sigset struct{}
66
67
68
69 func mpreinit(mp *m) {
70 mp.gsignal = malg(32 * 1024)
71 mp.gsignal.m = mp
72 }
73
74
75 func usleep_no_g(usec uint32) {
76 usleep(usec)
77 }
78
79
80 func sigsave(p *sigset) {
81 }
82
83
84 func msigrestore(sigmask sigset) {
85 }
86
87
88
89 func clearSignalHandlers() {
90 }
91
92
93 func sigblock(exiting bool) {
94 }
95
96
97
98 func minit() {
99 }
100
101
102 func unminit() {
103 }
104
105
106
107 func mdestroy(mp *m) {
108 }
109
110
111 const _NSIG = 0
112
113 func signame(sig uint32) string {
114 return ""
115 }
116
117 func crash() {
118 abort()
119 }
120
121 func initsig(preinit bool) {
122 }
123
124
125
126
127 func newosproc(mp *m) {
128 throw("newosproc: not implemented")
129 }
130
131
132
133
134 func os_sigpipe() {}
135
136
137 func syscall_now() (sec int64, nsec int32) {
138 sec, nsec, _ = time_now()
139 return
140 }
141
142
143 func cputicks() int64 {
144
145 return nanotime()
146 }
147
148
149 type gsignalStack struct{}
150
151 const preemptMSupported = false
152
153 func preemptM(gp *g) {
154 casfrom_Gscanstatus(gp, _Gscanrunning, _Grunning)
155
156
157 }
158
159
160
161
162
163 func getfp() uintptr { return 0 }
164
165 func setProcessCPUProfiler(hz int32) {}
166 func setThreadCPUProfiler(hz int32) {}
167 func sigdisable(uint32) {}
168 func sigenable(uint32) {}
169 func sigignore(uint32) {}
170
171
172 func open(name *byte, mode, perm int32) int32 { panic("not implemented") }
173 func closefd(fd int32) int32 { panic("not implemented") }
174 func read(fd int32, p unsafe.Pointer, n int32) int32 { panic("not implemented") }
175
View as plain text