1 // Copyright 2009 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.
11 // Temporary for C code to call:
12 //go:linkname minit runtime.minit
14 // Called to initialize a new m (including the bootstrap m).
15 // Called on the parent thread (main thread in case of bootstrap), can allocate memory.
16 func mpreinit(mp
*m
) {
17 mp
.gsignal
= malg(true, true, &mp
.gsignalstack
, &mp
.gsignalstacksize
)
21 // minit is called to initialize a new m (including the bootstrap m).
22 // Called on the new thread, cannot allocate memory.
26 // FIXME: We should set _g_.m.procid here.
29 // Called from dropm to undo the effect of an minit.
35 var urandom_dev
= []byte("/dev/urandom\x00")
37 func getRandomData(r
[]byte) {
38 if startupRandomData
!= nil {
39 n
:= copy(r
, startupRandomData
)
43 fd
:= open(&urandom_dev
[0], 0 /* O_RDONLY */, 0)
44 n
:= read(fd
, unsafe
.Pointer(&r
[0]), int32(len(r
)))
46 extendRandom(r
, int(n
))