OLD | NEW |
1 // Use of this source file is governed by a BSD-style | 1 // Use of this source file is governed by a BSD-style |
2 // license that can be found in the LICENSE file.` | 2 // license that can be found in the LICENSE file.` |
3 | 3 |
4 #include "runtime.h" | 4 #include "runtime.h" |
5 #include "defs_GOOS_GOARCH.h" | 5 #include "defs_GOOS_GOARCH.h" |
6 #include "os_GOOS.h" | 6 #include "os_GOOS.h" |
7 #include "stack.h" | 7 #include "stack.h" |
8 | 8 |
9 extern SigTab runtime·sigtab[]; | 9 extern SigTab runtime·sigtab[]; |
10 extern int32 runtime·sys_umtx_op(uint32*, int32, uint32, void*, void*); | 10 extern int32 runtime·sys_umtx_op(uint32*, int32, uint32, void*, void*); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 mp->tls[0] = mp->id; // so 386 asm can find it | 106 mp->tls[0] = mp->id; // so 386 asm can find it |
107 | 107 |
108 runtime·thr_new(¶m, sizeof param); | 108 runtime·thr_new(¶m, sizeof param); |
109 runtime·sigprocmask(&oset, nil); | 109 runtime·sigprocmask(&oset, nil); |
110 } | 110 } |
111 | 111 |
112 void | 112 void |
113 runtime·osinit(void) | 113 runtime·osinit(void) |
114 { | 114 { |
115 runtime·ncpu = getncpu(); | 115 runtime·ncpu = getncpu(); |
| 116 |
| 117 if (runtime·startup_random_data == nil) { |
| 118 static byte urandom_data[HashRandomBytes]; |
| 119 int32 fd = runtime·open((uint8*)"/dev/urandom", 0 /* O_RDONLY */
, 0); |
| 120 if (runtime·read(fd, urandom_data, HashRandomBytes) == HashRando
mBytes) { |
| 121 runtime·startup_random_data = urandom_data; |
| 122 runtime·startup_random_data_len = HashRandomBytes; |
| 123 } |
| 124 runtime·close(fd); |
| 125 } |
116 } | 126 } |
117 | 127 |
118 void | 128 void |
119 runtime·goenvs(void) | 129 runtime·goenvs(void) |
120 { | 130 { |
121 runtime·goenvs_unix(); | 131 runtime·goenvs_unix(); |
122 } | 132 } |
123 | 133 |
124 // Called to initialize a new m (including the bootstrap m). | 134 // Called to initialize a new m (including the bootstrap m). |
125 // Called on the parent thread (main thread in case of bootstrap), can allocate
memory. | 135 // Called on the parent thread (main thread in case of bootstrap), can allocate
memory. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 } | 244 } |
235 runtime·write(2, badsignal, sizeof badsignal - 1); | 245 runtime·write(2, badsignal, sizeof badsignal - 1); |
236 if (0 <= sig && sig < NSIG) { | 246 if (0 <= sig && sig < NSIG) { |
237 // Call runtime·findnull dynamically to circumvent static stack
size check. | 247 // Call runtime·findnull dynamically to circumvent static stack
size check. |
238 static int32 (*findnull)(byte*) = runtime·findnull; | 248 static int32 (*findnull)(byte*) = runtime·findnull; |
239 runtime·write(2, runtime·sigtab[sig].name, findnull((byte*)runti
me·sigtab[sig].name)); | 249 runtime·write(2, runtime·sigtab[sig].name, findnull((byte*)runti
me·sigtab[sig].name)); |
240 } | 250 } |
241 runtime·write(2, "\n", 1); | 251 runtime·write(2, "\n", 1); |
242 runtime·exit(1); | 252 runtime·exit(1); |
243 } | 253 } |
OLD | NEW |