]>
git.saurik.com Git - apple/libpthread.git/blob - tests/main_stack.c
3 #include "darwintest_defaults.h"
4 #include <machine/vmparam.h>
6 T_DECL(main_stack
, "tests the reported values for the main thread stack",
7 T_META_CHECK_LEAKS(NO
), T_META_ALL_VALID_ARCHS(YES
)){
8 const uintptr_t stackaddr
= (uintptr_t)pthread_get_stackaddr_np(pthread_self());
9 const size_t stacksize
= pthread_get_stacksize_np(pthread_self());
10 T_LOG("stack: %zx -> %zx (+%zx)", stackaddr
- stacksize
, stackaddr
, stacksize
);
11 T_EXPECT_LT((uintptr_t)__builtin_frame_address(0), stackaddr
, NULL
);
12 T_EXPECT_GT((uintptr_t)__builtin_frame_address(0), stackaddr
- stacksize
, NULL
);
15 T_ASSERT_POSIX_SUCCESS(getrlimit(RLIMIT_STACK
, &lim
), NULL
);
16 T_EXPECT_EQ((size_t)lim
.rlim_cur
, pthread_get_stacksize_np(pthread_self()), "reported rlimit should match stacksize");
18 lim
.rlim_cur
= lim
.rlim_cur
/ 8;
19 T_ASSERT_POSIX_SUCCESS(setrlimit(RLIMIT_STACK
, &lim
), NULL
);
22 T_EXPECT_EQ((size_t)lim
.rlim_cur
, pthread_get_stacksize_np(pthread_self()), "new rlimit should should match stacksize");