mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 09:18:00 +08:00
nuttx/libc: Fix some spacing and alignment issues
This commit is contained in:
@@ -68,8 +68,8 @@
|
||||
|
||||
FAR void *memccpy(FAR void *s1, FAR const void *s2, int c, size_t n)
|
||||
{
|
||||
FAR unsigned char *pout = (FAR unsigned char*)s1;
|
||||
FAR unsigned char *pin = (FAR unsigned char*)s2;
|
||||
FAR unsigned char *pout = (FAR unsigned char *)s1;
|
||||
FAR unsigned char *pin = (FAR unsigned char *)s2;
|
||||
|
||||
/* Copy at most n bytes */
|
||||
|
||||
|
||||
@@ -56,8 +56,8 @@
|
||||
#ifndef CONFIG_ARCH_MEMCPY
|
||||
FAR void *memcpy(FAR void *dest, FAR const void *src, size_t n)
|
||||
{
|
||||
FAR unsigned char *pout = (FAR unsigned char*)dest;
|
||||
FAR unsigned char *pin = (FAR unsigned char*)src;
|
||||
FAR unsigned char *pout = (FAR unsigned char *)dest;
|
||||
FAR unsigned char *pin = (FAR unsigned char *)src;
|
||||
while (n-- > 0) *pout++ = *pin++;
|
||||
return dest;
|
||||
}
|
||||
|
||||
@@ -52,11 +52,14 @@
|
||||
#ifndef CONFIG_ARCH_MEMMOVE
|
||||
FAR void *memmove(FAR void *dest, FAR const void *src, size_t count)
|
||||
{
|
||||
char *tmp, *s;
|
||||
FAR char *tmp;
|
||||
FAR char *s;
|
||||
|
||||
if (dest <= src)
|
||||
{
|
||||
tmp = (char*) dest;
|
||||
s = (char*) src;
|
||||
tmp = (FAR char *) dest;
|
||||
s = (FAR char *) src;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
*tmp++ = *s++;
|
||||
@@ -64,8 +67,9 @@ FAR void *memmove(FAR void *dest, FAR const void *src, size_t count)
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = (char*) dest + count;
|
||||
s = (char*) src + count;
|
||||
tmp = (FAR char *) dest + count;
|
||||
s = (FAR char *) src + count;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
*--tmp = *--s;
|
||||
|
||||
+10
-10
@@ -64,7 +64,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_ARCH_MEMSET
|
||||
void *memset(void *s, int c, size_t n)
|
||||
FAR void *memset(FAR void *s, int c, size_t n)
|
||||
{
|
||||
#ifdef CONFIG_MEMSET_OPTSPEED
|
||||
/* This version is optimized for speed (you could do better
|
||||
@@ -87,7 +87,7 @@ void *memset(void *s, int c, size_t n)
|
||||
|
||||
if ((addr & 1) != 0)
|
||||
{
|
||||
*(uint8_t*)addr = (uint8_t)c;
|
||||
*(FAR uint8_t *)addr = (uint8_t)c;
|
||||
addr += 1;
|
||||
n -= 1;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ void *memset(void *s, int c, size_t n)
|
||||
|
||||
if ((addr & 3) != 0)
|
||||
{
|
||||
*(uint16_t*)addr = val16;
|
||||
*(FAR uint16_t *)addr = val16;
|
||||
addr += 2;
|
||||
n -= 2;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ void *memset(void *s, int c, size_t n)
|
||||
|
||||
while (n >= 4)
|
||||
{
|
||||
*(uint32_t*)addr = val32;
|
||||
*(FAR uint32_t *)addr = val32;
|
||||
addr += 4;
|
||||
n -= 4;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ void *memset(void *s, int c, size_t n)
|
||||
|
||||
if ((addr & 7) != 0)
|
||||
{
|
||||
*(uint32_t*)addr = val32;
|
||||
*(FAR uint32_t *)addr = val32;
|
||||
addr += 4;
|
||||
n -= 4;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ void *memset(void *s, int c, size_t n)
|
||||
|
||||
while (n >= 8)
|
||||
{
|
||||
*(uint64_t*)addr = val64;
|
||||
*(FAR uint64_t *)addr = val64;
|
||||
addr += 8;
|
||||
n -= 8;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ void *memset(void *s, int c, size_t n)
|
||||
|
||||
if (n >= 4)
|
||||
{
|
||||
*(uint32_t*)addr = val32;
|
||||
*(FAR uint32_t *)addr = val32;
|
||||
addr += 4;
|
||||
n -= 4;
|
||||
}
|
||||
@@ -167,20 +167,20 @@ void *memset(void *s, int c, size_t n)
|
||||
|
||||
if (n >= 2)
|
||||
{
|
||||
*(uint16_t*)addr = val16;
|
||||
*(FAR uint16_t *)addr = val16;
|
||||
addr += 2;
|
||||
n -= 2;
|
||||
}
|
||||
|
||||
if (n >= 1)
|
||||
{
|
||||
*(uint8_t*)addr = (uint8_t)c;
|
||||
*(FAR uint8_t *)addr = (uint8_t)c;
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* This version is optimized for size */
|
||||
|
||||
unsigned char *p = (unsigned char*)s;
|
||||
FAR unsigned char *p = (FAR unsigned char*)s;
|
||||
while (n-- > 0) *p++ = c;
|
||||
#endif
|
||||
return s;
|
||||
|
||||
@@ -47,10 +47,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_ARCH_STRCMP
|
||||
int strcasecmp(const char *cs, const char *ct)
|
||||
int strcasecmp(FAR const char *cs, FAR const char *ct)
|
||||
{
|
||||
int result;
|
||||
for (;;)
|
||||
for (; ; )
|
||||
{
|
||||
if ((result = (int)toupper(*cs) - (int)toupper(*ct)) != 0 || !*cs)
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ static FAR char *strcasechr(FAR const char *s, int uc)
|
||||
ch = *s;
|
||||
if (toupper(ch) == uc)
|
||||
{
|
||||
return (FAR char*)s;
|
||||
return (FAR char *)s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,9 +71,9 @@ static FAR char *strcasechr(FAR const char *s, int uc)
|
||||
|
||||
FAR char *strcasestr(FAR const char *str, FAR const char *substr)
|
||||
{
|
||||
const char *candidate; /* Candidate in str with matching start character */
|
||||
char ch; /* First character of the substring */
|
||||
int len; /* The length of the substring */
|
||||
FAR const char *candidate; /* Candidate in str with matching start character */
|
||||
char ch; /* First character of the substring */
|
||||
int len; /* The length of the substring */
|
||||
|
||||
/* Special case the empty substring */
|
||||
|
||||
@@ -86,7 +86,7 @@ FAR char *strcasestr(FAR const char *str, FAR const char *substr)
|
||||
* the string
|
||||
*/
|
||||
|
||||
return (char*)str;
|
||||
return (FAR char *)str;
|
||||
}
|
||||
|
||||
/* Search for the substring */
|
||||
@@ -94,7 +94,7 @@ FAR char *strcasestr(FAR const char *str, FAR const char *substr)
|
||||
candidate = str;
|
||||
ch = toupper(ch);
|
||||
|
||||
for (;;)
|
||||
for (; ; )
|
||||
{
|
||||
/* strcasechr() will return a pointer to the next occurrence of the
|
||||
* character ch in the string (ignoring case)
|
||||
@@ -103,23 +103,23 @@ FAR char *strcasestr(FAR const char *str, FAR const char *substr)
|
||||
candidate = strcasechr(candidate, ch);
|
||||
if (!candidate || strlen(candidate) < len)
|
||||
{
|
||||
/* First character of the substring does not appear in the string
|
||||
* or the remainder of the string is not long enough to contain the
|
||||
* substring.
|
||||
*/
|
||||
/* First character of the substring does not appear in the string
|
||||
* or the remainder of the string is not long enough to contain the
|
||||
* substring.
|
||||
*/
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Check if this is the beginning of a matching substring (ignoring case) */
|
||||
|
||||
if (strncasecmp(candidate, substr, len) == 0)
|
||||
{
|
||||
/* Yes.. return the pointer to the first occurrence of the matching
|
||||
* substring.
|
||||
*/
|
||||
/* Yes.. return the pointer to the first occurrence of the matching
|
||||
* substring.
|
||||
*/
|
||||
|
||||
return (char*)candidate;
|
||||
return (FAR char *)candidate;
|
||||
}
|
||||
|
||||
/* No, find the next candidate after this one */
|
||||
|
||||
@@ -46,10 +46,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_ARCH_STRCMP
|
||||
int strcmp(const char *cs, const char *ct)
|
||||
int strcmp(FAR const char *cs, FAR const char *ct)
|
||||
{
|
||||
register signed char result;
|
||||
for (;;)
|
||||
for (; ; )
|
||||
{
|
||||
if ((result = *cs - *ct++) != 0 || !*cs++)
|
||||
break;
|
||||
|
||||
@@ -47,12 +47,12 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
FAR char *strdup(const char *s)
|
||||
FAR char *strdup(FAR const char *s)
|
||||
{
|
||||
FAR char *news = NULL;
|
||||
if (s)
|
||||
{
|
||||
news = (FAR char*)lib_malloc(strlen(s) + 1);
|
||||
news = (FAR char *)lib_malloc(strlen(s) + 1);
|
||||
if (news)
|
||||
{
|
||||
strcpy(news, s);
|
||||
|
||||
@@ -74,7 +74,7 @@ FAR char *strndup(FAR const char *s, size_t size)
|
||||
|
||||
/* Allocate the new string, adding 1 for the NUL terminator */
|
||||
|
||||
news = (FAR char*)lib_malloc(allocsize + 1);
|
||||
news = (FAR char *)lib_malloc(allocsize + 1);
|
||||
if (news)
|
||||
{
|
||||
/* Copy the string into the allocated memory and add a NUL
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
char *strpbrk(const char *str, const char *charset)
|
||||
FAR char *strpbrk(FAR const char *str, FAR const char *charset)
|
||||
{
|
||||
/* Sanity checking */
|
||||
|
||||
@@ -66,7 +66,7 @@ char *strpbrk(const char *str, const char *charset)
|
||||
{
|
||||
/* Yes, then this position must be the first occurrence in string */
|
||||
|
||||
return (char*)str;
|
||||
return (FAR char *)str;
|
||||
}
|
||||
|
||||
/* This character from the strings matches none of those in the charset.
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
* occurrence of the character c in the string s.
|
||||
*/
|
||||
|
||||
char *strrchr(const char *s, int c)
|
||||
FAR char *strrchr(FAR const char *s, int c)
|
||||
{
|
||||
if (s)
|
||||
{
|
||||
@@ -58,7 +58,7 @@ char *strrchr(const char *s, int c)
|
||||
{
|
||||
if (*p == c)
|
||||
{
|
||||
return (char*)p;
|
||||
return (FAR char *)p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,13 +62,13 @@ FAR char *strstr(FAR const char *str, FAR const char *substr)
|
||||
* the string
|
||||
*/
|
||||
|
||||
return (char*)str;
|
||||
return (FAR char *)str;
|
||||
}
|
||||
|
||||
/* Search for the substring */
|
||||
|
||||
candidate = str;
|
||||
for (;;)
|
||||
for (; ; )
|
||||
{
|
||||
/* strchr() will return a pointer to the next occurrence of the
|
||||
* character ch in the string
|
||||
@@ -77,19 +77,19 @@ FAR char *strstr(FAR const char *str, FAR const char *substr)
|
||||
candidate = strchr(candidate, ch);
|
||||
if (!candidate || strlen(candidate) < len)
|
||||
{
|
||||
/* First character of the substring does not appear in the string
|
||||
* or the remainder of the string is not long enough to contain the
|
||||
* substring.
|
||||
*/
|
||||
/* First character of the substring does not appear in the string
|
||||
* or the remainder of the string is not long enough to contain the
|
||||
* substring.
|
||||
*/
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Check if this is the beginning of a matching substring */
|
||||
|
||||
if (strncmp(candidate, substr, len) == 0)
|
||||
{
|
||||
return (char*)candidate;
|
||||
return (FAR char *)candidate;
|
||||
}
|
||||
|
||||
/* No, find the next candidate after this one */
|
||||
|
||||
@@ -310,10 +310,10 @@ typedef uint32_t UIntN;
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void *memcpy(void *dest, const void *src, size_t count)
|
||||
FAR void *memcpy(FAR void *dest, FAR const void *src, size_t count)
|
||||
{
|
||||
uint8_t *dst8 = (uint8_t*)dest;
|
||||
uint8_t *src8 = (uint8_t*)src;
|
||||
FAR uint8_t *dst8 = (FAR uint8_t *)dest;
|
||||
FAR uint8_t *src8 = (FAR uint8_t *)src;
|
||||
|
||||
if (count < 8)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user