OSDN Git Service

libdl.c,dl-string.h: do not use inlined _dl_memset and others in libdl
authorPeter S. Mazinger <ps.m@gmx.net>
Thu, 24 Mar 2011 09:32:10 +0000 (10:32 +0100)
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Fri, 15 Jun 2012 12:00:32 +0000 (14:00 +0200)
Use the one from libc.
While there, remove unused _dl_strncmp() and superfluos static forward declarations.

Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
ldso/include/dl-string.h
ldso/libdl/libdl.c

index a7e2f47..dc96533 100644 (file)
 # define do_div_10(result, remain) ((result) /= 10)
 #endif
 
-static size_t _dl_strlen(const char *str);
-static char *_dl_strcat(char *dst, const char *src);
-static char *_dl_strcpy(char *dst, const char *src);
-static int _dl_strcmp(const char *s1, const char *s2);
-static int _dl_strncmp(const char *s1, const char *s2, size_t len);
-static char *_dl_strchr(const char *str, int c);
-static char *_dl_strrchr(const char *str, int c);
-static char *_dl_strstr(const char *s1, const char *s2);
-static void *_dl_memcpy(void *dst, const void *src, size_t len);
-static int _dl_memcmp(const void *s1, const void *s2, size_t len);
-static void *_dl_memset(void *str, int c, size_t len);
-static char *_dl_get_last_path_component(char *path);
-static char *_dl_simple_ltoa(char *local, unsigned long i);
-static char *_dl_simple_ltoahex(char *local, unsigned long i);
-
 #ifndef NULL
 #define NULL ((void *) 0)
 #endif
 
+#ifndef IS_IN_libdl
 static __always_inline size_t _dl_strlen(const char *str)
 {
        register const char *ptr = (char *) str-1;
@@ -84,22 +70,6 @@ static __always_inline int _dl_strcmp(const char *s1, const char *s2)
        return c1 - c2;
 }
 
-static __always_inline int _dl_strncmp(const char *s1, const char *s2, size_t len)
-{
-       register unsigned char c1 = '\0';
-       register unsigned char c2 = '\0';
-
-       s1--;s2--;
-       while (len > 0) {
-               c1 = (unsigned char) *++s1;
-               c2 = (unsigned char) *++s2;
-               if (c1 == '\0' || c1 != c2)
-                       return c1 - c2;
-               len--;
-       }
-       return c1 - c2;
-}
-
 static __always_inline char * _dl_strchr(const char *str, int c)
 {
        register char ch;
@@ -228,6 +198,17 @@ static __always_inline char * _dl_get_last_path_component(char *path)
                ;/* empty */
        return ptr == path ? ptr : ptr+1;
 }
+#else /* IS_IN_libdl */
+# define _dl_strlen strlen
+# define _dl_strcat strcat
+# define _dl_strcpy strcpy
+# define _dl_strcmp strcmp
+# define _dl_strrchr strrchr
+# define _dl_strstr strstr
+# define _dl_memcpy memcpy
+# define _dl_memcmp memcmp
+# define _dl_memset memset
+#endif /* IS_IN_libdl */
 
 /* Early on, we can't call printf, so use this to print out
  * numbers using the SEND_STDERR() macro.  Avoid using mod
index 51bcf7d..540dd94 100644 (file)
@@ -32,7 +32,7 @@
 
 #include <ldso.h>
 #include <stdio.h>
-#include <string.h> /* Needed for 'strstr' prototype' */
+#include <string.h>
 #include <stdbool.h>
 #include <bits/uClibc_mutex.h>
 
@@ -393,7 +393,7 @@ static void *do_dlopen(const char *libname, int flag)
                return NULL;
        }
        dyn_chain = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
-       _dl_memset(dyn_chain, 0, sizeof(struct dyn_elf));
+       memset(dyn_chain, 0, sizeof(struct dyn_elf));
        dyn_chain->dyn = tpnt;
        tpnt->rtld_flags |= (flag & RTLD_GLOBAL);
 
@@ -444,7 +444,7 @@ static void *do_dlopen(const char *libname, int flag)
 
                                /* This list is for dlsym() and relocation */
                                dyn_ptr->next = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
-                               _dl_memset (dyn_ptr->next, 0, sizeof (struct dyn_elf));
+                               memset (dyn_ptr->next, 0, sizeof (struct dyn_elf));
                                dyn_ptr = dyn_ptr->next;
                                dyn_ptr->dyn = tpnt1;
                                /* Used to record RTLD_LOCAL scope */