203331d
From a39a5f0870149b47292f7bc3d303d3d8f569f013 Mon Sep 17 00:00:00 2001
203331d
From: Christian Krause <chkr@fedoraproject.org>
203331d
Date: Thu, 6 Jan 2011 23:12:43 +0100
203331d
Subject: [PATCH] fix alignment issues on x86
203331d
203331d
---
203331d
 bindings/mono/Makefile.include            |    2 +-
203331d
 bindings/mono/libgpod-sharp/Artwork.cs    |    4 ++++
203331d
 bindings/mono/libgpod-sharp/Chapter.cs    |    4 ++++
203331d
 bindings/mono/libgpod-sharp/IpodInfo.cs   |    5 +++++
203331d
 bindings/mono/libgpod-sharp/PhotoAlbum.cs |    5 +++++
203331d
 bindings/mono/libgpod-sharp/Playlist.cs   |    5 +++++
203331d
 bindings/mono/libgpod-sharp/Track.cs      |    4 ++++
203331d
 configure.ac                              |    7 +++++++
203331d
 8 files changed, 35 insertions(+), 1 deletions(-)
203331d
203331d
diff --git a/bindings/mono/Makefile.include b/bindings/mono/Makefile.include
203331d
index 504b059..a587456 100644
203331d
--- a/bindings/mono/Makefile.include
203331d
+++ b/bindings/mono/Makefile.include
203331d
@@ -18,7 +18,7 @@ all: $(ASSEMBLY_FILE)
203331d
 $(ASSEMBLY_FILE).mdb: $(ASSEMBLY_FILE)
203331d
 
203331d
 $(ASSEMBLY_FILE): $(SOURCES_BUILD)
203331d
-	$(MCS) -debug -unsafe -target:$(TARGET) -out:$@ $(LINK) $(SOURCES_BUILD)
203331d
+	$(MCS) $(GMCS_FLAGS) -debug -unsafe -target:$(TARGET) -out:$@ $(LINK) $(SOURCES_BUILD)
203331d
 
203331d
 EXTRA_DIST = $(SOURCES_BUILD)
203331d
 
203331d
diff --git a/bindings/mono/libgpod-sharp/Artwork.cs b/bindings/mono/libgpod-sharp/Artwork.cs
203331d
index 5be7369..5773e35 100644
203331d
--- a/bindings/mono/libgpod-sharp/Artwork.cs
203331d
+++ b/bindings/mono/libgpod-sharp/Artwork.cs
203331d
@@ -24,7 +24,11 @@ namespace GPod {
Nathaniel McCallum b56a744
 	using native;
Nathaniel McCallum b56a744
 	
Nathaniel McCallum b56a744
 	namespace native {
203331d
+#if ALIGNMENT_X86_LINUX
203331d
+		[StructLayout (LayoutKind.Sequential, Pack=4)]
203331d
+#else
203331d
 		[StructLayout (LayoutKind.Sequential)]
203331d
+#endif
Nathaniel McCallum b56a744
 		internal struct Itdb_Artwork {
Nathaniel McCallum b56a744
 			public IntPtr thumbnail;
Nathaniel McCallum b56a744
 			public uint   id;
203331d
diff --git a/bindings/mono/libgpod-sharp/Chapter.cs b/bindings/mono/libgpod-sharp/Chapter.cs
203331d
index 66ca556..ea632cd 100644
203331d
--- a/bindings/mono/libgpod-sharp/Chapter.cs
203331d
+++ b/bindings/mono/libgpod-sharp/Chapter.cs
203331d
@@ -22,7 +22,11 @@ namespace GPod {
Nathaniel McCallum b56a744
 	using native;
Nathaniel McCallum b56a744
 	
Nathaniel McCallum b56a744
 	namespace native {
203331d
+#if ALIGNMENT_X86_LINUX
203331d
+		[StructLayout (LayoutKind.Sequential, Pack=4)]
203331d
+#else
203331d
 		[StructLayout (LayoutKind.Sequential)]
203331d
+#endif
Nathaniel McCallum b56a744
 		internal struct Itdb_Chapter {
Nathaniel McCallum b56a744
 			public uint   startpos;
Nathaniel McCallum b56a744
 			public IntPtr chaptertitle;
203331d
diff --git a/bindings/mono/libgpod-sharp/IpodInfo.cs b/bindings/mono/libgpod-sharp/IpodInfo.cs
203331d
index 697041b..14024eb 100644
203331d
--- a/bindings/mono/libgpod-sharp/IpodInfo.cs
203331d
+++ b/bindings/mono/libgpod-sharp/IpodInfo.cs
203331d
@@ -23,6 +23,11 @@ namespace GPod {
Nathaniel McCallum b56a744
 	using System.Collections.Generic;
Nathaniel McCallum b56a744
 	
Nathaniel McCallum b56a744
 	namespace native {
203331d
+#if ALIGNMENT_X86_LINUX
203331d
+		[StructLayout (LayoutKind.Sequential, Pack=4)]
203331d
+#else
203331d
+		[StructLayout (LayoutKind.Sequential)]
203331d
+#endif
Nathaniel McCallum b56a744
 		internal struct Itdb_IpodInfo {
Nathaniel McCallum b56a744
 			public IntPtr         model_number;
Nathaniel McCallum b56a744
 			public double         capacity;
203331d
diff --git a/bindings/mono/libgpod-sharp/PhotoAlbum.cs b/bindings/mono/libgpod-sharp/PhotoAlbum.cs
203331d
index 42b2365..4a248ec 100644
203331d
--- a/bindings/mono/libgpod-sharp/PhotoAlbum.cs
203331d
+++ b/bindings/mono/libgpod-sharp/PhotoAlbum.cs
203331d
@@ -24,6 +24,11 @@ namespace GPod {
Nathaniel McCallum b56a744
 	using native;
Nathaniel McCallum b56a744
 	
Nathaniel McCallum b56a744
 	namespace native {
203331d
+#if ALIGNMENT_X86_LINUX
203331d
+		[StructLayout (LayoutKind.Sequential, Pack=4)]
203331d
+#else
203331d
+		[StructLayout (LayoutKind.Sequential)]
203331d
+#endif
Nathaniel McCallum b56a744
 		internal struct Itdb_PhotoAlbum {
Nathaniel McCallum b56a744
 			public IntPtr photodb;
Nathaniel McCallum b56a744
 			public IntPtr name;
203331d
diff --git a/bindings/mono/libgpod-sharp/Playlist.cs b/bindings/mono/libgpod-sharp/Playlist.cs
203331d
index 7ff5a68..48e4e32 100644
203331d
--- a/bindings/mono/libgpod-sharp/Playlist.cs
203331d
+++ b/bindings/mono/libgpod-sharp/Playlist.cs
203331d
@@ -24,6 +24,11 @@ namespace GPod {
Nathaniel McCallum b56a744
 	using native;
Nathaniel McCallum b56a744
 	
Nathaniel McCallum b56a744
 	namespace native {
203331d
+#if ALIGNMENT_X86_LINUX
203331d
+		[StructLayout (LayoutKind.Sequential, Pack=4)]
203331d
+#else
203331d
+		[StructLayout (LayoutKind.Sequential)]
203331d
+#endif
Nathaniel McCallum b56a744
 		internal struct Itdb_Playlist {
Nathaniel McCallum b56a744
 			public IntPtr itdb;
Nathaniel McCallum b56a744
 			public IntPtr name;
203331d
diff --git a/bindings/mono/libgpod-sharp/Track.cs b/bindings/mono/libgpod-sharp/Track.cs
203331d
index 434df7e..ce716fa 100644
203331d
--- a/bindings/mono/libgpod-sharp/Track.cs
203331d
+++ b/bindings/mono/libgpod-sharp/Track.cs
203331d
@@ -24,7 +24,11 @@ namespace GPod {
Nathaniel McCallum b56a744
 	
Nathaniel McCallum b56a744
 	
Nathaniel McCallum b56a744
 	namespace native {
203331d
+#if ALIGNMENT_X86_LINUX
203331d
+		[StructLayout (LayoutKind.Sequential, Pack=4)]
203331d
+#else
203331d
 		[StructLayout (LayoutKind.Sequential)]
203331d
+#endif
Nathaniel McCallum b56a744
 		internal struct Itdb_Track {
Nathaniel McCallum b56a744
 			public IntPtr		itdb;
Nathaniel McCallum b56a744
 			public IntPtr		title;
203331d
diff --git a/configure.ac b/configure.ac
203331d
index 295faf6..e278392 100644
203331d
--- a/configure.ac
203331d
+++ b/configure.ac
203331d
@@ -315,6 +315,13 @@ dnl **************************************************
203331d
 MONO_MIN_VERSION=1.9.1
203331d
 GTK_SHARP_MIN_VERSION=2.12
203331d
 LIBGPOD_CHECK_MONO
203331d
+AC_CHECK_ALIGNOF([double])
203331d
+if test "$ac_cv_alignof_double" -eq 4 ; then
203331d
+    GMCS_FLAGS=-define:ALIGNMENT_X86_LINUX
203331d
+else
203331d
+    GMCS_FLAGS=
203331d
+fi
203331d
+AC_SUBST(GMCS_FLAGS)
203331d
 
203331d
 dnl warnings bits, copied from gnome-keyring configure.in
203331d
 dnl Turn on the additional warnings last, so -Werror doesn't affect other tests.
203331d
-- 
203331d
1.7.3.4
203331d