qt-4.7.3-pthread_getattr_np_webkit.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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,18 @@
  4. #endif
  5. #include <unistd.h>
  6. +#if defined(__UCLIBC__)
  7. +// versions of uClibc 0.9.31 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__ <= 31))
  12. +#define UCLIBC_USE_PROC_SELF_MAPS 1
  13. +#include <stdio_ext.h>
  14. +extern int* __libc_stack_end;
  15. +#endif
  16. +#endif
  17. +
  18. #if OS(SOLARIS)
  19. #include <thread.h>
  20. #else
  21. @@ -580,6 +592,37 @@
  22. get_thread_info(find_thread(NULL), &threadInfo);
  23. return threadInfo.stack_end;
  24. #elif OS(UNIX)
  25. +#ifdef UCLIBC_USE_PROC_SELF_MAPS
  26. + // Read /proc/self/maps and locate the line whose address
  27. + // range contains __libc_stack_end.
  28. + FILE* file = fopen("/proc/self/maps", "r");
  29. + if (!file)
  30. + return 0;
  31. + __fsetlocking(file, FSETLOCKING_BYCALLER);
  32. + char* line = 0;
  33. + size_t lineLen = 0;
  34. + while (!feof_unlocked(file)) {
  35. + if (getdelim(&line, &lineLen, '\n', file) <= 0)
  36. + break;
  37. +
  38. + long from;
  39. + long to;
  40. + if (sscanf (line, "%lx-%lx", &from, &to) != 2)
  41. + continue;
  42. + if (from <= (long)__libc_stack_end && (long)__libc_stack_end < to) {
  43. + fclose(file);
  44. + free(line);
  45. +#ifdef _STACK_GROWS_UP
  46. + return (void *)from;
  47. +#else
  48. + return (void *)to;
  49. +#endif
  50. + }
  51. + }
  52. + fclose(file);
  53. + free(line);
  54. + return 0;
  55. +#else
  56. AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
  57. MutexLocker locker(mutex);
  58. static void* stackBase = 0;
  59. @@ -603,6 +646,7 @@
  60. stackThread = thread;
  61. }
  62. return static_cast<char*>(stackBase) + stackSize;
  63. +#endif
  64. #elif OS(WINCE)
  65. AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
  66. MutexLocker locker(mutex);