Browse Source

Fix glib aarch64 atomics, leading to hang on a-fluidsynth

tags/v1.0
falkTX 4 years ago
parent
commit
edbc66fba3
3 changed files with 133 additions and 3 deletions
  1. +1
    -1
      .travis.yml
  2. +1
    -2
      .travis/script.sh
  3. +131
    -0
      patches/glib/macos-universal/01_aarch64-atomic-as-mutex.patch

+ 1
- 1
.travis.yml View File

@@ -13,7 +13,7 @@ cache:

env:
global:
- BOOTSTRAP_VERSION=6
- BOOTSTRAP_VERSION=7

jobs:
include:


+ 1
- 2
.travis/script.sh View File

@@ -13,12 +13,11 @@ else
LAST_BOOTSTRAP_VERSION=0
fi

PLUGINS_BASE="abgate artyfx caps fomp mda"
PLUGINS_BASE="abgate artyfx caps die-plugins fomp mda"
PLUGINS_CROSS="blop dpf-plugins"
PLUGINS_DISTRHO="distrho-ports-arctican distrho-ports-drowaudio distrho-ports-tal-plugins"

# TODO
# die-plugins: hangs during fluidsynth runtime check
# ninjas2: need to put http://kxstudio.sf.net/ns/lv2ext/props#NonAutomable spec somewhere

# only build full set of distrho-ports if we have previously cached builds, otherwise we time-out in travis


+ 131
- 0
patches/glib/macos-universal/01_aarch64-atomic-as-mutex.patch View File

@@ -0,0 +1,131 @@
--- glib-2.22.5/glib/gatomic.c 2021-01-12 00:34:17.000000000 +0000
+++ glib-2.22.5.mod/glib/gatomic.c 2021-01-12 00:31:22.000000000 +0000
@@ -561,55 +561,33 @@
# error "Your system has an unsupported pointer size"
# endif /* GLIB_SIZEOF_VOID_P */
# elif defined (__aarch64__)
-static volatile int atomic_spin = 0;
-
-static int atomic_spin_trylock (void)
-{
- int result;
-
- asm volatile (
- "swp %0, %1, [%2]\n"
- : "=&r,&r" (result)
- : "r,0" (1), "r,r" (&atomic_spin)
- : "memory");
- if (result == 0)
- return 0;
- else
- return -1;
-}
-
-static void atomic_spin_lock (void)
-{
- while (atomic_spin_trylock())
- sched_yield();
-}
-
-static void atomic_spin_unlock (void)
-{
- atomic_spin = 0;
-}
+#include <pthread.h>
+static pthread_mutex_t g_atomic_lock = PTHREAD_MUTEX_INITIALIZER;
gint
g_atomic_int_exchange_and_add (volatile gint G_GNUC_MAY_ALIAS *atomic,
gint val)
{
- gint result;
-
- atomic_spin_lock();
- result = *atomic;
- *atomic += val;
- atomic_spin_unlock();
+ guint oldval;
- return result;
+ pthread_mutex_lock (&g_atomic_lock);
+ oldval = *atomic;
+ *atomic = oldval & val;
+ pthread_mutex_unlock (&g_atomic_lock);
+
+ return oldval;
}
void
g_atomic_int_add (volatile gint G_GNUC_MAY_ALIAS *atomic,
gint val)
{
- atomic_spin_lock();
- *atomic += val;
- atomic_spin_unlock();
+ guint oldval;
+
+ pthread_mutex_lock (&g_atomic_lock);
+ oldval = *atomic;
+ *atomic = oldval & val;
+ pthread_mutex_unlock (&g_atomic_lock);
}
gboolean
@@ -617,19 +595,16 @@
gint oldval,
gint newval)
{
- gboolean result;
+ gboolean success;
- atomic_spin_lock();
- if (*atomic == oldval)
- {
- result = TRUE;
- *atomic = newval;
- }
- else
- result = FALSE;
- atomic_spin_unlock();
+ pthread_mutex_lock (&g_atomic_lock);
- return result;
+ if ((success = (*atomic == oldval)))
+ *atomic = newval;
+
+ pthread_mutex_unlock (&g_atomic_lock);
+
+ return success;
}
gboolean
@@ -637,19 +612,17 @@
gpointer oldval,
gpointer newval)
{
- gboolean result;
-
- atomic_spin_lock();
- if (*atomic == oldval)
- {
- result = TRUE;
- *atomic = newval;
- }
- else
- result = FALSE;
- atomic_spin_unlock();
+ gpointer *ptr = atomic;
+ gboolean success;
- return result;
+ pthread_mutex_lock (&g_atomic_lock);
+
+ if ((success = (*ptr == oldval)))
+ *ptr = newval;
+
+ pthread_mutex_unlock (&g_atomic_lock);
+
+ return success;
}
# elif defined (G_ATOMIC_CRIS) || defined (G_ATOMIC_CRISV32)
# ifdef G_ATOMIC_CRIS

Loading…
Cancel
Save