51f0aa
commit bef8fd6013f7d398661077340753c745a8939279
51f0aa
Author: Joseph Myers <joseph@codesourcery.com>
51f0aa
Date:   Wed Nov 12 22:33:41 2014 +0000
51f0aa
51f0aa
    Fix qsort_r namespace (bug 17571).
51f0aa
51f0aa
diff --git a/include/stdlib.h b/include/stdlib.h
51f0aa
index c20ce9da58bd2cdf..152c12fe9cb41509 100644
51f0aa
--- a/include/stdlib.h
51f0aa
+++ b/include/stdlib.h
51f0aa
@@ -37,7 +37,8 @@ extern __typeof (secure_getenv) __libc_secure_getenv;
51f0aa
 libc_hidden_proto (__libc_secure_getenv)
51f0aa
 libc_hidden_proto (bsearch)
51f0aa
 libc_hidden_proto (qsort)
51f0aa
-libc_hidden_proto (qsort_r)
51f0aa
+extern __typeof (qsort_r) __qsort_r;
51f0aa
+libc_hidden_proto (__qsort_r)
51f0aa
 libc_hidden_proto (lrand48_r)
51f0aa
 libc_hidden_proto (wctomb)
51f0aa
 
51f0aa
diff --git a/nscd/gai.c b/nscd/gai.c
51f0aa
index 060933293838c4ee..018b449339813df5 100644
51f0aa
--- a/nscd/gai.c
51f0aa
+++ b/nscd/gai.c
51f0aa
@@ -29,6 +29,7 @@
51f0aa
 #define __sendto sendto
51f0aa
 #define __strchrnul strchrnul
51f0aa
 #define __getline getline
51f0aa
+#define __qsort_r qsort_r
51f0aa
 /* nscd uses 1MB or 2MB thread stacks.  */
51f0aa
 #define __libc_use_alloca(size) (size <= __MAX_ALLOCA_CUTOFF)
51f0aa
 
51f0aa
diff --git a/posix/tst-rfc3484-2.c b/posix/tst-rfc3484-2.c
51f0aa
index a37be36e6ad5a279..afd4b2959fc830f0 100644
51f0aa
--- a/posix/tst-rfc3484-2.c
51f0aa
+++ b/posix/tst-rfc3484-2.c
51f0aa
@@ -9,6 +9,7 @@
51f0aa
 #define __inet_aton inet_aton
51f0aa
 #define __gethostbyaddr_r gethostbyaddr_r
51f0aa
 #define __gethostbyname2_r gethostbyname2_r
51f0aa
+#define __qsort_r qsort_r
51f0aa
 
51f0aa
 void
51f0aa
 attribute_hidden
51f0aa
diff --git a/posix/tst-rfc3484-3.c b/posix/tst-rfc3484-3.c
51f0aa
index 493e76015c74be9e..92efecd242a0baa3 100644
51f0aa
--- a/posix/tst-rfc3484-3.c
51f0aa
+++ b/posix/tst-rfc3484-3.c
51f0aa
@@ -9,6 +9,7 @@
51f0aa
 #define __inet_aton inet_aton
51f0aa
 #define __gethostbyaddr_r gethostbyaddr_r
51f0aa
 #define __gethostbyname2_r gethostbyname2_r
51f0aa
+#define __qsort_r qsort_r
51f0aa
 
51f0aa
 void
51f0aa
 attribute_hidden
51f0aa
diff --git a/posix/tst-rfc3484.c b/posix/tst-rfc3484.c
51f0aa
index db3ae1b7bb86406a..8e886d987fd42b1d 100644
51f0aa
--- a/posix/tst-rfc3484.c
51f0aa
+++ b/posix/tst-rfc3484.c
51f0aa
@@ -9,6 +9,7 @@
51f0aa
 #define __inet_aton inet_aton
51f0aa
 #define __gethostbyaddr_r gethostbyaddr_r
51f0aa
 #define __gethostbyname2_r gethostbyname2_r
51f0aa
+#define __qsort_r qsort_r
51f0aa
 
51f0aa
 void
51f0aa
 attribute_hidden
51f0aa
diff --git a/stdlib/msort.c b/stdlib/msort.c
51f0aa
index e419734cd634ba5c..6f4b846b05fea8b9 100644
51f0aa
--- a/stdlib/msort.c
51f0aa
+++ b/stdlib/msort.c
51f0aa
@@ -162,7 +162,7 @@ msort_with_tmp (const struct msort_param *p, void *b, size_t n)
51f0aa
 
51f0aa
 
51f0aa
 void
51f0aa
-qsort_r (void *b, size_t n, size_t s, __compar_d_fn_t cmp, void *arg)
51f0aa
+__qsort_r (void *b, size_t n, size_t s, __compar_d_fn_t cmp, void *arg)
51f0aa
 {
51f0aa
   size_t size = n * s;
51f0aa
   char *tmp = NULL;
51f0aa
@@ -298,12 +298,13 @@ qsort_r (void *b, size_t n, size_t s, __compar_d_fn_t cmp, void *arg)
51f0aa
     }
51f0aa
   free (tmp);
51f0aa
 }
51f0aa
-libc_hidden_def (qsort_r)
51f0aa
+libc_hidden_def (__qsort_r)
51f0aa
+weak_alias (__qsort_r, qsort_r)
51f0aa
 
51f0aa
 
51f0aa
 void
51f0aa
 qsort (void *b, size_t n, size_t s, __compar_fn_t cmp)
51f0aa
 {
51f0aa
-  return qsort_r (b, n, s, (__compar_d_fn_t) cmp, NULL);
51f0aa
+  return __qsort_r (b, n, s, (__compar_d_fn_t) cmp, NULL);
51f0aa
 }
51f0aa
 libc_hidden_def (qsort)
51f0aa
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
51f0aa
index b1c72fda9d2aa365..a678d8d7e8b23d1d 100644
51f0aa
--- a/sysdeps/posix/getaddrinfo.c
51f0aa
+++ b/sysdeps/posix/getaddrinfo.c
51f0aa
@@ -2639,11 +2639,11 @@ getaddrinfo (const char *name, const char *service,
51f0aa
 	  __libc_lock_lock (lock);
51f0aa
 	  if (__libc_once_get (old_once) && gaiconf_reload_flag)
51f0aa
 	    gaiconf_reload ();
51f0aa
-	  qsort_r (order, nresults, sizeof (order[0]), rfc3484_sort, &src;;
51f0aa
+	  __qsort_r (order, nresults, sizeof (order[0]), rfc3484_sort, &src;;
51f0aa
 	  __libc_lock_unlock (lock);
51f0aa
 	}
51f0aa
       else
51f0aa
-	qsort_r (order, nresults, sizeof (order[0]), rfc3484_sort, &src;;
51f0aa
+	__qsort_r (order, nresults, sizeof (order[0]), rfc3484_sort, &src;;
51f0aa
 
51f0aa
       /* Queue the results up as they come out of sorting.  */
51f0aa
       q = p = results[order[0]].dest_addr;