From 02196e2efa8dae8e715576cea7e523c4ddcc3b68 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sat, 25 Apr 2015 17:29:23 -0600 Subject: [PATCH] Makefile/CMakeLists.txt: factor out stack size setting to here. --- CMakeLists.txt | 5 ++++- Makefile | 8 ++++++++ common/threads.c | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb3716a0..996a5dc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,7 +118,10 @@ endif (CMAKE_USE_PTHREADS_INIT) #FIXME: Should be only for qbsp add_definitions(-DDOUBLEVEC_T) +set(STACKSIZE 8388608) +add_definitions(-DQ_STACKSIZE=${STACKSIZE}) + #request 8MB stack if (WIN32) - set(CMAKE_EXE_LINKER_FLAGS -Wl,--stack,8388608) + set(CMAKE_EXE_LINKER_FLAGS -Wl,--stack,${STACKSIZE}) endif (WIN32) diff --git a/Makefile b/Makefile index 8d027616..9590601a 100644 --- a/Makefile +++ b/Makefile @@ -116,6 +116,14 @@ CFLAGS += $(call cc-option,-ffast-math,) endif endif +# give a generous 8MB stack +STACKSIZE := 8388608 +CFLAGS += -DQ_STACKSIZE=$(STACKSIZE) + +ifeq ($(TARGET_OS),WIN32) +LDFLAGS += -Wl,--stack,$(STACKSIZE) +endif + # ============================================================================ # Helper functions # ============================================================================ diff --git a/common/threads.c b/common/threads.c index 3286ebb2..00420d9c 100644 --- a/common/threads.c +++ b/common/threads.c @@ -233,7 +233,7 @@ RunThreadsOn(int start, int workcnt, void *(func)(void *), void *arg) status = pthread_attr_init(&attrib); if (status) Error("pthread_attr_init failed"); - status = pthread_attr_setstacksize(&attrib, 0x100000); + status = pthread_attr_setstacksize(&attrib, Q_STACKSIZE); if (status) Error("pthread_attr_setstacksize failed");