forked from Archive/PX4-Autopilot
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:
parent
d59b634a70
commit
4796879663
|
@ -4452,6 +4452,7 @@ build
|
||||||
<ul><li>
|
<ul><li>
|
||||||
<code>CONFIG_MEMCPY_VIK</code>:
|
<code>CONFIG_MEMCPY_VIK</code>:
|
||||||
Select this option to use the optimized <code>memcpy()</code> function by Daniel Vik.
|
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.
|
See licensing information in the top-level <code>COPYING</code> file.
|
||||||
Default: <code>n</code>.
|
Default: <code>n</code>.
|
||||||
</li></ul>
|
</li></ul>
|
||||||
|
|
|
@ -625,8 +625,9 @@ defconfig -- This is a configuration file similar to the Linux
|
||||||
Vik's optimized implementation of memcpy():
|
Vik's optimized implementation of memcpy():
|
||||||
|
|
||||||
CONFIG_MEMCPY_VIK - Select this option to use the optimized memcpy()
|
CONFIG_MEMCPY_VIK - Select this option to use the optimized memcpy()
|
||||||
function by Daniel Vik. See licensing information in the top-level
|
function by Daniel Vik. Select this option for improved performance
|
||||||
COPYING file. Default: n
|
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:
|
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
|
CONFIG_MEMCPY_INDEXED_COPY - Copying data using array indexing. Using
|
||||||
this option, disables the CONFIG_MEMCPY_PRE_INC_PTRS option.
|
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
|
If CONFIG_ARCH_MEMSET is not selected, then the following option is
|
||||||
also available:
|
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
|
And if CONFIG_MEMSET_OPTSPEED is selected, the following tuning option is
|
||||||
available:
|
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
|
The architecture may provide custom versions of certain standard header
|
||||||
files:
|
files:
|
||||||
|
|
|
@ -165,8 +165,8 @@ config MEMCPY_VIK
|
||||||
depends on !ARCH_MEMCPY
|
depends on !ARCH_MEMCPY
|
||||||
---help---
|
---help---
|
||||||
Select this option to use the optimized memcpy() function by Daniel Vik.
|
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.
|
Select this option for improved performance at the expense of increased
|
||||||
See licensing information in the top-level COPYING file.
|
size. See licensing information in the top-level COPYING file.
|
||||||
|
|
||||||
if MEMCPY_VIK
|
if MEMCPY_VIK
|
||||||
config MEMCPY_PRE_INC_PTRS
|
config MEMCPY_PRE_INC_PTRS
|
||||||
|
@ -186,7 +186,8 @@ config MEMCPY_64BIT
|
||||||
bool "64-bit memcpy()"
|
bool "64-bit memcpy()"
|
||||||
default n
|
default n
|
||||||
---help---
|
---help---
|
||||||
Compiles memcpy() for 64 bit architectures
|
Compiles memcpy() for architectures that suppport 64-bit operations
|
||||||
|
efficiently.
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -224,7 +225,8 @@ config MEMSET_64BIT
|
||||||
default n
|
default n
|
||||||
depends on MEMSET_OPTSPEED
|
depends on MEMSET_OPTSPEED
|
||||||
---help---
|
---help---
|
||||||
Compiles memset() for 64 bit architectures
|
Compiles memset() for architectures that suppport 64-bit operations
|
||||||
|
efficiently.
|
||||||
|
|
||||||
config ARCH_STRCMP
|
config ARCH_STRCMP
|
||||||
bool "strcmp()"
|
bool "strcmp()"
|
||||||
|
|
|
@ -92,7 +92,7 @@ void *memset(void *s, int c, size_t n)
|
||||||
n -= 1;
|
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)
|
if (n >= 2)
|
||||||
{
|
{
|
||||||
|
@ -108,7 +108,7 @@ void *memset(void *s, int c, size_t n)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CONFIG_MEMSET_64BIT
|
#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)
|
while (n >= 4)
|
||||||
{
|
{
|
||||||
|
@ -117,7 +117,7 @@ void *memset(void *s, int c, size_t n)
|
||||||
n -= 4;
|
n -= 4;
|
||||||
}
|
}
|
||||||
#else
|
#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)
|
if (n >= 4)
|
||||||
{
|
{
|
||||||
|
@ -132,7 +132,7 @@ void *memset(void *s, int c, size_t n)
|
||||||
n -= 4;
|
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)
|
while (n >= 8)
|
||||||
{
|
{
|
||||||
|
@ -145,16 +145,16 @@ void *memset(void *s, int c, size_t n)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_MEMSET_64BIT
|
#ifdef CONFIG_MEMSET_64BIT
|
||||||
/* We may get here with n in the range 0..7. If n >= 4, then we should
|
/* We may get here with n in the range 0..7. If n >= 4, then we should
|
||||||
* have 64-bit alignment.
|
* have 64-bit alignment.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (n >= 4)
|
if (n >= 4)
|
||||||
{
|
{
|
||||||
*(uint32_t*)addr = val32;
|
*(uint32_t*)addr = val32;
|
||||||
addr += 4;
|
addr += 4;
|
||||||
n -= 4;
|
n -= 4;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* We may get here under the following conditions:
|
/* We may get here under the following conditions:
|
||||||
|
@ -165,23 +165,16 @@ void *memset(void *s, int c, size_t n)
|
||||||
* n = 3, addr is aligned to a 32-bit boundary
|
* n = 3, addr is aligned to a 32-bit boundary
|
||||||
*/
|
*/
|
||||||
|
|
||||||
switch (n)
|
if (n >= 2)
|
||||||
{
|
{
|
||||||
default:
|
*(uint16_t*)addr = val16;
|
||||||
case 0:
|
addr += 2;
|
||||||
DEBUGASSERT(n == 0);
|
n -= 2;
|
||||||
break;
|
}
|
||||||
|
|
||||||
case 2:
|
if (n >= 1)
|
||||||
*(uint16_t*)addr = val16;
|
{
|
||||||
break;
|
*(uint8_t*)addr = (uint8_t)c;
|
||||||
|
|
||||||
case 3:
|
|
||||||
*(uint16_t*)addr = val16;
|
|
||||||
addr += 2;
|
|
||||||
case 1:
|
|
||||||
*(uint8_t*)addr = (uint8_t)c;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue