qt-4.7.4-pthread_getattr_np_webkit.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. --- a/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp 2010-09-10 11:05:22.000000000 +0200
  2. +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp 2010-11-15 16:39:53.000000000 +0100
  3. @@ -70,6 +70,19 @@
  4. #endif
  5. #include <unistd.h>
  6. +#if defined(__UCLIBC__)
  7. +// versions of uClibc 0.9.32 with linuxthreads.old and below do not have
  8. +// pthread_getattr_np or pthread_attr_getstack.
  9. +#if __UCLIBC_MAJOR__ == 0 && \
  10. + (__UCLIBC_MINOR__ < 9 || \
  11. + (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ <= 32)) && \
  12. + defined(__LINUXTHREADS_OLD__)
  13. +#define UCLIBC_USE_PROC_SELF_MAPS 1
  14. +#include <stdio_ext.h>
  15. +extern int* __libc_stack_end;
  16. +#endif
  17. +#endif
  18. +
  19. #if OS(SOLARIS)
  20. #include <thread.h>
  21. #else
  22. @@ -580,6 +592,37 @@
  23. get_thread_info(find_thread(NULL), &threadInfo);
  24. return threadInfo.stack_end;
  25. #elif OS(UNIX)
  26. +#ifdef UCLIBC_USE_PROC_SELF_MAPS
  27. + // Read /proc/self/maps and locate the line whose address
  28. + // range contains __libc_stack_end.
  29. + FILE* file = fopen("/proc/self/maps", "r");
  30. + if (!file)
  31. + return 0;
  32. + __fsetlocking(file, FSETLOCKING_BYCALLER);
  33. + char* line = 0;
  34. + size_t lineLen = 0;
  35. + while (!feof_unlocked(file)) {
  36. + if (getdelim(&line, &lineLen, '\n', file) <= 0)
  37. + break;
  38. +
  39. + long from;
  40. + long to;
  41. + if (sscanf (line, "%lx-%lx", &from, &to) != 2)
  42. + continue;
  43. + if (from <= (long)__libc_stack_end && (long)__libc_stack_end < to) {
  44. + fclose(file);
  45. + free(line);
  46. +#ifdef _STACK_GROWS_UP
  47. + return (void *)from;
  48. +#else
  49. + return (void *)to;
  50. +#endif
  51. + }
  52. + }
  53. + fclose(file);
  54. + free(line);
  55. + return 0;
  56. +#else
  57. AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
  58. MutexLocker locker(mutex);
  59. static void* stackBase = 0;
  60. @@ -603,6 +646,7 @@
  61. stackThread = thread;
  62. }
  63. return static_cast<char*>(stackBase) + stackSize;
  64. +#endif
  65. #elif OS(WINCE)
  66. AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
  67. MutexLocker locker(mutex);