aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/os_darwin.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2018-04-30 07:50:10 -0700
committerKeith Randall <khr@golang.org>2018-05-01 00:20:55 +0000
commit21656d09b710799806aee182856b2a02068609bd (patch)
tree7977f4b4bb2e4b40748a6c81414a15f405e0de1d /src/runtime/os_darwin.go
parent6f7ec484f67b7128b4158babd48cbf47f4443f32 (diff)
downloadgo-21656d09b710799806aee182856b2a02068609bd.tar.gz
go-21656d09b710799806aee182856b2a02068609bd.zip
runtime: convert exit to use pthread library on Darwin
Now we no longer need to mess with TLS on Darwin 386/amd64, we always rely on the pthread library to set it up. We now just use one entry in the TLS for the G. Return from mstart to let the pthread library clean up the OS thread. Change-Id: Iccf58049d545515d9b1d090b161f420e40ffd244 Reviewed-on: https://go-review.googlesource.com/110215 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/os_darwin.go')
-rw-r--r--src/runtime/os_darwin.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/runtime/os_darwin.go b/src/runtime/os_darwin.go
index 9d3139b2ad..067b7debfa 100644
--- a/src/runtime/os_darwin.go
+++ b/src/runtime/os_darwin.go
@@ -135,11 +135,14 @@ func newosproc(mp *m) {
exit(1)
}
- // Set the stack we want to use.
- if pthread_attr_setstack(&attr, unsafe.Pointer(mp.g0.stack.lo), mp.g0.stack.hi-mp.g0.stack.lo) != 0 {
+ // Set the stack size we want to use. 64KB for now.
+ // TODO: just use OS default size?
+ const stackSize = 1 << 16
+ if pthread_attr_setstacksize(&attr, stackSize) != 0 {
write(2, unsafe.Pointer(&failthreadcreate[0]), int32(len(failthreadcreate)))
exit(1)
}
+ //mSysStatInc(&memstats.stacks_sys, stackSize) //TODO: do this?
// Tell the pthread library we won't join with this thread.
if pthread_attr_setdetachstate(&attr, _PTHREAD_CREATE_DETACHED) != 0 {
@@ -169,12 +172,6 @@ func mstart_stub()
//
//go:nosplit
func newosproc0(stacksize uintptr, fn uintptr) {
- stack := sysAlloc(stacksize, &memstats.stacks_sys)
- if stack == nil {
- write(2, unsafe.Pointer(&failallocatestack[0]), int32(len(failallocatestack)))
- exit(1)
- }
-
// Initialize an attribute object.
var attr pthreadattr
var err int32
@@ -185,10 +182,11 @@ func newosproc0(stacksize uintptr, fn uintptr) {
}
// Set the stack we want to use.
- if pthread_attr_setstack_trampoline(&attr, stack, stacksize) != 0 {
+ if pthread_attr_setstacksize_trampoline(&attr, stacksize) != 0 {
write(2, unsafe.Pointer(&failthreadcreate[0]), int32(len(failthreadcreate)))
exit(1)
}
+ mSysStatInc(&memstats.stacks_sys, stacksize)
// Tell the pthread library we won't join with this thread.
if pthread_attr_setdetachstate_trampoline(&attr, _PTHREAD_CREATE_DETACHED) != 0 {