webkit-pthread_getattr_np.patch 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. Patch WebKit because pthread_getattr_np is not implemented in uClibc
  2. Define UCLIBC_USE_PROC_SELF_MAPS etc. as a workaround for uClibc. This
  3. code was in the qtoipa webkit but appears to have been removed from
  4. more recent versions of webkit.
  5. See: http://bugreports.qt.nokia.com/browse/QTBUG-6551
  6. Credit for fix: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=545066#545066
  7. Signed-off-by: Paul Jones <paul@pauljones.id.au>
  8. Index: webkit-1.2.3/JavaScriptCore/runtime/Collector.cpp
  9. ===================================================================
  10. --- webkit-1.2.3.orig/JavaScriptCore/runtime/Collector.cpp 2010-07-22 17:16:19.000000000 +0200
  11. +++ webkit-1.2.3/JavaScriptCore/runtime/Collector.cpp 2010-07-22 17:25:02.000000000 +0200
  12. @@ -75,6 +75,18 @@
  13. #endif
  14. #include <unistd.h>
  15. +#if defined(__UCLIBC__)
  16. +// versions of uClibc 0.9.31 and below do not have
  17. +// pthread_getattr_np or pthread_attr_getstack.
  18. +#if __UCLIBC_MAJOR__ == 0 && \
  19. + (__UCLIBC_MINOR__ < 9 || \
  20. + (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ <= 31))
  21. +#define UCLIBC_USE_PROC_SELF_MAPS 1
  22. +#include <stdio_ext.h>
  23. +extern int *__libc_stack_end;
  24. +#endif
  25. +#endif
  26. +
  27. #if OS(SOLARIS)
  28. #include <thread.h>
  29. #else
  30. @@ -610,6 +622,36 @@
  31. get_thread_info(find_thread(NULL), &threadInfo);
  32. return threadInfo.stack_end;
  33. #elif OS(UNIX)
  34. +#ifdef UCLIBC_USE_PROC_SELF_MAPS
  35. + // Read /proc/self/maps and locate the line whose address
  36. + // range contains __libc_stack_end.
  37. + FILE *file = fopen("/proc/self/maps", "r");
  38. + if (!file)
  39. + return 0;
  40. + __fsetlocking(file, FSETLOCKING_BYCALLER);
  41. + char *line = NULL;
  42. + size_t lineLen = 0;
  43. + while (!feof_unlocked(file)) {
  44. + if (getdelim(&line, &lineLen, '\n', file) <= 0)
  45. + break;
  46. + long from;
  47. + long to;
  48. + if (sscanf (line, "%lx-%lx", &from, &to) != 2)
  49. + continue;
  50. + if (from <= (long)__libc_stack_end && (long)__libc_stack_end < to) {
  51. + fclose(file);
  52. + free(line);
  53. +#ifdef _STACK_GROWS_UP
  54. + return (void *)from;
  55. +#else
  56. + return (void *)to;
  57. +#endif
  58. + }
  59. + }
  60. + fclose(file);
  61. + free(line);
  62. + return 0;
  63. +#else
  64. static void* stackBase = 0;
  65. static size_t stackSize = 0;
  66. static pthread_t stackThread;
  67. @@ -631,6 +673,7 @@
  68. stackThread = thread;
  69. }
  70. return static_cast<char*>(stackBase) + stackSize;
  71. +#endif
  72. #elif OS(WINCE)
  73. if (g_stackBase)
  74. return g_stackBase;