[vlc-devel] [PATCH] compat: work-around busted FreeBSD qsort_r()

Rémi Denis-Courmont remi at remlab.net
Thu Nov 29 17:17:44 CET 2018


Hi,

Thanks for the review. As I cannot test it (or cannot be bothered to install a FreeBSD VM), I have no plans to update the patch myself though.

Le 29 novembre 2018 14:33:44 GMT+02:00, Marvin Scholz <epirat07 at gmail.com> a écrit :
>On 20 Nov 2018, at 17:16, Rémi Denis-Courmont wrote:
>
>> This is untested.
>> ---
>>  configure.ac         | 15 +++++++++++++++
>>  include/vlc_fixups.h |  4 ++++
>>  2 files changed, 19 insertions(+)
>>
>> diff --git a/configure.ac b/configure.ac
>> index 1f33f5dc88..21fcb45203 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -742,6 +742,21 @@ AC_CHECK_LIB([m], [sincos], [
>>    AC_LIBOBJ([sincos])
>>  ])
>>
>> +AC_MSG_CHECKING([broken qsort_r prototype])
>> +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdlib.h>
>> +
>> +_Static_assert(_Generic((qsort_r),
>> +    void (*)(void *, size_t, size_t, void *,
>> +             int (*)(void *, const void *, const void *)) : 1, 
>> default: 0),
>> +    "Bad prototype not matched");
>> +])], [
>> +  AC_MSG_RESULT([broken])
>> +  AC_DEFINE([HAVE_BROKEN_QSORT_R], 1, [Defined to 1 if the qsort_r()
>
>> prototype contradicts the upcoming POSIX standard.])
>> +  AC_LIBOBJ([qsort_r])
>> +], [
>> +  AC_MSG_RESULT([no])
>> +])
>> +
>>  AC_MSG_CHECKING([_Thread_local support])
>>  AC_COMPILE_IFELSE([AC_LANG_SOURCE([_Thread_local int foo = 0;
>>                     int main() {}])], [
>> diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
>> index 0263286efc..45fec0f6d4 100644
>> --- a/include/vlc_fixups.h
>> +++ b/include/vlc_fixups.h
>> @@ -224,6 +224,10 @@ long long atoll (const char *);
>>  lldiv_t lldiv (long long, long long);
>>  #endif
>>
>> +#ifdef HAVE_BROKEN_QSORT_R
>> +# define qsort_r posix_qsort_r
>> +#endif
>> +
>>  #ifndef HAVE_QSORT_R
>>  void (qsort_r)(void *, size_t, size_t,
>>                 int (*)(const void *, const void *, void *), void *);
>> -- 
>> 2.19.1
>
>Thanks for the patch, this actually affects Darwin too and probably
>every other BSD variant.
>
>With the patch applied configure properly detects the qsort_r as having
>
>the
>wrong prototype but the compat replacement collides with the already 
>existing
>qsort_r declaration:
>
>   CC       qsort_r.lo
>../../extras/package/macosx/../../../compat/qsort_r.c:41:6: error: 
>conflicting types for 'posix_qsort_r'
>void qsort_r(void *base, size_t nmemb, size_t size,
>      ^
>../../extras/package/macosx/../../../include/vlc_fixups.h:228:18: note:
>
>expanded from macro 'qsort_r'
># define qsort_r posix_qsort_r
>                  ^
>/[...]/usr/include/stdlib.h:330:7: note: previous declaration is here
>void     qsort_r(void *__base, size_t __nel, size_t __width, void *,
>          ^
>../../extras/package/macosx/../../../include/vlc_fixups.h:228:18: note:
>
>expanded from macro 'qsort_r'
># define qsort_r posix_qsort_r
>                  ^
>1 error generated.
>make[3]: *** [qsort_r.lo] Error 1
>
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
>_______________________________________________
>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/20181129/a13f04f8/attachment.html>


More information about the vlc-devel mailing list