source: packages/Xorg/lib/qt4/patches/100-fix-webkit-for-uclibc.patch @ 20371

Last change on this file since 20371 was 20371, checked in by mirko, 7 years ago

add support for qt4

File size: 4.0 KB
  • src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp

    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
    old new  
    7474#endif 
    7575#include <unistd.h> 
    7676 
     77#if defined(__UCLIBC__) 
     78// versions of uClibc 0.9.28 and below do not have 
     79// pthread_getattr_np or pthread_attr_getstack. 
     80#if __UCLIBC_MAJOR__ == 0 && \ 
     81    (__UCLIBC_MINOR__ < 9 || \ 
     82    (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ <= 30)) 
     83#define UCLIBC_USE_PROC_SELF_MAPS 1 
     84#include <stdio_ext.h> 
     85extern int *__libc_stack_end; 
     86#endif 
     87#endif 
     88 
    7789#if PLATFORM(SOLARIS) 
    7890#include <thread.h> 
    7991#else 
     
    630642    return static_cast<void*>(pTib->StackBase); 
    631643#elif PLATFORM(QNX) 
    632644    return currentThreadStackBaseQNX(); 
    633 #elif PLATFORM(HPUX) 
    634     return hpux_get_stack_base(); 
    635645#elif PLATFORM(SOLARIS) 
    636646    stack_t s; 
    637647    thr_stksegment(&s); 
    638648    return s.ss_sp; 
    639 #elif PLATFORM(AIX) 
    640     pthread_t thread = pthread_self(); 
    641     struct __pthrdsinfo threadinfo; 
    642     char regbuf[256]; 
    643     int regbufsize = sizeof regbuf; 
    644  
    645     if (pthread_getthrds_np(&thread, PTHRDSINFO_QUERY_ALL, 
    646                             &threadinfo, sizeof threadinfo, 
    647                             &regbuf, &regbufsize) == 0) 
    648         return threadinfo.__pi_stackaddr; 
    649  
    650     return 0; 
    651649#elif PLATFORM(OPENBSD) 
    652650    pthread_t thread = pthread_self(); 
    653651    stack_t stack; 
     
    667665    get_thread_info(find_thread(NULL), &threadInfo); 
    668666    return threadInfo.stack_end; 
    669667#elif PLATFORM(UNIX) 
     668#ifdef UCLIBC_USE_PROC_SELF_MAPS 
     669    // Read /proc/self/maps and locate the line whose address 
     670    // range contains __libc_stack_end. 
     671    FILE *file = fopen("/proc/self/maps", "r"); 
     672    if (!file) 
     673        return 0; 
     674    __fsetlocking(file, FSETLOCKING_BYCALLER); 
     675    char *line = NULL; 
     676    size_t lineLen = 0; 
     677    while (!feof_unlocked(file)) { 
     678        if (getdelim(&line, &lineLen, '\n', file) <= 0) 
     679            break; 
     680 
     681        long from; 
     682        long to; 
     683        if (sscanf (line, "%lx-%lx", &from, &to) != 2) 
     684            continue; 
     685        if (from <= (long)__libc_stack_end && (long)__libc_stack_end < to) { 
     686            fclose(file); 
     687            free(line); 
     688#ifdef _STACK_GROWS_UP 
     689            return (void *)from; 
     690#else 
     691            return (void *)to; 
     692#endif 
     693        } 
     694    } 
     695    fclose(file); 
     696    free(line); 
     697    return 0; 
     698#else 
    670699    static void* stackBase = 0; 
    671700    static size_t stackSize = 0; 
    672701    static pthread_t stackThread; 
    673702    pthread_t thread = pthread_self(); 
    674703    if (stackBase == 0 || thread != stackThread) { 
     704#if defined(QT_LINUXBASE) 
     705        // LinuxBase is missing pthread_getattr_np - resolve it once at runtime instead 
     706        // see http://bugs.linuxbase.org/show_bug.cgi?id=2364 
     707        typedef int (*GetAttrPtr)(pthread_t, pthread_attr_t *); 
     708        static int (*pthread_getattr_np_ptr)(pthread_t, pthread_attr_t *) = 0; 
     709        if (!pthread_getattr_np_ptr) 
     710            *(void **)&pthread_getattr_np_ptr = dlsym(RTLD_DEFAULT, "pthread_getattr_np"); 
     711#endif 
    675712        pthread_attr_t sattr; 
    676713        pthread_attr_init(&sattr); 
    677714#if HAVE(PTHREAD_NP_H) || PLATFORM(NETBSD) 
    678715        // e.g. on FreeBSD 5.4, neundorf@kde.org 
    679716        pthread_attr_get_np(thread, &sattr); 
     717#elif defined(QT_LINUXBASE) 
     718        if (pthread_getattr_np_ptr) 
     719            pthread_getattr_np_ptr(thread, &sattr); 
    680720#else 
    681721        // FIXME: this function is non-portable; other POSIX systems may have different np alternatives 
    682722        pthread_getattr_np(thread, &sattr); 
     
    688728        stackThread = thread; 
    689729    } 
    690730    return static_cast<char*>(stackBase) + stackSize; 
     731#endif 
    691732#elif PLATFORM(WINCE) 
    692733    if (g_stackBase) 
    693734        return g_stackBase; 
Note: See TracBrowser for help on using the repository browser.