From 6de765342c1505efa7e8a57a5287815e88cefa33 Mon Sep 17 00:00:00 2001 From: haopengxiang Date: Tue, 6 Jul 2021 20:46:56 +0800 Subject: [PATCH] delete small to big endian marco to avoid byte alignment Change-Id: I24076bfeeae5b462756bcae9f166bce20ae4ad90 --- 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 18c7605b067..bb1f3cef438 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 @@ -60,9 +45,7 @@ #undef strstr 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; @@ -127,14 +110,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; @@ -149,7 +124,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