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