Nekochan Net

Official Chat Channel: #nekochan //
It is currently Mon Nov 24, 2014 1:00 am

All times are UTC - 8 hours [ DST ]

Forum rules

Any posts concerning pirated software or offering to buy/sell/trade commercial software are subject to removal.

Post new topic Reply to topic  [ 2 posts ] 
Author Message
Unread postPosted: Sat Mar 31, 2012 9:14 pm 

Joined: Thu Sep 28, 2006 6:50 pm
Posts: 139
Location: Long Beach, CA
It seems like a recurring problem for anyone trying to compile a modern web browser/JS engine (whether it's KJS/WebKit or Firefox) on IRIX is the lack of a function to get the stack base for the current thread. Well, here you go:

#define STK_BASE_OFFSET 0x74    // N32
#elif (_MIPS_SIM == _MIPS_SIM_ABI64)
#define STK_BASE_OFFSET 0xB8    // 64
#error N32 and 64 only

void* IRIX_currentThreadStackBase()
        void **pstk = (void **)((char *)(PRDALIB->pthread_data[1]) + STK_BASE_OFFSET);
        return *pstk;

File comment: currentThreadStackBase() implemented for IRIX
irix_currentThreadStackBase.c [430 Bytes]
Downloaded 21 times

I figured this out when trying to compile WebKit a few years ago--KJS implements a function called currentThreadStackBase() (in kjs/Collector.cpp) which returns the base address for the current thread's stack (with #ifdefs for a bunch of different OSes, and none of the paths worked on IRIX).

For example (and as search keywords), here's how it's done in other OSes (from qt 4.4.3's WebKit):
Darwin uses:
    return pthread_get_stackaddr_np(pthread_self())

    stack_t s;
    return s.ss_sp;

    static void *stackBase = 0;
    static size_t stackSize = 0;
    static pthread_t stackThread;
    pthread_t thread = pthread_self();
    if (stackBase == 0 || thread != stackThread) {
        pthread_attr_t sattr;
        // e.g. on FreeBSD 5.4,
        pthread_attr_get_np(thread, &sattr);
        // FIXME: this function is non-portable; other POSIX systems may have different np alternatives
        pthread_getattr_np(thread, &sattr);
        int rc = pthread_attr_getstack(&sattr, &stackBase, &stackSize);
        (void)rc; // FIXME: deal with error code somehow?  seems fatal...
        stackThread = thread;
    return (void*)(size_t(stackBase) + stackSize);

I never looked into getting the stack size (since WebKit didn't need it), but if something else (Firefox?) does, we can try to figure that out also.

:Octane: R12K/300x2, MXE
:1600SW: :ChallengeL:

Unread postPosted: Sun Jul 22, 2012 11:30 am 

Joined: Tue Aug 03, 2010 9:08 am
Posts: 48
Thanks for posting this! This is no doubt going to save me a chunk of time.

:1600SW: :O2: :O2+: :O2: :1600SW:

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours [ DST ]

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group