From 7be4636d9265b1826f67adf2c6c426b6afb37aa0 Mon Sep 17 00:00:00 2001 From: schmidt Date: Mon, 27 Mar 2006 03:41:31 +0000 Subject: ChangeLogTag:Sun Mar 26 21:40:10 2006 Douglas C. Schmidt --- ace/TSS_T.cpp | 160 +++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 96 insertions(+), 64 deletions(-) (limited to 'ace/TSS_T.cpp') diff --git a/ace/TSS_T.cpp b/ace/TSS_T.cpp index 93897437e64..d6dc2599e8d 100644 --- a/ace/TSS_T.cpp +++ b/ace/TSS_T.cpp @@ -81,7 +81,7 @@ ACE_TSS::dump (void) const #if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) #if defined (ACE_HAS_THR_C_DEST) -extern "C" void ACE_TSS_C_cleanup(void *); // defined in Synch.cpp +extern "C" void ACE_TSS_C_cleanup (void *); // defined in Synch.cpp #endif /* ACE_HAS_THR_C_DEST */ template void @@ -94,7 +94,7 @@ ACE_TSS::cleanup (void *ptr) template int ACE_TSS::ts_init (void) const { - // Insure that we are serialized! + // Ensure that we are serialized! ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, (ACE_Thread_Mutex &) this->keylock_, 0); // Use the Double-Check pattern to make sure we only create the key @@ -195,18 +195,20 @@ ACE_TSS::ts_get (void) const ACE_TSS_Adapter *tss_adapter = 0; // Get the adapter from thread-specific storage - if (ACE_Thread::getspecific (this->key_, - (void **) &tss_adapter) == -1) + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + if (ACE_Thread::getspecific (this->key_, &temp) == -1) return 0; // This should not happen! + tss_adapter = static_cast (temp); // Check to see if this is the first time in for this thread. if (tss_adapter == 0) #else // Get the ts_obj from thread-specific storage. Note that no locks // are required here... - if (ACE_Thread::getspecific (this->key_, - (void **) &ts_obj) == -1) + void *temp = ts_obj; // Need this temp to keep G++ from complaining. + if (ACE_Thread::getspecific (this->key_, &temp) == -1) return 0; // This should not happen! + ts_obj = static_cast (temp); // Check to see if this is the first time in for this thread. if (ts_obj == 0) @@ -249,7 +251,7 @@ ACE_TSS::ts_get (void) const #if defined (ACE_HAS_THR_C_DEST) // Return the underlying ts object. - return (TYPE *) tss_adapter->ts_obj_; + return static_cast (tss_adapter->ts_obj_); #else return ts_obj; #endif /* ACE_HAS_THR_C_DEST */ @@ -274,16 +276,25 @@ ACE_TSS::ts_object (void) const ACE_TSS_Adapter *tss_adapter = 0; // Get the tss adapter from thread-specific storage - if (ACE_Thread::getspecific (this->key_, - (void **) &tss_adapter) == -1) - return 0; // This should not happen! - else if (tss_adapter != 0) - // Extract the real TS object. - ts_obj = (TYPE *) tss_adapter->ts_obj_; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + if (ACE_Thread::getspecific (this->key_, &temp) == -1) + { + return 0; // This should not happen! + } + else + { + tss_adapter = static_cast (temp); + { + if (tss_adapter != 0) + // Extract the real TS object. + ts_obj = static_cast (tss_adapter->ts_obj_); + } + } #else - if (ACE_Thread::getspecific (this->key_, - (void **) &ts_obj) == -1) + void *temp = ts_obj; // Need this temp to keep G++ from complaining. + if (ACE_Thread::getspecific (this->key_, &temp) == -1) return 0; // This should not happen! + ts_obj = static_cast (temp); #endif /* ACE_HAS_THR_C_DEST */ return ts_obj; @@ -310,13 +321,14 @@ ACE_TSS::ts_object (TYPE *new_ts_obj) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - if (ACE_Thread::getspecific (this->key_, - (void **) &tss_adapter) == -1) + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + if (ACE_Thread::getspecific (this->key_, &temp) == -1) return 0; // This should not happen! + tss_adapter = static_cast (temp); if (tss_adapter != 0) { - ts_obj = (TYPE *) tss_adapter->ts_obj_; + ts_obj = static_cast (tss_adapter->ts_obj_); delete tss_adapter; // don't need this anymore } @@ -332,9 +344,11 @@ ACE_TSS::ts_object (TYPE *new_ts_obj) return ts_obj; // This should not happen! } #else + void *temp = ts_obj; // Need this temp to keep G++ from complaining. if (ACE_Thread::getspecific (this->key_, - (void **) &ts_obj) == -1) + &temp) == -1) return 0; // This should not happen! + ts_obj = static_cast (temp); if (ACE_Thread::setspecific (this->key_, (void *) new_ts_obj) == -1) return ts_obj; // This should not happen! @@ -389,12 +403,14 @@ ACE_TSS_Guard::release (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, - (void **) &tss_adapter); - guard = (ACE_Guard *)tss_adapter->ts_obj_; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); #else - ACE_Thread::getspecific (this->key_, - (void **) &guard); + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); #endif /* ACE_HAS_THR_C_DEST */ return guard->release (); @@ -409,12 +425,14 @@ ACE_TSS_Guard::remove (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, - (void **) &tss_adapter); - guard = (ACE_Guard *) tss_adapter->ts_obj_; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); #else - ACE_Thread::getspecific (this->key_, - (void **) &guard); + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); #endif /* ACE_HAS_THR_C_DEST */ return guard->remove (); @@ -429,12 +447,14 @@ ACE_TSS_Guard::~ACE_TSS_Guard (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, - (void **) &tss_adapter); - guard = (ACE_Guard *) tss_adapter->ts_obj_; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); #else - ACE_Thread::getspecific (this->key_, - (void **) &guard); + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); #endif /* ACE_HAS_THR_C_DEST */ // Make sure that this pointer is NULL when we shut down... @@ -486,12 +506,14 @@ ACE_TSS_Guard::acquire (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, - (void **) &tss_adapter); - guard = (ACE_Guard *) tss_adapter->ts_obj_; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); #else - ACE_Thread::getspecific (this->key_, - (void **) &guard); + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); #endif /* ACE_HAS_THR_C_DEST */ return guard->acquire (); @@ -506,12 +528,14 @@ ACE_TSS_Guard::tryacquire (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, - (void **) &tss_adapter); - guard = (ACE_Guard *) tss_adapter->ts_obj_; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); #else - ACE_Thread::getspecific (this->key_, - (void **) &guard); + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); #endif /* ACE_HAS_THR_C_DEST */ return guard->tryacquire (); @@ -551,12 +575,14 @@ ACE_TSS_Write_Guard::acquire (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, - (void **) &tss_adapter); - guard = (ACE_Guard *) tss_adapter->ts_obj_; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); #else - ACE_Thread::getspecific (this->key_, - (void **) &guard); + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); #endif /* ACE_HAS_THR_C_DEST */ return guard->acquire_write (); @@ -571,12 +597,14 @@ ACE_TSS_Write_Guard::tryacquire (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, - (void **) &tss_adapter); - guard = (ACE_Guard *) tss_adapter->ts_obj_; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); #else - ACE_Thread::getspecific (this->key_, - (void **) &guard); + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, temp); + guard = static_cast *> (temp); #endif /* ACE_HAS_THR_C_DEST */ return guard->tryacquire_write (); @@ -639,12 +667,14 @@ ACE_TSS_Read_Guard::acquire (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, - (void **) &tss_adapter); - guard = (ACE_Guard *) tss_adapter->ts_obj_; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); #else - ACE_Thread::getspecific (this->key_, - (void **) &guard); + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); #endif /* ACE_HAS_THR_C_DEST */ return guard->acquire_read (); @@ -659,12 +689,14 @@ ACE_TSS_Read_Guard::tryacquire (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, - (void **) &tss_adapter); - guard = (ACE_Guard *) tss_adapter->ts_obj_; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); #else - ACE_Thread::getspecific (this->key_, - (void **) &guard); + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); #endif /* ACE_HAS_THR_C_DEST */ return guard->tryacquire_read (); -- cgit v1.2.1