diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-11-24 03:14:02 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-11-24 03:14:02 +0000 |
commit | 62f310fadec27373c797c7475ff19204a5787833 (patch) | |
tree | 8d9efb9aca5e1b07987531b845cf192da2315cd3 /ace | |
parent | 8a12d3ae7f93fb3ca79c44938c40c521e30d4031 (diff) | |
download | ATCD-62f310fadec27373c797c7475ff19204a5787833.tar.gz |
ChangeLogTag:Tue Nov 23 12:47:39 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Malloc.h | 31 | ||||
-rw-r--r-- | ace/Malloc_T.cpp | 22 | ||||
-rw-r--r-- | ace/OS.h | 2 |
3 files changed, 32 insertions, 23 deletions
diff --git a/ace/Malloc.h b/ace/Malloc.h index 4a0c99b3e63..e7fc0641801 100644 --- a/ace/Malloc.h +++ b/ace/Malloc.h @@ -56,9 +56,9 @@ struct ACE_Export ACE_Malloc_Stats ACE_INT ninuse_; // Number of blocks in use }; -#define AMS(X) X +#define ACE_MALLOC_STATS(X) X #else -#define AMS(X) +#define ACE_MALLOC_STATS(X) #endif /* ACE_HAS_MALLOC_STATS */ #if !defined (ACE_MALLOC_PADDING) @@ -75,7 +75,7 @@ struct ACE_Export ACE_Malloc_Stats // // #define ACE_MALLOC_PADDING ((int) 4096) -#define ACE_MALLOC_PADDING 1 +#define ACE_MALLOC_PADDING 4096 #endif /* ACE_MALLOC_PADDING */ #if !defined (ACE_MALLOC_ALIGN) @@ -112,9 +112,10 @@ public: #if (ACE_MALLOC_PADDING > 1) #define ACE_MALLOC_PADDING_SIZE ((ACE_MALLOC_PADDING - \ - (sizeof (ACE_Malloc_Header)) / ACE_MALLOC_ALIGN)) - long padding_[ACE_MALLOC_PADDING_SIZE < 1 : ACE_MALLOC_PADDING_SIZE]; -#endif /* ACE_MALLOC_PADDING > 0 */ + (sizeof (ACE_MALLOC_HEADER_PTR) + sizeof (size_t)) \ + / sizeof (long))) + long padding_[ACE_MALLOC_PADDING_SIZE < 1 ? 1 : ACE_MALLOC_PADDING_SIZE]; +#endif /* ACE_MALLOC_PADDING > 1 */ void dump (void) const; // Dump the state of the object. @@ -201,21 +202,29 @@ public: // Keep statistics about ACE_Malloc state and performance. ACE_Malloc_Stats malloc_stats_; #define ACE_CONTROL_BLOCK_SIZE ((int)(sizeof (ACE_NAME_NODE_PTR) \ - + sizeof (ACE_Malloc_Header *) \ + + sizeof (ACE_MALLOC_HEADER_PTR) \ + MAXNAMELEN \ + sizeof (ACE_Malloc_Stats))) #else #define ACE_CONTROL_BLOCK_SIZE ((int)(sizeof (ACE_NAME_NODE_PTR) \ - + sizeof (ACE_Malloc_Header *) \ + + sizeof (ACE_MALLOC_HEADER_PTR) \ + MAXNAMELEN)) #endif /* ACE_HAS_MALLOC_STATS */ + // We have to assert that base_'s offset is a multiple of + // ACE_MALLOC_ALIGN so if ACE_CONTROL_BLOCK_SIZE % ACE_MALLOC_ALIGN + // != 0 we have to add padding of X longs so that + // ACE_CONTROL_BLOCK_SIZE + X * sizeof (long) % ACE_MALLOC_ALIGN == + // 0. This predicate can be satisfied by the following macro: #define ACE_CONTROL_BLOCK_ALIGN ((ACE_CONTROL_BLOCK_SIZE % ACE_MALLOC_ALIGN != 0 \ - ? ACE_MALLOC_ALIGN - (ACE_CONTROL_BLOCK_SIZE) \ - : ACE_MALLOC_ALIGN) / ACE_MALLOC_ALIGN) + ? ACE_MALLOC_ALIGN - (ACE_CONTROL_BLOCK_SIZE % \ + ACE_MALLOC_ALIGN) \ + : ACE_MALLOC_ALIGN) / int (sizeof (long))) long align_[ACE_CONTROL_BLOCK_ALIGN < 1 ? 1 : ACE_CONTROL_BLOCK_ALIGN]; - // Force alignment. + // Force alignment. Ideally we would want to have nothing here when + // ACE_CONTROL_BLOCK_ALIGN == 0, but standard C++ does not allow + // zero length arrays. ACE_Malloc_Header base_; // Dummy node used to anchor the freelist. This needs to come last... diff --git a/ace/Malloc_T.cpp b/ace/Malloc_T.cpp index 193a61a1be7..a741a5d9346 100644 --- a/ace/Malloc_T.cpp +++ b/ace/Malloc_T.cpp @@ -207,9 +207,9 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::open (void) / sizeof (ACE_Malloc_Header); #endif /* (__hpux) && defined (__LP64__) */ - AMS (++this->cb_ptr_->malloc_stats_.nchunks_); - AMS (++this->cb_ptr_->malloc_stats_.nblocks_); - AMS (++this->cb_ptr_->malloc_stats_.ninuse_); + ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.nchunks_); + ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.nblocks_); + ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.ninuse_); // Insert the newly allocated chunk of memory into the free // list. Add "1" to skip over the <ACE_Malloc_Header> when @@ -324,7 +324,7 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::shared_malloc (size_t nbytes) { if (currp->size_ >= nunits) // Big enough { - AMS (++this->cb_ptr_->malloc_stats_.ninuse_); + ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.ninuse_); if (currp->size_ == nunits) // Exact size, just update the pointers. prevp->next_block_ = currp->next_block_; @@ -332,7 +332,7 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::shared_malloc (size_t nbytes) { // Remaining chunk is larger than requested block, so // allocate at tail end. - AMS (++this->cb_ptr_->malloc_stats_.nblocks_); + ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.nblocks_); currp->size_ -= nunits; currp += currp->size_; #if defined (ACE_HAS_POSITION_INDEPENDENT_MALLOC) @@ -358,9 +358,9 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::shared_malloc (size_t nbytes) chunk_bytes); if (currp != 0) { - AMS (++this->cb_ptr_->malloc_stats_.nblocks_); - AMS (++this->cb_ptr_->malloc_stats_.nchunks_); - AMS (++this->cb_ptr_->malloc_stats_.ninuse_); + ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.nblocks_); + ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.nchunks_); + ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.ninuse_); #if defined (ACE_HAS_POSITION_INDEPENDENT_MALLOC) new ((void *) &currp->next_block_) ACE_MALLOC_HEADER_PTR; @@ -444,7 +444,7 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::shared_free (void *ap) // Join to upper neighbor. if ((blockp + blockp->size_) == currp->next_block_) { - AMS (--this->cb_ptr_->malloc_stats_.nblocks_); + ACE_MALLOC_STATS (--this->cb_ptr_->malloc_stats_.nblocks_); blockp->size_ += currp->next_block_->size_; blockp->next_block_ = currp->next_block_->next_block_; } @@ -454,14 +454,14 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::shared_free (void *ap) // Join to lower neighbor. if ((currp + currp->size_) == blockp) { - AMS (--this->cb_ptr_->malloc_stats_.nblocks_); + ACE_MALLOC_STATS (--this->cb_ptr_->malloc_stats_.nblocks_); currp->size_ += blockp->size_; currp->next_block_ = blockp->next_block_; } else currp->next_block_ = blockp; - AMS (--this->cb_ptr_->malloc_stats_.ninuse_); + ACE_MALLOC_STATS (--this->cb_ptr_->malloc_stats_.ninuse_); this->cb_ptr_->freep_ = currp; } @@ -693,7 +693,7 @@ private: # define ACE_SET_BITS(WORD, BITS) (WORD |= (BITS)) # define ACE_CLR_BITS(WORD, BITS) (WORD &= ~(BITS)) # define ACE_MAX(x,y) (((x)>(y))?(x):(y)) -# define ACE_MIN(x,y) (((x)<(y))?(x):(y)) +# define ACE_MIN(x,y) (((y)>(x))?(x):(y)) // Keep the compiler from complaining about parameters which are not used. # if defined (ghs) || defined (__GNUC__) || defined (__hpux) || defined (__sgi) || defined (DEC_CXX) || defined (__KCC) || defined (__rational__) || (__USLC__) |