summaryrefslogtreecommitdiff
path: root/cppu/source
diff options
context:
space:
mode:
authorDouglas Mencken <dougmencken@gmail.com>2016-03-15 13:52:08 -0400
committerStephan Bergmann <sbergman@redhat.com>2016-03-29 08:28:07 +0000
commit3e48e0ed7114d4a9c26c3ae5087c4f1c352a8a65 (patch)
treef88dc309d965a0125c269452dc9b913da6eaba4b /cppu/source
parent6fa19d6f9d5e108cfa54725847648e1ac2ffbffa (diff)
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@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'cppu/source')
-rw-r--r--cppu/source/uno/check.cxx43
1 files changed, 20 insertions, 23 deletions
diff --git a/cppu/source/uno/check.cxx b/cppu/source/uno/check.cxx
index f6f47e316f97..620a97072a68 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);