AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2007.10.23 08:38 "[Tiff] universal build patch", by Kai-Uwe Behrmann
2007.10.23 15:37 "Re: [Tiff] universal build patch", by Bob Friesenhahn
2007.10.23 15:50 "Re: [Tiff] universal build patch", by Andrey Kiselev
2007.10.23 16:12 "Re: [Tiff] universal build patch", by Bob Friesenhahn
2007.10.23 19:17 "Re: [Tiff] universal build patch", by Andrey Kiselev
2007.10.23 20:44 "Re: [Tiff] universal build patch", by Bob Friesenhahn
2007.10.24 07:19 "Re: [Tiff] universal build patch", by Andrey Kiselev
2007.10.24 08:32 "Re: [Tiff] universal build patch", by Kai-Uwe Behrmann
2007.10.24 11:26 "Re: [Tiff] universal build patch", by Andrey Kiselev
2007.10.24 15:44 "Re: [Tiff] universal build patch", by Bob Friesenhahn
2007.10.23 20:56 "Re: [Tiff] universal build patch", by Toby Thain

2007.10.23 08:38 "[Tiff] universal build patch", by Kai-Uwe Behrmann

Attached is a patch for v3.9.0beta to run libtiff in a universal build on osX fro one configuration.

It is just for testing libtiff, the tools are unchanged as it is not clear, whether this direction of handling the issue will be accepted.

In tif_swab.c a function int _TIFFBigEndian() is added to do the runtime endianess check.

kind regards

Kai-Uwe Behrmann
--
developing for colour management
www.behrmann.name + www.oyranos.org + www.cinepaint.org

diff -aur tiff-3.9.0beta_orig/libtiff/tif_open.c tiff-3.9.0beta/libtiff/tif_open.c

--- tiff-3.9.0beta_orig/libtiff/tif_open.c      2006-06-08 16:27:17.000000000 +0200

+++ tiff-3.9.0beta/libtiff/tif_open.c   2007-10-22 23:18:54.000000000 +0200

@@ -102,14 +102,12 @@
        tif->tif_typemask = typemask;
        if (magic == TIFF_BIGENDIAN) {
                tif->tif_typeshift = bigTypeshift;
-#ifndef WORDS_BIGENDIAN
+ if (!_TIFFBigEndian())
                tif->tif_flags |= TIFF_SWAB;
-#endif
        } else {
                tif->tif_typeshift = litTypeshift;
-#ifdef WORDS_BIGENDIAN
+ if (_TIFFBigEndian())
                tif->tif_flags |= TIFF_SWAB;
-#endif
        }
 }

@@ -258,16 +256,14 @@
        for (cp = mode; *cp; cp++)
                switch (*cp) {
                case 'b':
-#ifndef WORDS_BIGENDIAN
- if (m&O_CREAT)
+ if (!_TIFFBigEndian() &&
+ m&O_CREAT)
                                tif->tif_flags |= TIFF_SWAB;
-#endif
                        break;
                case 'l':
-#ifdef WORDS_BIGENDIAN
- if ((m&O_CREAT))
+ if (_TIFFBigEndian() &&
+ (m&O_CREAT))
                                tif->tif_flags |= TIFF_SWAB;
-#endif
                        break;
                case 'B':
                        tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) |
@@ -314,13 +310,13 @@
                /*
                 * Setup header and write.
                 */
-#ifdef WORDS_BIGENDIAN
- tif->tif_header.tiff_magic = tif->tif_flags & TIFF_SWAB
+ if (_TIFFBigEndian())
+ tif->tif_header.tiff_magic = tif->tif_flags & TIFF_SWAB
                    ? TIFF_LITTLEENDIAN: TIFF_BIGENDIAN;
-#else
- tif->tif_header.tiff_magic = tif->tif_flags & TIFF_SWAB
+ else
+ tif->tif_header.tiff_magic = tif->tif_flags & TIFF_SWAB
                    ? TIFF_BIGENDIAN: TIFF_LITTLEENDIAN;
-#endif
+
                tif->tif_header.tiff_version = TIFF_VERSION;
                if (tif->tif_flags & TIFF_SWAB)
                        TIFFSwabShort(&tif->tif_header.tiff_version);
@@ -363,11 +359,10 @@
            tif->tif_header.tiff_magic != TIFF_LITTLEENDIAN
 #if MDI_SUPPORT
            &&
-#if HOST_BIGENDIAN

+            ((_TIFFBigEndian() &&
+            tif->tif_header.tiff_magic != MDI_BIGENDIAN) ||
+             (!_TIFFBigEndian() &&
+            tif->tif_header.tiff_magic != MDI_LITTLEENDIAN))

            ) {
                TIFFErrorExt(tif->tif_clientdata, name,
                        "Not a TIFF or MDI file, bad magic number %d (0x%x)",

diff -aur tiff-3.9.0beta_orig/libtiff/tif_predict.c tiff-3.9.0beta/libtiff/tif_predict.c

--- tiff-3.9.0beta_orig/libtiff/tif_predict.c   2007-04-07 16:58:30.000000000 +0200
+++ tiff-3.9.0beta/libtiff/tif_predict.c        2007-10-22 23:25:47.000000000 +0200

@@ -317,12 +317,11 @@
        for (count = 0; count < wc; count++) {
                uint32 byte;
                for (byte = 0; byte < bps; byte++) {
-#if WORDS_BIGENDIAN

+                        if (_TIFFBigEndian())
+                         cp[bps * count + byte] = tmp[byte * wc + count];
+                        else
+