diff options
author | Joseph Myers <joseph@codesourcery.com> | 2014-11-12 22:33:41 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2014-11-12 22:33:41 +0000 |
commit | bef8fd6013f7d398661077340753c745a8939279 (patch) | |
tree | 1cd588148b457edb6d8f8d4955ccefb0f0c0125c /stdlib | |
parent | c52ff39e8ee052e4a57676d65a27f09bd0a859ad (diff) | |
download | glibc-bef8fd6013f7d398661077340753c745a8939279.tar.gz |
Fix qsort_r namespace (bug 17571).
qsort_r is defined in the same file as qsort, but is not an ISO C
function, so should be a weak alias for __qsort_r. The uses in
getaddrinfo should also call __qsort_r, since getaddrinfo is a POSIX
function and qsort_r isn't. This patch implements this. Because nscd
uses the getaddrinfo sources outside libc, as do the tst-rfc3484
tests, a #define of __qsort_r to qsort_r is added there alongside the
similar defines for other libc-internal symbols used in getaddrinfo.
Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by the patch).
[BZ #17571]
* stdlib/msort.c (qsort_r): Rename to __qsort_r and define as weak
alias of __qsort_r.
(qsort): Call __qsort_r instead of qsort_r.
* include/stdlib.h (qsort_r): Do not call libc_hidden_proto.
(__qsort_r): Declare. Call libc_hidden_proto.
* sysdeps/posix/getaddrinfo.c (getaddrinfo): Call __qsort_r
instead of qsort_r.
* nscd/gai.c (__qsort_r): Define to qsort_r.
* posix/tst-rfc3484.c (__qsort_r): Likewise.
* posix/tst-rfc3484-2.c (__qsort_r): Likewise.
* posix/tst-rfc3484-3.c (__qsort_r): Likewise.
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/msort.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/stdlib/msort.c b/stdlib/msort.c index 02ef28b89d..5ac5df710d 100644 --- a/stdlib/msort.c +++ b/stdlib/msort.c @@ -162,7 +162,7 @@ msort_with_tmp (const struct msort_param *p, void *b, size_t n) void -qsort_r (void *b, size_t n, size_t s, __compar_d_fn_t cmp, void *arg) +__qsort_r (void *b, size_t n, size_t s, __compar_d_fn_t cmp, void *arg) { size_t size = n * s; char *tmp = NULL; @@ -298,12 +298,13 @@ qsort_r (void *b, size_t n, size_t s, __compar_d_fn_t cmp, void *arg) } free (tmp); } -libc_hidden_def (qsort_r) +libc_hidden_def (__qsort_r) +weak_alias (__qsort_r, qsort_r) void qsort (void *b, size_t n, size_t s, __compar_fn_t cmp) { - return qsort_r (b, n, s, (__compar_d_fn_t) cmp, NULL); + return __qsort_r (b, n, s, (__compar_d_fn_t) cmp, NULL); } libc_hidden_def (qsort) |