You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/04/14 13:46:20 UTC
[incubator-nuttx] 02/03: libc/string:delete small to big endian marco
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit fa9ad9b398261bab6d31ff57a7ceb8732be2532b
Author: haopengxiang <ha...@xiaomi.com>
AuthorDate: Tue Jul 6 20:46:56 2021 +0800
libc/string:delete small to big endian marco
avoid byte alignment
Signed-off-by: haopengxiang <ha...@xiaomi.com>
Signed-off-by: anjiahao <an...@xiaomi.com>
---
libs/libc/string/lib_strstr.c | 28 +---------------------------
1 file changed, 1 insertion(+), 27 deletions(-)
diff --git a/libs/libc/string/lib_strstr.c b/libs/libc/string/lib_strstr.c
index ab7bfd7cc1..4c49583e6b 100644
--- a/libs/libc/string/lib_strstr.c
+++ b/libs/libc/string/lib_strstr.c
@@ -32,22 +32,7 @@
* Pre-processor Definitions
****************************************************************************/
-#if LONG_MAX == INT32_MAX
- #define LONG_INT_IS_4_BYTES 1
- #define LONG_INT_N_BYTES 4
-#else
- #define LONG_INT_N_BYTES sizeof(long)
-#endif
-
-/* Determine the size, in bytes, of a long integer. */
-
-#if defined (CONFIG_ENDIAN_BIG)
- #define ULONG_BIGENDIAN(x) (x)
-#elif defined (LONG_INT_IS_4_BYTES)
- #define ULONG_BIGENDIAN(x) htonl(x)
-#else
- #undef ULONG_BIGENDIAN
-#endif
+#define LONG_INT_N_BYTES sizeof(long)
/****************************************************************************
* Public Functions
@@ -59,9 +44,7 @@
FAR char *strstr(FAR const char *haystack, FAR const char *needle)
{
-#ifndef ULONG_BIGENDIAN
FAR const unsigned char *needle_cmp_end;
-#endif
FAR const unsigned char *i_haystack;
const char needle_first = *needle;
FAR const unsigned char *i_needle;
@@ -126,14 +109,6 @@ FAR char *strstr(FAR const char *haystack, FAR const char *needle)
needle_cmp_len = (needle_len < LONG_INT_N_BYTES) ?
needle_len : LONG_INT_N_BYTES;
-#ifdef ULONG_BIGENDIAN
- last_needle_chars =
- ULONG_BIGENDIAN(*((FAR unsigned long *)(i_needle - needle_cmp_len)))
- >> (8 * (LONG_INT_N_BYTES - needle_cmp_len));
- last_haystack_chars =
- ULONG_BIGENDIAN(*((FAR unsigned long *)(i_haystack - needle_cmp_len)))
- >> (8 * (LONG_INT_N_BYTES - needle_cmp_len));
-#else
needle_cmp_end = i_needle;
i_needle -= needle_cmp_len;
@@ -148,7 +123,6 @@ FAR char *strstr(FAR const char *haystack, FAR const char *needle)
last_haystack_chars <<= 8;
last_haystack_chars ^= *i_haystack++;
}
-#endif
/* At this point:
* needle is at least two characters long