24494517 lcms2 chunk allocator doesn't align properly for SPARC, causes bus errors
authorAlan Coopersmith <Alan.Coopersmith@Oracle.COM>
Sun, 21 Aug 2016 21:07:54 -0700
changeset 6658 06a8b969738e
parent 6657 9988136f27c3
child 6659 da624acb223a
24494517 lcms2 chunk allocator doesn't align properly for SPARC, causes bus errors
components/lcms2/Makefile
components/lcms2/patches/01-alignment.patch
--- a/components/lcms2/Makefile	Mon Aug 22 12:40:33 2016 -0700
+++ b/components/lcms2/Makefile	Sun Aug 21 21:07:54 2016 -0700
@@ -43,6 +43,11 @@
 # Seems that we have no other way to designate that we want large file support.
 CFLAGS += $(CPP_LARGEFILES)
 
+# Need to ensure lcms custom chunk memory allocator aligns properly for all
+# of our platforms - see _cmsALIGNMEM macro in src/lcms2_internal.h and
+# _MAX_ALIGNMENT definition in per-platform sections of <sys/isa_defs.h>
+CPPFLAGS += -DCMS_PTR_ALIGNMENT=_MAX_ALIGNMENT
+
 CONFIGURE_OPTIONS +=	--includedir=$(USRINCDIR)/lcms
 CONFIGURE_OPTIONS +=	--enable-shared
 CONFIGURE_OPTIONS +=	--disable-static
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/lcms2/patches/01-alignment.patch	Sun Aug 21 21:07:54 2016 -0700
@@ -0,0 +1,38 @@
+Patch from upstream git repo to allow us to specify correct alignment to fix
+24494517 lcms2 chunk allocator doesn't align properly for SPARC, causes bus errors
+
+From 51809bd437c159fda9a753959361d208ff47228b Mon Sep 17 00:00:00 2001
+From: Chris Liddell <[email protected]>
+Date: Tue, 24 Mar 2015 09:03:55 +0000
+Subject: [PATCH] Allow ptr alignment to be set at build time
+
+At least some configurations of gcc on UltraSPARC require 8 byte alignment of
+memory pointers (even on 32 bit user space, where sizeof(void *) == 4).
+
+Rather than contaminate the source, provide ability to set the ptr alignment
+on the compiler command line (on Unix, using CFLAGS when calling configure).
+---
+ src/lcms2_internal.h | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/src/lcms2_internal.h b/src/lcms2_internal.h
+index 9fe91ad..1e46740 100644
+--- a/src/lcms2_internal.h
++++ b/src/lcms2_internal.h
+@@ -57,7 +57,15 @@
+ #define _cmsALIGNLONG(x) (((x)+(sizeof(cmsUInt32Number)-1)) & ~(sizeof(cmsUInt32Number)-1))
+ 
+ // Alignment to memory pointer
+-#define _cmsALIGNMEM(x)  (((x)+(sizeof(void *) - 1)) & ~(sizeof(void *) - 1))
++
++// (Ultra)SPARC with gcc requires ptr alignment of 8 bytes
++// even though sizeof(void *) is only four: for greatest flexibility
++// allow the build to specify ptr alignment.
++#ifndef CMS_PTR_ALIGNMENT
++# define CMS_PTR_ALIGNMENT sizeof(void *)
++#endif
++
++#define _cmsALIGNMEM(x)  (((x)+(CMS_PTR_ALIGNMENT - 1)) & ~(CMS_PTR_ALIGNMENT - 1))
+ 
+ // Maximum encodeable values in floating point
+ #define MAX_ENCODEABLE_XYZ  (1.0 + 32767.0/32768.0)