summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2023-05-16 17:40:05 +0000
committerEven Rouault <even.rouault@spatialys.com>2023-05-16 17:40:05 +0000
commita0a18437d669bc30f91bfada555417903fee65b5 (patch)
treeb084380d5f27e36024ca3efc1ff66682da1a5c08
parentcea60470546fcb8bc1bb937512485aae15367b5d (diff)
parent0dabdfe85732147d1c8d6016e8c3e40522104568 (diff)
downloadlibtiff-git-master.tar.gz
Merge branch 'fix_558' into 'master'HEADmaster
Hardcode HOST_FILLORDER to FILLORDER_LSB2MSB, and make 'H' flag of TIFFOpen()... See merge request libtiff/libtiff!488
-rw-r--r--cmake/ProcessorChecks.cmake11
-rw-r--r--configure.ac16
-rw-r--r--doc/internals.rst8
-rw-r--r--libtiff/tif_lerc.c2
-rw-r--r--libtiff/tif_open.c6
-rw-r--r--libtiff/tiffconf.h.cmake.in13
-rw-r--r--libtiff/tiffconf.h.in13
7 files changed, 31 insertions, 38 deletions
diff --git a/cmake/ProcessorChecks.cmake b/cmake/ProcessorChecks.cmake
index 8d8c568a..08e89604 100644
--- a/cmake/ProcessorChecks.cmake
+++ b/cmake/ProcessorChecks.cmake
@@ -26,17 +26,6 @@
include(TestBigEndian)
-
-# CPU bit order
-set(HOST_FILLORDER FILLORDER_MSB2LSB)
-if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i.*86.*" OR
- CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*" OR
- # AMD64 on Windows
- CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "AMD64" OR
- CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64.*")
- set(HOST_FILLORDER FILLORDER_LSB2MSB)
-endif()
-
# CPU endianness
test_big_endian(HOST_BIG_ENDIAN)
if(HOST_BIG_ENDIAN)
diff --git a/configure.ac b/configure.ac
index 292bb20e..8d1a52d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -255,22 +255,6 @@ dnl Will use local replacements for unavailable functions
AC_REPLACE_FUNCS(getopt)
dnl ---------------------------------------------------------------------------
-dnl Check the native cpu bit order.
-dnl ---------------------------------------------------------------------------
-AC_MSG_CHECKING([native cpu bit order])
-case "$host_cpu" in
- i*86*|x86_64*)
- HOST_FILLORDER=FILLORDER_LSB2MSB
- AC_MSG_RESULT([lsb2msb])
- ;;
- *)
- HOST_FILLORDER=FILLORDER_MSB2LSB
- AC_MSG_RESULT([msb2lsb])
- ;;
-esac
-AC_DEFINE_UNQUOTED(HOST_FILLORDER, $HOST_FILLORDER, [Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB)])
-
-dnl ---------------------------------------------------------------------------
dnl Configure legacy tifconf.h HOST_BIGENDIAN.
dnl ---------------------------------------------------------------------------
if test "$ac_cv_c_bigendian" = yes ; then
diff --git a/doc/internals.rst b/doc/internals.rst
index 86014d9f..7ea1b5e5 100644
--- a/doc/internals.rst
+++ b/doc/internals.rst
@@ -189,11 +189,9 @@ as possible in two files: :file:`tiffcomp.h` and
operating system-specific routines to do I/O and I/O-related operations.
The UNIX (:file:`tif_unix.c`) code has had the most use.
-Native CPU byte order is determined on the fly by
-the library and does not need to be specified.
-The :c:macro:`HOST_FILLORDER` and :c:macro:`HOST_BIGENDIAN`
-definitions are not currently used, but may be employed by
-codecs for optimization purposes.
+Native CPU byte order is determined through the :c:macro:`WORDS_BIGENDIAN`
+definition, which must be set to the appropriate value in :file:`tif_config.h`
+by the build system.
The following defines control general portability:
diff --git a/libtiff/tif_lerc.c b/libtiff/tif_lerc.c
index 99de713c..4f357a60 100644
--- a/libtiff/tif_lerc.c
+++ b/libtiff/tif_lerc.c
@@ -517,7 +517,7 @@ static int LERCPreDecode(TIFF *tif, uint16_t s)
{
const unsigned nb_pixels = sp->segment_width * sp->segment_height;
unsigned i;
-#if HOST_BIGENDIAN
+#if WORDS_BIGENDIAN
const unsigned char nan_bytes[] = {0x7f, 0xc0, 0, 0};
#else
const unsigned char nan_bytes[] = {0, 0, 0xc0, 0x7f};
diff --git a/libtiff/tif_open.c b/libtiff/tif_open.c
index aa16a64f..23fcf81c 100644
--- a/libtiff/tif_open.c
+++ b/libtiff/tif_open.c
@@ -365,8 +365,12 @@ TIFF *TIFFClientOpenExt(const char *name, const char *mode,
(tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_LSB2MSB;
break;
case 'H':
+ TIFFWarningExtR(tif, name,
+ "H(ost) mode is deprecated. Since "
+ "libtiff 4.5.1, it is an alias of 'B' / "
+ "FILLORDER_MSB2LSB.");
tif->tif_flags =
- (tif->tif_flags & ~TIFF_FILLORDER) | HOST_FILLORDER;
+ (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_MSB2LSB;
break;
case 'M':
if (m == O_RDONLY)
diff --git a/libtiff/tiffconf.h.cmake.in b/libtiff/tiffconf.h.cmake.in
index e3a830d4..306874f5 100644
--- a/libtiff/tiffconf.h.cmake.in
+++ b/libtiff/tiffconf.h.cmake.in
@@ -52,8 +52,17 @@
machine */
#cmakedefine HAVE_IEEEFP 1
-/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */
-#define HOST_FILLORDER @HOST_FILLORDER@
+/* The concept of HOST_FILLORDER is broken. Since libtiff 4.5.1
+ * this macro will always be hardcoded to FILLORDER_LSB2MSB on all
+ * architectures, to reflect past long behavior of doing so on x86 architecture.
+ * Note however that the default FillOrder used by libtiff is FILLORDER_MSB2LSB,
+ * as mandated per the TIFF specification.
+ * The influence of HOST_FILLORDER is only when passing the 'H' mode in
+ * TIFFOpen().
+ * You should NOT rely on this macro to decide the CPU endianness!
+ * This macro will be removed in libtiff 4.6
+ */
+#define HOST_FILLORDER FILLORDER_LSB2MSB
/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
(Intel) */
diff --git a/libtiff/tiffconf.h.in b/libtiff/tiffconf.h.in
index 2a8b03e9..ab017357 100644
--- a/libtiff/tiffconf.h.in
+++ b/libtiff/tiffconf.h.in
@@ -52,8 +52,17 @@
machine */
#undef HAVE_IEEEFP
-/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */
-#undef HOST_FILLORDER
+/* The concept of HOST_FILLORDER is broken. Since libtiff 4.5.1
+ * this macro will always be hardcoded to FILLORDER_LSB2MSB on all
+ * architectures, to reflect past long behavior of doing so on x86 architecture.
+ * Note however that the default FillOrder used by libtiff is FILLORDER_MSB2LSB,
+ * as mandated per the TIFF specification.
+ * The influence of HOST_FILLORDER is only when passing the 'H' mode in
+ * TIFFOpen().
+ * You should NOT rely on this macro to decide the CPU endianness!
+ * This macro will be removed in libtiff 4.6
+ */
+#define HOST_FILLORDER FILLORDER_LSB2MSB
/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
(Intel) */