Merge pull request #1291 from abdollar/set_stack_size_linux
provide an option to set the default stack size on linux
This commit is contained in:
commit
36bd9dfe4a
@ -455,6 +455,7 @@ AC_CHECK_FUNCS([getcwd gettimeofday getwd memset munmap putenv realpath strcasec
|
|||||||
AC_CHECK_LIB(m,cbrt,[AC_DEFINE(HAVE_CBRT,1,[have cbrt() in libm.])])
|
AC_CHECK_LIB(m,cbrt,[AC_DEFINE(HAVE_CBRT,1,[have cbrt() in libm.])])
|
||||||
AC_CHECK_LIB(m,hypot,[AC_DEFINE(HAVE_HYPOT,1,[have hypot() in libm.])])
|
AC_CHECK_LIB(m,hypot,[AC_DEFINE(HAVE_HYPOT,1,[have hypot() in libm.])])
|
||||||
AC_CHECK_LIB(m,atan2,[AC_DEFINE(HAVE_ATAN2,1,[have atan2() in libm.])])
|
AC_CHECK_LIB(m,atan2,[AC_DEFINE(HAVE_ATAN2,1,[have atan2() in libm.])])
|
||||||
|
AC_CHECK_LIB([pthread], [pthread_setattr_default_np], [AC_DEFINE(HAVE_PTHREAD_DEFAULT_NP,1,[have pthread_setattr_default_np() in pthread.])])
|
||||||
|
|
||||||
# have to have these
|
# have to have these
|
||||||
# need glib 2.6 for GOption
|
# need glib 2.6 for GOption
|
||||||
|
@ -90,6 +90,10 @@
|
|||||||
#include <vips/vector.h>
|
#include <vips/vector.h>
|
||||||
#include <vips/vips7compat.h>
|
#include <vips/vips7compat.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_PTHREAD_DEFAULT_NP
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif /*HAVE_PTHREAD_DEFAULT_NP*/
|
||||||
|
|
||||||
/* abort() on the first warning or error.
|
/* abort() on the first warning or error.
|
||||||
*/
|
*/
|
||||||
int vips__fatal = 0;
|
int vips__fatal = 0;
|
||||||
@ -309,6 +313,32 @@ vips_init( const char *argv0 )
|
|||||||
(void) _setmaxstdio( 2048 );
|
(void) _setmaxstdio( 2048 );
|
||||||
#endif /*OS_WIN32*/
|
#endif /*OS_WIN32*/
|
||||||
|
|
||||||
|
#ifdef HAVE_PTHREAD_DEFAULT_NP
|
||||||
|
{
|
||||||
|
const char *pstacksize_str;
|
||||||
|
/* Set the default stack size especially if you use musl
|
||||||
|
*/
|
||||||
|
if( (pstacksize_str = g_getenv( "VIPS_MIN_STACK_SIZE" )) ) {
|
||||||
|
guint64 default_min_stack_size = 1 << 21; // 2MB
|
||||||
|
guint64 vips_min_stack_size;
|
||||||
|
guint64 cur_stack_size;
|
||||||
|
pthread_attr_t attr;
|
||||||
|
vips_min_stack_size = vips__parse_size(pstacksize_str);
|
||||||
|
if (vips_min_stack_size == 0) {
|
||||||
|
vips_min_stack_size = default_min_stack_size;
|
||||||
|
}
|
||||||
|
if (pthread_attr_init(&attr) ||
|
||||||
|
pthread_attr_getstacksize(&attr, &cur_stack_size) ||
|
||||||
|
(cur_stack_size > vips_min_stack_size) ||
|
||||||
|
pthread_attr_setstacksize(&attr, vips_min_stack_size) ||
|
||||||
|
pthread_setattr_default_np(&attr)) {
|
||||||
|
g_warning("Could not set minimum pthread stack size of %s, current size is %dk",
|
||||||
|
pstacksize_str, (int) (cur_stack_size / 1024.0) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /*HAVE_PTHREAD_DEFAULT_NP*/
|
||||||
|
|
||||||
#ifdef HAVE_TYPE_INIT
|
#ifdef HAVE_TYPE_INIT
|
||||||
/* Before glib 2.36 you have to call this on startup.
|
/* Before glib 2.36 you have to call this on startup.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user