25#include <rtl/ustring.hxx>
42 sal_Int32
n2 CPPU_GCC3_ALIGN( C1 );
51 sal_Int32
n4 CPPU_GCC3_ALIGN( C3 );
61 C5 c6 CPPU_GCC3_ALIGN( C1 );
90 sal_Int16
p CPPU_GCC3_ALIGN( M );
105 sal_Int16 p2 CPPU_GCC3_ALIGN( O );
116struct second :
public empty
131struct Char2 :
public Char1
133 char c2 CPPU_GCC3_ALIGN( Char1 );
135struct Char3 :
public Char2
137 char c3 CPPU_GCC3_ALIGN( Char2 );
149static_assert(
static_cast<sal_Bool>(
true) == sal_True,
150 "must be binary compatible" );
152static_assert(
static_cast<sal_Bool>(
false) == sal_False,
153 "must be binary compatible" );
154#if SAL_TYPES_ALIGNMENT8 == 2
155static_assert(offsetof(AlignSize_Impl, dDouble) == 2,
"offsetof(AlignSize_Impl, dDouble) != 2");
156static_assert(
sizeof(AlignSize_Impl) == 10,
"sizeof(AlignSize_Impl) != 10");
157#elif SAL_TYPES_ALIGNMENT8 == 4
158static_assert(offsetof(AlignSize_Impl, dDouble) == 4,
"offsetof(AlignSize_Impl, dDouble) != 4");
159static_assert(
sizeof(AlignSize_Impl) == 12,
"sizeof(AlignSize_Impl) != 12");
160#elif SAL_TYPES_ALIGNMENT8 == 8
161static_assert(offsetof(AlignSize_Impl, dDouble) == 8,
"offsetof(AlignSize_Impl, dDouble) != 8");
162static_assert(
sizeof(AlignSize_Impl) == 16,
"sizeof(AlignSize_Impl) != 16");
164# error unexpected alignment of 8 byte types
168static_assert((
SAL_SEQUENCE_HEADER_SIZE % 8) == 0,
"binary compatibility test failed: (SAL_SEQUENCE_HEADER_SIZE % 8) == 0!!!");
170static_assert(
sizeof(Enum) ==
sizeof(sal_Int32),
"binary compatibility test failed: (sizeof(Enum) == sizeof(sal_Int32))");
172static_assert(
sizeof(
void *) >=
sizeof(sal_Int32),
"binary compatibility test failed: (sizeof(void *) >= sizeof(sal_Int32))");
173static_assert(
sizeof(
uno_Any) ==
sizeof(
void *) * 3,
"binary compatibility test failed: (sizeof(uno_Any) == sizeof(void *) * 3");
174static_assert(offsetof(
uno_Any, pType) == 0,
"offsetof(uno_Any, pType) != 0");
175static_assert(offsetof(
uno_Any, pData) == 1 *
sizeof(
void *),
"offsetof(uno_Any, pTData) != (1 * sizeof(void *))");
176static_assert(offsetof(
uno_Any, pReserved) == 2 *
sizeof(
void *),
"offsetof(uno_Any, pReserved) != (2 * sizeof(void *))");
178static_assert(
sizeof(OUString) ==
sizeof(rtl_uString *),
"binary compatibility test failed: sizeof(OUString) != sizeof(rtl_uString *)");
180#if SAL_TYPES_ALIGNMENT8 == 2
181static_assert(
sizeof(
M) == 6,
"sizeof(M) != 6");
182static_assert(
sizeof(
N) == 8,
"sizeof(N) != 8");
183static_assert(
sizeof(
N2) == 8,
"sizeof(N2) != 8");
184static_assert(offsetof(N2, p) == 6,
"offsetof(N2, p) != 6");
186static_assert(
sizeof(
M) == 8,
"sizeof(M) != 8");
187static_assert(
sizeof(
N) == 12,
"sizeof(N) != 12");
188static_assert(
sizeof(
N2) == 12,
"sizeof(N2) != 12");
189static_assert(offsetof(N2, p) == 8,
"offsetof(N2, p) != 8");
191static_assert(offsetof(M, o) == 4,
"offsetof(M, o) != 4");
193#if SAL_TYPES_ALIGNMENT8 == 2
194static_assert(
sizeof(O) == 16,
"sizeof(O) != 16");
195#elif SAL_TYPES_ALIGNMENT8 == 4
196static_assert(
sizeof(O) == 20,
"sizeof(O) != 20");
197#elif SAL_TYPES_ALIGNMENT8 == 8
198static_assert(
sizeof(O) == 24,
"sizeof(O) != 24");
200# error unexpected alignment of 8 byte types
203#if SAL_TYPES_ALIGNMENT8 == 2
204static_assert(
sizeof(
C2) == 6,
"sizeof(C2) != 6");
205static_assert(
sizeof(
D) == 6,
"sizeof(D) != 6");
206static_assert(offsetof(D, e) == 2,
"offsetof(D, e) != 2");
207static_assert(offsetof(E, e) == 6,
"offsetof(E, e) != 6");
209static_assert(
sizeof(
C2) == 8,
"sizeof(C2) != 8");
210static_assert(
sizeof(
D) == 8,
"sizeof(D) != 8");
211static_assert(offsetof(D, e) == 4,
"offsetof(D, e) != 4");
212static_assert(offsetof(E, e) == 8,
"offsetof(E, e) != 8");
215static_assert(
sizeof(
C1) == 2,
"sizeof(C1) != 2");
216static_assert(offsetof(E, d) == 4,
"offsetof(E, d) != 4");
218#if SAL_TYPES_ALIGNMENT8 == 2
219static_assert(
sizeof(C3) == 18,
"sizeof(C3) != 18");
220static_assert(
sizeof(C4) == 30,
"sizeof(C4) != 30");
221static_assert(
sizeof(C5) == 40,
"sizeof(C5) != 40");
222static_assert(
sizeof(C6) == 44,
"sizeof(C6) != 44");
224static_assert(
sizeof(O2) == 18,
"sizeof(O2) != 18");
225#elif SAL_TYPES_ALIGNMENT8 == 4
226static_assert(
sizeof(C3) == 20,
"sizeof(C3) != 20");
227static_assert(
sizeof(C4) == 32,
"sizeof(C4) != 32");
228static_assert(
sizeof(C5) == 44,
"sizeof(C5) != 44");
229static_assert(
sizeof(C6) == 52,
"sizeof(C6) != 52");
231static_assert(
sizeof(O2) == 24,
"sizeof(O2) != 24");
232#elif SAL_TYPES_ALIGNMENT8 == 8
233static_assert(
sizeof(C3) == 24,
"sizeof(C3) != 24");
234static_assert(
sizeof(C4) == 40,
"sizeof(C4) != 40");
235static_assert(
sizeof(C5) == 56,
"sizeof(C5) != 56");
236static_assert(
sizeof(C6) == 72,
"sizeof(C6) != 72");
238static_assert(
sizeof(O2) == 32,
"sizeof(O2) != 32");
240# error unexpected alignment of 8 byte types
243static_assert(
sizeof(Char3) == 3,
"sizeof(Char3) != 3");
245#if SAL_TYPES_ALIGNMENT8 == 2
247static_assert(
sizeof(P) == 16,
"sizeof(P) != 16");
248#elif SAL_TYPES_ALIGNMENT8 == 4
250static_assert(
sizeof(P) == 20,
"sizeof(P) != 20");
251#elif SAL_TYPES_ALIGNMENT8 == 8
253static_assert(
sizeof(P) == 24,
"sizeof(P) != 24");
254static_assert(
sizeof(second) ==
sizeof(
int),
"sizeof(second) != sizeof(int)");
256# error unexpected alignment of 8 byte types
259#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
263#if defined __GNUC__ && (__GNUC__ < 12 || (__GNUC__ == 12 && __GNUC_MINOR__ < 1)) && !defined __clang__
264#pragma GCC diagnostic push
265#pragma GCC diagnostic ignored "-Wattributes"
267 [[maybe_unused]] Char3 chars;
268#if defined __GNUC__ && (__GNUC__ < 12 || (__GNUC__ == 12 && __GNUC_MINOR__ < 1)) && !defined __clang__
269#pragma GCC diagnostic pop
274template<
typename T1,
typename T2> std::size_t OFFSET_OF(T2 T1::* p) {
275 return reinterpret_cast< size_t >(
reinterpret_cast<char *
>(&(
reinterpret_cast<T1 *
>(16)->*p)) -16);
278class BinaryCompatible_Impl
281 BinaryCompatible_Impl();
283BinaryCompatible_Impl::BinaryCompatible_Impl()
285 assert(OFFSET_OF(&N::p) == 8);
287 assert(OFFSET_OF(&C2::n2) == 4);
289#if SAL_TYPES_ALIGNMENT8 == 2
290 assert(OFFSET_OF(&C3::d3) == 6);
291 assert(OFFSET_OF(&C3::n3) == 14);
292 assert(OFFSET_OF(&C4::n4) == 18);
293 assert(OFFSET_OF(&C4::d4) == 22);
294 assert(OFFSET_OF(&C5::n5) == 30);
295 assert(OFFSET_OF(&C5::b5) == 38);
296 assert(OFFSET_OF(&C6::c6) == 2);
297 assert(OFFSET_OF(&C6::b6) == 42);
299 assert(OFFSET_OF(&O2::p2) == 16);
300#elif SAL_TYPES_ALIGNMENT8 == 4
301 assert(OFFSET_OF(&C3::d3) == 8);
302 assert(OFFSET_OF(&C3::n3) == 16);
303 assert(OFFSET_OF(&C4::n4) == 20);
304 assert(OFFSET_OF(&C4::d4) == 24);
305 assert(OFFSET_OF(&C5::n5) == 32);
306 assert(OFFSET_OF(&C5::b5) == 40);
307 assert(OFFSET_OF(&C6::c6) == 4);
308 assert(OFFSET_OF(&C6::b6) == 48);
310 assert(OFFSET_OF(&O2::p2) == 20);
311#elif SAL_TYPES_ALIGNMENT8 == 8
312 assert(OFFSET_OF(&C3::d3) == 8);
313 assert(OFFSET_OF(&C3::n3) == 16);
314 assert(OFFSET_OF(&C4::n4) == 24);
315 assert(OFFSET_OF(&C4::d4) == 32);
316 assert(OFFSET_OF(&C5::n5) == 40);
317 assert(OFFSET_OF(&C5::b5) == 48);
318 assert(OFFSET_OF(&C6::c6) == 8);
319 assert(OFFSET_OF(&C6::b6) == 64);
321 assert(OFFSET_OF(&O2::p2) == 24);
323# error unexpected alignment of 8 byte types
326 assert(OFFSET_OF(&Char4::c) == 3);
329BinaryCompatible_Impl aTest;
#define SAL_SEQUENCE_HEADER_SIZE