Minor tweaks to memset

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5245 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-10-21 05:38:24 +00:00
parent d59b634a70
commit 4796879663
4 changed files with 35 additions and 36 deletions

View File

@ -4452,6 +4452,7 @@ build
<ul><li>
<code>CONFIG_MEMCPY_VIK</code>:
Select this option to use the optimized <code>memcpy()</code> function by Daniel Vik.
Select this option for improved performance at the expense of increased size.
See licensing information in the top-level <code>COPYING</code> file.
Default: <code>n</code>.
</li></ul>

View File

@ -625,8 +625,9 @@ defconfig -- This is a configuration file similar to the Linux
Vik's optimized implementation of memcpy():
CONFIG_MEMCPY_VIK - Select this option to use the optimized memcpy()
function by Daniel Vik. See licensing information in the top-level
COPYING file. Default: n
function by Daniel Vik. Select this option for improved performance
at the expense of increased size. See licensing information in the
top-level COPYING file. Default: n
And if CONFIG_MEMCPY_VIK is selected, the following tuning options are available:
@ -636,7 +637,8 @@ defconfig -- This is a configuration file similar to the Linux
CONFIG_MEMCPY_INDEXED_COPY - Copying data using array indexing. Using
this option, disables the CONFIG_MEMCPY_PRE_INC_PTRS option.
CONFIG_MEMCPY_64BIT - Compiles memcpy for 64 bit architectures
CONFIG_MEMCPY_64BIT - Compiles memcpy for architectures that suppport
64-bit operations efficiently.
If CONFIG_ARCH_MEMSET is not selected, then the following option is
also available:
@ -647,7 +649,8 @@ defconfig -- This is a configuration file similar to the Linux
And if CONFIG_MEMSET_OPTSPEED is selected, the following tuning option is
available:
CONFIG_MEMSET_64BIT - Compiles memset() for 64 bit architectures
CONFIG_MEMSET_64BIT - Compiles memset() for architectures that suppport
64-bit operations efficiently.
The architecture may provide custom versions of certain standard header
files:

View File

@ -165,8 +165,8 @@ config MEMCPY_VIK
depends on !ARCH_MEMCPY
---help---
Select this option to use the optimized memcpy() function by Daniel Vik.
Select this option to option for speed at the expense of increased size.
See licensing information in the top-level COPYING file.
Select this option for improved performance at the expense of increased
size. See licensing information in the top-level COPYING file.
if MEMCPY_VIK
config MEMCPY_PRE_INC_PTRS
@ -186,7 +186,8 @@ config MEMCPY_64BIT
bool "64-bit memcpy()"
default n
---help---
Compiles memcpy() for 64 bit architectures
Compiles memcpy() for architectures that suppport 64-bit operations
efficiently.
endif
@ -224,7 +225,8 @@ config MEMSET_64BIT
default n
depends on MEMSET_OPTSPEED
---help---
Compiles memset() for 64 bit architectures
Compiles memset() for architectures that suppport 64-bit operations
efficiently.
config ARCH_STRCMP
bool "strcmp()"

View File

@ -92,7 +92,7 @@ void *memset(void *s, int c, size_t n)
n -= 1;
}
/* Check if there are at least 16-bits left to be zeroed */
/* Check if there are at least 16-bits left to be written */
if (n >= 2)
{
@ -108,7 +108,7 @@ void *memset(void *s, int c, size_t n)
}
#ifndef CONFIG_MEMSET_64BIT
/* Loop while there are at least 32-bits left to be zeroed */
/* Loop while there are at least 32-bits left to be written */
while (n >= 4)
{
@ -117,7 +117,7 @@ void *memset(void *s, int c, size_t n)
n -= 4;
}
#else
/* Check if there are at least 32-bits left to be zeroed */
/* Check if there are at least 32-bits left to be written */
if (n >= 4)
{
@ -132,7 +132,7 @@ void *memset(void *s, int c, size_t n)
n -= 4;
}
/* Loop while there are at least 64-bits left to be zeroed */
/* Loop while there are at least 64-bits left to be written */
while (n >= 8)
{
@ -165,23 +165,16 @@ void *memset(void *s, int c, size_t n)
* n = 3, addr is aligned to a 32-bit boundary
*/
switch (n)
if (n >= 2)
{
default:
case 0:
DEBUGASSERT(n == 0);
break;
case 2:
*(uint16_t*)addr = val16;
break;
case 3:
*(uint16_t*)addr = val16;
addr += 2;
case 1:
n -= 2;
}
if (n >= 1)
{
*(uint8_t*)addr = (uint8_t)c;
break;
}
}
#else