Cross-Platform build scripts for audio plugins
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
2.6KB

  1. --- glib-2.22.5/glib/gatomic.c 2021-01-12 00:34:17.000000000 +0000
  2. +++ glib-2.22.5.mod/glib/gatomic.c 2021-01-12 00:31:22.000000000 +0000
  3. @@ -561,55 +561,33 @@
  4. # error "Your system has an unsupported pointer size"
  5. # endif /* GLIB_SIZEOF_VOID_P */
  6. # elif defined (__aarch64__)
  7. -static volatile int atomic_spin = 0;
  8. -
  9. -static int atomic_spin_trylock (void)
  10. -{
  11. - int result;
  12. -
  13. - asm volatile (
  14. - "swp %0, %1, [%2]\n"
  15. - : "=&r,&r" (result)
  16. - : "r,0" (1), "r,r" (&atomic_spin)
  17. - : "memory");
  18. - if (result == 0)
  19. - return 0;
  20. - else
  21. - return -1;
  22. -}
  23. -
  24. -static void atomic_spin_lock (void)
  25. -{
  26. - while (atomic_spin_trylock())
  27. - sched_yield();
  28. -}
  29. -
  30. -static void atomic_spin_unlock (void)
  31. -{
  32. - atomic_spin = 0;
  33. -}
  34. +#include <pthread.h>
  35. +static pthread_mutex_t g_atomic_lock = PTHREAD_MUTEX_INITIALIZER;
  36. gint
  37. g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic,
  38. gint val)
  39. {
  40. - gint result;
  41. -
  42. - atomic_spin_lock();
  43. - result = *atomic;
  44. - *atomic += val;
  45. - atomic_spin_unlock();
  46. + guint oldval;
  47. - return result;
  48. + pthread_mutex_lock (&g_atomic_lock);
  49. + oldval = *atomic;
  50. + *atomic = oldval & val;
  51. + pthread_mutex_unlock (&g_atomic_lock);
  52. +
  53. + return oldval;
  54. }
  55. void
  56. g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic,
  57. gint val)
  58. {
  59. - atomic_spin_lock();
  60. - *atomic += val;
  61. - atomic_spin_unlock();
  62. + guint oldval;
  63. +
  64. + pthread_mutex_lock (&g_atomic_lock);
  65. + oldval = *atomic;
  66. + *atomic = oldval & val;
  67. + pthread_mutex_unlock (&g_atomic_lock);
  68. }
  69. gboolean
  70. @@ -617,19 +595,16 @@
  71. gint oldval,
  72. gint newval)
  73. {
  74. - gboolean result;
  75. + gboolean success;
  76. - atomic_spin_lock();
  77. - if (*atomic == oldval)
  78. - {
  79. - result = TRUE;
  80. - *atomic = newval;
  81. - }
  82. - else
  83. - result = FALSE;
  84. - atomic_spin_unlock();
  85. + pthread_mutex_lock (&g_atomic_lock);
  86. - return result;
  87. + if ((success = (*atomic == oldval)))
  88. + *atomic = newval;
  89. +
  90. + pthread_mutex_unlock (&g_atomic_lock);
  91. +
  92. + return success;
  93. }
  94. gboolean
  95. @@ -637,19 +612,17 @@
  96. gpointer oldval,
  97. gpointer newval)
  98. {
  99. - gboolean result;
  100. -
  101. - atomic_spin_lock();
  102. - if (*atomic == oldval)
  103. - {
  104. - result = TRUE;
  105. - *atomic = newval;
  106. - }
  107. - else
  108. - result = FALSE;
  109. - atomic_spin_unlock();
  110. + gpointer *ptr = atomic;
  111. + gboolean success;
  112. - return result;
  113. + pthread_mutex_lock (&g_atomic_lock);
  114. +
  115. + if ((success = (*ptr == oldval)))
  116. + *ptr = newval;
  117. +
  118. + pthread_mutex_unlock (&g_atomic_lock);
  119. +
  120. + return success;
  121. }
  122. # elif defined (G_ATOMIC_CRIS) || defined (G_ATOMIC_CRISV32)
  123. # ifdef G_ATOMIC_CRIS