libtiff: Merge branch 'fix_616' into 'master'

From e1b4eef40f848e1d6db317f20119909ff40d1421 Mon Sep 17 00:00:00 2001
From: Even Rouault <[EMAIL REDACTED]>
Date: Thu, 12 Oct 2023 12:38:53 +0200
Subject: [PATCH] tif_lzw.c: avoid warning about misaligned address with UBSAN
 (fixes #616)

The branch suppressed by this commit wasn't useful as I've verified that
with -O2 and -O3 and gcc or clang, doing a memcpy() + _byteswap_uint64()
generates exactly the same code as _byteswap_uint64(*ptr).
The warning with UBSAN thus only comes from UBSAN generating special code
to catch the misalignment, but is unlikely to cause any issue in
practice given the above observation.
---
 libtiff/tif_lzw.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/libtiff/tif_lzw.c b/libtiff/tif_lzw.c
index d631fa10..5cd536d5 100644
--- a/libtiff/tif_lzw.c
+++ b/libtiff/tif_lzw.c
@@ -329,10 +329,7 @@ static int LZWPreDecode(TIFF *tif, uint16_t s)
 #ifdef WORDS_BIGENDIAN
 #define GetNextData(nextdata, bp) memcpy(&nextdata, bp, sizeof(nextdata))
 #elif SIZEOF_WORDTYPE == 8
-#if defined(__GNUC__) && defined(__x86_64__)
-#define GetNextData(nextdata, bp)                                              \
-    nextdata = __builtin_bswap64(*(uint64_t *)(bp))
-#elif defined(_M_X64)
+#if defined(_M_X64)
 #define GetNextData(nextdata, bp) nextdata = _byteswap_uint64(*(uint64_t *)(bp))
 #elif defined(__GNUC__)
 #define GetNextData(nextdata, bp)                                              \
@@ -346,10 +343,7 @@ static int LZWPreDecode(TIFF *tif, uint16_t s)
                (((uint64_t)bp[6]) << 8) | (((uint64_t)bp[7]))
 #endif
 #elif SIZEOF_WORDTYPE == 4
-#if defined(__GNUC__) && defined(__i386__)
-#define GetNextData(nextdata, bp)                                              \
-    nextdata = __builtin_bswap32(*(uint32_t *)(bp))
-#elif defined(_M_X86)
+#if defined(_M_X86)
 #define GetNextData(nextdata, bp)                                              \
     nextdata = _byteswap_ulong(*(unsigned long *)(bp))
 #elif defined(__GNUC__)