python/cryptography: native 64-bit build
[unleashed-userland.git] / components / qt4 / patches / MachineStackMarker_cpp.patch
blob84c66e7f77aef331c807782bb687dbbddc8c2722
1 $NetBSD: patch-src_3rdparty_webkit_Source_JavaScriptCore_heap_MachineStackMarker.cpp,v 1.2 2012/04/09 09:12:49 adam Exp $
3 --- a/src/3rdparty/webkit/Source/JavaScriptCore/heap/MachineStackMarker.cpp.orig 2012-03-14 14:01:26.000000000 +0000
4 +++ b/src/3rdparty/webkit/Source/JavaScriptCore/heap/MachineStackMarker.cpp
5 @@ -20,6 +20,9 @@
6 */
8 #include "config.h"
9 +#if OS(SOLARIS)
10 +#undef _FILE_OFFSET_BITS
11 +#endif
12 #include "MachineStackMarker.h"
14 #include "ConservativeRoots.h"
15 @@ -64,6 +67,10 @@
16 #include <unistd.h>
18 #if OS(SOLARIS)
19 +#include <sys/types.h>
20 +#include <sys/stat.h>
21 +#include <fcntl.h>
22 +#include <procfs.h>
23 #include <thread.h>
24 #else
25 #include <pthread.h>
26 @@ -341,6 +348,7 @@ typedef pthread_attr_t PlatformThreadReg
27 #error Need a thread register struct for this platform
28 #endif
30 +#if !OS(SOLARIS)
31 static size_t getPlatformThreadRegisters(const PlatformThread& platformThread, PlatformThreadRegisters& regs)
33 #if OS(DARWIN)
34 @@ -391,6 +399,7 @@ static size_t getPlatformThreadRegisters
35 #error Need a way to get thread registers on this platform
36 #endif
38 +#endif
40 static inline void* otherThreadStackPointer(const PlatformThreadRegisters& regs)
42 @@ -441,6 +450,7 @@ static inline void* otherThreadStackPoin
43 #endif
46 +#if !OS(SOLARIS)
47 static void freePlatformThreadRegisters(PlatformThreadRegisters& regs)
49 #if USE(PTHREADS) && !OS(WINDOWS) && !OS(DARWIN)
50 @@ -449,24 +459,40 @@ static void freePlatformThreadRegisters(
51 UNUSED_PARAM(regs);
52 #endif
54 +#endif
56 void MachineThreads::gatherFromOtherThread(ConservativeRoots& conservativeRoots, Thread* thread)
58 suspendThread(thread->platformThread);
60 +#if OS(SOLARIS)
61 + struct lwpstatus lwp;
62 + char procfile[64];
63 + int fd;
64 + snprintf(procfile, 64, "/proc/self/lwp/%u/lwpstatus", thread->platformThread);
65 + fd = open(procfile, O_RDONLY, 0);
66 + if (fd == -1) {
67 + fprintf(stderr, "%s: %s\n", procfile, strerror(errno));
68 + abort();
69 + }
70 + pread(fd, &lwp, sizeof(lwp), 0);
71 + close(fd);
72 + void* stackPointer = (void*)lwp.pr_reg[REG_SP];
73 +#else
74 PlatformThreadRegisters regs;
75 size_t regSize = getPlatformThreadRegisters(thread->platformThread, regs);
77 conservativeRoots.add(static_cast<void*>(&regs), static_cast<void*>(reinterpret_cast<char*>(&regs) + regSize));
79 void* stackPointer = otherThreadStackPointer(regs);
81 + freePlatformThreadRegisters(regs);
82 +#endif
83 void* stackBase = thread->stackBase;
84 swapIfBackwards(stackPointer, stackBase);
85 conservativeRoots.add(stackPointer, stackBase);
87 resumeThread(thread->platformThread);
89 - freePlatformThreadRegisters(regs);
92 #endif