Bug 695544 - endianness tests in lcms2.h cannot work without include endian.h
Summary: endianness tests in lcms2.h cannot work without include endian.h
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Color Management (show other bugs)
Version: 9.15
Hardware: PC Linux
: P4 normal
Assignee: Chris Liddell (chrisl)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-29 03:04 UTC by jsmeix
Modified: 2015-05-21 06:33 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments
ppc64le-support.patch (689 bytes, patch)
2014-09-29 03:04 UTC, jsmeix
Details | Diff
My current ppc64le-support.patch for ghostscript-9.16rc2 (236 bytes, text/plain)
2015-03-25 06:07 UTC, jsmeix
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jsmeix 2014-09-29 03:04:31 UTC
Created attachment 11194 [details]
ppc64le-support.patch

I use self-compiled Ghostscript 9.15 on SUSE Linux.

A colleague informed me that the endianness tests in lcms2.h
cannot work without "include <endian.h>" (at least on Linux).

The endianness tests in lcms2.h are in particular needed
to make it work on PowerPC little endian machines.

The following fixes it:
-------------------------------------------------------------------------
--- ghostscript-9.15/lcms2/include/lcms2.h
+++ ghostscript-9.15/lcms2/include/lcms2.h
@@ -67,6 +67,7 @@
 #include <limits.h>
 #include <time.h>
 #include <stddef.h>
+#include <endian.h>
 
 #ifndef CMS_USE_CPP_API
 #   ifdef __cplusplus
-------------------------------------------------------------------------

By the way:

LittleCMS 1.x in Ghostscript is not fixed for PowerPC little endian.
Regardless that by default LittleCMS 2.x is now used, I think it
should also work on PowerPC little endian machines in case of
"configure --with-lcms".

I attach our current ppc64le-support.patch for Ghostscript 9.15.
Comment 1 Chris Liddell (chrisl) 2014-09-29 04:26:16 UTC
(In reply to jsmeix from comment #0)
> By the way:
> 
> LittleCMS 1.x in Ghostscript is not fixed for PowerPC little endian.
> Regardless that by default LittleCMS 2.x is now used, I think it
> should also work on PowerPC little endian machines in case of
> "configure --with-lcms".

We'll be removing LCMS 1.x before the next release.......
Comment 2 jsmeix 2015-03-25 06:05:58 UTC
It seems in
http://downloads.ghostscript.com/public/.release_candidate/ghostscript-9.16rc2.tar.gz
the file lcms2/include/lcms2.h does still not contain
#include <endian.h>

Could you apply my "The following fixes it" from comment#0
to Ghostscript 9.16 so that no further patch is needed for
ppc64le-support or could you explain why it cannot be applied.
Comment 3 jsmeix 2015-03-25 06:07:08 UTC
Created attachment 11544 [details]
My current ppc64le-support.patch for ghostscript-9.16rc2
Comment 4 Michael Vrhel 2015-05-19 13:10:11 UTC
I am not seeing anything in the tests of lcms2.h which would require that header file.   I am passing to Chris to check with a PowerPC machine.
Comment 5 Robin Watts 2015-05-19 13:17:31 UTC
I bet endian.h sets __BYTE_ORDER and __LITTLE_ENDIAN.

Possibly we want something like:

#ifdef (__GNUC__)
#include <endian.h>
#endif

to be added *within* the existing:

#if defined(__powerpc__) || defined(__ppc__) || defined(TARGET_CPU_PPC)

section?
Comment 6 Chris Liddell (chrisl) 2015-05-19 23:25:02 UTC
Seems to me that there are two issues here.

The first (and more significant for us) is that LCMS2's endiannes is *supposed* to be settable on the compiler command line, but lcms2.h will override that setting, and favor its own test results - I feel that is wrong.

Second is the endian.h inclusion. I think the correct solution for that is to have configure check for the header, and have endian.h included if configure finds it is available.