Source file
src/runtime/os_openbsd_libc.go
1
2
3
4
5
6
7 package runtime
8
9 import (
10 "internal/abi"
11 "unsafe"
12 )
13
14
15 func mstart_stub()
16
17
18
19
20 func newosproc(mp *m) {
21 if false {
22 print("newosproc m=", mp, " g=", mp.g0, " id=", mp.id, " ostk=", &mp, "\n")
23 }
24
25
26 var attr pthreadattr
27 if err := pthread_attr_init(&attr); err != 0 {
28 writeErrStr(failthreadcreate)
29 exit(1)
30 }
31
32
33 var stacksize uintptr
34 if pthread_attr_getstacksize(&attr, &stacksize) != 0 {
35 writeErrStr(failthreadcreate)
36 exit(1)
37 }
38 mp.g0.stack.hi = stacksize
39
40
41 if pthread_attr_setdetachstate(&attr, _PTHREAD_CREATE_DETACHED) != 0 {
42 writeErrStr(failthreadcreate)
43 exit(1)
44 }
45
46
47
48 var oset sigset
49 sigprocmask(_SIG_SETMASK, &sigset_all, &oset)
50 err := retryOnEAGAIN(func() int32 {
51 return pthread_create(&attr, abi.FuncPCABI0(mstart_stub), unsafe.Pointer(mp))
52 })
53 sigprocmask(_SIG_SETMASK, &oset, nil)
54 if err != 0 {
55 writeErrStr(failthreadcreate)
56 exit(1)
57 }
58
59 pthread_attr_destroy(&attr)
60 }
61
View as plain text