]> git.saurik.com Git - apple/libpthread.git/blame - tests/main_stack_legacy.c
libpthread-301.20.1.tar.gz
[apple/libpthread.git] / tests / main_stack_legacy.c
CommitLineData
2546420a
A
1#include <stdlib.h>
2#include <pthread.h>
a0619f9c 3#include "darwintest_defaults.h"
2546420a
A
4#include <machine/vmparam.h>
5
6T_DECL(main_stack_legacy, "tests the reported values for a custom main thread stack",
7 T_META_CHECK_LEAKS(NO))
8{
9 T_EXPECT_LT((uintptr_t)0, pthread_get_stacksize_np(pthread_self()), NULL);
10
11 const uintptr_t stackaddr = (uintptr_t)pthread_get_stackaddr_np(pthread_self());
12 size_t stacksize = pthread_get_stacksize_np(pthread_self());
13 T_LOG("stack: %zx -> %zx (+%zx)", stackaddr - stacksize, stackaddr, stacksize);
14 T_EXPECT_LT((uintptr_t)__builtin_frame_address(0), stackaddr, NULL);
15 T_EXPECT_GT((uintptr_t)__builtin_frame_address(0), stackaddr - stacksize, NULL);
16}