From b30657647a7f816a2945302b3569b882d7ac6b72 Mon Sep 17 00:00:00 2001 From: Petr Nejedly Date: Thu, 27 Jun 2013 12:51:22 -0700 Subject: [PATCH] QNX-specific implementation of the stack base retrieval. The garbage collector needs the top of the stack. On QNX, every thread has the TLS structure at the top of the stack, then the stack extends below this TLS structure This is the easiest and fastest way resolve the stack base of the current thread. Change-Id: I9cc9592928298d06aeaee0f6110d61bf3cf68e49 Reviewed-by: Simon Hausmann --- src/qml/qml/v4/qv4mm.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/qml/qml/v4/qv4mm.cpp b/src/qml/qml/v4/qv4mm.cpp index 34f4728..0e53a20 100644 --- a/src/qml/qml/v4/qv4mm.cpp +++ b/src/qml/qml/v4/qv4mm.cpp @@ -62,6 +62,10 @@ #include #endif +#if OS(QNX) +#include // __tls() +#endif + QT_BEGIN_NAMESPACE using namespace QV4; @@ -142,7 +146,12 @@ MemoryManager::MemoryManager() VALGRIND_CREATE_MEMPOOL(this, 0, true); #endif -#if USE(PTHREADS) +#if OS(QNX) + // TLS is at the top of each thread's stack, + // so the stack base for thread is the result of __tls() + m_d->stackTop = reinterpret_cast( + (((uintptr_t)__tls() + __PAGESIZE - 1) & ~(__PAGESIZE - 1))); +#elif USE(PTHREADS) # if OS(DARWIN) void *st = pthread_get_stackaddr_np(pthread_self()); m_d->stackTop = static_cast(st); -- 2.7.4