From e772ce948c8a93bfc72b7d945ccd046dc8985dd7 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Fri, 1 Nov 2002 18:13:51 +0000 Subject: [PATCH] fixed gnu warnings --- src/ca/cac.cpp | 2 +- src/ca/cacChannel.cpp | 4 ++-- src/ca/tcpiiu.cpp | 2 +- src/db/dbServiceIO.cpp | 3 ++- src/libCom/cxxTemplates/epicsOnce.cpp | 6 +++--- src/libCom/cxxTemplates/epicsSingleton.h | 18 ++++++++++-------- src/libCom/timer/epicsTimer.cpp | 5 +++-- src/libCom/timer/timerQueueActive.cpp | 2 +- 8 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/ca/cac.cpp b/src/ca/cac.cpp index 87b12ea45..7c12e7607 100644 --- a/src/ca/cac.cpp +++ b/src/ca/cac.cpp @@ -137,7 +137,7 @@ cac::cac ( cacNotify & notifyIn, bool enablePreemptiveCallbackIn ) : programBeginTime ( epicsTime::getCurrent() ), connTMO ( CA_CONN_VERIFY_PERIOD ), cbMutex ( ! enablePreemptiveCallbackIn ), - globalServiceList ( globalServiceListCAC ), + globalServiceList ( globalServiceListCAC.getReference () ), timerQueue ( epicsTimerQueueActive::allocate ( false, lowestPriorityLevelAbove(epicsThreadGetPrioritySelf()) ) ), pUserName ( 0 ), diff --git a/src/ca/cacChannel.cpp b/src/ca/cacChannel.cpp index 938df389a..82317f6bb 100644 --- a/src/ca/cacChannel.cpp +++ b/src/ca/cacChannel.cpp @@ -74,7 +74,7 @@ void cacChannel::hostName ( char *pBuf, unsigned bufLength ) const { if ( bufLength ) { epicsSingleton < localHostName >::reference - ref ( localHostNameAtLoadTime ); + ref ( localHostNameAtLoadTime.getReference () ); ref->copy ( pBuf, bufLength ); } } @@ -84,7 +84,7 @@ void cacChannel::hostName ( char *pBuf, unsigned bufLength ) const const char * cacChannel::pHostName () const { epicsSingleton < localHostName >::reference - ref ( localHostNameAtLoadTime ); + ref ( localHostNameAtLoadTime.getReference () ); return ref->pointer (); } diff --git a/src/ca/tcpiiu.cpp b/src/ca/tcpiiu.cpp index 9747ec2a6..d45fb6280 100644 --- a/src/ca/tcpiiu.cpp +++ b/src/ca/tcpiiu.cpp @@ -894,7 +894,7 @@ void tcpiiu::hostNameSetRequest ( epicsGuard < cacMutex > & ) } epicsSingleton < localHostName >::reference - ref ( localHostNameAtLoadTime ); + ref ( localHostNameAtLoadTime.getReference () ); const char * pName = ref->pointer (); unsigned size = strlen ( pName ) + 1u; unsigned postSize = CA_MESSAGE_ALIGN ( size ); diff --git a/src/db/dbServiceIO.cpp b/src/db/dbServiceIO.cpp index e599fae40..1e75dbe30 100644 --- a/src/db/dbServiceIO.cpp +++ b/src/db/dbServiceIO.cpp @@ -60,7 +60,8 @@ dbBaseIO::dbBaseIO () {} dbServiceIOLoadTimeInit::dbServiceIOLoadTimeInit () { - epicsSingleton < cacServiceList > :: reference ref ( globalServiceListCAC ); + epicsSingleton < cacServiceList > :: reference + ref ( globalServiceListCAC.getReference () ); ref->registerService ( this->dbio ); } diff --git a/src/libCom/cxxTemplates/epicsOnce.cpp b/src/libCom/cxxTemplates/epicsOnce.cpp index 6ec94deaa..cb704ae0a 100644 --- a/src/libCom/cxxTemplates/epicsOnce.cpp +++ b/src/libCom/cxxTemplates/epicsOnce.cpp @@ -65,19 +65,19 @@ epicsSingleton < tsFreeList < class epicsOnceImpl, 16 > > epicsOnceImpl::freeLis inline void * epicsOnceImpl::operator new ( size_t size ) { epicsSingleton < tsFreeList < class epicsOnceImpl, 16 > > :: reference ref = - epicsOnceImpl::freeList; + epicsOnceImpl::freeList.getReference (); return ref->allocate ( size ); } inline void epicsOnceImpl::operator delete ( void *pCadaver, size_t size ) { epicsSingleton < tsFreeList < class epicsOnceImpl, 16 > > :: reference ref = - epicsOnceImpl::freeList; + epicsOnceImpl::freeList.getReference (); ref->release ( pCadaver, size ); } inline epicsOnceImpl::epicsOnceImpl ( epicsOnceNotify & notifyIn ) : -mutexRef ( epicsOnceImpl::mutex ), notify ( notifyIn ), onceFlag ( false ) +mutexRef ( epicsOnceImpl::mutex.getReference() ), notify ( notifyIn ), onceFlag ( false ) { } diff --git a/src/libCom/cxxTemplates/epicsSingleton.h b/src/libCom/cxxTemplates/epicsSingleton.h index 40db208f8..64e9e8ba0 100644 --- a/src/libCom/cxxTemplates/epicsSingleton.h +++ b/src/libCom/cxxTemplates/epicsSingleton.h @@ -78,8 +78,8 @@ public: }; // lock overhead every time these are called - operator typename epicsSingleton::reference (); - operator const typename epicsSingleton::reference () const; + typename epicsSingleton::reference getReference (); + const typename epicsSingleton::reference getReference () const; private: TYPE * pSingleton; @@ -103,21 +103,23 @@ inline epicsSingleton::~epicsSingleton () epicsShareFunc epicsMutex & epicsSingletonPrivateMutex (); template < class TYPE > -epicsSingleton::operator typename epicsSingleton::reference () +inline typename epicsSingleton::reference epicsSingleton::getReference () { - epicsGuard < epicsMutex > guard ( epicsSingletonPrivateMutex() ); - if ( ! this->pSingleton ) { - this->pSingleton = new TYPE; + { + epicsGuard < epicsMutex > guard ( epicsSingletonPrivateMutex() ); + if ( ! this->pSingleton ) { + this->pSingleton = new TYPE; + } } return reference ( * this->pSingleton ); } template < class TYPE > -epicsSingleton::operator const typename epicsSingleton::reference () const +inline const typename epicsSingleton::reference epicsSingleton::getReference () const { epicsSingleton < TYPE > * pConstCastAway = const_cast < epicsSingleton < TYPE > * > ( this ); - return *pConstCastAway; + return pConstCastAway->getReference (); } #endif // epicsSingleton_h diff --git a/src/libCom/timer/epicsTimer.cpp b/src/libCom/timer/epicsTimer.cpp index 7762cf633..fdbc61557 100644 --- a/src/libCom/timer/epicsTimer.cpp +++ b/src/libCom/timer/epicsTimer.cpp @@ -73,7 +73,7 @@ epicsTimerQueueActiveForC::~epicsTimerQueueActiveForC () void epicsTimerQueueActiveForC::release () epicsThrows (()) { epicsSingleton < timerQueueActiveMgr >::reference pMgr = - timerQueueMgrEPICS; + timerQueueMgrEPICS.getReference (); pMgr->release ( *this ); } @@ -179,7 +179,8 @@ extern "C" epicsTimerQueueId epicsShareAPI epicsTimerQueueAllocate ( int okToShare, unsigned int threadPriority ) { try { - epicsSingleton < timerQueueActiveMgr >::reference ref = timerQueueMgrEPICS; + epicsSingleton < timerQueueActiveMgr >::reference ref = + timerQueueMgrEPICS.getReference (); epicsTimerQueueActiveForC & tmr = ref->allocate ( okToShare ? true : false, threadPriority ); return &tmr; diff --git a/src/libCom/timer/timerQueueActive.cpp b/src/libCom/timer/timerQueueActive.cpp index c52ed5b27..3eda1fdf8 100644 --- a/src/libCom/timer/timerQueueActive.cpp +++ b/src/libCom/timer/timerQueueActive.cpp @@ -36,7 +36,7 @@ epicsTimerQueueActive::~epicsTimerQueueActive () {} epicsTimerQueueActive & epicsTimerQueueActive::allocate ( bool okToShare, unsigned threadPriority ) { epicsSingleton < timerQueueActiveMgr >::reference pMgr = - timerQueueMgrEPICS; + timerQueueMgrEPICS.getReference (); return pMgr->allocate ( okToShare, threadPriority ); }