8 #include <sys/resource.h>
10 static void use_stack (size_t needed);
12 void (*use_stack_ptr) (size_t) = use_stack;
15 use_stack (size_t needed)
17 size_t sz = sysconf (_SC_PAGESIZE);
18 char *buf = alloca (sz);
19 memset (buf, '\0', sz);
22 use_stack_ptr (needed - sz);
29 getrlimit (RLIMIT_AS, &rl);
30 rl.rlim_cur = 10 * 1024 * 1024;
31 setrlimit (RLIMIT_AS, &rl);
34 int PAGESIZE = getpagesize ();
37 c = mmap (NULL, PAGESIZE, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
56 /* Allocate the memory needed for the stack. */
57 use_stack_ptr (PTHREAD_STACK_MIN);
61 err = pthread_create (&tid, NULL, child, NULL);
64 printf ("pthread_create returns %d: %s\n", err,
65 err == EAGAIN ? "OK" : "FAIL");
69 /* We did not fail to allocate memory despite the preparation. Oh well. */
73 #define TEST_FUNCTION do_test ()
74 #include "../test-skeleton.c"