diff --git a/src/aclocal.m4 b/src/aclocal.m4 index 6adc5c63d..cf011efd0 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -665,6 +665,21 @@ case "${ECL_STACK_DIR}" in up|UP) AC_MSG_RESULT(no) ;; *) AC_MSG_ERROR(Unable to determine stack growth direction) esac]) + +dnl +dnl -------------------------------------------------------------- +dnl Check if we can determine the stack size at runtime +dnl +AC_DEFUN(ECL_STACK_SIZE,[ +AC_CHECK_HEADER([sys/resource.h], + [AC_DEFINE([HAVE_SYS_RESOURCE_H], [], [Define to 1 if you have the header file.]) + AC_CHECK_DECL([RLIMIT_STACK], + [AC_DEFINE([ECL_CAN_SET_STACK_SIZE], [], [Define to 1 if we can set the stack size at runtime.])], + [], + [#include ])], + [],[]) +]) + dnl dnl ------------------------------------------------------------ dnl Find out a setjmp() that does not save signals. It is called diff --git a/src/c/stacks.d b/src/c/stacks.d index d985766ba..217dfb4bd 100644 --- a/src/c/stacks.d +++ b/src/c/stacks.d @@ -29,7 +29,7 @@ cs_set_size(cl_env_ptr env, cl_index new_size) { volatile char foo = 0; cl_index margin = ecl_option_values[ECL_OPT_C_STACK_SAFETY_AREA]; -#if defined(HAVE_SYS_RESOURCE_H) && defined(RLIMIT_STACK) && !defined(NACL) +#if defined(ECL_CAN_SET_STACK_SIZE) { struct rlimit rl; diff --git a/src/configure b/src/configure index 103f4102b..b2e760888 100755 --- a/src/configure +++ b/src/configure @@ -7125,7 +7125,7 @@ fi done -for ac_header in sys/resource.h sys/utsname.h float.h pwd.h dlfcn.h link.h \ +for ac_header in sys/utsname.h float.h pwd.h dlfcn.h link.h \ mach-o/dyld.h dirent.h sys/ioctl.h sys/select.h \ sys/wait.h semaphore.h do : @@ -8345,6 +8345,24 @@ $as_echo "no" >&6; } ;; *) as_fn_error $? "Unable to determine stack growth direction" "$LINENO" 5 esac +ac_fn_c_check_header_mongrel "$LINENO" "sys/resource.h" "ac_cv_header_sys_resource_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_resource_h" = xyes; then : + +$as_echo "#define HAVE_SYS_RESOURCE_H /**/" >>confdefs.h + + ac_fn_c_check_decl "$LINENO" "RLIMIT_STACK" "ac_cv_have_decl_RLIMIT_STACK" "#include +" +if test "x$ac_cv_have_decl_RLIMIT_STACK" = xyes; then : + +$as_echo "#define ECL_CAN_SET_STACK_SIZE /**/" >>confdefs.h + +fi + +fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether closedir returns void" >&5 $as_echo_n "checking whether closedir returns void... " >&6; } @@ -8997,8 +9015,6 @@ main () if (*(data + i) != *(data3 + i)) return 14; close (fd); - free (data); - free (data3); return 0; } _ACEOF diff --git a/src/configure.ac b/src/configure.ac index 4e615408e..8103d88bc 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -658,7 +658,7 @@ AC_CHECK_HEADERS( [fcntl.h limits.h netdb.h netinet/in.h] \ [sched.h] ) dnl !!! end autoscan -AC_CHECK_HEADERS( [sys/resource.h sys/utsname.h float.h pwd.h dlfcn.h link.h] \ +AC_CHECK_HEADERS( [sys/utsname.h float.h pwd.h dlfcn.h link.h] \ [mach-o/dyld.h dirent.h sys/ioctl.h sys/select.h] \ [sys/wait.h semaphore.h] ) @@ -711,8 +711,9 @@ ECL_SSE ECL_COMPLEX_C99 dnl ----------------------------------------------------------------------- -dnl Study the call conventions +dnl Stack size and growth direction ECL_STACK_DIRECTION +ECL_STACK_SIZE dnl ===================================================================== dnl Checks for library functions diff --git a/src/ecl/configpre.h b/src/ecl/configpre.h index 98f96bd65..aeda058e0 100644 --- a/src/ecl/configpre.h +++ b/src/ecl/configpre.h @@ -9,6 +9,9 @@ /* ECL_AVOID_FPE_H */ #undef ECL_AVOID_FPE_H +/* Define to 1 if we can set the stack size at runtime. */ +#undef ECL_CAN_SET_STACK_SIZE + /* Allow STREAM operations to work on arbitrary objects */ #undef ECL_CLOS_STREAMS diff --git a/src/h/config-internal.h.in b/src/h/config-internal.h.in index dd7a4f8ad..6b4438ad5 100644 --- a/src/h/config-internal.h.in +++ b/src/h/config-internal.h.in @@ -240,7 +240,10 @@ #include "@ECL_LIBFFI_HEADER@" #endif -#if defined(HAVE_SYS_RESOURCE_H) && defined(RLIMIT_STACK) && !defined(NACL) +/* Can we determine and set the stack size at runtime? */ +#undef ECL_CAN_SET_STACK_SIZE + +#if defined(ECL_CAN_SET_STACK_SIZE) #define ECL_DEFAULT_C_STACK_SIZE 0 /* Use the stack size provided by the OS */ #else #define ECL_DEFAULT_C_STACK_SIZE @ECL_DEFAULT_C_STACK_SIZE@