[vlc-devel] [PATCH 2/7] core: utils: add vlc_qsort
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Tue Jan 22 11:12:46 CET 2019
On Tue, Jan 22, 2019, at 10:34 AM, Thomas Guillem wrote:
> On Mon, Jan 21, 2019, at 18:09, Hugo Beauzée-Luyssen wrote:
> >
> > Any reason not to use "thread_local" ?
>
> No, no idea, just copied the code from Rémi compat code.
>
Since _Thread_local might be missing on some platform, I'd be in favor of using thread_local instead
> >
> > > +{
> > > + int (*compar)(const void *, const void *, void *);
> > > + void *arg;
> > > +} state;
> > > +
> > > +static int compar_wrapper(const void *a, const void *b)
> > > +{
> > > + return state.compar(a, b, state.arg);
> > > +}
> > > +
> > > +/* Follow the upcoming POSIX prototype, coming from GNU/libc.
> > > + * Note that this differs from the BSD prototype. */
> > > +
> > > +VLC_WEAK void vlc_qsort(void *base, size_t nmemb, size_t size,
> > > + int (*compar)(const void *, const void *, void *),
> > > + void *arg)
> >
> > Any particular reason to use VLC_WEAK instead of the usual per-platform
> > implementation?
>
> It's more future proof for me. We could add more utility functions to
> misc/utils.c. Some of these functions could be implemented differently
> depending of the OS or not. With VLC_WEAK, we don't have to play with
> conditions in the Makefile.am, this seems more convenient.
>
Fair enough, the question is mostly that we don't use it much but more often use multiple source files. Your point is very valid IMO, I just find weak symbols harder to reason about, or less intuitive, than a plain different source file, but I'm absolutely fine with your solution :)
> As you want, I don't have strong opinions about wether we should use
> VLC_WEAK in that case.
>
--
Hugo Beauzée-Luyssen
hugo at beauzee.fr
More information about the vlc-devel
mailing list