| File: | cppu/source/uno/data.cxx |
| Location: | line 63, column 13 |
| Description: | Access to field 'ppAllMembers' results in a dereference of a null pointer (loaded from variable 'pTXInterfaceDescr') |
| 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |||||
| 2 | /* | |||||
| 3 | * This file is part of the LibreOffice project. | |||||
| 4 | * | |||||
| 5 | * This Source Code Form is subject to the terms of the Mozilla Public | |||||
| 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this | |||||
| 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | |||||
| 8 | * | |||||
| 9 | * This file incorporates work covered by the following license notice: | |||||
| 10 | * | |||||
| 11 | * Licensed to the Apache Software Foundation (ASF) under one or more | |||||
| 12 | * contributor license agreements. See the NOTICE file distributed | |||||
| 13 | * with this work for additional information regarding copyright | |||||
| 14 | * ownership. The ASF licenses this file to you under the Apache | |||||
| 15 | * License, Version 2.0 (the "License"); you may not use this file | |||||
| 16 | * except in compliance with the License. You may obtain a copy of | |||||
| 17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | |||||
| 18 | */ | |||||
| 19 | ||||||
| 20 | ||||||
| 21 | #include <cstddef> | |||||
| 22 | #include <stdio.h> | |||||
| 23 | ||||||
| 24 | #include "cppu/macros.hxx" | |||||
| 25 | ||||||
| 26 | #include "osl/mutex.hxx" | |||||
| 27 | ||||||
| 28 | #include "constr.hxx" | |||||
| 29 | #include "destr.hxx" | |||||
| 30 | #include "copy.hxx" | |||||
| 31 | #include "assign.hxx" | |||||
| 32 | #include "eq.hxx" | |||||
| 33 | ||||||
| 34 | #include "boost/static_assert.hpp" | |||||
| 35 | ||||||
| 36 | ||||||
| 37 | using namespace ::cppu; | |||||
| 38 | using namespace ::rtl; | |||||
| 39 | using namespace ::osl; | |||||
| 40 | ||||||
| 41 | ||||||
| 42 | namespace cppu | |||||
| 43 | { | |||||
| 44 | ||||||
| 45 | // Sequence<>() (default ctor) relies on this being static: | |||||
| 46 | uno_Sequence g_emptySeq = { 1, 0, { 0 } }; | |||||
| 47 | typelib_TypeDescriptionReference * g_pVoidType = 0; | |||||
| 48 | ||||||
| 49 | //-------------------------------------------------------------------------------------------------- | |||||
| 50 | void * binuno_queryInterface( void * pUnoI, typelib_TypeDescriptionReference * pDestType ) | |||||
| 51 | { | |||||
| 52 | // init queryInterface() td | |||||
| 53 | static typelib_TypeDescription * g_pQITD = 0; | |||||
| 54 | if (0 == g_pQITD) | |||||
| ||||||
| 55 | { | |||||
| 56 | MutexGuard aGuard( Mutex::getGlobalMutex() ); | |||||
| 57 | if (0 == g_pQITD) | |||||
| 58 | { | |||||
| 59 | typelib_TypeDescriptionReference * type_XInterface = | |||||
| 60 | * typelib_static_type_getByTypeClass( typelib_TypeClass_INTERFACE ); | |||||
| 61 | typelib_InterfaceTypeDescription * pTXInterfaceDescr = 0; | |||||
| 62 | TYPELIB_DANGER_GET( (typelib_TypeDescription **) &pTXInterfaceDescr, type_XInterface ){ typelib_TypeDescriptionReference * pMacroTypeRef = (type_XInterface ); typelib_TypeDescription ** ppMacroTypeDescr = ((typelib_TypeDescription **) &pTXInterfaceDescr); if (((pMacroTypeRef->eTypeClass ) == typelib_TypeClass_INTERFACE_METHOD || (pMacroTypeRef-> eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE)) { typelib_typedescriptionreference_getDescription ( ppMacroTypeDescr, pMacroTypeRef ); } else if (!pMacroTypeRef ->pType || !pMacroTypeRef->pType->pWeakRef) { typelib_typedescriptionreference_getDescription ( ppMacroTypeDescr, pMacroTypeRef ); if (*ppMacroTypeDescr) typelib_typedescription_release ( *ppMacroTypeDescr ); } else { *ppMacroTypeDescr = pMacroTypeRef ->pType; } }; | |||||
| 63 | OSL_ASSERT( pTXInterfaceDescr->ppAllMembers )do { if (true && (!(pTXInterfaceDescr->ppAllMembers ))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/cppu/source/uno/data.cxx" ":" "63" ": "), "OSL_ASSERT: %s", "pTXInterfaceDescr->ppAllMembers" ); } } while (false); | |||||
| ||||||
| 64 | typelib_typedescriptionreference_getDescription( | |||||
| 65 | &g_pQITD, pTXInterfaceDescr->ppAllMembers[ 0 ] ); | |||||
| 66 | TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *) pTXInterfaceDescr ){ if (((((typelib_TypeDescription *) pTXInterfaceDescr)->eTypeClass ) == typelib_TypeClass_INTERFACE_METHOD || (((typelib_TypeDescription *) pTXInterfaceDescr)->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) typelib_typedescription_release( (typelib_TypeDescription * ) pTXInterfaceDescr ); }; | |||||
| 67 | } | |||||
| 68 | } | |||||
| 69 | ||||||
| 70 | uno_Any aRet, aExc; | |||||
| 71 | uno_Any * pExc = &aExc; | |||||
| 72 | void * aArgs[ 1 ]; | |||||
| 73 | aArgs[ 0 ] = &pDestType; | |||||
| 74 | (*((uno_Interface *) pUnoI)->pDispatcher)( | |||||
| 75 | (uno_Interface *) pUnoI, g_pQITD, &aRet, aArgs, &pExc ); | |||||
| 76 | ||||||
| 77 | uno_Interface * ret = 0; | |||||
| 78 | if (0 == pExc) | |||||
| 79 | { | |||||
| 80 | typelib_TypeDescriptionReference * ret_type = aRet.pType; | |||||
| 81 | switch (ret_type->eTypeClass) | |||||
| 82 | { | |||||
| 83 | case typelib_TypeClass_VOID: // common case | |||||
| 84 | typelib_typedescriptionreference_release( ret_type ); | |||||
| 85 | break; | |||||
| 86 | case typelib_TypeClass_INTERFACE: | |||||
| 87 | // tweaky... avoiding acquire/ release pair | |||||
| 88 | typelib_typedescriptionreference_release( ret_type ); | |||||
| 89 | ret = (uno_Interface *) aRet.pReserved; // serving acquired interface | |||||
| 90 | break; | |||||
| 91 | default: | |||||
| 92 | _destructAny( &aRet, 0 ); | |||||
| 93 | break; | |||||
| 94 | } | |||||
| 95 | } | |||||
| 96 | else | |||||
| 97 | { | |||||
| 98 | #if OSL_DEBUG_LEVEL1 > 1 | |||||
| 99 | OUStringBuffer buf( 128 ); | |||||
| 100 | buf.appendAscii( | |||||
| 101 | RTL_CONSTASCII_STRINGPARAM("### exception occurred querying for interface ")(&("### exception occurred querying for interface ")[0]), ((sal_Int32)(sizeof ("### exception occurred querying for interface " ) / sizeof (("### exception occurred querying for interface " )[0]))-1) ); | |||||
| 102 | buf.append( * reinterpret_cast< OUString const * >( &pDestType->pTypeName ) ); | |||||
| 103 | buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(": [")(&(": [")[0]), ((sal_Int32)(sizeof (": [") / sizeof ((": [" )[0]))-1) ); | |||||
| 104 | buf.append( * reinterpret_cast< OUString const * >( &pExc->pType->pTypeName ) ); | |||||
| 105 | buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("] ")(&("] ")[0]), ((sal_Int32)(sizeof ("] ") / sizeof (("] ") [0]))-1) ); | |||||
| 106 | // Message is very first member | |||||
| 107 | buf.append( * reinterpret_cast< OUString const * >( pExc->pData ) ); | |||||
| 108 | OString cstr( | |||||
| 109 | OUStringToOString( buf.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) ) ); | |||||
| 110 | OSL_FAIL( cstr.getStr() )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppu/source/uno/data.cxx" ":" "110" ": "), "%s", cstr.getStr()); } } while (false); | |||||
| 111 | #endif | |||||
| 112 | uno_any_destruct( pExc, 0 ); | |||||
| 113 | } | |||||
| 114 | return ret; | |||||
| 115 | } | |||||
| 116 | ||||||
| 117 | //================================================================================================== | |||||
| 118 | void defaultConstructStruct( | |||||
| 119 | void * pMem, | |||||
| 120 | typelib_CompoundTypeDescription * pCompType ) | |||||
| 121 | SAL_THROW(()) | |||||
| 122 | { | |||||
| 123 | _defaultConstructStruct( pMem, pCompType ); | |||||
| 124 | } | |||||
| 125 | //================================================================================================== | |||||
| 126 | void copyConstructStruct( | |||||
| 127 | void * pDest, void * pSource, | |||||
| 128 | typelib_CompoundTypeDescription * pTypeDescr, | |||||
| 129 | uno_AcquireFunc acquire, uno_Mapping * mapping ) | |||||
| 130 | SAL_THROW(()) | |||||
| 131 | { | |||||
| 132 | _copyConstructStruct( pDest, pSource, pTypeDescr, acquire, mapping ); | |||||
| 133 | } | |||||
| 134 | //================================================================================================== | |||||
| 135 | void destructStruct( | |||||
| 136 | void * pValue, | |||||
| 137 | typelib_CompoundTypeDescription * pTypeDescr, | |||||
| 138 | uno_ReleaseFunc release ) | |||||
| 139 | SAL_THROW(()) | |||||
| 140 | { | |||||
| 141 | _destructStruct( pValue, pTypeDescr, release ); | |||||
| 142 | } | |||||
| 143 | //================================================================================================== | |||||
| 144 | sal_Bool equalStruct( | |||||
| 145 | void * pDest, void *pSource, | |||||
| 146 | typelib_CompoundTypeDescription * pTypeDescr, | |||||
| 147 | uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release ) | |||||
| 148 | SAL_THROW(()) | |||||
| 149 | { | |||||
| 150 | return _equalStruct( pDest, pSource, pTypeDescr, queryInterface, release ); | |||||
| 151 | } | |||||
| 152 | //================================================================================================== | |||||
| 153 | sal_Bool assignStruct( | |||||
| 154 | void * pDest, void * pSource, | |||||
| 155 | typelib_CompoundTypeDescription * pTypeDescr, | |||||
| 156 | uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release ) | |||||
| 157 | SAL_THROW(()) | |||||
| 158 | { | |||||
| 159 | return _assignStruct( pDest, pSource, pTypeDescr, queryInterface, acquire, release ); | |||||
| 160 | } | |||||
| 161 | ||||||
| 162 | //============================================================================== | |||||
| 163 | uno_Sequence * copyConstructSequence( | |||||
| 164 | uno_Sequence * pSource, | |||||
| 165 | typelib_TypeDescriptionReference * pElementType, | |||||
| 166 | uno_AcquireFunc acquire, uno_Mapping * mapping ) | |||||
| 167 | { | |||||
| 168 | return icopyConstructSequence( pSource, pElementType, acquire, mapping ); | |||||
| 169 | } | |||||
| 170 | ||||||
| 171 | //============================================================================== | |||||
| 172 | void destructSequence( | |||||
| 173 | uno_Sequence * pSequence, | |||||
| 174 | typelib_TypeDescriptionReference * pType, | |||||
| 175 | typelib_TypeDescription * pTypeDescr, | |||||
| 176 | uno_ReleaseFunc release ) | |||||
| 177 | { | |||||
| 178 | idestructSequence( pSequence, pType, pTypeDescr, release ); | |||||
| 179 | } | |||||
| 180 | ||||||
| 181 | //================================================================================================== | |||||
| 182 | sal_Bool equalSequence( | |||||
| 183 | uno_Sequence * pDest, uno_Sequence * pSource, | |||||
| 184 | typelib_TypeDescriptionReference * pElementType, | |||||
| 185 | uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release ) | |||||
| 186 | SAL_THROW(()) | |||||
| 187 | { | |||||
| 188 | return _equalSequence( pDest, pSource, pElementType, queryInterface, release ); | |||||
| 189 | } | |||||
| 190 | ||||||
| 191 | extern "C" | |||||
| 192 | { | |||||
| 193 | //################################################################################################## | |||||
| 194 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) void SAL_CALL uno_type_constructData( | |||||
| 195 | void * pMem, typelib_TypeDescriptionReference * pType ) | |||||
| 196 | SAL_THROW_EXTERN_C()throw () | |||||
| 197 | { | |||||
| 198 | _defaultConstructData( pMem, pType, 0 ); | |||||
| 199 | } | |||||
| 200 | //################################################################################################## | |||||
| 201 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) void SAL_CALL uno_constructData( | |||||
| 202 | void * pMem, typelib_TypeDescription * pTypeDescr ) | |||||
| 203 | SAL_THROW_EXTERN_C()throw () | |||||
| 204 | { | |||||
| 205 | _defaultConstructData( pMem, pTypeDescr->pWeakRef, pTypeDescr ); | |||||
| 206 | } | |||||
| 207 | //################################################################################################## | |||||
| 208 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) void SAL_CALL uno_type_destructData( | |||||
| 209 | void * pValue, typelib_TypeDescriptionReference * pType, | |||||
| 210 | uno_ReleaseFunc release ) | |||||
| 211 | SAL_THROW_EXTERN_C()throw () | |||||
| 212 | { | |||||
| 213 | _destructData( pValue, pType, 0, release ); | |||||
| 214 | } | |||||
| 215 | //################################################################################################## | |||||
| 216 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) void SAL_CALL uno_destructData( | |||||
| 217 | void * pValue, | |||||
| 218 | typelib_TypeDescription * pTypeDescr, | |||||
| 219 | uno_ReleaseFunc release ) | |||||
| 220 | SAL_THROW_EXTERN_C()throw () | |||||
| 221 | { | |||||
| 222 | _destructData( pValue, pTypeDescr->pWeakRef, pTypeDescr, release ); | |||||
| 223 | } | |||||
| 224 | //################################################################################################## | |||||
| 225 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) void SAL_CALL uno_type_copyData( | |||||
| 226 | void * pDest, void * pSource, | |||||
| 227 | typelib_TypeDescriptionReference * pType, | |||||
| 228 | uno_AcquireFunc acquire ) | |||||
| 229 | SAL_THROW_EXTERN_C()throw () | |||||
| 230 | { | |||||
| 231 | _copyConstructData( pDest, pSource, pType, 0, acquire, 0 ); | |||||
| 232 | } | |||||
| 233 | //################################################################################################## | |||||
| 234 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) void SAL_CALL uno_copyData( | |||||
| 235 | void * pDest, void * pSource, | |||||
| 236 | typelib_TypeDescription * pTypeDescr, | |||||
| 237 | uno_AcquireFunc acquire ) | |||||
| 238 | SAL_THROW_EXTERN_C()throw () | |||||
| 239 | { | |||||
| 240 | _copyConstructData( pDest, pSource, pTypeDescr->pWeakRef, pTypeDescr, acquire, 0 ); | |||||
| 241 | } | |||||
| 242 | //################################################################################################## | |||||
| 243 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) void SAL_CALL uno_type_copyAndConvertData( | |||||
| 244 | void * pDest, void * pSource, | |||||
| 245 | typelib_TypeDescriptionReference * pType, | |||||
| 246 | uno_Mapping * mapping ) | |||||
| 247 | SAL_THROW_EXTERN_C()throw () | |||||
| 248 | { | |||||
| 249 | _copyConstructData( pDest, pSource, pType, 0, 0, mapping ); | |||||
| 250 | } | |||||
| 251 | //################################################################################################## | |||||
| 252 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) void SAL_CALL uno_copyAndConvertData( | |||||
| 253 | void * pDest, void * pSource, | |||||
| 254 | typelib_TypeDescription * pTypeDescr, | |||||
| 255 | uno_Mapping * mapping ) | |||||
| 256 | SAL_THROW_EXTERN_C()throw () | |||||
| 257 | { | |||||
| 258 | _copyConstructData( pDest, pSource, pTypeDescr->pWeakRef, pTypeDescr, 0, mapping ); | |||||
| 259 | } | |||||
| 260 | //################################################################################################## | |||||
| 261 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) sal_Bool SAL_CALL uno_type_equalData( | |||||
| 262 | void * pVal1, typelib_TypeDescriptionReference * pVal1Type, | |||||
| 263 | void * pVal2, typelib_TypeDescriptionReference * pVal2Type, | |||||
| 264 | uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release ) | |||||
| 265 | SAL_THROW_EXTERN_C()throw () | |||||
| 266 | { | |||||
| 267 | return _equalData( | |||||
| 268 | pVal1, pVal1Type, 0, | |||||
| 269 | pVal2, pVal2Type, | |||||
| 270 | queryInterface, release ); | |||||
| 271 | } | |||||
| 272 | //################################################################################################## | |||||
| 273 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) sal_Bool SAL_CALL uno_equalData( | |||||
| 274 | void * pVal1, typelib_TypeDescription * pVal1TD, | |||||
| 275 | void * pVal2, typelib_TypeDescription * pVal2TD, | |||||
| 276 | uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release ) | |||||
| 277 | SAL_THROW_EXTERN_C()throw () | |||||
| 278 | { | |||||
| 279 | return _equalData( | |||||
| 280 | pVal1, pVal1TD->pWeakRef, pVal1TD, | |||||
| 281 | pVal2, pVal2TD->pWeakRef, | |||||
| 282 | queryInterface, release ); | |||||
| 283 | } | |||||
| 284 | //################################################################################################## | |||||
| 285 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) sal_Bool SAL_CALL uno_type_assignData( | |||||
| 286 | void * pDest, typelib_TypeDescriptionReference * pDestType, | |||||
| 287 | void * pSource, typelib_TypeDescriptionReference * pSourceType, | |||||
| 288 | uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release ) | |||||
| 289 | SAL_THROW_EXTERN_C()throw () | |||||
| 290 | { | |||||
| 291 | return _assignData( | |||||
| 292 | pDest, pDestType, 0, | |||||
| 293 | pSource, pSourceType, 0, | |||||
| 294 | queryInterface, acquire, release ); | |||||
| 295 | } | |||||
| 296 | //################################################################################################## | |||||
| 297 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) sal_Bool SAL_CALL uno_assignData( | |||||
| 298 | void * pDest, typelib_TypeDescription * pDestTD, | |||||
| 299 | void * pSource, typelib_TypeDescription * pSourceTD, | |||||
| 300 | uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release ) | |||||
| 301 | SAL_THROW_EXTERN_C()throw () | |||||
| 302 | { | |||||
| 303 | return _assignData( | |||||
| 304 | pDest, pDestTD->pWeakRef, pDestTD, | |||||
| 305 | pSource, pSourceTD->pWeakRef, pSourceTD, | |||||
| 306 | queryInterface, acquire, release ); | |||||
| 307 | } | |||||
| 308 | //################################################################################################## | |||||
| 309 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) sal_Bool SAL_CALL uno_type_isAssignableFromData( | |||||
| 310 | typelib_TypeDescriptionReference * pAssignable, | |||||
| 311 | void * pFrom, typelib_TypeDescriptionReference * pFromType, | |||||
| 312 | uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release ) | |||||
| 313 | SAL_THROW_EXTERN_C()throw () | |||||
| 314 | { | |||||
| 315 | if (::typelib_typedescriptionreference_isAssignableFrom( pAssignable, pFromType )) | |||||
| 316 | return sal_True((sal_Bool)1); | |||||
| 317 | if (typelib_TypeClass_INTERFACE != pFromType->eTypeClass || | |||||
| 318 | typelib_TypeClass_INTERFACE != pAssignable->eTypeClass) | |||||
| 319 | { | |||||
| 320 | return sal_False((sal_Bool)0); | |||||
| 321 | } | |||||
| 322 | ||||||
| 323 | // query | |||||
| 324 | if (0 == pFrom) | |||||
| 325 | return sal_False((sal_Bool)0); | |||||
| 326 | void * pInterface = *(void **)pFrom; | |||||
| 327 | if (0 == pInterface) | |||||
| 328 | return sal_False((sal_Bool)0); | |||||
| 329 | ||||||
| 330 | if (0 == queryInterface) | |||||
| 331 | queryInterface = binuno_queryInterface; | |||||
| 332 | void * p = (*queryInterface)( pInterface, pAssignable ); | |||||
| 333 | _release( p, release ); | |||||
| 334 | return (0 != p); | |||||
| 335 | } | |||||
| 336 | } | |||||
| 337 | ||||||
| 338 | ||||||
| 339 | //################################################################################################## | |||||
| 340 | //################################################################################################## | |||||
| 341 | //################################################################################################## | |||||
| 342 | ||||||
| 343 | ||||||
| 344 | #if OSL_DEBUG_LEVEL1 > 1 | |||||
| 345 | ||||||
| 346 | #if defined( SAL_W32) | |||||
| 347 | #pragma pack(push, 8) | |||||
| 348 | #endif | |||||
| 349 | ||||||
| 350 | // Why hardcode like this instead of using the (generated) | |||||
| 351 | // <sal/typesizes.h> ? | |||||
| 352 | ||||||
| 353 | #if (defined(INTEL1) \ | |||||
| 354 | && (defined(__GNUC__4) && (defined(LINUX1) || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD)) \ | |||||
| 355 | || defined(MACOSX) || defined(DRAGONFLY) || (defined(__SUNPRO_CC) && defined(SOLARIS)))) \ | |||||
| 356 | || defined(IOS) | |||||
| 357 | #define MAX_ALIGNMENT_4 | |||||
| 358 | #endif | |||||
| 359 | ||||||
| 360 | #define OFFSET_OF( s, m ) reinterpret_cast< size_t >((char *)&((s *)16)->m -16) | |||||
| 361 | ||||||
| 362 | #define BINTEST_VERIFY( c ) \ | |||||
| 363 | if (! (c)) \ | |||||
| 364 | { \ | |||||
| 365 | fprintf( stderrstderr, "### binary compatibility test failed: %s [line %d]!!!\n", #c, __LINE__365 ); \ | |||||
| 366 | abort(); \ | |||||
| 367 | } | |||||
| 368 | ||||||
| 369 | #define BINTEST_VERIFYOFFSET( s, m, n ) \ | |||||
| 370 | if (OFFSET_OF(s, m) != static_cast<size_t>(n)) \ | |||||
| 371 | { \ | |||||
| 372 | fprintf(stderrstderr, "### OFFSET_OF(" #s ", " #m ") = %" SAL_PRI_SIZET"z" "u instead of expected %" SAL_PRI_SIZET"z" "u!!!\n", \ | |||||
| 373 | OFFSET_OF(s, m), static_cast<size_t>(n)); \ | |||||
| 374 | abort(); \ | |||||
| 375 | } | |||||
| 376 | ||||||
| 377 | #define BINTEST_VERIFYSIZE( s, n ) \ | |||||
| 378 | if (sizeof(s) != static_cast<size_t>(n)) \ | |||||
| 379 | { \ | |||||
| 380 | fprintf(stderrstderr, "### sizeof(" #s ") = %" SAL_PRI_SIZET"z" "u instead of expected %" SAL_PRI_SIZET"z" "u!!!\n", \ | |||||
| 381 | sizeof(s), static_cast<size_t>(n)); \ | |||||
| 382 | abort(); \ | |||||
| 383 | } | |||||
| 384 | ||||||
| 385 | struct C1 | |||||
| 386 | { | |||||
| 387 | sal_Int16 n1; | |||||
| 388 | }; | |||||
| 389 | struct C2 : public C1 | |||||
| 390 | { | |||||
| 391 | sal_Int32 n2 CPPU_GCC3_ALIGN( C1 )__attribute__ ((aligned (__alignof__ (C1)))); | |||||
| 392 | }; | |||||
| 393 | struct C3 : public C2 | |||||
| 394 | { | |||||
| 395 | double d3; | |||||
| 396 | sal_Int32 n3; | |||||
| 397 | }; | |||||
| 398 | struct C4 : public C3 | |||||
| 399 | { | |||||
| 400 | sal_Int32 n4 CPPU_GCC3_ALIGN( C3 )__attribute__ ((aligned (__alignof__ (C3)))); | |||||
| 401 | double d4; | |||||
| 402 | }; | |||||
| 403 | struct C5 : public C4 | |||||
| 404 | { | |||||
| 405 | sal_Int64 n5; | |||||
| 406 | sal_Bool b5; | |||||
| 407 | }; | |||||
| 408 | struct C6 : public C1 | |||||
| 409 | { | |||||
| 410 | C5 c6 CPPU_GCC3_ALIGN( C1 )__attribute__ ((aligned (__alignof__ (C1)))); | |||||
| 411 | sal_Bool b6; | |||||
| 412 | }; | |||||
| 413 | ||||||
| 414 | struct D | |||||
| 415 | { | |||||
| 416 | sal_Int16 d; | |||||
| 417 | sal_Int32 e; | |||||
| 418 | }; | |||||
| 419 | struct E | |||||
| 420 | { | |||||
| 421 | sal_Bool a; | |||||
| 422 | sal_Bool b; | |||||
| 423 | sal_Bool c; | |||||
| 424 | sal_Int16 d; | |||||
| 425 | sal_Int32 e; | |||||
| 426 | }; | |||||
| 427 | ||||||
| 428 | struct M | |||||
| 429 | { | |||||
| 430 | sal_Int32 n; | |||||
| 431 | sal_Int16 o; | |||||
| 432 | }; | |||||
| 433 | ||||||
| 434 | struct N : public M | |||||
| 435 | { | |||||
| 436 | sal_Int16 p CPPU_GCC3_ALIGN( M )__attribute__ ((aligned (__alignof__ (M)))); | |||||
| 437 | }; | |||||
| 438 | struct N2 | |||||
| 439 | { | |||||
| 440 | M m; | |||||
| 441 | sal_Int16 p; | |||||
| 442 | }; | |||||
| 443 | ||||||
| 444 | struct O : public M | |||||
| 445 | { | |||||
| 446 | double p; | |||||
| 447 | sal_Int16 q; | |||||
| 448 | }; | |||||
| 449 | struct O2 : public O | |||||
| 450 | { | |||||
| 451 | sal_Int16 p2 CPPU_GCC3_ALIGN( O )__attribute__ ((aligned (__alignof__ (O)))); | |||||
| 452 | }; | |||||
| 453 | ||||||
| 454 | struct P : public N | |||||
| 455 | { | |||||
| 456 | double p2; | |||||
| 457 | }; | |||||
| 458 | ||||||
| 459 | struct empty | |||||
| 460 | { | |||||
| 461 | }; | |||||
| 462 | struct second : public empty | |||||
| 463 | { | |||||
| 464 | int a; | |||||
| 465 | }; | |||||
| 466 | ||||||
| 467 | struct AlignSize_Impl | |||||
| 468 | { | |||||
| 469 | sal_Int16 nInt16; | |||||
| 470 | double dDouble; | |||||
| 471 | }; | |||||
| 472 | ||||||
| 473 | struct Char1 | |||||
| 474 | { | |||||
| 475 | char c1; | |||||
| 476 | }; | |||||
| 477 | struct Char2 : public Char1 | |||||
| 478 | { | |||||
| 479 | char c2 CPPU_GCC3_ALIGN( Char1 )__attribute__ ((aligned (__alignof__ (Char1)))); | |||||
| 480 | }; | |||||
| 481 | struct Char3 : public Char2 | |||||
| 482 | { | |||||
| 483 | char c3 CPPU_GCC3_ALIGN( Char2 )__attribute__ ((aligned (__alignof__ (Char2)))); | |||||
| 484 | }; | |||||
| 485 | struct Char4 | |||||
| 486 | { | |||||
| 487 | Char3 chars; | |||||
| 488 | char c; | |||||
| 489 | }; | |||||
| 490 | class Ref | |||||
| 491 | { | |||||
| 492 | void * p; | |||||
| 493 | }; | |||||
| 494 | enum Enum | |||||
| 495 | { | |||||
| 496 | v = SAL_MAX_ENUM0x7fffffff | |||||
| 497 | }; | |||||
| 498 | ||||||
| 499 | ||||||
| 500 | class BinaryCompatible_Impl | |||||
| 501 | { | |||||
| 502 | public: | |||||
| 503 | BinaryCompatible_Impl(); | |||||
| 504 | }; | |||||
| 505 | BinaryCompatible_Impl::BinaryCompatible_Impl() | |||||
| 506 | { | |||||
| 507 | BOOST_STATIC_ASSERT( ((sal_Bool) true) == sal_True &&typedef ::boost::static_assert_test< sizeof(::boost::STATIC_ASSERTION_FAILURE < ((((sal_Bool) true) == ((sal_Bool)1) && (1 != 0) == ((sal_Bool)1)) == 0 ? false : true) >)> boost_static_assert_typedef_508 | |||||
| 508 | (1 != 0) == sal_True )typedef ::boost::static_assert_test< sizeof(::boost::STATIC_ASSERTION_FAILURE < ((((sal_Bool) true) == ((sal_Bool)1) && (1 != 0) == ((sal_Bool)1)) == 0 ? false : true) >)> boost_static_assert_typedef_508; | |||||
| 509 | BOOST_STATIC_ASSERT( ((sal_Bool) false) == sal_False &&typedef ::boost::static_assert_test< sizeof(::boost::STATIC_ASSERTION_FAILURE < ((((sal_Bool) false) == ((sal_Bool)0) && (1 == 0 ) == ((sal_Bool)0)) == 0 ? false : true) >)> boost_static_assert_typedef_510 | |||||
| 510 | (1 == 0) == sal_False )typedef ::boost::static_assert_test< sizeof(::boost::STATIC_ASSERTION_FAILURE < ((((sal_Bool) false) == ((sal_Bool)0) && (1 == 0 ) == ((sal_Bool)0)) == 0 ? false : true) >)> boost_static_assert_typedef_510; | |||||
| 511 | #ifdef MAX_ALIGNMENT_4 | |||||
| 512 | // max alignment is 4 | |||||
| 513 | BINTEST_VERIFYOFFSET( AlignSize_Impl, dDouble, 4 ); | |||||
| 514 | BINTEST_VERIFYSIZE( AlignSize_Impl, 12 ); | |||||
| 515 | #else | |||||
| 516 | // max alignment is 8 | |||||
| 517 | BINTEST_VERIFYOFFSET( AlignSize_Impl, dDouble, 8 ); | |||||
| 518 | BINTEST_VERIFYSIZE( AlignSize_Impl, 16 ); | |||||
| 519 | #endif | |||||
| 520 | ||||||
| 521 | // sequence | |||||
| 522 | BINTEST_VERIFY( (SAL_SEQUENCE_HEADER_SIZE((sal_Size)&((sal_Sequence *)0)->elements) % 8) == 0 ); | |||||
| 523 | // enum | |||||
| 524 | BINTEST_VERIFY( sizeof( Enum ) == sizeof( sal_Int32 ) ); | |||||
| 525 | // any | |||||
| 526 | BINTEST_VERIFY( sizeof(void *) >= sizeof(sal_Int32) ); | |||||
| 527 | BINTEST_VERIFY( sizeof( uno_Any ) == sizeof( void * ) * 3 ); | |||||
| 528 | BINTEST_VERIFYOFFSET( uno_Any, pType, 0 ); | |||||
| 529 | BINTEST_VERIFYOFFSET( uno_Any, pData, 1 * sizeof (void *) ); | |||||
| 530 | BINTEST_VERIFYOFFSET( uno_Any, pReserved, 2 * sizeof (void *) ); | |||||
| 531 | // interface | |||||
| 532 | BINTEST_VERIFY( sizeof( Ref ) == sizeof( void * ) ); | |||||
| 533 | // string | |||||
| 534 | BINTEST_VERIFY( sizeof( OUString ) == sizeof( rtl_uString * ) ); | |||||
| 535 | // struct | |||||
| 536 | BINTEST_VERIFYSIZE( M, 8 ); | |||||
| 537 | BINTEST_VERIFYOFFSET( M, o, 4 ); | |||||
| 538 | BINTEST_VERIFYSIZE( N, 12 ); | |||||
| 539 | BINTEST_VERIFYOFFSET( N, p, 8 ); | |||||
| 540 | BINTEST_VERIFYSIZE( N2, 12 ); | |||||
| 541 | BINTEST_VERIFYOFFSET( N2, p, 8 ); | |||||
| 542 | #ifdef MAX_ALIGNMENT_4 | |||||
| 543 | BINTEST_VERIFYSIZE( O, 20 ); | |||||
| 544 | #else | |||||
| 545 | BINTEST_VERIFYSIZE( O, 24 ); | |||||
| 546 | #endif | |||||
| 547 | BINTEST_VERIFYSIZE( D, 8 ); | |||||
| 548 | BINTEST_VERIFYOFFSET( D, e, 4 ); | |||||
| 549 | BINTEST_VERIFYOFFSET( E, d, 4 ); | |||||
| 550 | BINTEST_VERIFYOFFSET( E, e, 8 ); | |||||
| 551 | ||||||
| 552 | BINTEST_VERIFYSIZE( C1, 2 ); | |||||
| 553 | BINTEST_VERIFYSIZE( C2, 8 ); | |||||
| 554 | BINTEST_VERIFYOFFSET( C2, n2, 4 ); | |||||
| 555 | ||||||
| 556 | #ifdef MAX_ALIGNMENT_4 | |||||
| 557 | BINTEST_VERIFYSIZE( C3, 20 ); | |||||
| 558 | BINTEST_VERIFYOFFSET( C3, d3, 8 ); | |||||
| 559 | BINTEST_VERIFYOFFSET( C3, n3, 16 ); | |||||
| 560 | BINTEST_VERIFYSIZE( C4, 32 ); | |||||
| 561 | BINTEST_VERIFYOFFSET( C4, n4, 20 ); | |||||
| 562 | BINTEST_VERIFYOFFSET( C4, d4, 24 ); | |||||
| 563 | BINTEST_VERIFYSIZE( C5, 44 ); | |||||
| 564 | BINTEST_VERIFYOFFSET( C5, n5, 32 ); | |||||
| 565 | BINTEST_VERIFYOFFSET( C5, b5, 40 ); | |||||
| 566 | BINTEST_VERIFYSIZE( C6, 52 ); | |||||
| 567 | BINTEST_VERIFYOFFSET( C6, c6, 4 ); | |||||
| 568 | BINTEST_VERIFYOFFSET( C6, b6, 48 ); | |||||
| 569 | ||||||
| 570 | BINTEST_VERIFYSIZE( O2, 24 ); | |||||
| 571 | BINTEST_VERIFYOFFSET( O2, p2, 20 ); | |||||
| 572 | #else | |||||
| 573 | BINTEST_VERIFYSIZE( C3, 24 ); | |||||
| 574 | BINTEST_VERIFYOFFSET( C3, d3, 8 ); | |||||
| 575 | BINTEST_VERIFYOFFSET( C3, n3, 16 ); | |||||
| 576 | BINTEST_VERIFYSIZE( C4, 40 ); | |||||
| 577 | BINTEST_VERIFYOFFSET( C4, n4, 24 ); | |||||
| 578 | BINTEST_VERIFYOFFSET( C4, d4, 32 ); | |||||
| 579 | BINTEST_VERIFYSIZE( C5, 56 ); | |||||
| 580 | BINTEST_VERIFYOFFSET( C5, n5, 40 ); | |||||
| 581 | BINTEST_VERIFYOFFSET( C5, b5, 48 ); | |||||
| 582 | BINTEST_VERIFYSIZE( C6, 72 ); | |||||
| 583 | BINTEST_VERIFYOFFSET( C6, c6, 8 ); | |||||
| 584 | BINTEST_VERIFYOFFSET( C6, b6, 64 ); | |||||
| 585 | ||||||
| 586 | BINTEST_VERIFYSIZE( O2, 32 ); | |||||
| 587 | BINTEST_VERIFYOFFSET( O2, p2, 24 ); | |||||
| 588 | #endif | |||||
| 589 | ||||||
| 590 | BINTEST_VERIFYSIZE( Char3, 3 ); | |||||
| 591 | BINTEST_VERIFYOFFSET( Char4, c, 3 ); | |||||
| 592 | ||||||
| 593 | #ifdef MAX_ALIGNMENT_4 | |||||
| 594 | // max alignment is 4 | |||||
| 595 | BINTEST_VERIFYSIZE( P, 20 ); | |||||
| 596 | #else | |||||
| 597 | // alignment of P is 8, because of P[] ... | |||||
| 598 | BINTEST_VERIFYSIZE( P, 24 ); | |||||
| 599 | BINTEST_VERIFYSIZE( second, sizeof( int ) ); | |||||
| 600 | #endif | |||||
| 601 | } | |||||
| 602 | ||||||
| 603 | #ifdef SAL_W32 | |||||
| 604 | # pragma pack(pop) | |||||
| 605 | #endif | |||||
| 606 | ||||||
| 607 | static BinaryCompatible_Impl aTest; | |||||
| 608 | ||||||
| 609 | #endif | |||||
| 610 | ||||||
| 611 | } | |||||
| 612 | ||||||
| 613 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |