mirror of
https://github.com/golang/go
synced 2024-11-27 05:21:22 -07:00
runtime/cgo: use pthread_get_stacksize_np to get stack size on darwin
This commit is contained in:
parent
3c8353502b
commit
b29c74599e
@ -14,19 +14,12 @@ static void (*setg_gcc)(void*);
|
||||
void
|
||||
x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
size_t size, cur;
|
||||
size_t size;
|
||||
|
||||
setg_gcc = setg;
|
||||
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_getstacksize(&attr, &size);
|
||||
cur = pthread_get_stacksize_np(pthread_self());
|
||||
if (cur > size) {
|
||||
size = cur;
|
||||
}
|
||||
g->stacklo = (uintptr)&attr - size + 4096;
|
||||
pthread_attr_destroy(&attr);
|
||||
size = pthread_get_stacksize_np(pthread_self());
|
||||
g->stacklo = (uintptr)&size - size + 4096;
|
||||
}
|
||||
|
||||
|
||||
@ -36,19 +29,15 @@ _cgo_sys_thread_start(ThreadStart *ts)
|
||||
pthread_attr_t attr;
|
||||
sigset_t ign, oset;
|
||||
pthread_t p;
|
||||
size_t size, cur;
|
||||
size_t size;
|
||||
int err;
|
||||
|
||||
sigfillset(&ign);
|
||||
pthread_sigmask(SIG_SETMASK, &ign, &oset);
|
||||
|
||||
size = pthread_get_stacksize_np(pthread_self());
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_getstacksize(&attr, &size);
|
||||
cur = pthread_get_stacksize_np(pthread_self());
|
||||
if (cur > size) {
|
||||
size = cur;
|
||||
pthread_attr_setstacksize(&attr, size);
|
||||
}
|
||||
pthread_attr_setstacksize(&attr, size);
|
||||
// Leave stacklo=0 and set stackhi=size; mstart will do the rest.
|
||||
ts->g->stackhi = size;
|
||||
err = _cgo_try_pthread_create(&p, &attr, threadentry, ts);
|
||||
|
@ -36,8 +36,9 @@ _cgo_sys_thread_start(ThreadStart *ts)
|
||||
sigfillset(&ign);
|
||||
pthread_sigmask(SIG_SETMASK, &ign, &oset);
|
||||
|
||||
size = pthread_get_stacksize_np(pthread_self());
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_getstacksize(&attr, &size);
|
||||
pthread_attr_setstacksize(&attr, size);
|
||||
// Leave stacklo=0 and set stackhi=size; mstart will do the rest.
|
||||
ts->g->stackhi = size;
|
||||
err = _cgo_try_pthread_create(&p, &attr, threadentry, ts);
|
||||
@ -126,15 +127,12 @@ init_working_dir()
|
||||
void
|
||||
x_cgo_init(G *g, void (*setg)(void*))
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
size_t size;
|
||||
|
||||
//fprintf(stderr, "x_cgo_init = %p\n", &x_cgo_init); // aid debugging in presence of ASLR
|
||||
setg_gcc = setg;
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_getstacksize(&attr, &size);
|
||||
g->stacklo = (uintptr)&attr - size + 4096;
|
||||
pthread_attr_destroy(&attr);
|
||||
size = pthread_get_stacksize_np(pthread_self());
|
||||
g->stacklo = (uintptr)&size - size + 4096;
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
darwin_arm_init_mach_exception_handler();
|
||||
|
Loading…
Reference in New Issue
Block a user