[vlc-devel] [PATCH 2/7] core: utils: add vlc_qsort

Rémi Denis-Courmont remi at remlab.net
Tue Jan 22 12:59:31 CET 2019


I am more concerned about the real problem that some craptastic libc do not provide <threads.h> and thus thread_local, than that the compiler does not support C11.

Le 22 janvier 2019 12:12:46 GMT+02:00, "Hugo Beauzée-Luyssen" <hugo at beauzee.fr> a écrit :
>
>
>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
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190122/67e024f0/attachment.html>


More information about the vlc-devel mailing list