[git commit future 1/1] libdl.c, dl-string.h: do not use inlined _dl_memset and others in libdl

Khem Raj raj.khem at gmail.com
Sat Mar 19 18:51:25 UTC 2011


commit: http://git.uclibc.org/uClibc/commit/?id=051c6fa29374ffa552703f277ce14814f12a7deb
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/future

Use the one from libc.
While there, remove unused _dl_strncmp() and superfluos static forward declarations.

Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
---
 ldso/include/dl-string.h |   43 ++++++++++++-------------------------------
 ldso/libdl/libdl.c       |    6 +++---
 2 files changed, 15 insertions(+), 34 deletions(-)

diff --git a/ldso/include/dl-string.h b/ldso/include/dl-string.h
index 01ab50e..4d1fdb7 100644
--- a/ldso/include/dl-string.h
+++ b/ldso/include/dl-string.h
@@ -19,25 +19,11 @@
 # 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
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 68cd579..c3c2ddb 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -32,7 +32,7 @@
 
 #include <ldso.h>
 #include <stdio.h>
-#include <string.h> /* Needed for 'strstr' prototype' */
+#include <string.h>
 #include <stdbool.h>
 
 #ifdef __UCLIBC_HAS_TLS__
@@ -365,7 +365,7 @@ void *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);
 
@@ -416,7 +416,7 @@ void *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 */
-- 
1.7.3.4



More information about the uClibc-cvs mailing list