0017-core-Fix-TLS-usage.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. From a8a9f64d358be38fb5f5a0a85cbd4652a84a9321 Mon Sep 17 00:00:00 2001
  2. From: Thomas Guillem <thomas@gllm.fr>
  3. Date: Fri, 2 Jun 2017 15:56:34 +0200
  4. Subject: [PATCH 17/17] core: Fix TLS usage
  5. TLS is not implement on arm ios (for iPhone5). We may drop this platform for
  6. 4.0, so this patch is only temporary.
  7. ---
  8. src/misc/variables.c | 9 ++++++---
  9. 1 file changed, 6 insertions(+), 3 deletions(-)
  10. diff --git a/src/misc/variables.c b/src/misc/variables.c
  11. index 121ef5ea70..3e7b43f912 100644
  12. --- a/src/misc/variables.c
  13. +++ b/src/misc/variables.c
  14. @@ -1378,7 +1378,7 @@ void DumpVariables(vlc_object_t *obj)
  15. vlc_mutex_unlock(&vlc_internals(obj)->var_lock);
  16. }
  17. -static _Thread_local void *twalk_ctx;
  18. +static vlc_threadvar_t twalk_key;
  19. static void TwalkGetNames(const void *data, const VISIT which, const int depth)
  20. {
  21. @@ -1387,7 +1387,7 @@ static void TwalkGetNames(const void *data, const VISIT which, const int depth)
  22. (void) depth;
  23. const variable_t *var = *(const variable_t **)data;
  24. - DECL_ARRAY(char *) *names = twalk_ctx;
  25. + DECL_ARRAY(char *) *names = vlc_threadvar_get(twalk_key);
  26. char *dup = strdup(var->psz_name);
  27. if (dup != NULL)
  28. ARRAY_APPEND(*names, dup);
  29. @@ -1400,11 +1400,14 @@ char **var_GetAllNames(vlc_object_t *obj)
  30. DECL_ARRAY(char *) names;
  31. ARRAY_INIT(names);
  32. - twalk_ctx = &names;
  33. + if (vlc_threadvar_create(&twalk_key, NULL) != 0)
  34. + return NULL;
  35. + vlc_threadvar_set(twalk_key, &names);
  36. vlc_mutex_lock(&priv->var_lock);
  37. twalk(priv->var_root, TwalkGetNames);
  38. vlc_mutex_unlock(&priv->var_lock);
  39. + vlc_threadvar_delete(&twalk_key);
  40. if (names.i_size == 0)
  41. return NULL;
  42. ARRAY_APPEND(names, NULL);
  43. --
  44. 2.11.0