2017-03-02 Richard Biener <rguenther@suse.de>
[official-gcc.git] / libgo / go / runtime / os_gccgo.go
bloba8f05a4b3d703da94f581d2d9012b57b67456384
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.
5 package runtime
7 import (
8 "unsafe"
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)
18 mp.gsignal.m = mp
21 // minit is called to initialize a new m (including the bootstrap m).
22 // Called on the new thread, cannot allocate memory.
23 func minit() {
24 minitSignals()
26 // FIXME: We should set _g_.m.procid here.
29 // Called from dropm to undo the effect of an minit.
30 //go:nosplit
31 func unminit() {
32 unminitSignals()
35 var urandom_dev = []byte("/dev/urandom\x00")
37 func getRandomData(r []byte) {
38 if startupRandomData != nil {
39 n := copy(r, startupRandomData)
40 extendRandom(r, n)
41 return
43 fd := open(&urandom_dev[0], 0 /* O_RDONLY */, 0)
44 n := read(fd, unsafe.Pointer(&r[0]), int32(len(r)))
45 closefd(fd)
46 extendRandom(r, int(n))