$NetBSD: patch-src_3rdparty_webkit_Source_JavaScriptCore_heap_MachineStackMarker.cpp,v 1.2 2012/04/09 09:12:49 adam Exp $ --- src/3rdparty/webkit/Source/JavaScriptCore/heap/MachineStackMarker.cpp.orig 2012-03-14 14:01:26.000000000 +0000 +++ src/3rdparty/webkit/Source/JavaScriptCore/heap/MachineStackMarker.cpp @@ -20,6 +20,9 @@ */ #include "config.h" +#if OS(SOLARIS) +#undef _FILE_OFFSET_BITS +#endif #include "MachineStackMarker.h" #include "ConservativeRoots.h" @@ -64,6 +67,10 @@ #include #if OS(SOLARIS) +#include +#include +#include +#include #include #else #include @@ -341,6 +348,7 @@ typedef pthread_attr_t PlatformThreadReg #error Need a thread register struct for this platform #endif +#if !OS(SOLARIS) static size_t getPlatformThreadRegisters(const PlatformThread& platformThread, PlatformThreadRegisters& regs) { #if OS(DARWIN) @@ -391,6 +399,7 @@ static size_t getPlatformThreadRegisters #error Need a way to get thread registers on this platform #endif } +#endif static inline void* otherThreadStackPointer(const PlatformThreadRegisters& regs) { @@ -441,6 +450,7 @@ static inline void* otherThreadStackPoin #endif } +#if !OS(SOLARIS) static void freePlatformThreadRegisters(PlatformThreadRegisters& regs) { #if USE(PTHREADS) && !OS(WINDOWS) && !OS(DARWIN) @@ -449,24 +459,40 @@ static void freePlatformThreadRegisters( UNUSED_PARAM(regs); #endif } +#endif void MachineThreads::gatherFromOtherThread(ConservativeRoots& conservativeRoots, Thread* thread) { suspendThread(thread->platformThread); +#if OS(SOLARIS) + struct lwpstatus lwp; + char procfile[64]; + int fd; + snprintf(procfile, 64, "/proc/self/lwp/%u/lwpstatus", thread->platformThread); + fd = open(procfile, O_RDONLY, 0); + if (fd == -1) { + fprintf(stderr, "%s: %s\n", procfile, strerror(errno)); + abort(); + } + pread(fd, &lwp, sizeof(lwp), 0); + close(fd); + void* stackPointer = (void*)lwp.pr_reg[REG_SP]; +#else PlatformThreadRegisters regs; size_t regSize = getPlatformThreadRegisters(thread->platformThread, regs); conservativeRoots.add(static_cast(®s), static_cast(reinterpret_cast(®s) + regSize)); void* stackPointer = otherThreadStackPointer(regs); + + freePlatformThreadRegisters(regs); +#endif void* stackBase = thread->stackBase; swapIfBackwards(stackPointer, stackBase); conservativeRoots.add(stackPointer, stackBase); resumeThread(thread->platformThread); - - freePlatformThreadRegisters(regs); } #endif