]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: http/h1: rely on HA_UNALIGNED_LE instead of checking for CPU families
authorWilly Tarreau <w@1wt.eu>
Fri, 21 Feb 2020 15:31:22 +0000 (16:31 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 21 Feb 2020 15:32:57 +0000 (16:32 +0100)
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).

src/h1.c
src/http.c

index 63fbee8c0f78257025ac1931ec25d317550e829e..7513773c8155024a865b9cce5be5e10d4756e3ee 100644 (file)
--- 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;
index 8e17bed0cf408e24823072ad6afb37bfc79ca02e..75251992a7b94b77707f186038bb4f812d5a939f 100644 (file)
@@ -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