View | Details | Raw Unified | Return to bug 266227 | Differences between
and this patch

Collapse All | Expand All

(-)b/graphics/mesa-dri/files/patch-meson.build (+46 lines)
Added Link Here
1
--- meson.build.orig	2022-03-18 19:26:47 UTC
2
+++ meson.build
3
@@ -1414,11 +1414,42 @@ foreach f : ['strtof', 'mkostemp', 'timespec_get', 'me
4
 endforeach
5
 
6
 foreach f : ['strtof', 'mkostemp', 'timespec_get', 'memfd_create', 'random_r',
7
-             'flock', 'strtok_r', 'getrandom', 'qsort_r', 'qsort_s']
8
+             'flock', 'strtok_r', 'getrandom', 'qsort_s']
9
   if cc.has_function(f)
10
     pre_args += '-DHAVE_@0@'.format(f.to_upper())
11
   endif
12
 endforeach
13
+
14
+if cpp.links('''
15
+    #define _GNU_SOURCE
16
+    #include <stdlib.h>
17
+
18
+    static int dcomp(const void *l, const void *r, void *t) { return 0; }
19
+
20
+    int main(int ac, char **av) {
21
+      int arr[] = { 1 };
22
+      void *t = NULL;
23
+      qsort_r((void*)&arr[0], 1, 1, dcomp, t);
24
+      return (0);
25
+    }''',
26
+    args : pre_args,
27
+    name : 'GNU qsort_r')
28
+  pre_args += '-DHAVE_GNU_QSORT_R'
29
+elif cpp.links('''
30
+    #include <stdlib.h>
31
+
32
+    static int dcomp(void *t, const void *l, const void *r) { return 0; }
33
+
34
+    int main(int ac, char **av) {
35
+      int arr[] = { 1 };
36
+      void *t = NULL;
37
+      qsort_r((void*)&arr[0], 1, 1, t, dcomp);
38
+      return (0);
39
+    }''',
40
+    args : pre_args,
41
+    name : 'BSD qsort_r')
42
+  pre_args += '-DHAVE_BSD_QSORT_R'
43
+endif
44
 
45
 if cc.has_header_symbol('errno.h', 'program_invocation_name',
46
                         args : '-D_GNU_SOURCE')
(-)b/graphics/mesa-dri/files/patch-src_util_u__qsort.h (-1 / +26 lines)
Added Link Here
0
- 
1
--- src/util/u_qsort.h.orig	2022-03-18 19:26:47 UTC
2
+++ src/util/u_qsort.h
3
@@ -56,8 +56,10 @@ util_qsort_r(void *base, size_t nmemb, size_t size,
4
              int (*compar)(const void *, const void *, void *),
5
              void *arg)
6
 {
7
-#if HAVE_QSORT_R
8
-#  if DETECT_OS_APPLE || DETECT_OS_BSD
9
+#if HAVE_GNU_QSORT_R
10
+   /* GNU extension added in glibc 2.8 */
11
+   qsort_r(base, nmemb, size, compar, arg);
12
+#elif HAVE_BSD_QSORT_R
13
    /* BSD/macOS qsort_r takes "arg" before the comparison function and it
14
     * pass the "arg" before the elements.
15
     */
16
@@ -66,10 +68,6 @@ util_qsort_r(void *base, size_t nmemb, size_t size,
17
       arg
18
    };
19
    qsort_r(base, nmemb, size, &data, util_qsort_adapter);
20
-#  else
21
-   /* GNU extension added in glibc 2.8 */
22
-   qsort_r(base, nmemb, size, compar, arg);
23
-#  endif
24
 #elif HAVE_QSORT_S
25
 #  ifdef _WIN32
26
    /* MSVC/MinGW qsort_s takes "arg" after the comparison function and it

Return to bug 266227