mirror of git://gcc.gnu.org/git/gcc.git
runtime: Use dl_iterate_phdr to get TLS size.
From-SVN: r188290
This commit is contained in:
parent
079d26b9d6
commit
0d7afaa749
|
|
@ -21,6 +21,9 @@
|
||||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
#undef HAVE_DLFCN_H
|
#undef HAVE_DLFCN_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `dl_iterate_phdr' function. */
|
||||||
|
#undef HAVE_DL_ITERATE_PHDR
|
||||||
|
|
||||||
/* Define to 1 if you have the `epoll_create1' function. */
|
/* Define to 1 if you have the `epoll_create1' function. */
|
||||||
#undef HAVE_EPOLL_CREATE1
|
#undef HAVE_EPOLL_CREATE1
|
||||||
|
|
||||||
|
|
@ -286,9 +289,6 @@
|
||||||
/* Define to 1 if you have the `wait4' function. */
|
/* Define to 1 if you have the `wait4' function. */
|
||||||
#undef HAVE_WAIT4
|
#undef HAVE_WAIT4
|
||||||
|
|
||||||
/* Define to 1 if you have the `_dl_get_tls_static_info' function. */
|
|
||||||
#undef HAVE__DL_GET_TLS_STATIC_INFO
|
|
||||||
|
|
||||||
/* Define if the C++ compiler is configured for setjmp/longjmp exceptions. */
|
/* Define if the C++ compiler is configured for setjmp/longjmp exceptions. */
|
||||||
#undef LIBGO_SJLJ_EXCEPTIONS
|
#undef LIBGO_SJLJ_EXCEPTIONS
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14584,7 +14584,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
for ac_func in strerror_r strsignal wait4 mincore setenv _dl_get_tls_static_info
|
for ac_func in strerror_r strsignal wait4 mincore setenv dl_iterate_phdr
|
||||||
do :
|
do :
|
||||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||||
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
|
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
|
||||||
|
|
|
||||||
|
|
@ -481,7 +481,7 @@ fi
|
||||||
|
|
||||||
AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes)
|
AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes)
|
||||||
|
|
||||||
AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv _dl_get_tls_static_info)
|
AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv dl_iterate_phdr)
|
||||||
AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes)
|
AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes)
|
||||||
AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes)
|
AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,11 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_DL_ITERATE_PHDR
|
||||||
|
#include <link.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "runtime.h"
|
#include "runtime.h"
|
||||||
#include "arch.h"
|
#include "arch.h"
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
@ -36,12 +41,12 @@ extern void __splitstack_block_signals_context (void *context[10], int *,
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef PTHREAD_STACK_MIN
|
||||||
|
# define PTHREAD_STACK_MIN 8192
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(USING_SPLIT_STACK) && defined(LINKER_SUPPORTS_SPLIT_STACK)
|
#if defined(USING_SPLIT_STACK) && defined(LINKER_SUPPORTS_SPLIT_STACK)
|
||||||
# ifdef PTHREAD_STACK_MIN
|
# define StackMin PTHREAD_STACK_MIN
|
||||||
# define StackMin PTHREAD_STACK_MIN
|
|
||||||
# else
|
|
||||||
# define StackMin 8192
|
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
# define StackMin 2 * 1024 * 1024
|
# define StackMin 2 * 1024 * 1024
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -138,6 +143,46 @@ runtime_m(void)
|
||||||
|
|
||||||
int32 runtime_gcwaiting;
|
int32 runtime_gcwaiting;
|
||||||
|
|
||||||
|
// The static TLS size. See runtime_newm.
|
||||||
|
static int tlssize;
|
||||||
|
|
||||||
|
#ifdef HAVE_DL_ITERATE_PHDR
|
||||||
|
|
||||||
|
// Called via dl_iterate_phdr.
|
||||||
|
|
||||||
|
static int
|
||||||
|
addtls(struct dl_phdr_info* info, size_t size __attribute__ ((unused)), void *data)
|
||||||
|
{
|
||||||
|
size_t *total = (size_t *)data;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for(i = 0; i < info->dlpi_phnum; ++i) {
|
||||||
|
if(info->dlpi_phdr[i].p_type == PT_TLS)
|
||||||
|
*total += info->dlpi_phdr[i].p_memsz;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the total TLS size.
|
||||||
|
|
||||||
|
static void
|
||||||
|
inittlssize()
|
||||||
|
{
|
||||||
|
size_t total = 0;
|
||||||
|
|
||||||
|
dl_iterate_phdr(addtls, (void *)&total);
|
||||||
|
tlssize = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static void
|
||||||
|
inittlssize()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// Go scheduler
|
// Go scheduler
|
||||||
//
|
//
|
||||||
// The go scheduler's job is to match ready-to-run goroutines (`g's)
|
// The go scheduler's job is to match ready-to-run goroutines (`g's)
|
||||||
|
|
@ -393,6 +438,7 @@ runtime_schedinit(void)
|
||||||
g->m = m;
|
g->m = m;
|
||||||
|
|
||||||
initcontext();
|
initcontext();
|
||||||
|
inittlssize();
|
||||||
|
|
||||||
m->nomemprof++;
|
m->nomemprof++;
|
||||||
runtime_mallocinit();
|
runtime_mallocinit();
|
||||||
|
|
@ -1116,34 +1162,15 @@ runtime_newm(void)
|
||||||
if(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
|
if(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
|
||||||
runtime_throw("pthread_attr_setdetachstate");
|
runtime_throw("pthread_attr_setdetachstate");
|
||||||
|
|
||||||
#ifndef PTHREAD_STACK_MIN
|
|
||||||
#define PTHREAD_STACK_MIN 8192
|
|
||||||
#endif
|
|
||||||
|
|
||||||
stacksize = PTHREAD_STACK_MIN;
|
stacksize = PTHREAD_STACK_MIN;
|
||||||
|
|
||||||
#if 0
|
// With glibc before version 2.16 the static TLS size is taken
|
||||||
#ifdef HAVE__DL_GET_TLS_STATIC_INFO
|
// out of the stack size, and we get an error or a crash if
|
||||||
{
|
// there is not enough stack space left. Add it back in if we
|
||||||
/* On GNU/Linux the static TLS size is taken out of
|
// can, in case the program uses a lot of TLS space. FIXME:
|
||||||
the stack size, and we get an error or a crash if
|
// This can be disabled in glibc 2.16 and later, if the bug is
|
||||||
there is not enough stack space left. Add it back
|
// indeed fixed then.
|
||||||
in if we can, in case the program uses a lot of TLS
|
stacksize += tlssize;
|
||||||
space. */
|
|
||||||
#ifndef internal_function
|
|
||||||
#ifdef __i386__
|
|
||||||
#define internal_function __attribute__ ((regparm (3), stdcall))
|
|
||||||
#else
|
|
||||||
#define internal_function
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
extern void _dl_get_tls_static_info(size_t*, size_t*) internal_function;
|
|
||||||
size_t tlssize, tlsalign;
|
|
||||||
_dl_get_tls_static_info(&tlssize, &tlsalign);
|
|
||||||
stacksize += tlssize;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(pthread_attr_setstacksize(&attr, stacksize) != 0)
|
if(pthread_attr_setstacksize(&attr, stacksize) != 0)
|
||||||
runtime_throw("pthread_attr_setstacksize");
|
runtime_throw("pthread_attr_setstacksize");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue