fix-mono-android-tkill.diff 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. diff --git a/libgc/include/private/gcconfig.h b/libgc/include/private/gcconfig.h
  2. index e2bdf13ac3e..f962200ba4e 100644
  3. --- a/libgc/include/private/gcconfig.h
  4. +++ b/libgc/include/private/gcconfig.h
  5. @@ -2255,6 +2255,14 @@
  6. # define GETPAGESIZE() getpagesize()
  7. # endif
  8. +#if defined(HOST_ANDROID) && !(__ANDROID_API__ >= 23) \
  9. + && ((defined(MIPS) && (CPP_WORDSZ == 32)) \
  10. + || defined(ARM32) || defined(I386) /* but not x32 */)
  11. + /* tkill() exists only on arm32/mips(32)/x86. */
  12. + /* NDK r11+ deprecates tkill() but keeps it for Mono clients. */
  13. +# define USE_TKILL_ON_ANDROID
  14. +#endif
  15. +
  16. # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
  17. /* OS has SVR4 generic features. Probably others also qualify. */
  18. # define SVR4
  19. diff --git a/libgc/pthread_stop_world.c b/libgc/pthread_stop_world.c
  20. index f93ce26b562..4a49a6d578c 100644
  21. --- a/libgc/pthread_stop_world.c
  22. +++ b/libgc/pthread_stop_world.c
  23. @@ -336,7 +336,7 @@ void GC_push_all_stacks()
  24. pthread_t GC_stopping_thread;
  25. int GC_stopping_pid;
  26. -#ifdef HOST_ANDROID
  27. +#ifdef USE_TKILL_ON_ANDROID
  28. static
  29. int android_thread_kill(pid_t tid, int sig)
  30. {
  31. diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c
  32. index ad9b8823f8f..3542b32b540 100644
  33. --- a/mono/metadata/threads.c
  34. +++ b/mono/metadata/threads.c
  35. @@ -77,8 +77,12 @@ mono_native_thread_join_handle (HANDLE thread_handle, gboolean close_handle);
  36. #include <zircon/syscalls.h>
  37. #endif
  38. -#if defined(HOST_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64)
  39. -#define USE_TKILL_ON_ANDROID 1
  40. +#if defined(HOST_ANDROID) && !(__ANDROID_API__ >= 23) \
  41. + && ((defined(MIPS) && (CPP_WORDSZ == 32)) \
  42. + || defined(ARM32) || defined(I386) /* but not x32 */)
  43. + /* tkill() exists only on arm32/mips(32)/x86. */
  44. + /* NDK r11+ deprecates tkill() but keeps it for Mono clients. */
  45. +# define USE_TKILL_ON_ANDROID
  46. #endif
  47. #ifdef HOST_ANDROID
  48. diff --git a/mono/utils/mono-threads-posix.c b/mono/utils/mono-threads-posix.c
  49. index 3e4bf93de5f..79c9f731fe7 100644
  50. --- a/mono/utils/mono-threads-posix.c
  51. +++ b/mono/utils/mono-threads-posix.c
  52. @@ -31,8 +31,12 @@
  53. #include <errno.h>
  54. -#if defined(HOST_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64)
  55. -#define USE_TKILL_ON_ANDROID 1
  56. +#if defined(HOST_ANDROID) && !(__ANDROID_API__ >= 23) \
  57. + && ((defined(MIPS) && (CPP_WORDSZ == 32)) \
  58. + || defined(ARM32) || defined(I386) /* but not x32 */)
  59. + /* tkill() exists only on arm32/mips(32)/x86. */
  60. + /* NDK r11+ deprecates tkill() but keeps it for Mono clients. */
  61. +# define USE_TKILL_ON_ANDROID
  62. #endif
  63. #ifdef USE_TKILL_ON_ANDROID