Make stack size a multiple of the page size

Should fix #27
parent 382bb91d
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <signal.h> #include <signal.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include "fellow_testenv.h" #include "fellow_testenv.h"
...@@ -54,8 +55,16 @@ static pthread_attr_t attr; ...@@ -54,8 +55,16 @@ static pthread_attr_t attr;
static void __attribute__((constructor)) static void __attribute__((constructor))
attr_init(void) attr_init(void)
{ {
size_t pg, sz;
pg = (size_t)sysconf(_SC_PAGESIZE);
pg--;
sz = (size_t)64 * 1024;
sz += pg;
sz &= ~pg;
AZ(pthread_attr_init(&attr)); AZ(pthread_attr_init(&attr));
AZ(pthread_attr_setstacksize(&attr, (size_t)64 * 1024)); AZ(pthread_attr_setstacksize(&attr, sz));
AZ(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)); AZ(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment