[packages] debootstrap: move package to the admin directory
[packages.git] / Xorg / lib / qt4 / patches / 100-fix-webkit-for-uclibc.patch
1 diff -ruN qt-everywhere-opensource-src-4.6.2.orig/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp qt-everywhere-opensource-src-4.6.2/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp
2 --- qt-everywhere-opensource-src-4.6.2.orig/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp    2010-02-11 16:55:20.000000000 +0100
3 +++ qt-everywhere-opensource-src-4.6.2/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp 2010-02-25 04:34:49.855131784 +0100
4 @@ -74,6 +74,18 @@
5  #endif
6  #include <unistd.h>
7  
8 +#if defined(__UCLIBC__)
9 +// versions of uClibc 0.9.28 and below do not have
10 +// pthread_getattr_np or pthread_attr_getstack.
11 +#if __UCLIBC_MAJOR__ == 0 && \
12 +    (__UCLIBC_MINOR__ < 9 || \
13 +    (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ <= 30))
14 +#define UCLIBC_USE_PROC_SELF_MAPS 1
15 +#include <stdio_ext.h>
16 +extern int *__libc_stack_end;
17 +#endif
18 +#endif
19 +
20  #if PLATFORM(SOLARIS)
21  #include <thread.h>
22  #else
23 @@ -630,24 +642,10 @@
24      return static_cast<void*>(pTib->StackBase);
25  #elif PLATFORM(QNX)
26      return currentThreadStackBaseQNX();
27 -#elif PLATFORM(HPUX)
28 -    return hpux_get_stack_base();
29  #elif PLATFORM(SOLARIS)
30      stack_t s;
31      thr_stksegment(&s);
32      return s.ss_sp;
33 -#elif PLATFORM(AIX)
34 -    pthread_t thread = pthread_self();
35 -    struct __pthrdsinfo threadinfo;
36 -    char regbuf[256];
37 -    int regbufsize = sizeof regbuf;
38 -
39 -    if (pthread_getthrds_np(&thread, PTHRDSINFO_QUERY_ALL,
40 -                            &threadinfo, sizeof threadinfo,
41 -                            &regbuf, &regbufsize) == 0)
42 -        return threadinfo.__pi_stackaddr;
43 -
44 -    return 0;
45  #elif PLATFORM(OPENBSD)
46      pthread_t thread = pthread_self();
47      stack_t stack;
48 @@ -667,16 +665,58 @@
49      get_thread_info(find_thread(NULL), &threadInfo);
50      return threadInfo.stack_end;
51  #elif PLATFORM(UNIX)
52 +#ifdef UCLIBC_USE_PROC_SELF_MAPS
53 +    // Read /proc/self/maps and locate the line whose address
54 +    // range contains __libc_stack_end.
55 +    FILE *file = fopen("/proc/self/maps", "r");
56 +    if (!file)
57 +        return 0;
58 +    __fsetlocking(file, FSETLOCKING_BYCALLER);
59 +    char *line = NULL;
60 +    size_t lineLen = 0;
61 +    while (!feof_unlocked(file)) {
62 +        if (getdelim(&line, &lineLen, '\n', file) <= 0)
63 +            break;
64 +
65 +        long from;
66 +        long to;
67 +        if (sscanf (line, "%lx-%lx", &from, &to) != 2)
68 +            continue;
69 +        if (from <= (long)__libc_stack_end && (long)__libc_stack_end < to) {
70 +            fclose(file);
71 +            free(line);
72 +#ifdef _STACK_GROWS_UP
73 +            return (void *)from;
74 +#else
75 +            return (void *)to;
76 +#endif
77 +        }
78 +    }
79 +    fclose(file);
80 +    free(line);
81 +    return 0;
82 +#else
83      static void* stackBase = 0;
84      static size_t stackSize = 0;
85      static pthread_t stackThread;
86      pthread_t thread = pthread_self();
87      if (stackBase == 0 || thread != stackThread) {
88 +#if defined(QT_LINUXBASE)
89 +        // LinuxBase is missing pthread_getattr_np - resolve it once at runtime instead
90 +        // see http://bugs.linuxbase.org/show_bug.cgi?id=2364
91 +        typedef int (*GetAttrPtr)(pthread_t, pthread_attr_t *);
92 +        static int (*pthread_getattr_np_ptr)(pthread_t, pthread_attr_t *) = 0;
93 +        if (!pthread_getattr_np_ptr)
94 +            *(void **)&pthread_getattr_np_ptr = dlsym(RTLD_DEFAULT, "pthread_getattr_np");
95 +#endif
96          pthread_attr_t sattr;
97          pthread_attr_init(&sattr);
98  #if HAVE(PTHREAD_NP_H) || PLATFORM(NETBSD)
99          // e.g. on FreeBSD 5.4, neundorf@kde.org
100          pthread_attr_get_np(thread, &sattr);
101 +#elif defined(QT_LINUXBASE)
102 +        if (pthread_getattr_np_ptr)
103 +            pthread_getattr_np_ptr(thread, &sattr);
104  #else
105          // FIXME: this function is non-portable; other POSIX systems may have different np alternatives
106          pthread_getattr_np(thread, &sattr);
107 @@ -688,6 +728,7 @@
108          stackThread = thread;
109      }
110      return static_cast<char*>(stackBase) + stackSize;
111 +#endif
112  #elif PLATFORM(WINCE)
113      if (g_stackBase)
114          return g_stackBase;