package/xfont_font-cronyx-cyrillic: add hash file
[buildroot-gz.git] / package / qt / 0004-pthread_getattr_np.patch
blob28f0c8411b1ea2cdbb7f6627861d217b4d4d3f32
1 Add pthred_getattr_np / phread_attr_getstrack alternatives for uClibc
3 Based on https://dev.openwrt.org/log/packages/Xorg/lib/qt4/patches/100-fix-webkit-for-uclibc.patch?rev=20371
5 Signed-off-by: Johan Sagaert <sagaert.johan@skynet.be>
6 ---
7 src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp | 61 ++++++++++
8 1 file changed, 61 insertions(+)
10 Index: qt-everywhere-opensource-src-4.8.1/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp
11 ===================================================================
12 --- qt-everywhere-opensource-src-4.8.1.orig/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp
13 +++ qt-everywhere-opensource-src-4.8.1/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp
14 @@ -70,6 +70,23 @@
15 #endif
16 #include <unistd.h>
18 +#if defined(QT_LINUXBASE)
19 +#include <dlfcn.h>
20 +#endif
22 +#if defined(__UCLIBC__)
23 +// versions of uClibc 0.9.32 and below with linuxthreads.old do not have
24 +// pthread_getattr_np or pthread_attr_getstack.
25 +#if __UCLIBC_MAJOR__ == 0 && \
26 + (__UCLIBC_MINOR__ < 9 || \
27 + (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ <= 32)) && \
28 + defined(__LINUXTHREADS_OLD__)
29 +#define UCLIBC_USE_PROC_SELF_MAPS 1
30 +#include <stdio_ext.h>
31 +extern int *__libc_stack_end;
32 +#endif
33 +#endif
35 #if OS(SOLARIS)
36 #include <thread.h>
37 #else
38 @@ -648,6 +665,37 @@
39 get_thread_info(find_thread(NULL), &threadInfo);
40 return threadInfo.stack_end;
41 #elif OS(UNIX)
42 +#ifdef UCLIBC_USE_PROC_SELF_MAPS
43 + // Read /proc/self/maps and locate the line whose address
44 + // range contains __libc_stack_end.
45 + FILE *file = fopen("/proc/self/maps", "r");
46 + if (!file)
47 + return 0;
48 + __fsetlocking(file, FSETLOCKING_BYCALLER);
49 + char *line = NULL;
50 + size_t lineLen = 0;
51 + while (!feof_unlocked(file)) {
52 + if (getdelim(&line, &lineLen, '\n', file) <= 0)
53 + break;
55 + long from;
56 + long to;
57 + if (sscanf (line, "%lx-%lx", &from, &to) != 2)
58 + continue;
59 + if (from <= (long)__libc_stack_end && (long)__libc_stack_end < to) {
60 + fclose(file);
61 + free(line);
62 +#ifdef _STACK_GROWS_UP
63 + return (void *)from;
64 +#else
65 + return (void *)to;
66 +#endif
67 + }
68 + }
69 + fclose(file);
70 + free(line);
71 + return 0;
72 +#else
73 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
74 MutexLocker locker(mutex);
75 static void* stackBase = 0;
76 @@ -655,11 +703,23 @@
77 static pthread_t stackThread;
78 pthread_t thread = pthread_self();
79 if (stackBase == 0 || thread != stackThread) {
81 +#if defined(QT_LINUXBASE)
82 + // LinuxBase is missing pthread_getattr_np - resolve it once at runtime instead
83 + // see http://bugs.linuxbase.org/show_bug.cgi?id=2364
84 + typedef int (*GetAttrPtr)(pthread_t, pthread_attr_t *);
85 + static int (*pthread_getattr_np_ptr)(pthread_t, pthread_attr_t *) = 0;
86 + if (!pthread_getattr_np_ptr)
87 + *(void **)&pthread_getattr_np_ptr = dlsym(RTLD_DEFAULT, "pthread_getattr_np");
88 +#endif
89 pthread_attr_t sattr;
90 pthread_attr_init(&sattr);
91 #if HAVE(PTHREAD_NP_H) || OS(NETBSD)
92 // e.g. on FreeBSD 5.4, neundorf@kde.org
93 pthread_attr_get_np(thread, &sattr);
94 +#elif defined(QT_LINUXBASE)
95 + if (pthread_getattr_np_ptr)
96 + pthread_getattr_np_ptr(thread, &sattr);
97 #else
98 // FIXME: this function is non-portable; other POSIX systems may have different np alternatives
99 pthread_getattr_np(thread, &sattr);
100 @@ -671,6 +731,7 @@
101 stackThread = thread;
103 return static_cast<char*>(stackBase) + stackSize;
104 +#endif
105 #else
106 #error Need a way to get the stack base on this platform
107 #endif