From: Willy Tarreau Date: Fri, 21 Feb 2020 15:31:22 +0000 (+0100) Subject: CLEANUP: http/h1: rely on HA_UNALIGNED_LE instead of checking for CPU families X-Git-Tag: v2.2-dev3~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=02ac950a115ae819d863ec1d2250b7c262348ede;p=thirdparty%2Fhaproxy.git CLEANUP: http/h1: rely on HA_UNALIGNED_LE instead of checking for CPU families Now that we have flags indicating the CPU's capabilities, better use them instead of missing some updates for new CPU families (ARMv8 was missing there). --- diff --git a/src/h1.c b/src/h1.c index 63fbee8c0f..7513773c81 100644 --- a/src/h1.c +++ b/src/h1.c @@ -386,9 +386,7 @@ int h1_headers_to_hdr_list(char *start, const char *stop, case H1_MSG_RQURI: http_msg_rquri: -#if defined(__x86_64__) || \ - defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || \ - defined(__ARM_ARCH_7A__) +#ifdef HA_UNALIGNED_LE /* speedup: skip bytes not between 0x21 and 0x7e inclusive */ while (ptr <= end - sizeof(int)) { int x = *(int *)ptr - 0x21212121; @@ -734,16 +732,14 @@ int h1_headers_to_hdr_list(char *start, const char *stop, * also remove the sign bit test so that bytes 0x8e..0x0d break the * loop, but we don't care since they're very rare in header values. */ -#if defined(__x86_64__) +#ifdef HA_UNALIGNED_LE64 while (ptr <= end - sizeof(long)) { if ((*(long *)ptr - 0x0e0e0e0e0e0e0e0eULL) & 0x8080808080808080ULL) goto http_msg_hdr_val2; ptr += sizeof(long); } #endif -#if defined(__x86_64__) || \ - defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || \ - defined(__ARM_ARCH_7A__) +#ifdef HA_UNALIGNED_LE while (ptr <= end - sizeof(int)) { if ((*(int*)ptr - 0x0e0e0e0e) & 0x80808080) goto http_msg_hdr_val2; diff --git a/src/http.c b/src/http.c index 8e17bed0cf..75251992a7 100644 --- a/src/http.c +++ b/src/http.c @@ -640,9 +640,7 @@ char *http_find_hdr_value_end(char *s, const char *e) quoted = qdpair = 0; -#if defined(__x86_64__) || \ - defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || \ - defined(__ARM_ARCH_7A__) +#ifdef HA_UNALIGNED_LE /* speedup: skip everything not a comma nor a double quote */ for (; s <= e - sizeof(int); s += sizeof(int)) { unsigned int c = *(int *)s; // comma