From 0dce06f4cf55ac93139236f401b17166d528b9d1 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Wed, 30 Oct 2002 17:19:26 +0000 Subject: [PATCH] upgraded compiler specific macros --- src/libCom/cxxTemplates/epicsSingleton.h | 12 ++++++------ src/libCom/cxxTemplates/tsFreeList.h | 24 +++++++++++------------ src/libCom/misc/cxxCompilerDependencies.h | 13 +++++++++--- src/libCom/osi/epicsMutex.cpp | 14 ++++++------- src/libCom/osi/epicsMutex.h | 14 ++++++------- src/libCom/timer/epicsTimer.cpp | 10 +++------- src/libCom/timer/timer.cpp | 2 +- src/libCom/timer/timerPrivate.h | 14 +++++-------- 8 files changed, 51 insertions(+), 52 deletions(-) diff --git a/src/libCom/cxxTemplates/epicsSingleton.h b/src/libCom/cxxTemplates/epicsSingleton.h index dd5c38605..40db208f8 100644 --- a/src/libCom/cxxTemplates/epicsSingleton.h +++ b/src/libCom/cxxTemplates/epicsSingleton.h @@ -42,33 +42,33 @@ public: // inline func def required by visual c++ 7 class reference { public: - reference ( TYPE & tIn ) epics_throws (()) : + reference ( TYPE & tIn ) epicsThrows (()) : instance ( tIn ) { } - ~reference () epics_throws (()) + ~reference () epicsThrows (()) { } - TYPE * operator -> () epics_throws (()) + TYPE * operator -> () epicsThrows (()) { return & this->instance; } - const TYPE * operator -> () const epics_throws (()) + const TYPE * operator -> () const epicsThrows (()) { typename epicsSingleton::reference & ref = const_cast < typename epicsSingleton::reference & > ( *this ); return ref.operator -> (); } - TYPE & operator * () epics_throws (()) + TYPE & operator * () epicsThrows (()) { return * this->operator -> (); } - const TYPE & operator * () const epics_throws (()) + const TYPE & operator * () const epicsThrows (()) { return * this->operator -> (); } diff --git a/src/libCom/cxxTemplates/tsFreeList.h b/src/libCom/cxxTemplates/tsFreeList.h index e58b0a198..8510df13b 100644 --- a/src/libCom/cxxTemplates/tsFreeList.h +++ b/src/libCom/cxxTemplates/tsFreeList.h @@ -86,21 +86,21 @@ template < class T, unsigned N = 0x400, class tsFreeList { public: tsFreeList () - epics_throws (()); + epicsThrows (()); ~tsFreeList () - epics_throws (()); + epicsThrows (()); void * allocate ( size_t size ) - epics_throws (( std::bad_alloc )); + epicsThrows (( std::bad_alloc )); void release ( void * p ) - epics_throws (()); + epicsThrows (()); void release ( void * p, size_t size ) - epics_throws (()); + epicsThrows (()); private: MUTEX mutex; tsFreeListItem < T > * pFreeList; tsFreeListChunk < T, N > * pChunkList; void * allocateFromNewChunk () - epics_throws (( std::bad_alloc )); + epicsThrows (( std::bad_alloc )); }; template < class T > @@ -118,10 +118,10 @@ struct tsFreeListChunk { template < class T, unsigned N, class MUTEX > inline tsFreeList < T, N, MUTEX > :: tsFreeList () - epics_throws (()) : pFreeList ( 0 ), pChunkList ( 0 ) {} + epicsThrows (()) : pFreeList ( 0 ), pChunkList ( 0 ) {} template < class T, unsigned N, class MUTEX > -tsFreeList < T, N, MUTEX > :: ~tsFreeList () epics_throws (()) +tsFreeList < T, N, MUTEX > :: ~tsFreeList () epicsThrows (()) { while ( tsFreeListChunk < T, N > *pChunk = this->pChunkList ) { this->pChunkList = this->pChunkList->pNext; @@ -131,7 +131,7 @@ tsFreeList < T, N, MUTEX > :: ~tsFreeList () epics_throws (()) template < class T, unsigned N, class MUTEX > void * tsFreeList < T, N, MUTEX >::allocate ( size_t size ) - epics_throws (( std::bad_alloc )) + epicsThrows (( std::bad_alloc )) { if ( size != sizeof ( T ) || N == 0u || tsFreeListDebugBypass ) { void * p = ::operator new ( size ); @@ -151,7 +151,7 @@ void * tsFreeList < T, N, MUTEX >::allocate ( size_t size ) template < class T, unsigned N, class MUTEX > void * tsFreeList < T, N, MUTEX >::allocateFromNewChunk () - epics_throws (( std::bad_alloc )) + epicsThrows (( std::bad_alloc )) { tsFreeListChunk < T, N > * pChunk = new tsFreeListChunk < T, N >; @@ -171,7 +171,7 @@ void * tsFreeList < T, N, MUTEX >::allocateFromNewChunk () template < class T, unsigned N, class MUTEX > void tsFreeList < T, N, MUTEX >::release ( void * pCadaver, size_t size ) - epics_throws (()) + epicsThrows (()) { if ( size != sizeof ( T ) ) { tsFreeListMemSetDelete ( pCadaver, size ); @@ -184,7 +184,7 @@ void tsFreeList < T, N, MUTEX >::release ( void * pCadaver, size_t size ) template < class T, unsigned N, class MUTEX > void tsFreeList < T, N, MUTEX >::release ( void * pCadaver ) - epics_throws (()) + epicsThrows (()) { if ( N == 0u || tsFreeListDebugBypass ) { tsFreeListMemSetDelete ( pCadaver, sizeof ( T ) ); diff --git a/src/libCom/misc/cxxCompilerDependencies.h b/src/libCom/misc/cxxCompilerDependencies.h index 9dbb95570..1c048e8a5 100644 --- a/src/libCom/misc/cxxCompilerDependencies.h +++ b/src/libCom/misc/cxxCompilerDependencies.h @@ -52,11 +52,18 @@ # define CXX_THROW_SPECIFICATION #endif -// usage: void func () epics_throws (( std::bad_alloc, std::logic_error )) +// usage: void func () epicsThrows (( std::bad_alloc, std::logic_error )) #if defined ( CXX_THROW_SPECIFICATION ) -# define epics_throws(X) throw X +# define epicsThrows(X) throw X #else -# define epics_throws(X) +# define epicsThrows(X) +#endif + +// usage: epicsPlacementDeleteOperator (( void *, myMemoryManager & )) +#if defined ( CXX_PLACEMENT_DELETE ) +# define epicsPlacementDeleteOperator(X) void operator delete X epicsThrows (); +#else +# define epicsPlacementDeleteOperator(X) #endif #endif // ifndef cxxCompilerDependencies_h diff --git a/src/libCom/osi/epicsMutex.cpp b/src/libCom/osi/epicsMutex.cpp index f81fa7d2f..894ff00d4 100644 --- a/src/libCom/osi/epicsMutex.cpp +++ b/src/libCom/osi/epicsMutex.cpp @@ -127,7 +127,7 @@ void epicsShareAPI epicsMutexShowAll(int onlyLocked,unsigned int level) epicsMutexUnlock(epicsMutexGlobalLock); } -epicsMutex :: epicsMutex () epics_throws (( epicsMutex::mutexCreateFailed )) : +epicsMutex :: epicsMutex () epicsThrows (( epicsMutex::mutexCreateFailed )) : id ( epicsMutexCreate () ) { if ( this->id == 0 ) { @@ -136,13 +136,13 @@ epicsMutex :: epicsMutex () epics_throws (( epicsMutex::mutexCreateFailed )) : } epicsMutex ::~epicsMutex () - epics_throws (()) + epicsThrows (()) { epicsMutexDestroy ( this->id ); } void epicsMutex::lock () - epics_throws (( epicsMutex::invalidMutex )) + epicsThrows (( epicsMutex::invalidMutex )) { epicsMutexLockStatus status = epicsMutexLock ( this->id ); if ( status != epicsMutexLockOK ) { @@ -151,7 +151,7 @@ void epicsMutex::lock () } bool epicsMutex::lock ( double timeOut ) // X aCC 361 - epics_throws (( epicsMutex::invalidMutex )) + epicsThrows (( epicsMutex::invalidMutex )) { epicsMutexLockStatus status = epicsMutexLockWithTimeout ( this->id, timeOut ); if ( status == epicsMutexLockOK ) { @@ -167,7 +167,7 @@ bool epicsMutex::lock ( double timeOut ) // X aCC 361 } bool epicsMutex::tryLock () // X aCC 361 - epics_throws (( epicsMutex::invalidMutex )) + epicsThrows (( epicsMutex::invalidMutex )) { epicsMutexLockStatus status = epicsMutexTryLock ( this->id ); if ( status == epicsMutexLockOK ) { @@ -183,13 +183,13 @@ bool epicsMutex::tryLock () // X aCC 361 } void epicsMutex::unlock () - epics_throws (()) + epicsThrows (()) { epicsMutexUnlock ( this->id ); } void epicsMutex :: show ( unsigned level ) const - epics_throws (()) + epicsThrows (()) { epicsMutexShow ( this->id, level ); } diff --git a/src/libCom/osi/epicsMutex.h b/src/libCom/osi/epicsMutex.h index 075ca20da..f7f3fa8f7 100644 --- a/src/libCom/osi/epicsMutex.h +++ b/src/libCom/osi/epicsMutex.h @@ -28,19 +28,19 @@ public: class mutexCreateFailed {}; // exception class invalidMutex {}; // exception epicsMutex () - epics_throws (( mutexCreateFailed )); + epicsThrows (( mutexCreateFailed )); ~epicsMutex () - epics_throws (()); + epicsThrows (()); void show ( unsigned level ) const - epics_throws (()); + epicsThrows (()); void lock () /* blocks until success */ - epics_throws (( invalidMutex )); + epicsThrows (( invalidMutex )); void unlock () - epics_throws (()); + epicsThrows (()); bool lock ( double timeOut ) /* true if successful */ - epics_throws (( invalidMutex )); + epicsThrows (( invalidMutex )); bool tryLock () /* true if successful */ - epics_throws (( invalidMutex )); + epicsThrows (( invalidMutex )); private: epicsMutexId id; epicsMutex ( const epicsMutex & ); diff --git a/src/libCom/timer/epicsTimer.cpp b/src/libCom/timer/epicsTimer.cpp index 6e0ed0c61..7762cf633 100644 --- a/src/libCom/timer/epicsTimer.cpp +++ b/src/libCom/timer/epicsTimer.cpp @@ -39,7 +39,7 @@ epicsTimerNotify::~epicsTimerNotify () {} void epicsTimerNotify::show ( unsigned /* level */ ) const {} -epicsTimerForC::epicsTimerForC ( timerQueue &queue, epicsTimerCallback pCBIn, void *pPrivateIn ) epics_throws (()) : +epicsTimerForC::epicsTimerForC ( timerQueue &queue, epicsTimerCallback pCBIn, void *pPrivateIn ) epicsThrows (()) : timer ( queue ), pCallBack ( pCBIn ), pPrivate ( pPrivateIn ) { } @@ -52,11 +52,7 @@ void epicsTimerForC::destroy () { timerQueue & queueTmp ( this->queue ); this->~epicsTimerForC (); -# ifdef CXX_PLACEMENT_DELETE - epicsTimerForC::operator delete ( this, queueTmp.timerForCFreeList ); -# else - queueTmp.timerForCFreeList.release ( this ); -# endif + queueTmp.timerForCFreeList.release ( this ); } epicsTimerNotify::expireStatus epicsTimerForC::expire ( const epicsTime & ) @@ -74,7 +70,7 @@ epicsTimerQueueActiveForC::~epicsTimerQueueActiveForC () { } -void epicsTimerQueueActiveForC::release () epics_throws (()) +void epicsTimerQueueActiveForC::release () epicsThrows (()) { epicsSingleton < timerQueueActiveMgr >::reference pMgr = timerQueueMgrEPICS; diff --git a/src/libCom/timer/timer.cpp b/src/libCom/timer/timer.cpp index 51b3cd3a9..f0e07aa71 100644 --- a/src/libCom/timer/timer.cpp +++ b/src/libCom/timer/timer.cpp @@ -35,7 +35,7 @@ template class tsFreeList < timer, 0x20 >; # pragma warning ( pop ) #endif -timer::timer ( timerQueue & queueIn ) epics_throws (()): +timer::timer ( timerQueue & queueIn ) epicsThrows (()): queue ( queueIn ), curState ( stateLimbo ), pNotify ( 0 ) { } diff --git a/src/libCom/timer/timerPrivate.h b/src/libCom/timer/timerPrivate.h index d5cc82ebd..c5cc10247 100644 --- a/src/libCom/timer/timerPrivate.h +++ b/src/libCom/timer/timerPrivate.h @@ -41,11 +41,9 @@ public: expireInfo getExpireInfo () const; void show ( unsigned int level ) const; void * operator new ( size_t size, tsFreeList < timer, 0x20 > & ); -#ifdef CXX_PLACEMENT_DELETE - void operator delete ( void *, tsFreeList < timer, 0x20 > & ); -#endif + epicsPlacementDeleteOperator (( void *, tsFreeList < timer, 0x20 > & )) protected: - timer ( class timerQueue & ) epics_throws (()); + timer ( class timerQueue & ) epicsThrows (()); ~timer (); timerQueue & queue; private: @@ -69,12 +67,10 @@ struct epicsTimerForC : public epicsTimerNotify, public timer { public: void destroy (); protected: - epicsTimerForC ( timerQueue &, epicsTimerCallback, void *pPrivateIn ) epics_throws (()); + epicsTimerForC ( timerQueue &, epicsTimerCallback, void *pPrivateIn ) epicsThrows (()); ~epicsTimerForC (); void * operator new ( size_t size, tsFreeList < epicsTimerForC, 0x20 > & ); -#ifdef CXX_PLACEMENT_DELETE - void operator delete ( void *, tsFreeList < epicsTimerForC, 0x20 > & ); -#endif + epicsPlacementDeleteOperator (( void *, tsFreeList < epicsTimerForC, 0x20 > & )) private: epicsTimerCallback pCallBack; void * pPrivate; @@ -199,7 +195,7 @@ struct epicsTimerQueueActiveForC : public timerQueueActive, public tsDLNode < epicsTimerQueueActiveForC > { public: epicsTimerQueueActiveForC ( bool okToShare, unsigned priority ); - void release () epics_throws (()); + void release () epicsThrows (()); void * operator new ( size_t ); void operator delete ( void * ); protected: