summaryrefslogtreecommitdiff
path: root/ldso/include/dl-string.h
diff options
context:
space:
mode:
Diffstat (limited to 'ldso/include/dl-string.h')
-rw-r--r--ldso/include/dl-string.h121
1 files changed, 60 insertions, 61 deletions
diff --git a/ldso/include/dl-string.h b/ldso/include/dl-string.h
index d1504f403..b3fdb5b20 100644
--- a/ldso/include/dl-string.h
+++ b/ldso/include/dl-string.h
@@ -33,8 +33,8 @@ static char *_dl_simple_ltoahex(char * local, unsigned long i);
static __always_inline size_t _dl_strlen(const char * str)
{
register const char *ptr = (char *) str-1;
-
- while (*++ptr);
+ while (*++ptr)
+ ;/* empty */
return (ptr - str);
}
@@ -56,7 +56,8 @@ static __always_inline char * _dl_strcpy(char * dst,const char *src)
register char *ptr = dst;
dst--;src--;
- while ((*++dst = *++src) != 0);
+ while ((*++dst = *++src) != 0)
+ ;/* empty */
return ptr;
}
@@ -70,8 +71,7 @@ static __always_inline int _dl_strcmp(const char * s1,const char * s2)
c2 = (unsigned char) *++s2;
if (c1 == '\0')
return c1 - c2;
- }
- while (c1 == c2);
+ } while (c1 == c2);
return c1 - c2;
}
@@ -105,40 +105,38 @@ static __always_inline char * _dl_strchr(const char * str,int c)
return 0;
}
-static inline char * _dl_strrchr(const char *str, int c)
+static __always_inline char * _dl_strrchr(const char *str, int c)
{
- register char *prev = 0;
- register char *ptr = (char *) str-1;
-
- while (*++ptr != '\0') {
- if (*ptr == c)
- prev = ptr;
- }
- if (c == '\0')
- return(ptr);
- return(prev);
+ register char *prev = 0;
+ register char *ptr = (char *) str-1;
+
+ while (*++ptr != '\0') {
+ if (*ptr == c)
+ prev = ptr;
+ }
+ if (c == '\0')
+ return(ptr);
+ return(prev);
}
-static inline char * _dl_strstr(const char *s1, const char *s2)
+static __always_inline char * _dl_strstr(const char *s1, const char *s2)
{
- register const char *s = s1;
- register const char *p = s2;
+ register const char *s = s1;
+ register const char *p = s2;
- do {
- if (!*p) {
- return (char *) s1;;
- }
- if (*p == *s) {
- ++p;
- ++s;
- } else {
- p = s2;
- if (!*s) {
- return NULL;
- }
- s = ++s1;
- }
- } while (1);
+ do {
+ if (!*p)
+ return (char *) s1;;
+ if (*p == *s) {
+ ++p;
+ ++s;
+ } else {
+ p = s2;
+ if (!*s)
+ return NULL;
+ s = ++s1;
+ }
+ } while (1);
}
static __always_inline void * _dl_memcpy(void * dst, const void * src, size_t len)
@@ -170,27 +168,28 @@ static __always_inline int _dl_memcmp(const void * s1,const void * s2,size_t len
/* Will generate smaller and faster code due to loop unrolling.*/
static __always_inline void * _dl_memset(void *to, int c, size_t n)
{
- unsigned long chunks;
- unsigned long *tmp_to;
+ unsigned long chunks;
+ unsigned long *tmp_to;
unsigned char *tmp_char;
- chunks = n / 4;
- tmp_to = to + n;
- c = c << 8 | c;
- c = c << 16 | c;
- if (!chunks)
- goto lessthan4;
- do {
- *--tmp_to = c;
- } while (--chunks);
- lessthan4:
- n = n % 4;
- if (!n ) return to;
- tmp_char = (unsigned char *)tmp_to;
- do {
- *--tmp_char = c;
- } while (--n);
- return to;
+ chunks = n / 4;
+ tmp_to = to + n;
+ c = c << 8 | c;
+ c = c << 16 | c;
+ if (!chunks)
+ goto lessthan4;
+ do {
+ *--tmp_to = c;
+ } while (--chunks);
+lessthan4:
+ n = n % 4;
+ if (!n)
+ return to;
+ tmp_char = (unsigned char *)tmp_to;
+ do {
+ *--tmp_char = c;
+ } while (--n);
+ return to;
}
#else
static __always_inline void * _dl_memset(void * str,int c,size_t len)
@@ -232,10 +231,10 @@ static __always_inline char * _dl_simple_ltoa(char * local, unsigned long i)
char *p = &local[22];
*--p = '\0';
do {
- char temp;
- do_rem(temp, i, 10);
- *--p = '0' + temp;
- i /= 10;
+ char temp;
+ do_rem(temp, i, 10);
+ *--p = '0' + temp;
+ i /= 10;
} while (i > 0);
return p;
}
@@ -249,9 +248,9 @@ static __always_inline char * _dl_simple_ltoahex(char * local, unsigned long i)
do {
char temp = i & 0xf;
if (temp <= 0x09)
- *--p = '0' + temp;
+ *--p = '0' + temp;
else
- *--p = 'a' - 0x0a + temp;
+ *--p = 'a' - 0x0a + temp;
i >>= 4;
} while (i > 0);
*--p = 'x';
@@ -277,8 +276,8 @@ static __always_inline char * _dl_simple_ltoahex(char * local, unsigned long i)
/* On some arches constant strings are referenced through the GOT.
* This requires that load_addr must already be defined... */
-#if defined(mc68000) || defined(__arm__) || defined(__mips__) \
- || defined(__sh__) || defined(__powerpc__)
+#if defined(mc68000) || defined(__arm__) || defined(__mips__) \
+ || defined(__sh__) || defined(__powerpc__)
# define CONSTANT_STRING_GOT_FIXUP(X) \
if ((X) < (const char *) load_addr) (X) += load_addr
# define NO_EARLY_SEND_STDERR