[Libreoffice-commits] core.git: cppu/source

Douglas Mencken dougmencken at gmail.com
Tue Mar 29 08:28:48 UTC 2016


 cppu/source/uno/check.cxx |   43 ++++++++++++++++++++-----------------------
 1 file changed, 20 insertions(+), 23 deletions(-)

New commits:
commit 3e48e0ed7114d4a9c26c3ae5087c4f1c352a8a65
Author: Douglas Mencken <dougmencken at gmail.com>
Date:   Tue Mar 15 13:52:08 2016 -0400

    uno/check.cxx: use alignment calculated at runtime instead of hardcode
    
    Change-Id: I0f9a48ef01bee4153cd9231bdef4b5a763b6bda2
    Reviewed-on: https://gerrit.libreoffice.org/23283
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/cppu/source/uno/check.cxx b/cppu/source/uno/check.cxx
index f6f47e3..620a970 100644
--- a/cppu/source/uno/check.cxx
+++ b/cppu/source/uno/check.cxx
@@ -26,17 +26,6 @@
 #include <sal/types.h>
 #include <uno/any2.h>
 
-// Why hardcode like this instead of using the (generated)
-// <sal/typesizes.h> ?
-#if (defined(INTEL) \
-    && (defined(__GNUC__) && (defined(LINUX) || defined(FREEBSD) ||   \
-                              defined(NETBSD) || defined(OPENBSD) ||  \
-                              defined(DRAGONFLY) || defined(SOLARIS) || \
-                              defined(ANDROID)) \
-        || defined(MACOSX) )) \
-    || defined(IOS)
-#define MAX_ALIGNMENT_4
-#endif
 
 namespace {
 
@@ -162,14 +151,14 @@ static_assert( static_cast<sal_Bool>(true) == sal_True,
                "must be binary compatible" );
 static_assert( static_cast<sal_Bool>(false) == sal_False,
                "must be binary compatible" );
-#ifdef MAX_ALIGNMENT_4
-// max alignment is 4
+#if SAL_TYPES_ALIGNMENT8 == 4
 static_assert(offsetof(AlignSize_Impl, dDouble) == 4, "offsetof(AlignSize_Impl, dDouble) != 4");
 static_assert(sizeof(AlignSize_Impl) == 12, "sizeof(AlignSize_Impl) != 12");
-#else
-// max alignment is 8
+#elif SAL_TYPES_ALIGNMENT8 == 8
 static_assert(offsetof(AlignSize_Impl, dDouble) == 8, "offsetof(AlignSize_Impl, dDouble) != 8");
 static_assert(sizeof(AlignSize_Impl) == 16, "sizeof(AlignSize_Impl) != 16");
+#else
+# error unexpected alignment of 8 byte types
 #endif
 
 // sequence
@@ -192,10 +181,12 @@ static_assert(sizeof(N) == 12, "sizeof(N) != 12");
 static_assert(sizeof(N2) == 12, "sizeof(N2) != 12");
 
 static_assert(offsetof(N2, p) == 8, "offsetof(N2, p) != 8");
-#ifdef MAX_ALIGNMENT_4
+#if SAL_TYPES_ALIGNMENT8 == 4
 static_assert(sizeof(O) == 20, "sizeof(O) != 20");
-#else
+#elif SAL_TYPES_ALIGNMENT8 == 8
 static_assert(sizeof(O) == 24, "sizeof(O) != 24");
+#else
+# error unexpected alignment of 8 byte types
 #endif
 static_assert(sizeof(D) == 8, "sizeof(D) != 8");
 static_assert(offsetof(D, e) == 4, "offsetof(D, e) != 4");
@@ -205,31 +196,35 @@ static_assert(offsetof(E, e) == 8, "offsetof(E, e) != 8");
 static_assert(sizeof(C1) == 2, "sizeof(C1) != 2");
 static_assert(sizeof(C2) == 8, "sizeof(C2) != 8");
 
-#ifdef MAX_ALIGNMENT_4
+#if SAL_TYPES_ALIGNMENT8 == 4
 static_assert(sizeof(C3) == 20, "sizeof(C3) != 20");
 static_assert(sizeof(C4) == 32, "sizeof(C4) != 32");
 static_assert(sizeof(C5) == 44, "sizeof(C5) != 44");
 static_assert(sizeof(C6) == 52, "sizeof(C6) != 52");
 
 static_assert(sizeof(O2) == 24, "sizeof(O2) != 24");
-#else
+#elif SAL_TYPES_ALIGNMENT8 == 8
 static_assert(sizeof(C3) == 24, "sizeof(C3) != 24");
 static_assert(sizeof(C4) == 40, "sizeof(C4) != 40");
 static_assert(sizeof(C5) == 56, "sizeof(C5) != 56");
 static_assert(sizeof(C6) == 72, "sizeof(C6) != 72");
 
 static_assert(sizeof(O2) == 32, "sizeof(O2) != 32");
+#else
+# error unexpected alignment of 8 byte types
 #endif
 
 static_assert(sizeof(Char3) == 3, "sizeof(Char3) != 3");
 
-#ifdef MAX_ALIGNMENT_4
+#if SAL_TYPES_ALIGNMENT8 == 4
 // max alignment is 4
 static_assert(sizeof(P) == 20, "sizeof(P) != 20");
-#else
+#elif SAL_TYPES_ALIGNMENT8 == 8
 // alignment of P is 8, because of P[] ...
 static_assert(sizeof(P) == 24, "sizeof(P) != 24");
 static_assert(sizeof(second) == sizeof(int), "sizeof(second) != sizeof(int)");
+#else
+# error unexpected alignment of 8 byte types
 #endif
 
 #if OSL_DEBUG_LEVEL > 0
@@ -247,7 +242,7 @@ BinaryCompatible_Impl::BinaryCompatible_Impl()
 
     assert(OFFSET_OF(C2, n2) == 4);
 
-#ifdef MAX_ALIGNMENT_4
+#if SAL_TYPES_ALIGNMENT8 == 4
     assert(OFFSET_OF(C3, d3) == 8);
     assert(OFFSET_OF(C3, n3) == 16);
     assert(OFFSET_OF(C4, n4) == 20);
@@ -258,7 +253,7 @@ BinaryCompatible_Impl::BinaryCompatible_Impl()
     assert(OFFSET_OF(C6, b6) == 48);
 
     assert(OFFSET_OF(O2, p2) == 20);
-#else
+#elif SAL_TYPES_ALIGNMENT8 == 8
     assert(OFFSET_OF(C3, d3) == 8);
     assert(OFFSET_OF(C3, n3) == 16);
     assert(OFFSET_OF(C4, n4) == 24);
@@ -269,6 +264,8 @@ BinaryCompatible_Impl::BinaryCompatible_Impl()
     assert(OFFSET_OF(C6, b6) == 64);
 
     assert(OFFSET_OF(O2, p2) == 24);
+#else
+# error unexpected alignment of 8 byte types
 #endif
 
     assert(OFFSET_OF(Char4, c) == 3);


More information about the Libreoffice-commits mailing list