about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2015-02-18 18:47:34 +0000
committerJoseph Myers <joseph@codesourcery.com>2015-02-18 18:47:34 +0000
commit4ffb1771554dd4661beb44be2036c598aa56c80a (patch)
tree28c5450c2dca041865cd73a3b1f90178fd7f20ba
parent94c5a52a841f807a23dbdd19a5ddeb505cc1d543 (diff)
downloadglibc-4ffb1771554dd4661beb44be2036c598aa56c80a.tar.gz
glibc-4ffb1771554dd4661beb44be2036c598aa56c80a.tar.xz
glibc-4ffb1771554dd4661beb44be2036c598aa56c80a.zip
Fix search.h namespace (bug 17996).
The implementation of the (XSI POSIX) functions hsearch / hcreate /
hdestroy uses hsearch_r / hcreate_r / hdestroy_r, which are not POSIX
functions.  This patch makes those into weak aliases for __*_r and
uses those names for the calls within libc.

Tested for x86_64 that the disassembly of installed shared libraries
is unchanged by this patch.

	[BZ #17996]
	* include/search.h (hcreate_r): Don't use libc_hidden_proto.
	(hdestroy_r): Likewise.
	(hsearch_r): Likewise.
	(__hcreate_r): Declare and use libc_hidden_proto.
	(__hdestroy_r): Likewise.
	(__hsearch_r): Likewise.
	* misc/hsearch.c (hsearch): Call __hsearch_r instead of hsearch_r.
	(hcreate): Call __hcreate_r instead of hcreate_r.
	(__hdestroy): Call __hdestroy_r instead of hdestroy_r.
	* misc/hsearch_r.c (hcreate_r): Rename to __hcreate_r and define
	as weak alias of __hcreate_r.
	(hdestroy_r): Rename to __hdestroy_r and define as weak alias of
	__hdestroy_r.
	(hsearch_r): Rename to __hsearch_r and define as weak alias of
	__hsearch_r.
	* conform/Makefile (test-xfail-XPG3/search.h/linknamespace):
	Remove variable.
	(test-xfail-XPG4/search.h/linknamespace): Likewise.
	(test-xfail-UNIX98/search.h/linknamespace): Likewise.
	(test-xfail-XOPEN2K/search.h/linknamespace): Likewise.
	(test-xfail-XOPEN2K8/search.h/linknamespace): Likewise.
-rw-r--r--ChangeLog25
-rw-r--r--NEWS2
-rw-r--r--conform/Makefile5
-rw-r--r--include/search.h9
-rw-r--r--misc/hsearch.c6
-rw-r--r--misc/hsearch_r.c15
6 files changed, 44 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 3ada4f6ef0..6589167275 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2015-02-18  Joseph Myers  <joseph@codesourcery.com>
+
+	[BZ #17996]
+	* include/search.h (hcreate_r): Don't use libc_hidden_proto.
+	(hdestroy_r): Likewise.
+	(hsearch_r): Likewise.
+	(__hcreate_r): Declare and use libc_hidden_proto.
+	(__hdestroy_r): Likewise.
+	(__hsearch_r): Likewise.
+	* misc/hsearch.c (hsearch): Call __hsearch_r instead of hsearch_r.
+	(hcreate): Call __hcreate_r instead of hcreate_r.
+	(__hdestroy): Call __hdestroy_r instead of hdestroy_r.
+	* misc/hsearch_r.c (hcreate_r): Rename to __hcreate_r and define
+	as weak alias of __hcreate_r.
+	(hdestroy_r): Rename to __hdestroy_r and define as weak alias of
+	__hdestroy_r.
+	(hsearch_r): Rename to __hsearch_r and define as weak alias of
+	__hsearch_r.
+	* conform/Makefile (test-xfail-XPG3/search.h/linknamespace):
+	Remove variable.
+	(test-xfail-XPG4/search.h/linknamespace): Likewise.
+	(test-xfail-UNIX98/search.h/linknamespace): Likewise.
+	(test-xfail-XOPEN2K/search.h/linknamespace): Likewise.
+	(test-xfail-XOPEN2K8/search.h/linknamespace): Likewise.
+
 2015-02-18  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
 	* malloc/malloc.c (__libc_malloc): Consolidate arena_lookup and
diff --git a/NEWS b/NEWS
index 29af3e9979..0fe66f8d90 100644
--- a/NEWS
+++ b/NEWS
@@ -10,7 +10,7 @@ Version 2.22
 * The following bugs are resolved with this release:
 
   4719, 15467, 15790, 16560, 17569, 17792, 17912, 17932, 17944, 17949,
-  17964, 17965, 17967, 17969, 17978, 17987, 17991.
+  17964, 17965, 17967, 17969, 17978, 17987, 17991, 17996.
 
 Version 2.21
 
diff --git a/conform/Makefile b/conform/Makefile
index c0c0db74a9..39f41bd7c5 100644
--- a/conform/Makefile
+++ b/conform/Makefile
@@ -348,7 +348,6 @@ test-xfail-XOPEN2K8/ndbm.h/linknamespace = yes
 test-xfail-XPG3/fnmatch.h/linknamespace = yes
 test-xfail-XPG3/glob.h/linknamespace = yes
 test-xfail-XPG3/regex.h/linknamespace = yes
-test-xfail-XPG3/search.h/linknamespace = yes
 test-xfail-XPG3/stdio.h/linknamespace = yes
 test-xfail-XPG3/unistd.h/linknamespace = yes
 test-xfail-XPG3/wordexp.h/linknamespace = yes
@@ -357,7 +356,6 @@ test-xfail-XPG4/fnmatch.h/linknamespace = yes
 test-xfail-XPG4/glob.h/linknamespace = yes
 test-xfail-XPG4/netdb.h/linknamespace = yes
 test-xfail-XPG4/regex.h/linknamespace = yes
-test-xfail-XPG4/search.h/linknamespace = yes
 test-xfail-XPG4/stdio.h/linknamespace = yes
 test-xfail-XPG4/stdlib.h/linknamespace = yes
 test-xfail-XPG4/syslog.h/linknamespace = yes
@@ -377,7 +375,6 @@ test-xfail-UNIX98/glob.h/linknamespace = yes
 test-xfail-UNIX98/mqueue.h/linknamespace = yes
 test-xfail-UNIX98/netdb.h/linknamespace = yes
 test-xfail-UNIX98/regex.h/linknamespace = yes
-test-xfail-UNIX98/search.h/linknamespace = yes
 test-xfail-UNIX98/stdio.h/linknamespace = yes
 test-xfail-UNIX98/stdlib.h/linknamespace = yes
 test-xfail-UNIX98/syslog.h/linknamespace = yes
@@ -389,7 +386,6 @@ test-xfail-XOPEN2K/fnmatch.h/linknamespace = yes
 test-xfail-XOPEN2K/glob.h/linknamespace = yes
 test-xfail-XOPEN2K/netdb.h/linknamespace = yes
 test-xfail-XOPEN2K/regex.h/linknamespace = yes
-test-xfail-XOPEN2K/search.h/linknamespace = yes
 test-xfail-XOPEN2K/signal.h/linknamespace = yes
 test-xfail-XOPEN2K/stdlib.h/linknamespace = yes
 test-xfail-XOPEN2K/sys/wait.h/linknamespace = yes
@@ -409,6 +405,5 @@ test-xfail-XOPEN2K8/grp.h/linknamespace = yes
 test-xfail-XOPEN2K8/netdb.h/linknamespace = yes
 test-xfail-XOPEN2K8/pwd.h/linknamespace = yes
 test-xfail-XOPEN2K8/regex.h/linknamespace = yes
-test-xfail-XOPEN2K8/search.h/linknamespace = yes
 test-xfail-XOPEN2K8/syslog.h/linknamespace = yes
 test-xfail-XOPEN2K8/unistd.h/linknamespace = yes
diff --git a/include/search.h b/include/search.h
index cf9c343708..24eafc0f71 100644
--- a/include/search.h
+++ b/include/search.h
@@ -2,9 +2,12 @@
 #include <misc/search.h>
 
 #ifndef _ISOMAC
-libc_hidden_proto (hcreate_r)
-libc_hidden_proto (hdestroy_r)
-libc_hidden_proto (hsearch_r)
+extern __typeof (hcreate_r) __hcreate_r;
+libc_hidden_proto (__hcreate_r)
+extern __typeof (hdestroy_r) __hdestroy_r;
+libc_hidden_proto (__hdestroy_r)
+extern __typeof (hsearch_r) __hsearch_r;
+libc_hidden_proto (__hsearch_r)
 libc_hidden_proto (lfind)
 
 /* Now define the internal interfaces.  */
diff --git a/misc/hsearch.c b/misc/hsearch.c
index 510f170885..7a0b0dc406 100644
--- a/misc/hsearch.c
+++ b/misc/hsearch.c
@@ -30,7 +30,7 @@ hsearch (item, action)
 {
   ENTRY *result;
 
-  (void) hsearch_r (item, action, &result, &htab);
+  (void) __hsearch_r (item, action, &result, &htab);
 
   return result;
 }
@@ -40,14 +40,14 @@ int
 hcreate (nel)
      size_t nel;
 {
-  return hcreate_r (nel, &htab);
+  return __hcreate_r (nel, &htab);
 }
 
 
 void
 __hdestroy (void)
 {
-  hdestroy_r (&htab);
+  __hdestroy_r (&htab);
 }
 weak_alias (__hdestroy, hdestroy)
 
diff --git a/misc/hsearch_r.c b/misc/hsearch_r.c
index 3a7c52682c..9f55e845cf 100644
--- a/misc/hsearch_r.c
+++ b/misc/hsearch_r.c
@@ -62,7 +62,7 @@ isprime (unsigned int number)
    The contents of the table is zeroed, especially the field used
    becomes zero.  */
 int
-hcreate_r (nel, htab)
+__hcreate_r (nel, htab)
      size_t nel;
      struct hsearch_data *htab;
 {
@@ -97,13 +97,14 @@ hcreate_r (nel, htab)
   /* everything went alright */
   return 1;
 }
-libc_hidden_def (hcreate_r)
+libc_hidden_def (__hcreate_r)
+weak_alias (__hcreate_r, hcreate_r)
 
 
 /* After using the hash table it has to be destroyed. The used memory can
    be freed and the local static variable can be marked as not used.  */
 void
-hdestroy_r (htab)
+__hdestroy_r (htab)
      struct hsearch_data *htab;
 {
   /* Test for correct arguments.  */
@@ -119,7 +120,8 @@ hdestroy_r (htab)
   /* the sign for an existing table is an value != NULL in htable */
   htab->table = NULL;
 }
-libc_hidden_def (hdestroy_r)
+libc_hidden_def (__hdestroy_r)
+weak_alias (__hdestroy_r, hdestroy_r)
 
 
 /* This is the search function. It uses double hashing with open addressing.
@@ -136,7 +138,7 @@ libc_hidden_def (hdestroy_r)
    equality of the stored and the parameter value. This helps to prevent
    unnecessary expensive calls of strcmp.  */
 int
-hsearch_r (item, action, retval, htab)
+__hsearch_r (item, action, retval, htab)
      ENTRY item;
      ACTION action;
      ENTRY **retval;
@@ -224,4 +226,5 @@ hsearch_r (item, action, retval, htab)
   *retval = NULL;
   return 0;
 }
-libc_hidden_def (hsearch_r)
+libc_hidden_def (__hsearch_r)
+weak_alias (__hsearch_r, hsearch_r)