mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Use builtins for byteswapping
Make use of XCHG/BSWAP on x86, REV16 and REV on ARMv6-m and above, and whatever other optimized instructions on other platforms. Defines extra CONFIG variables, and removes the unused functions for endian-swapping. Fixes some oversights in using the macros.
This commit is contained in:
committed by
Xiang Xiao
parent
7e6d93da4d
commit
903a186304
@@ -55,7 +55,9 @@ int ffs(int j)
|
||||
|
||||
if (j != 0)
|
||||
{
|
||||
#ifdef CONFIG_HAVE_BUILTIN_CTZ
|
||||
#ifdef CONFIG_HAVE_BUILTIN_FFS
|
||||
ret = __builtin_ffs(j);
|
||||
#elif defined (CONFIG_HAVE_BUILTIN_CTZ)
|
||||
/* Count trailing zeros function can be used to implement ffs. */
|
||||
|
||||
ret = __builtin_ctz(j) + 1;
|
||||
|
||||
@@ -55,7 +55,9 @@ int ffsl(long j)
|
||||
|
||||
if (j != 0)
|
||||
{
|
||||
#ifdef CONFIG_HAVE_BUILTIN_CTZ
|
||||
#ifdef CONFIG_HAVE_BUILTIN_FFSL
|
||||
ret = __builtin_ffsl(j);
|
||||
#elif defined (CONFIG_HAVE_BUILTIN_CTZ)
|
||||
/* Count trailing zeros function can be used to implement ffs. */
|
||||
|
||||
ret = __builtin_ctzl(j) + 1;
|
||||
|
||||
@@ -57,7 +57,9 @@ int ffsll(long long j)
|
||||
|
||||
if (j != 0)
|
||||
{
|
||||
#ifdef CONFIG_HAVE_BUILTIN_CTZ
|
||||
#ifdef CONFIG_HAVE_BUILTIN_FFSLL
|
||||
ret = __builtin_ffsll(j);
|
||||
#elif defined (CONFIG_HAVE_BUILTIN_CTZ)
|
||||
/* Count trailing zeros function can be used to implement ffs. */
|
||||
|
||||
ret = __builtin_ctzll(j) + 1;
|
||||
|
||||
Reference in New Issue
Block a user