diff options
author | Tor Lillqvist <tml@collabora.com> | 2015-04-09 20:26:32 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2015-04-09 23:27:45 +0300 |
commit | 2dede8bfbab5d353f91acc5f5fa7c21b1b1a4fea (patch) | |
tree | 833dc2d6780c7eb934250190e6d62272bfe2202a /sal | |
parent | 04a98015101b8fea3b200e0bf3a2469d8c75fdf7 (diff) |
Change from <osl/diagnose.h> to <sal/log.hxx> and add more logging
Change-Id: Iee8c093f5aa8306c3e5336d6dd5e801df6df87a4
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/mutex.cxx | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/sal/osl/unx/mutex.cxx b/sal/osl/unx/mutex.cxx index 9a004755a668..4bc726d2cc10 100644 --- a/sal/osl/unx/mutex.cxx +++ b/sal/osl/unx/mutex.cxx @@ -25,8 +25,8 @@ #endif #include "system.hxx" +#include <sal/log.hxx> #include <osl/mutex.h> -#include <osl/diagnose.h> #include <pthread.h> #include <stdlib.h> @@ -37,16 +37,13 @@ typedef struct _oslMutexImpl pthread_mutex_t mutex; } oslMutexImpl; -/*****************************************************************************/ -/* osl_createMutex */ -/*****************************************************************************/ oslMutex SAL_CALL osl_createMutex() { oslMutexImpl* pMutex = static_cast<oslMutexImpl*>(malloc(sizeof(oslMutexImpl))); pthread_mutexattr_t aMutexAttr; int nRet=0; - OSL_ASSERT(pMutex); + SAL_WARN_IF(!pMutex, "sal.osl.mutex", "null pMutex"); if ( pMutex == 0 ) { @@ -60,8 +57,7 @@ oslMutex SAL_CALL osl_createMutex() nRet = pthread_mutex_init(&(pMutex->mutex), &aMutexAttr); if ( nRet != 0 ) { - OSL_TRACE("osl_createMutex : mutex init/setattr failed. Errno: %d; %s\n", - nRet, strerror(nRet)); + SAL_WARN("sal.osl.mutex", "pthread_muxex_init failed: " << strerror(nRet)); free(pMutex); pMutex = 0; @@ -69,12 +65,16 @@ oslMutex SAL_CALL osl_createMutex() pthread_mutexattr_destroy(&aMutexAttr); + SAL_INFO("sal.osl.mutex", "osl_createMutex(): " << pMutex); + return pMutex; } void SAL_CALL osl_destroyMutex(oslMutexImpl *pMutex) { - OSL_ASSERT(pMutex); + SAL_WARN_IF(!pMutex, "sal.osl.mutex", "null pMutex"); + + SAL_INFO("sal.osl.mutex", "osl_destroyMutex(" << pMutex << ")"); if ( pMutex != 0 ) { @@ -83,8 +83,7 @@ void SAL_CALL osl_destroyMutex(oslMutexImpl *pMutex) nRet = pthread_mutex_destroy(&(pMutex->mutex)); if ( nRet != 0 ) { - OSL_TRACE("osl_destroyMutex : mutex destroy failed. Errno: %d; %s\n", - nRet, strerror(nRet)); + SAL_WARN("sal.osl.mutex", "pthread_mutex_destroy failed: " << strerror(nRet)); } free(pMutex); @@ -95,7 +94,9 @@ void SAL_CALL osl_destroyMutex(oslMutexImpl *pMutex) sal_Bool SAL_CALL osl_acquireMutex(oslMutexImpl *pMutex) { - OSL_ASSERT(pMutex); + SAL_WARN_IF(!pMutex, "sal.osl.mutex", "null pMutex"); + + SAL_INFO("sal.osl.mutex", "osl_acquireMutex(" << pMutex << ")"); if ( pMutex != 0 ) { @@ -104,8 +105,7 @@ sal_Bool SAL_CALL osl_acquireMutex(oslMutexImpl *pMutex) nRet = pthread_mutex_lock(&(pMutex->mutex)); if ( nRet != 0 ) { - OSL_TRACE("osl_acquireMutex : mutex lock failed. Errno: %d; %s\n", - nRet, strerror(nRet)); + SAL_WARN("sal.osl.mutex", "pthread_mutex_lock failed: " << strerror(nRet)); return sal_False; } return sal_True; @@ -117,25 +117,28 @@ sal_Bool SAL_CALL osl_acquireMutex(oslMutexImpl *pMutex) sal_Bool SAL_CALL osl_tryToAcquireMutex(oslMutexImpl *pMutex) { - OSL_ASSERT(pMutex); + sal_Bool result = sal_False; + + SAL_WARN_IF(!pMutex, "sal.osl.mutex", "null pMutex"); if ( pMutex ) { int nRet = 0; nRet = pthread_mutex_trylock(&(pMutex->mutex)); - if ( nRet != 0 ) - return sal_False; - - return sal_True; + if ( nRet == 0 ) + result = sal_True; } - /* not initialized */ - return sal_False; + SAL_INFO("sal.osl.mutex", "osl_tryToAcquireMutex(" << pMutex << "): " << (result ? "YES" : "NO")); + + return result; } sal_Bool SAL_CALL osl_releaseMutex(oslMutexImpl *pMutex) { - OSL_ASSERT(pMutex); + SAL_WARN_IF(!pMutex, "sal.osl.mutex", "null pMutex"); + + SAL_INFO("sal.osl.mutex", "osl_releaseMutex(" << pMutex << ")"); if ( pMutex ) { @@ -143,8 +146,7 @@ sal_Bool SAL_CALL osl_releaseMutex(oslMutexImpl *pMutex) nRet = pthread_mutex_unlock(&(pMutex->mutex)); if ( nRet != 0 ) { - OSL_TRACE("osl_releaseMutex : mutex unlock failed. Errno: %d; %s\n", - nRet, strerror(nRet)); + SAL_WARN("sal.osl.mutex", "pthread_mutex_unlock failed: " << strerror(nRet)); return sal_False; } |