diff options
author | Jan Holesovsky <kendy@suse.cz> | 2011-03-23 16:59:59 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2011-03-23 16:59:59 +0100 |
commit | 4be7cca60bc7cc0a066b7384d56624266dc0dfcf (patch) | |
tree | 990b1fda00fca6f26ff74fd29552687b4e3c37ed /sal | |
parent | 79a6c0f8a28b43c36c3b02dc5e116f2d17e92ef0 (diff) | |
parent | a24842b43a687808376f69d4bdbb45fcddde73c4 (diff) |
Merge commit 'ooo/DEV300_m103'
Conflicts:
codemaker/source/bonobowrappermaker/corbaoptions.cxx
codemaker/source/cppumaker/cppuoptions.cxx
codemaker/source/cunomaker/cunooptions.cxx
codemaker/source/idlmaker/idloptions.cxx
codemaker/source/javamaker/javaoptions.cxx
cppu/source/typelib/typelib.cxx
idlc/source/options.cxx
offapi/com/sun/star/util/PathSubstitution.idl
offapi/drafts/com/sun/star/form/ListEntryEvent.idl
offapi/drafts/com/sun/star/form/XBindableValue.idl
offapi/drafts/com/sun/star/form/XListEntryListener.idl
offapi/drafts/com/sun/star/form/XListEntrySink.idl
offapi/drafts/com/sun/star/form/XListEntrySource.idl
offapi/drafts/com/sun/star/form/XValueBinding.idl
registry/tools/checksingleton.cxx
registry/tools/options.hxx
registry/tools/regcompare.cxx
registry/tools/regmerge.cxx
sal/cppunittester/cppunittester.cxx
sal/osl/unx/socket.c
sal/osl/w32/diagnose.c
sal/prj/d.lst
sal/rtl/source/alloc_fini.cxx
sal/rtl/source/alloc_global.c
sal/rtl/source/makefile.mk
Diffstat (limited to 'sal')
-rw-r--r-- | sal/cppunittester/cppunittester.cxx | 95 | ||||
-rw-r--r-- | sal/inc/cppunittester/protectorfactory.hxx | 45 | ||||
-rw-r--r-- | sal/osl/os2/diagnose.c | 3 | ||||
-rw-r--r-- | sal/osl/unx/diagnose.c | 16 | ||||
-rw-r--r-- | sal/osl/unx/file.cxx | 3 | ||||
-rw-r--r-- | sal/osl/unx/file_misc.cxx | 6 | ||||
-rw-r--r-- | sal/osl/unx/file_path_helper.cxx | 80 | ||||
-rw-r--r-- | sal/osl/unx/process_impl.cxx | 19 | ||||
-rw-r--r-- | sal/osl/unx/profile.c | 1 | ||||
-rw-r--r-- | sal/osl/unx/socket.c | 13 | ||||
-rwxr-xr-x | sal/osl/w32/diagnose.c | 52 | ||||
-rw-r--r-- | sal/osl/w32/file_dirvol.cxx | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | sal/osl/w32/module.cxx | 23 | ||||
-rwxr-xr-x[-rw-r--r--] | sal/osl/w32/procimpl.cxx | 35 | ||||
-rw-r--r-- | sal/prj/d.lst | 3 | ||||
-rw-r--r-- | sal/rtl/source/alloc_arena.c | 37 | ||||
-rw-r--r-- | sal/rtl/source/alloc_cache.c | 53 | ||||
-rw-r--r-- | sal/rtl/source/alloc_fini.cxx (renamed from sal/rtl/source/memory_fini.cxx) | 23 | ||||
-rw-r--r-- | sal/rtl/source/alloc_global.c | 2 | ||||
-rw-r--r-- | sal/rtl/source/alloc_impl.h | 24 | ||||
-rw-r--r-- | sal/rtl/source/makefile.mk | 9 |
21 files changed, 410 insertions, 134 deletions
diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx index 87d250114eb9..dd3d724298e3 100644 --- a/sal/cppunittester/cppunittester.cxx +++ b/sal/cppunittester/cppunittester.cxx @@ -29,13 +29,27 @@ #include "precompiled_sal.hxx" #include "sal/config.h" -#include <cstdlib> -#include <iostream> - #ifdef WNT #include <windows.h> #endif +#include <cstdlib> +#include <iostream> +#include <limits> +#include <string> + +#include "cppunittester/protectorfactory.hxx" +#include "osl/module.h" +#include "osl/module.hxx" +#include "osl/thread.h" +#include "rtl/process.h" +#include "rtl/string.h" +#include "rtl/string.hxx" +#include "rtl/textcvt.h" +#include "rtl/ustring.hxx" +#include "sal/main.h" +#include "sal/types.h" + #include "cppunit/CompilerOutputter.h" #include "cppunit/TestResult.h" #include "cppunit/TestResultCollector.h" @@ -43,15 +57,36 @@ #include "cppunit/extensions/TestFactoryRegistry.h" #include "cppunit/plugin/PlugInManager.h" #include "cppunit/portability/Stream.h" -#include "osl/thread.h" -#include "rtl/process.h" -#include "rtl/string.hxx" -#include "rtl/ustring.hxx" -#include "sal/main.h" -SAL_IMPLEMENT_MAIN() -{ +namespace { + +void usageFailure() { + std::cerr + << ("Usage: cppunittester (--protector <shared-library-path>" + " <function-symbol>)* <shared-library-path>") + << std::endl; + std::exit(EXIT_FAILURE); +} + +rtl::OUString getArgument(sal_Int32 index) { + rtl::OUString arg; + rtl_getAppCommandArg(index, &arg.pData); + return arg; +} + +std::string convertLazy(rtl::OUString const & s16) { + rtl::OString s8(rtl::OUStringToOString(s16, osl_getThreadTextEncoding())); + return std::string( + s8.getStr(), + ((static_cast< sal_uInt32 >(s8.getLength()) + > std::numeric_limits< std::string::size_type >::max()) + ? std::numeric_limits< std::string::size_type >::max() + : static_cast< std::string::size_type >(s8.getLength()))); +} +} + +SAL_IMPLEMENT_MAIN() { #ifdef WNT //Disable Dr-Watson in order to crash simply without popup dialogs under //windows @@ -59,31 +94,55 @@ SAL_IMPLEMENT_MAIN() SetErrorMode(SEM_NOGPFAULTERRORBOX|dwMode); #endif - sal_uInt32 nCommandArgs = rtl_getAppCommandArgCount(); - if (nCommandArgs < 1) - { - std::cerr << "Usage: cppunittester <shared-library-path>" << std::endl; - return EXIT_FAILURE; + CppUnit::TestResult result; + sal_uInt32 index = 0; + for (; index < rtl_getAppCommandArgCount(); index += 3) { + if (!getArgument(index).equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("--protector"))) + { + break; + } + if (rtl_getAppCommandArgCount() - index < 3) { + usageFailure(); + } + rtl::OUString lib(getArgument(index + 1)); + rtl::OUString sym(getArgument(index + 2)); + oslGenericFunction fn = (new osl::Module(lib, SAL_LOADMODULE_GLOBAL)) + ->getFunctionSymbol(sym); + CppUnit::Protector * p = fn == 0 + ? 0 + : (*reinterpret_cast< cppunittester::ProtectorFactory * >(fn))(); + if (p == 0) { + std::cerr + << "Failure instantiating protector \"" << convertLazy(lib) + << "\", \"" << convertLazy(sym) << '"' << std::endl; + std::exit(EXIT_FAILURE); + } + result.pushProtector(p); + } + if (rtl_getAppCommandArgCount() - index < 1) { + usageFailure(); } + std::string testlib; { rtl::OUString path; - rtl_getAppCommandArg(0, &path.pData); + rtl_getAppCommandArg(index, &path.pData); testlib = rtl::OUStringToOString(path, osl_getThreadTextEncoding()).getStr(); } std::string args = testlib; - for (sal_uInt32 i = 1; i < nCommandArgs; ++i) + for (sal_uInt32 i = index + 1; i < rtl_getAppCommandArgCount(); ++i) { rtl::OUString arg; rtl_getAppCommandArg(i, &arg.pData); args += ' '; args += rtl::OUStringToOString(arg, osl_getThreadTextEncoding()).getStr(); } + CppUnit::PlugInManager manager; manager.load(testlib, args); CppUnit::TestRunner runner; runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); - CppUnit::TestResult result; CppUnit::TestResultCollector collector; result.addListener(&collector); runner.run(result); diff --git a/sal/inc/cppunittester/protectorfactory.hxx b/sal/inc/cppunittester/protectorfactory.hxx new file mode 100644 index 000000000000..c309dbe8aa85 --- /dev/null +++ b/sal/inc/cppunittester/protectorfactory.hxx @@ -0,0 +1,45 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_CPPUNITTESTER_PROTECTORFACTORY_HXX +#define INCLUDED_CPPUNITTESTER_PROTECTORFACTORY_HXX + +#include "sal/config.h" + +#include "sal/types.h" + +namespace CppUnit { class Protector; } + +namespace cppunittester { + +// The type of CppUnit::Protector factory functions that can be plugged into +// cppunittester: +extern "C" typedef CppUnit::Protector * SAL_CALL ProtectorFactory(); + +} + +#endif diff --git a/sal/osl/os2/diagnose.c b/sal/osl/os2/diagnose.c index 999c304ae77e..f1b0048703cf 100644 --- a/sal/osl/os2/diagnose.c +++ b/sal/osl/os2/diagnose.c @@ -125,7 +125,8 @@ sal_Bool SAL_CALL osl_assertFailedLine( const sal_Char* pszFileName, sal_Int32 n fputs(szMessage, stderr); - return sal_True; /* abort */ + char const * env = getenv( "SAL_DIAGNOSE_ABORT" ); + return ( ( env != NULL ) && ( *env != '\0' ) ); } /*----------------------------------------------------------------------------*/ diff --git a/sal/osl/unx/diagnose.c b/sal/osl/unx/diagnose.c index 36c9c0d5fec1..5425810ae408 100644 --- a/sal/osl/unx/diagnose.c +++ b/sal/osl/unx/diagnose.c @@ -219,6 +219,11 @@ sal_Bool SAL_CALL osl_assertFailedLine ( oslDebugMessageFunc f = g_pDebugMessageFunc; char szMessage[1024]; + // after reporting the assertion, abort if told so by SAL_DIAGNOSE_ABORT, but *not* if + // assertions are routed to some external instance + char const * env = getenv( "SAL_DIAGNOSE_ABORT" ); + sal_Bool const doAbort = ( ( env != NULL ) && ( *env != '\0' ) && ( f == NULL ) ); + /* If there's a callback for detailed messages, use it */ if ( g_pDetailedDebugMessageFunc != NULL ) { @@ -228,7 +233,7 @@ sal_Bool SAL_CALL osl_assertFailedLine ( /* if SAL assertions are disabled in general, stop here */ if ( getenv("DISABLE_SAL_DBGBOX") ) - return sal_False; + return doAbort; /* format message into buffer */ if (pszMessage != 0) @@ -253,9 +258,10 @@ sal_Bool SAL_CALL osl_assertFailedLine ( /* output backtrace */ osl_diagnose_backtrace_Impl(f); - /* release lock and leave, w/o calling osl_breakDebug() */ + /* release lock and leave */ pthread_mutex_unlock(&g_mutex); - return sal_False; + + return doAbort; } /************************************************************************/ @@ -263,7 +269,7 @@ sal_Bool SAL_CALL osl_assertFailedLine ( /************************************************************************/ void SAL_CALL osl_breakDebug() { - exit(0); + abort(); } /************************************************************************/ @@ -310,4 +316,4 @@ void osl_trace(char const * pszFormat, ...) { va_end(args); } -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index ae8b161893da..a1984d9d3d45 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -216,7 +216,8 @@ FileHandle_Impl::Allocator::~Allocator() void FileHandle_Impl::Allocator::allocate (sal_uInt8 ** ppBuffer, size_t * pnSize) { OSL_PRECOND((0 != ppBuffer) && (0 != pnSize), "FileHandle_Impl::Allocator::allocate(): contract violation"); - *ppBuffer = static_cast< sal_uInt8* >(rtl_cache_alloc(m_cache)), *pnSize = m_bufsiz; + if ((0 != ppBuffer) && (0 != pnSize)) + *ppBuffer = static_cast< sal_uInt8* >(rtl_cache_alloc(m_cache)), *pnSize = m_bufsiz; } void FileHandle_Impl::Allocator::deallocate (sal_uInt8 * pBuffer) { diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx index 61f486995f29..2e822efb7e27 100644 --- a/sal/osl/unx/file_misc.cxx +++ b/sal/osl/unx/file_misc.cxx @@ -325,10 +325,8 @@ oslFileError SAL_CALL osl_getDirectoryItem( rtl_uString* ustrFileURL, oslDirecto rtl_uString* ustrSystemPath = NULL; oslFileError osl_error = osl_File_E_INVAL; - OSL_ASSERT(ustrFileURL); - OSL_ASSERT(pItem); - - if (0 == ustrFileURL->length || NULL == pItem) + OSL_ASSERT((0 != ustrFileURL) && (0 != pItem)); + if ((0 == ustrFileURL) || (0 == ustrFileURL->length) || (0 == pItem)) return osl_File_E_INVAL; osl_error = osl_getSystemPathFromFileURL_Ex(ustrFileURL, &ustrSystemPath, sal_False); diff --git a/sal/osl/unx/file_path_helper.cxx b/sal/osl/unx/file_path_helper.cxx index 76045efe661a..c956edfa29bf 100644 --- a/sal/osl/unx/file_path_helper.cxx +++ b/sal/osl/unx/file_path_helper.cxx @@ -74,19 +74,21 @@ void SAL_CALL osl_systemPathRemoveSeparator(rtl_uString* pustrPath) { - OSL_PRECOND(pustrPath, "osl_systemPathRemoveSeparator: Invalid parameter"); - - // maybe there are more than one separator at end - // so we run in a loop - while ((pustrPath->length > 1) && (FPH_CHAR_PATH_SEPARATOR == pustrPath->buffer[pustrPath->length - 1])) + OSL_PRECOND(0 != pustrPath, "osl_systemPathRemoveSeparator: Invalid parameter"); + if (0 != pustrPath) { - pustrPath->length--; - pustrPath->buffer[pustrPath->length] = (sal_Unicode)'\0'; - } + // maybe there are more than one separator at end + // so we run in a loop + while ((pustrPath->length > 1) && (FPH_CHAR_PATH_SEPARATOR == pustrPath->buffer[pustrPath->length - 1])) + { + pustrPath->length--; + pustrPath->buffer[pustrPath->length] = (sal_Unicode)'\0'; + } - OSL_POSTCOND((0 == pustrPath->length) || (1 == pustrPath->length) || \ - (pustrPath->length > 1 && pustrPath->buffer[pustrPath->length - 1] != FPH_CHAR_PATH_SEPARATOR), \ - "osl_systemPathRemoveSeparator: Post condition failed"); + OSL_POSTCOND((0 == pustrPath->length) || (1 == pustrPath->length) || \ + (pustrPath->length > 1 && pustrPath->buffer[pustrPath->length - 1] != FPH_CHAR_PATH_SEPARATOR), \ + "osl_systemPathRemoveSeparator: Post condition failed"); + } } /******************************************* @@ -95,21 +97,22 @@ void SAL_CALL osl_systemPathEnsureSeparator(rtl_uString** ppustrPath) { - OSL_PRECOND(ppustrPath && (NULL != *ppustrPath), \ - "osl_systemPathEnsureSeparator: Invalid parameter"); - - rtl::OUString path(*ppustrPath); - sal_Int32 lp = path.getLength(); - sal_Int32 i = path.lastIndexOf(FPH_CHAR_PATH_SEPARATOR); - - if ((lp > 1 && i != (lp - 1)) || ((lp < 2) && i < 0)) - { - path += FPH_PATH_SEPARATOR(); - rtl_uString_assign(ppustrPath, path.pData); - } - - OSL_POSTCOND(path.lastIndexOf(FPH_CHAR_PATH_SEPARATOR) == (path.getLength() - 1), \ - "osl_systemPathEnsureSeparator: Post condition failed"); + OSL_PRECOND((0 != ppustrPath) && (0 != *ppustrPath), "osl_systemPathEnsureSeparator: Invalid parameter"); + if ((0 != ppustrPath) && (0 != *ppustrPath)) + { + rtl::OUString path(*ppustrPath); + sal_Int32 lp = path.getLength(); + sal_Int32 i = path.lastIndexOf(FPH_CHAR_PATH_SEPARATOR); + + if ((lp > 1 && i != (lp - 1)) || ((lp < 2) && i < 0)) + { + path += FPH_PATH_SEPARATOR(); + rtl_uString_assign(ppustrPath, path.pData); + } + + OSL_POSTCOND(path.lastIndexOf(FPH_CHAR_PATH_SEPARATOR) == (path.getLength() - 1), \ + "osl_systemPathEnsureSeparator: Post condition failed"); + } } /******************************************* @@ -118,8 +121,8 @@ sal_Bool SAL_CALL osl_systemPathIsRelativePath(const rtl_uString* pustrPath) { - OSL_PRECOND(pustrPath, "osl_systemPathIsRelativePath: Invalid parameter"); - return ((0 == pustrPath->length) || (pustrPath->buffer[0] != FPH_CHAR_PATH_SEPARATOR)); + OSL_PRECOND(0 != pustrPath, "osl_systemPathIsRelativePath: Invalid parameter"); + return ((0 == pustrPath) || (0 == pustrPath->length) || (pustrPath->buffer[0] != FPH_CHAR_PATH_SEPARATOR)); } /****************************************** @@ -178,21 +181,16 @@ sal_Bool SAL_CALL osl_systemPathIsHiddenFileOrDirectoryEntry( const rtl_uString* pustrPath) { - OSL_PRECOND(pustrPath, "osl_systemPathIsHiddenFileOrDirectoryEntry: Invalid parameter"); - - sal_Bool is_hidden = sal_False; + OSL_PRECOND(0 != pustrPath, "osl_systemPathIsHiddenFileOrDirectoryEntry: Invalid parameter"); + if ((0 == pustrPath) || (0 == pustrPath->length)) + return sal_False; - if (pustrPath->length > 0) - { - rtl::OUString fdp; - - osl_systemPathGetFileNameOrLastDirectoryPart(pustrPath, &fdp.pData); - - is_hidden = ((fdp.pData->length > 0) && (fdp.pData->buffer[0] == FPH_CHAR_DOT) && - !osl_systemPathIsLocalOrParentDirectoryEntry(fdp.pData)); - } + rtl::OUString fdp; + osl_systemPathGetFileNameOrLastDirectoryPart(pustrPath, &fdp.pData); - return is_hidden; + return ((fdp.pData->length > 0) && + (fdp.pData->buffer[0] == FPH_CHAR_DOT) && + !osl_systemPathIsLocalOrParentDirectoryEntry(fdp.pData)); } diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx index ac043339b899..49d6603612ae 100644 --- a/sal/osl/unx/process_impl.cxx +++ b/sal/osl/unx/process_impl.cxx @@ -480,17 +480,20 @@ extern "C" int _imp_setProcessLocale( rtl_Locale * ); *********************************************/ oslProcessError SAL_CALL osl_getProcessLocale( rtl_Locale ** ppLocale ) { + oslProcessError result = osl_Process_E_Unknown; OSL_PRECOND(ppLocale, "osl_getProcessLocale(): Invalid parameter."); + if (ppLocale) + { + pthread_mutex_lock(&(g_process_locale.m_mutex)); - pthread_mutex_lock(&(g_process_locale.m_mutex)); - - if (g_process_locale.m_pLocale == 0) - _imp_getProcessLocale (&(g_process_locale.m_pLocale)); - *ppLocale = g_process_locale.m_pLocale; - - pthread_mutex_unlock (&(g_process_locale.m_mutex)); + if (g_process_locale.m_pLocale == 0) + _imp_getProcessLocale (&(g_process_locale.m_pLocale)); + *ppLocale = g_process_locale.m_pLocale; + result = osl_Process_E_None; - return (osl_Process_E_None); + pthread_mutex_unlock (&(g_process_locale.m_mutex)); + } + return (result); } /********************************************** diff --git a/sal/osl/unx/profile.c b/sal/osl/unx/profile.c index 6d6184887d4e..c2a0cc490af9 100644 --- a/sal/osl/unx/profile.c +++ b/sal/osl/unx/profile.c @@ -513,7 +513,6 @@ sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile, if ( pTmpProfile->m_bIsValid == sal_False ) { - OSL_ASSERT(pProfile->m_bIsValid); pthread_mutex_unlock(&(pTmpProfile->m_AccessLock)); #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_readProfileString [not valid]\n"); diff --git a/sal/osl/unx/socket.c b/sal/osl/unx/socket.c index 8beb70364647..a8e91236b02e 100644 --- a/sal/osl/unx/socket.c +++ b/sal/osl/unx/socket.c @@ -1104,7 +1104,6 @@ oslHostAddr SAL_CALL osl_createHostAddr ( rtl_string_release(strHostname); } - return HostAddr; } @@ -1128,7 +1127,7 @@ oslHostAddr SAL_CALL osl_psz_createHostAddr ( pHostAddr= (oslHostAddr) malloc(sizeof(struct oslHostAddrImpl)); OSL_ASSERT(pHostAddr); - if (pAddr == NULL) + if (pHostAddr == NULL) { free (cn); return ((oslHostAddr)NULL); @@ -2360,7 +2359,10 @@ sal_Bool __osl_socket_poll ( int timeout; int result; - OSL_ASSERT(pSocket); + OSL_ASSERT(0 != pSocket); + if (0 == pSocket) + return sal_False; /* EINVAL */ + pSocket->m_nLastError = 0; fds.fd = pSocket->m_Socket; @@ -2403,7 +2405,10 @@ sal_Bool __osl_socket_poll ( struct timeval tv; int result; - OSL_ASSERT(pSocket); + OSL_ASSERT(0 != pSocket); + if (0 == pSocket) + return sal_False; /* EINVAL */ + pSocket->m_nLastError = 0; FD_ZERO(&fds); diff --git a/sal/osl/w32/diagnose.c b/sal/osl/w32/diagnose.c index e25c60e8c886..30356ee9af8c 100755 --- a/sal/osl/w32/diagnose.c +++ b/sal/osl/w32/diagnose.c @@ -93,6 +93,7 @@ sal_Bool SAL_CALL osl_assertFailedLine(const sal_Char* pszFileName, sal_Int32 nL /* get app name or NULL if unknown (don't call assert) */ LPCSTR lpszAppName = "Error"; sal_Char szMessage[512]; + char const * env = getenv( "SAL_DIAGNOSE_ABORT" ); /* format message into buffer */ szMessage[sizeof(szMessage)-1] = '\0'; /* zero terminate always */ @@ -105,40 +106,45 @@ sal_Bool SAL_CALL osl_assertFailedLine(const sal_Char* pszFileName, sal_Int32 nL _pPrintDetailedDebugMessage( pszFileName, nLine, pszMessage ); else if ( _pPrintDebugMessage ) _pPrintDebugMessage( szMessage ); - else if ( !getenv( "DISABLE_SAL_DBGBOX" ) ) + else { - TCHAR szBoxMessage[1024]; - int nCode; + if ( !getenv( "DISABLE_SAL_DBGBOX" ) ) + { + TCHAR szBoxMessage[1024]; + int nCode; - /* active popup window for the current thread */ - hWndParent = GetActiveWindow(); - if (hWndParent != NULL) - hWndParent = GetLastActivePopup(hWndParent); + /* active popup window for the current thread */ + hWndParent = GetActiveWindow(); + if (hWndParent != NULL) + hWndParent = GetLastActivePopup(hWndParent); - /* set message box flags */ - nFlags = MB_TASKMODAL | MB_ICONWARNING | MB_YESNOCANCEL | MB_DEFBUTTON2 | MB_SETFOREGROUND; - if (hWndParent == NULL) - nFlags |= MB_SERVICE_NOTIFICATION; + /* set message box flags */ + nFlags = MB_TASKMODAL | MB_ICONWARNING | MB_YESNOCANCEL | MB_DEFBUTTON2 | MB_SETFOREGROUND; + if (hWndParent == NULL) + nFlags |= MB_SERVICE_NOTIFICATION; - /* display the assert */ + /* display the assert */ - szBoxMessage[sizeof(szBoxMessage)-1] = 0; - _snprintf(szBoxMessage, sizeof(szBoxMessage)-1, "%s\n( Yes=Abort / No=Ignore / Cancel=Debugger )", - szMessage); + szBoxMessage[sizeof(szBoxMessage)-1] = 0; + _snprintf(szBoxMessage, sizeof(szBoxMessage)-1, "%s\n( Yes=Abort / No=Ignore / Cancel=Debugger )", + szMessage); - nCode = MessageBox(hWndParent, szBoxMessage, "Assertion Failed!", nFlags); + nCode = MessageBox(hWndParent, szBoxMessage, "Assertion Failed!", nFlags); - if (nCode == IDYES) - FatalExit(-1); + if (nCode == IDYES) + FatalExit(-1); - if (nCode == IDNO) - return sal_False; /* ignore */ + if (nCode == IDNO) + return sal_False; /* ignore */ - if (nCode == IDCANCEL) - return sal_True; /* will cause oslDebugBreak */ + if (nCode == IDCANCEL) + return sal_True; /* will cause oslDebugBreak */ + } + return ( ( env != NULL ) && ( *env != '\0' ) ); } + + return sal_False; #endif /* NO_DEBUG_CRT */ - return sal_False; /* not sure, don't care */ } sal_Int32 SAL_CALL osl_reportError(sal_uInt32 nType, const sal_Char* pszMessage) diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx index 88cefe7d7eca..b6dc0028879e 100644 --- a/sal/osl/w32/file_dirvol.cxx +++ b/sal/osl/w32/file_dirvol.cxx @@ -155,7 +155,7 @@ namespace /* private */ void parse_UNC_path(const sal_Unicode* path, UNCComponents* puncc) { OSL_PRECOND(is_UNC_path(path), "Precondition violated: No UNC path"); - OSL_PRECOND(rtl_ustr_indexOfChar(path, SLASH) != -1, "Path must not contain slashes"); + OSL_PRECOND(rtl_ustr_indexOfChar(path, SLASH) == -1, "Path must not contain slashes"); const sal_Unicode* pend = path + rtl_ustr_getLength(path); const sal_Unicode* ppos = path + 2; diff --git a/sal/osl/w32/module.cxx b/sal/osl/w32/module.cxx index 1c2c485a6ca7..5554eadc02cc 100644..100755 --- a/sal/osl/w32/module.cxx +++ b/sal/osl/w32/module.cxx @@ -37,6 +37,7 @@ #include <osl/thread.h> #include <osl/file.h> #include <rtl/logfile.h> +#include <vector> /* under WIN32, we use the void* oslModule @@ -66,10 +67,32 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 /*nRtldM rtl_uString_assign(&Module, strModuleName); hInstance = LoadLibraryW(reinterpret_cast<LPCWSTR>(Module->buffer)); + if (hInstance == NULL) hInstance = LoadLibraryExW(reinterpret_cast<LPCWSTR>(Module->buffer), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + //In case of long path names (\\?\c:\...) try to shorten the filename. + //LoadLibrary cannot handle file names which exceed 260 letters. + //In case the path is to long, the function will fail. However, the error + //code can be different. For example, it returned ERROR_FILENAME_EXCED_RANGE + //on Windows XP and ERROR_INSUFFICIENT_BUFFER on Windows 7 (64bit) + if (hInstance == NULL && Module->length > 260) + { + std::vector<sal_Unicode, rtl::Allocator<sal_Unicode> > vec(Module->length + 1); + DWORD len = GetShortPathNameW(reinterpret_cast<LPCWSTR>(Module->buffer), + &vec[0], Module->length + 1); + if (len ) + { + hInstance = LoadLibraryW(&vec[0]); + + if (hInstance == NULL) + hInstance = LoadLibraryExW(&vec[0], NULL, + LOAD_WITH_ALTERED_SEARCH_PATH); + } + } + + if (hInstance <= (HINSTANCE)HINSTANCE_ERROR) hInstance = 0; diff --git a/sal/osl/w32/procimpl.cxx b/sal/osl/w32/procimpl.cxx index 87b47fe263a5..54d5f912d0e2 100644..100755 --- a/sal/osl/w32/procimpl.cxx +++ b/sal/osl/w32/procimpl.cxx @@ -301,6 +301,39 @@ namespace /* private */ return quoted.makeStringAndClear(); } + //The parameter path must be a system path. If it is longer than 260 characters + //then it is shortened using the GetShortPathName function. This function only + //works if the path exists. Because "path" can be the path to an executable, it + //may not have the file extension ".exe". However, if the file on disk has the + //".exe" extension, then the function will fail. In this case a second attempt + //is started by adding the parameter "extension" to "path". + rtl::OUString getShortPath(rtl::OUString const & path, rtl::OUString const & extension) + { + rtl::OUString ret(path); + if (path.getLength() > 260) + { + std::vector<sal_Unicode, rtl::Allocator<sal_Unicode> > vec(path.getLength() + 1); + //GetShortPathNameW only works if the file can be found! + const DWORD len = GetShortPathNameW( + path.getStr(), &vec[0], path.getLength() + 1); + + if (!len && GetLastError() == ERROR_FILE_NOT_FOUND + && extension.getLength()) + { + const rtl::OUString extPath(path + extension); + std::vector<sal_Unicode, rtl::Allocator<sal_Unicode> > vec2( + extPath.getLength() + 1); + const DWORD len2 = GetShortPathNameW( + extPath.getStr(), &vec2[0], extPath.getLength() + 1); + ret = rtl::OUString(&vec2[0], len2); + } + else + { + ret = rtl::OUString(&vec[0], len); + } + } + return ret; + } //########################################################## // Returns the system path of the executable which can either // be provided via the strImageName parameter or as first @@ -327,6 +360,8 @@ namespace /* private */ if (osl_File_E_None != osl::FileBase::getSystemPathFromFileURL(exe_url, exe_path)) return rtl::OUString(); + exe_path = getShortPath(exe_path, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".exe"))); + if (exe_path.indexOf(' ') != -1) exe_path = quote_string(exe_path); diff --git a/sal/prj/d.lst b/sal/prj/d.lst index e685e590e6d0..8891d15c418b 100644 --- a/sal/prj/d.lst +++ b/sal/prj/d.lst @@ -1,11 +1,12 @@ mkdir: %_DEST%\bin%_EXT%\cppunit +mkdir: %_DEST%\inc%_EXT%\cppunittester mkdir: %_DEST%\inc%_EXT%\sal mkdir: %_DEST%\inc%_EXT%\osl mkdir: %_DEST%\inc%_EXT%\rtl mkdir: %_DEST%\inc%_EXT%\systools mkdir: %_DEST%\inc%_EXT%\systools\win32 -mkdir: %_DEST%\bin%_EXT%\cppunit +..\inc\cppunittester\protectorfactory.hxx %_DEST%\inc%_EXT%\protectorfactory.hxx ..\%__SRC%\inc\rtlbootstrap.mk %_DEST%\inc%_EXT%\rtlbootstrap.mk ..\inc\sal\*.h %_DEST%\inc%_EXT%\sal\*.h ..\%__SRC%\inc\sal\typesizes.h %_DEST%\inc%_EXT%\sal\typesizes.h diff --git a/sal/rtl/source/alloc_arena.c b/sal/rtl/source/alloc_arena.c index 6766cf91e18d..69b4b9cf3bdb 100644 --- a/sal/rtl/source/alloc_arena.c +++ b/sal/rtl/source/alloc_arena.c @@ -29,22 +29,13 @@ #define _BSD_SOURCE /* sys/mman.h: MAP_ANON */ #include "alloc_arena.h" -#ifndef INCLUDED_RTL_ARENA_IMPL_H #include "alloc_impl.h" -#endif #include "internal/once.h" #include "sal/macros.h" #include "osl/diagnose.h" -#ifndef INCLUDED_STRING_H #include <string.h> -#endif - -#ifndef INCLUDED_STDIO_H #include <stdio.h> -#endif - -#include "sal/types.h" #ifdef OS2 #undef OSL_TRACE @@ -953,6 +944,7 @@ try_alloc: if (result != 0) { rtl_arena_type * arena = result; + VALGRIND_CREATE_MEMPOOL(arena, 0, 0); rtl_arena_constructor (arena); if (!source_arena) @@ -975,6 +967,7 @@ try_alloc: { rtl_arena_deactivate (arena); rtl_arena_destructor (arena); + VALGRIND_DESTROY_MEMPOOL(arena); rtl_arena_free (gp_arena_arena, arena, size); } } @@ -1000,6 +993,7 @@ SAL_CALL rtl_arena_destroy ( { rtl_arena_deactivate (arena); rtl_arena_destructor (arena); + VALGRIND_DESTROY_MEMPOOL(arena); rtl_arena_free (gp_arena_arena, arena, sizeof(rtl_arena_type)); } } @@ -1055,6 +1049,10 @@ SAL_CALL rtl_arena_alloc ( rtl_arena_hash_insert (arena, segment); + /* DEBUG ONLY: mark allocated, undefined */ + OSL_DEBUG_ONLY(memset((void*)(segment->m_addr), 0x77777777, segment->m_size)); + VALGRIND_MEMPOOL_ALLOC(arena, segment->m_addr, segment->m_size); + (*pSize) = segment->m_size; addr = (void*)(segment->m_addr); } @@ -1098,6 +1096,11 @@ SAL_CALL rtl_arena_free ( { rtl_arena_segment_type *next, *prev; + /* DEBUG ONLY: mark unallocated, undefined */ + VALGRIND_MEMPOOL_FREE(arena, segment->m_addr); + /* OSL_DEBUG_ONLY() */ VALGRIND_MAKE_MEM_UNDEFINED(segment->m_addr, segment->m_size); + OSL_DEBUG_ONLY(memset((void*)(segment->m_addr), 0x33333333, segment->m_size)); + /* coalesce w/ adjacent free segment(s) */ rtl_arena_segment_coalesce (arena, segment); @@ -1289,6 +1292,7 @@ rtl_arena_once_init (void) static rtl_arena_type g_machdep_arena; OSL_ASSERT(gp_machdep_arena == 0); + VALGRIND_CREATE_MEMPOOL(&g_machdep_arena, 0, 0); rtl_arena_constructor (&g_machdep_arena); gp_machdep_arena = rtl_arena_activate ( @@ -1305,6 +1309,7 @@ rtl_arena_once_init (void) static rtl_arena_type g_default_arena; OSL_ASSERT(gp_default_arena == 0); + VALGRIND_CREATE_MEMPOOL(&g_default_arena, 0, 0); rtl_arena_constructor (&g_default_arena); gp_default_arena = rtl_arena_activate ( @@ -1323,6 +1328,7 @@ rtl_arena_once_init (void) static rtl_arena_type g_arena_arena; OSL_ASSERT(gp_arena_arena == 0); + VALGRIND_CREATE_MEMPOOL(&g_arena_arena, 0, 0); rtl_arena_constructor (&g_arena_arena); gp_arena_arena = rtl_arena_activate ( @@ -1348,7 +1354,18 @@ rtl_arena_init (void) /* ================================================================= */ -#if defined(__GNUC__) +/* + Issue http://udk.openoffice.org/issues/show_bug.cgi?id=92388 + + Mac OS X does not seem to support "__cxa__atexit", thus leading + to the situation that "__attribute__((destructor))__" functions + (in particular "rtl_{memory|cache|arena}_fini") become called + _before_ global C++ object d'tors. + + Delegated the call to "rtl_arena_fini()" into a dummy C++ object, + see alloc_fini.cxx . +*/ +#if defined(__GNUC__) && !defined(MACOSX) static void rtl_arena_fini (void) __attribute__((destructor)); #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) #pragma fini(rtl_arena_fini) diff --git a/sal/rtl/source/alloc_cache.c b/sal/rtl/source/alloc_cache.c index 01d4e14961f8..9da21d32a3c9 100644 --- a/sal/rtl/source/alloc_cache.c +++ b/sal/rtl/source/alloc_cache.c @@ -508,6 +508,10 @@ rtl_cache_slab_alloc ( addr = (void*)rtl_cache_hash_insert (cache, bufctl); else addr = bufctl; + + /* DEBUG ONLY: mark allocated, undefined */ + OSL_DEBUG_ONLY(memset(addr, 0x77777777, cache->m_type_size)); + VALGRIND_MEMPOOL_ALLOC(cache, addr, cache->m_type_size); } RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); @@ -530,6 +534,11 @@ rtl_cache_slab_free ( RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_slab_lock)); + /* DEBUG ONLY: mark unallocated, undefined */ + VALGRIND_MEMPOOL_FREE(cache, addr); + /* OSL_DEBUG_ONLY() */ VALGRIND_MAKE_MEM_UNDEFINED(addr, cache->m_type_size); + OSL_DEBUG_ONLY(memset(addr, 0x33333333, cache->m_type_size)); + /* determine slab from addr */ if (cache->m_features & RTL_CACHE_FEATURE_HASH) { @@ -636,8 +645,13 @@ rtl_cache_magazine_clear ( void * obj = mag->m_objects[mag->m_mag_used - 1]; mag->m_objects[mag->m_mag_used - 1] = 0; + /* DEBUG ONLY: mark cached object allocated, undefined */ + VALGRIND_MEMPOOL_ALLOC(cache, obj, cache->m_type_size); if (cache->m_destructor != 0) { + /* DEBUG ONLY: keep constructed object defined */ + VALGRIND_MAKE_MEM_DEFINED(obj, cache->m_type_size); + /* destruct object */ (cache->m_destructor)(obj, cache->m_userarg); } @@ -966,11 +980,16 @@ rtl_cache_deactivate ( rtl_cache_type * cache ) { + int active = 1; + /* remove from cache list */ RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); + active = QUEUE_STARTED_NAMED(cache, cache_) == 0; QUEUE_REMOVE_NAMED(cache, cache_); RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); + OSL_PRECOND(active, "rtl_cache_deactivate(): orphaned cache."); + /* cleanup magazine layer */ if (cache->m_magazine_cache != 0) { @@ -1122,6 +1141,7 @@ try_alloc: if (result != 0) { rtl_cache_type * cache = result; + VALGRIND_CREATE_MEMPOOL(cache, 0, 0); (void) rtl_cache_constructor (cache); if (!source) @@ -1149,6 +1169,7 @@ try_alloc: /* activation failed */ rtl_cache_deactivate (cache); rtl_cache_destructor (cache); + VALGRIND_DESTROY_MEMPOOL(cache); rtl_arena_free (gp_cache_arena, cache, size); } } @@ -1173,6 +1194,7 @@ void SAL_CALL rtl_cache_destroy ( { rtl_cache_deactivate (cache); rtl_cache_destructor (cache); + VALGRIND_DESTROY_MEMPOOL(cache); rtl_arena_free (gp_cache_arena, cache, sizeof(rtl_cache_type)); } } @@ -1201,6 +1223,14 @@ SAL_CALL rtl_cache_alloc ( if ((curr != 0) && (curr->m_mag_used > 0)) { obj = curr->m_objects[--curr->m_mag_used]; +#if defined(HAVE_VALGRIND_MEMCHECK_H) + VALGRIND_MEMPOOL_ALLOC(cache, obj, cache->m_type_size); + if (cache->m_constructor != 0) + { + /* keep constructed object defined */ + VALGRIND_MAKE_MEM_DEFINED(obj, cache->m_type_size); + } +#endif /* HAVE_VALGRIND_MEMCHECK_H */ cache->m_cpu_stats.m_alloc += 1; RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); @@ -1243,7 +1273,6 @@ SAL_CALL rtl_cache_alloc ( rtl_cache_slab_free (cache, obj), obj = 0; } } - return (obj); } @@ -1268,6 +1297,9 @@ SAL_CALL rtl_cache_free ( if ((curr != 0) && (curr->m_mag_used < curr->m_mag_size)) { curr->m_objects[curr->m_mag_used++] = obj; +#if defined(HAVE_VALGRIND_MEMCHECK_H) + VALGRIND_MEMPOOL_FREE(cache, obj); +#endif /* HAVE_VALGRIND_MEMCHECK_H */ cache->m_cpu_stats.m_free += 1; RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); @@ -1581,6 +1613,7 @@ rtl_cache_once_init (void) static rtl_cache_type g_cache_magazine_cache; OSL_ASSERT(gp_cache_magazine_cache == 0); + VALGRIND_CREATE_MEMPOOL(&g_cache_magazine_cache, 0, 0); (void) rtl_cache_constructor (&g_cache_magazine_cache); gp_cache_magazine_cache = rtl_cache_activate ( @@ -1605,6 +1638,7 @@ rtl_cache_once_init (void) static rtl_cache_type g_cache_slab_cache; OSL_ASSERT(gp_cache_slab_cache == 0); + VALGRIND_CREATE_MEMPOOL(&g_cache_slab_cache, 0, 0); (void) rtl_cache_constructor (&g_cache_slab_cache); gp_cache_slab_cache = rtl_cache_activate ( @@ -1626,6 +1660,7 @@ rtl_cache_once_init (void) static rtl_cache_type g_cache_bufctl_cache; OSL_ASSERT(gp_cache_bufctl_cache == 0); + VALGRIND_CREATE_MEMPOOL(&g_cache_bufctl_cache, 0, 0); (void) rtl_cache_constructor (&g_cache_bufctl_cache); gp_cache_bufctl_cache = rtl_cache_activate ( @@ -1656,7 +1691,18 @@ rtl_cache_init (void) /* ================================================================= */ -#if defined(__GNUC__) +/* + Issue http://udk.openoffice.org/issues/show_bug.cgi?id=92388 + + Mac OS X does not seem to support "__cxa__atexit", thus leading + to the situation that "__attribute__((destructor))__" functions + (in particular "rtl_{memory|cache|arena}_fini") become called + _before_ global C++ object d'tors. + + Delegated the call to "rtl_cache_fini()" into a dummy C++ object, + see alloc_fini.cxx . +*/ +#if defined(__GNUC__) && !defined(MACOSX) static void rtl_cache_fini (void) __attribute__((destructor)); #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) #pragma fini(rtl_cache_fini) @@ -1677,18 +1723,21 @@ rtl_cache_fini (void) cache = gp_cache_bufctl_cache, gp_cache_bufctl_cache = 0; rtl_cache_deactivate (cache); rtl_cache_destructor (cache); + VALGRIND_DESTROY_MEMPOOL(cache); } if (gp_cache_slab_cache != 0) { cache = gp_cache_slab_cache, gp_cache_slab_cache = 0; rtl_cache_deactivate (cache); rtl_cache_destructor (cache); + VALGRIND_DESTROY_MEMPOOL(cache); } if (gp_cache_magazine_cache != 0) { cache = gp_cache_magazine_cache, gp_cache_magazine_cache = 0; rtl_cache_deactivate (cache); rtl_cache_destructor (cache); + VALGRIND_DESTROY_MEMPOOL(cache); } if (gp_cache_arena != 0) { diff --git a/sal/rtl/source/memory_fini.cxx b/sal/rtl/source/alloc_fini.cxx index a0fb012ff6a5..aba5093a362d 100644 --- a/sal/rtl/source/memory_fini.cxx +++ b/sal/rtl/source/alloc_fini.cxx @@ -26,32 +26,33 @@ * ************************************************************************/ - /* Issue http://udk.openoffice.org/issues/show_bug.cgi?id=92388 Mac OS X does not seem to support "__cxa__atexit", thus leading to the situation that "__attribute__((destructor))__" functions - (in particular "rtl_memory_fini") become called _before_ global - C++ object d'tors. + (in particular "rtl_{memory|cache|arena}_fini") become called + _before_ global C++ object d'tors. Using a C++ dummy object instead. */ -#include <stdio.h> - extern "C" void rtl_memory_fini (void); +extern "C" void rtl_cache_fini (void); +extern "C" void rtl_arena_fini (void); - -struct RTL_Memory_Fini { - ~RTL_Memory_Fini() ; +struct RTL_Alloc_Fini +{ + ~RTL_Alloc_Fini() ; }; -RTL_Memory_Fini::~RTL_Memory_Fini() { +RTL_Alloc_Fini::~RTL_Alloc_Fini() +{ rtl_memory_fini(); + rtl_cache_fini(); + rtl_arena_fini(); } - -static RTL_Memory_Fini rtl_Memory_Fini; +static RTL_Alloc_Fini g_RTL_Alloc_Fini; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/source/alloc_global.c b/sal/rtl/source/alloc_global.c index 5930e00e57a5..ac95c8e1b188 100644 --- a/sal/rtl/source/alloc_global.c +++ b/sal/rtl/source/alloc_global.c @@ -26,6 +26,7 @@ * ************************************************************************/ +#include "alloc_impl.h" #include "rtl/alloc.h" #include <sal/macros.h> @@ -63,7 +64,6 @@ static void determine_alloc_mode(void) * * ================================================================= */ -#include "alloc_impl.h" #include "internal/once.h" #include "sal/macros.h" #include "osl/diagnose.h" diff --git a/sal/rtl/source/alloc_impl.h b/sal/rtl/source/alloc_impl.h index 4a89e62af135..18073926399f 100644 --- a/sal/rtl/source/alloc_impl.h +++ b/sal/rtl/source/alloc_impl.h @@ -241,6 +241,30 @@ typedef CRITICAL_SECTION rtl_memory_lock_type; #define RTL_CACHE_FLAG_QUANTUMCACHE (2 << 13) /* used as arena quantum cache */ +/** Valgrind support macros. + */ +#if !defined(HAVE_MEMCHECK_H) || (OSL_DEBUG_LEVEL == 0) +#if !defined(NVALGRIND) +#define NVALGRIND 1 +#endif /* ! NVALGRIND */ +#endif /* ! HAVE_MEMCHECK_H || (OSL_DEBUG_LEVEL == 0) */ + +#if defined(NVALGRIND) +#define VALGRIND_MAKE_MEM_UNDEFINED(addr, size) +#define VALGRIND_MAKE_MEM_DEFINED(addr, size) +#define VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed) +#define VALGRIND_FREELIKE_BLOCK(addr, rzB) +#define VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed) +#define VALGRIND_DESTROY_MEMPOOL(pool) +#define VALGRIND_MEMPOOL_ALLOC(pool, addr, size) +#define VALGRIND_MEMPOOL_FREE(pool, addr) +#elif defined(HAVE_MEMCHECK_H) +#include <memcheck.h> +#if !defined(FORCE_SYSALLOC) +#define FORCE_SYSALLOC 1 +#endif /* !FORCE_SYSALLOC */ +#endif /* NVALGRIND || HAVE_MEMCHECK_H */ + #ifdef __cplusplus } #endif diff --git a/sal/rtl/source/makefile.mk b/sal/rtl/source/makefile.mk index 3121f184ba8b..67ae7f8d9177 100644 --- a/sal/rtl/source/makefile.mk +++ b/sal/rtl/source/makefile.mk @@ -46,6 +46,11 @@ TARGETTYPE=CUI .INCLUDE : settings.mk +.IF "$(VALGRIND_CFLAGS)" != "" +CFLAGS += $(VALGRIND_CFLAGS) +CDEFS += -DHAVE_MEMCHECK_H=1 +.ENDIF # VALGRIND_CFLAGS + .IF "$(ALLOC)" == "SYS_ALLOC" || "$(ALLOC)" == "TCMALLOC" || "$(ALLOC)" == "JEMALLOC" CDEFS+= -DFORCE_SYSALLOC .ENDIF @@ -98,7 +103,7 @@ SLOFILES= \ $(SLO)$/alloc_arena.obj .IF "$(OS)"=="MACOSX" || "$(OS)"=="AIX" -SLOFILES+=$(SLO)$/memory_fini.obj +SLOFILES+=$(SLO)$/alloc_fini.obj .ENDIF @@ -130,7 +135,7 @@ OBJFILES= \ $(OBJ)$/alloc_arena.obj .IF "$(OS)"=="MACOSX" || "$(OS)"=="AIX" -OBJFILES+=$(OBJ)$/memory_fini.obj +OBJFILES+=$(OBJ)$/alloc_fini.obj .ENDIF |