[vlc-devel] [PATCHv2 03/18] variables: add a twalk context

Thomas Guillem thomas at gllm.fr
Wed May 31 09:28:46 CEST 2017



On Tue, May 30, 2017, at 21:33, Rémi Denis-Courmont wrote:
> Le tiistaina 30. toukokuuta 2017, 18.40.53 EEST Thomas Guillem a écrit :
> > Since the libc twalk() function doesn't propose any user specific void *
> > context.
> > ---
> >  src/misc/variables.c | 6 +++++-
> >  src/misc/variables.h | 1 +
> >  2 files changed, 6 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/misc/variables.c b/src/misc/variables.c
> > index 5e9ba678a8..b043d2018b 100644
> > --- a/src/misc/variables.c
> > +++ b/src/misc/variables.c
> > @@ -100,6 +100,9 @@ struct variable_t
> >      callback_table_t    value_callbacks;
> >      /** Registered list callbacks */
> >      callback_table_t    list_callbacks;
> > +
> > +    /** Private context used for twalk callbacks */
> > +    void **twalk_ctx;
> 
> Urk. This is ugly, and it even only works as a side effect of the
> variable 
> mutex. You want _Thread_local for such cases (or rewrite the binary tree 
> functions).

Yes, I thought about thread local but I was afraid of problems with
others platforms.
Can we use __Thread_local (C11) in the core for every archs ?

> 
> >  };
> > 
> >  static int CmpBool( vlc_value_t v, vlc_value_t w )
> > @@ -298,6 +301,7 @@ int var_Create( vlc_object_t *p_this, const char
> > *psz_name, int i_type ) {
> >      assert( p_this );
> > 
> > +    vlc_object_internals_t *p_priv = vlc_internals( p_this );
> >      variable_t *p_var = calloc( 1, sizeof( *p_var ) );
> >      if( p_var == NULL )
> >          return VLC_ENOMEM;
> > @@ -356,11 +360,11 @@ int var_Create( vlc_object_t *p_this, const char
> > *psz_name, int i_type ) default:
> >              vlc_assert_unreachable ();
> >      }
> > +    p_var->twalk_ctx = &p_priv->var_twalk_ctx;
> > 
> >      if (i_type & VLC_VAR_DOINHERIT)
> >          var_Inherit(p_this, psz_name, i_type, &p_var->val);
> > 
> > -    vlc_object_internals_t *p_priv = vlc_internals( p_this );
> >      variable_t **pp_var, *p_oldvar;
> >      int ret = VLC_SUCCESS;
> > 
> > diff --git a/src/misc/variables.h b/src/misc/variables.h
> > index 97fb2ba18d..76a7dd3360 100644
> > --- a/src/misc/variables.h
> > +++ b/src/misc/variables.h
> > @@ -36,6 +36,7 @@ struct vlc_object_internals
> > 
> >      /* Object variables */
> >      void           *var_root;
> > +    void           *var_twalk_ctx;
> >      vlc_mutex_t     var_lock;
> >      vlc_cond_t      var_wait;
> 
> 
> -- 
> 雷米‧德尼-库尔蒙
> https://www.remlab.net/
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list