summaryrefslogtreecommitdiff
path: root/libc/misc/search
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc/search')
-rw-r--r--libc/misc/search/hsearch.c8
-rw-r--r--libc/misc/search/hsearch_r.c25
-rw-r--r--libc/misc/search/lsearch.c13
-rw-r--r--libc/misc/search/tsearch.c16
4 files changed, 36 insertions, 26 deletions
diff --git a/libc/misc/search/hsearch.c b/libc/misc/search/hsearch.c
index a9400f3ca..b369408cb 100644
--- a/libc/misc/search/hsearch.c
+++ b/libc/misc/search/hsearch.c
@@ -17,16 +17,16 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define hdestroy_r __hdestroy_r
-#define hsearch_r __hsearch_r
-#define hcreate_r __hcreate_r
-
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <search.h>
+libc_hidden_proto(hdestroy_r)
+libc_hidden_proto(hsearch_r)
+libc_hidden_proto(hcreate_r)
+
/* The non-reentrant version use a global space for storing the table. */
static struct hsearch_data htab;
diff --git a/libc/misc/search/hsearch_r.c b/libc/misc/search/hsearch_r.c
index d297b3280..47ff185d4 100644
--- a/libc/misc/search/hsearch_r.c
+++ b/libc/misc/search/hsearch_r.c
@@ -67,7 +67,7 @@ static int isprime (unsigned int number)
indexing as explained in the comment for the hsearch function.
The contents of the table is zeroed, especially the field used
becomes zero. */
-int attribute_hidden __hcreate_r (size_t nel, struct hsearch_data *htab)
+int hcreate_r (size_t nel, struct hsearch_data *htab)
{
/* Test for correct arguments. */
if (htab == NULL)
@@ -96,13 +96,14 @@ int attribute_hidden __hcreate_r (size_t nel, struct hsearch_data *htab)
/* everything went alright */
return 1;
}
-strong_alias(__hcreate_r,hcreate_r)
+libc_hidden_proto(hcreate_r)
+libc_hidden_def(hcreate_r)
#endif
#ifdef L_hdestroy_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 attribute_hidden __hdestroy_r (struct hsearch_data *htab)
+void hdestroy_r (struct hsearch_data *htab)
{
/* Test for correct arguments. */
if (htab == NULL)
@@ -118,7 +119,8 @@ void attribute_hidden __hdestroy_r (struct hsearch_data *htab)
/* the sign for an existing table is an value != NULL in htable */
htab->table = NULL;
}
-strong_alias(__hdestroy_r,hdestroy_r)
+libc_hidden_proto(hdestroy_r)
+libc_hidden_def(hdestroy_r)
#endif
#ifdef L_hsearch_r
@@ -135,12 +137,16 @@ strong_alias(__hdestroy_r,hdestroy_r)
means used. The used field can be used as a first fast comparison for
equality of the stored and the parameter value. This helps to prevent
unnecessary expensive calls of strcmp. */
-int attribute_hidden __hsearch_r (ENTRY item, ACTION action, ENTRY **retval,
+
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strlen)
+
+int hsearch_r (ENTRY item, ACTION action, ENTRY **retval,
struct hsearch_data *htab)
{
unsigned int hval;
unsigned int count;
- unsigned int len = __strlen (item.key);
+ unsigned int len = strlen (item.key);
unsigned int idx;
/* Compute an value for the given string. Perhaps use a better method. */
@@ -166,7 +172,7 @@ int attribute_hidden __hsearch_r (ENTRY item, ACTION action, ENTRY **retval,
unsigned hval2;
if (htab->table[idx].used == hval
- && __strcmp (item.key, htab->table[idx].entry.key) == 0)
+ && strcmp (item.key, htab->table[idx].entry.key) == 0)
{
*retval = &htab->table[idx].entry;
return 1;
@@ -190,7 +196,7 @@ int attribute_hidden __hsearch_r (ENTRY item, ACTION action, ENTRY **retval,
/* If entry is found use it. */
if (htab->table[idx].used == hval
- && __strcmp (item.key, htab->table[idx].entry.key) == 0)
+ && strcmp (item.key, htab->table[idx].entry.key) == 0)
{
*retval = &htab->table[idx].entry;
return 1;
@@ -224,5 +230,6 @@ int attribute_hidden __hsearch_r (ENTRY item, ACTION action, ENTRY **retval,
*retval = NULL;
return 0;
}
-strong_alias(__hsearch_r,hsearch_r)
+libc_hidden_proto(hsearch_r)
+libc_hidden_def(hsearch_r)
#endif
diff --git a/libc/misc/search/lsearch.c b/libc/misc/search/lsearch.c
index 4071cf1ab..eefef2121 100644
--- a/libc/misc/search/lsearch.c
+++ b/libc/misc/search/lsearch.c
@@ -12,9 +12,11 @@
#include <stdio.h>
#include <search.h>
+libc_hidden_proto(lfind)
+
#ifdef L_lfind
-void attribute_hidden *__lfind(const void *key, const void *base, size_t *nmemb,
+void *lfind(const void *key, const void *base, size_t *nmemb,
size_t size, int (*compar)(const void *, const void *))
{
register int n = *nmemb;
@@ -26,22 +28,21 @@ void attribute_hidden *__lfind(const void *key, const void *base, size_t *nmemb,
}
return (NULL);
}
-strong_alias(__lfind,lfind)
+libc_hidden_def(lfind)
#endif
#ifdef L_lsearch
-extern void *__lfind (__const void *__key, __const void *__base,
- size_t *__nmemb, size_t __size, __compar_fn_t __compar) attribute_hidden;
+libc_hidden_proto(memcpy)
void *lsearch(const void *key, void *base, size_t *nmemb,
size_t size, int (*compar)(const void *, const void *))
{
register char *p;
- if ((p = __lfind(key, base, nmemb, size, compar)) == NULL) {
- p = __memcpy((base + (size * (*nmemb))), key, size);
+ if ((p = lfind(key, base, nmemb, size, compar)) == NULL) {
+ p = memcpy((base + (size * (*nmemb))), key, size);
++(*nmemb);
}
return (p);
diff --git a/libc/misc/search/tsearch.c b/libc/misc/search/tsearch.c
index 58f16ab79..47d409468 100644
--- a/libc/misc/search/tsearch.c
+++ b/libc/misc/search/tsearch.c
@@ -51,7 +51,7 @@ register node **rootp; address of tree root
int (*compar)(); ordering function
*/
-void attribute_hidden *__tsearch(__const void *key, void **vrootp, __compar_fn_t compar)
+void *tsearch(__const void *key, void **vrootp, __compar_fn_t compar)
{
register node *q;
register node **rootp = (node **) vrootp;
@@ -77,11 +77,12 @@ void attribute_hidden *__tsearch(__const void *key, void **vrootp, __compar_fn_t
}
return (q);
}
-strong_alias(__tsearch,tsearch)
+libc_hidden_proto(tsearch)
+libc_hidden_def(tsearch)
#endif
#ifdef L_tfind
-void attribute_hidden *__tfind(__const void *key, void * __const *vrootp, __compar_fn_t compar)
+void *tfind(__const void *key, void * __const *vrootp, __compar_fn_t compar)
{
register node **rootp = (node **) vrootp;
@@ -99,7 +100,8 @@ void attribute_hidden *__tfind(__const void *key, void * __const *vrootp, __comp
}
return NULL;
}
-strong_alias(__tfind,tfind)
+libc_hidden_proto(tfind)
+libc_hidden_def(tfind)
#endif
#ifdef L_tdelete
@@ -206,15 +208,15 @@ tdestroy_recurse (node *root, __free_fn_t freefct)
free (root);
}
-void attribute_hidden __tdestroy (void *vroot, __free_fn_t freefct)
+void tdestroy (void *vroot, __free_fn_t freefct)
{
node *root = (node *) vroot;
if (root != NULL) {
tdestroy_recurse (root, freefct);
}
}
-strong_alias(__tdestroy,tdestroy)
+libc_hidden_proto(tdestroy)
+libc_hidden_def(tdestroy)
#endif
/* tsearch.c ends here */
-