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