diff options
author | arvindk <arvindk@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-10-20 13:59:49 +0000 |
---|---|---|
committer | arvindk <arvindk@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-10-20 13:59:49 +0000 |
commit | 0390f849874e2c62fcd0bd0f414a0dd43d7950cf (patch) | |
tree | 2c250cf531c7380a4ff4ee066bc6d38f9b903c11 /ace | |
parent | 04cfbcaf01f323301be03c8274f5cd9ffc4aca0d (diff) | |
download | ATCD-0390f849874e2c62fcd0bd0f414a0dd43d7950cf.tar.gz |
ChangelogTag: Thu Oct 20 08:53:47 2005 Arvind S. Krishna <arvindk@doc.dre.vanderbilt.edu>
Diffstat (limited to 'ace')
-rw-r--r-- | ace/CDR_Base.cpp | 6 | ||||
-rw-r--r-- | ace/CDR_Stream.cpp | 28 | ||||
-rw-r--r-- | ace/CDR_Stream.h | 12 | ||||
-rw-r--r-- | ace/CDR_Stream.inl | 34 | ||||
-rw-r--r-- | ace/Message_Block.cpp | 19 |
5 files changed, 96 insertions, 3 deletions
diff --git a/ace/CDR_Base.cpp b/ace/CDR_Base.cpp index 7f3c7d5c05f..ce0b182cbe9 100644 --- a/ace/CDR_Base.cpp +++ b/ace/CDR_Base.cpp @@ -482,8 +482,12 @@ ACE_CDR::swap_16_array (const char* orig, char* target, size_t n) void ACE_CDR::mb_align (ACE_Message_Block *mb) { +#if !defined (ACE_CDR_IGNORE_ALIGNMENT) char *start = ACE_ptr_align_binary (mb->base (), ACE_CDR::MAX_ALIGNMENT); +#else + char *start = mb->base (); +#endif /* ACE_CDR_IGNORE_ALIGNMENT */ mb->rd_ptr (start); mb->wr_ptr (start); } @@ -542,6 +546,7 @@ ACE_CDR::consolidate (ACE_Message_Block *dst, + ACE_CDR::MAX_ALIGNMENT); dst->size (newsize); +#if !defined (ACE_CDR_IGNORE_ALIGNMENT) // We must copy the contents of <src> into the new buffer, but // respecting the alignment. ptrdiff_t srcalign = @@ -553,6 +558,7 @@ ACE_CDR::consolidate (ACE_Message_Block *dst, offset += ACE_CDR::MAX_ALIGNMENT; dst->rd_ptr (offset); dst->wr_ptr (dst->rd_ptr ()); +#endif /* ACE_CDR_IGNORE_ALIGNMENT */ for (const ACE_Message_Block* i = src; i != 0; diff --git a/ace/CDR_Stream.cpp b/ace/CDR_Stream.cpp index 12a57ee11e3..bc8b49f409b 100644 --- a/ace/CDR_Stream.cpp +++ b/ace/CDR_Stream.cpp @@ -33,7 +33,9 @@ ACE_OutputCDR::ACE_OutputCDR (size_t size, ACE_Time_Value::max_time, data_block_allocator, message_block_allocator), +#if !defined (ACE_LACKS_CDR_ALIGNMENT) current_alignment_ (0), +#endif /* ACE_LACKS_CDR_ALIGNMENT */ current_is_writable_ (true), do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), good_bit_ (true), @@ -67,7 +69,9 @@ ACE_OutputCDR::ACE_OutputCDR (char *data, size_t size, ACE_Time_Value::max_time, data_block_allocator, message_block_allocator), +#if !defined (ACE_LACKS_CDR_ALIGNMENT) current_alignment_ (0), +#endif /* ACE_LACKS_CDR_ALIGNMENT */ current_is_writable_ (true), do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), good_bit_ (true), @@ -88,7 +92,9 @@ ACE_OutputCDR::ACE_OutputCDR (ACE_Message_Block *data, ACE_CDR::Octet major_version, ACE_CDR::Octet minor_version) : start_ (data->data_block ()->duplicate ()), +#if !defined (ACE_LACKS_CDR_ALIGNMENT) current_alignment_ (0), +#endif /* ACE_LACKS_CDR_ALIGNMENT */ current_is_writable_ (true), do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), good_bit_ (true), @@ -129,8 +135,12 @@ ACE_OutputCDR::grow_and_adjust (size_t size, size_t cursize = this->current_->size (); if (this->current_->cont () != 0) cursize = this->current_->cont ()->size (); + size_t minsize = size; + +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + minsize += ACE_CDR::MAX_ALIGNMENT; +#endif /* ACE_LACKS_CDR_ALIGNMENT */ - size_t minsize = size + ACE_CDR::MAX_ALIGNMENT; // Make sure that there is enough room for <minsize> bytes, but // also make it bigger than whatever our current size is. if (minsize < cursize) @@ -154,6 +164,7 @@ ACE_OutputCDR::grow_and_adjust (size_t size, -1); this->good_bit_ = true; +#if !defined (ACE_LACKS_CDR_ALIGNMENT) // The new block must start with the same alignment as the // previous block finished. ptrdiff_t tmpalign = @@ -165,6 +176,7 @@ ACE_OutputCDR::grow_and_adjust (size_t size, offset += ACE_CDR::MAX_ALIGNMENT; tmp->rd_ptr (offset); tmp->wr_ptr (tmp->rd_ptr ()); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ // grow the chain and set the current block. tmp->cont (this->current_->cont ()); @@ -364,8 +376,10 @@ ACE_OutputCDR::write_octet_array_mb (const ACE_Message_Block* mb) this->current_->cont (cont); this->current_ = cont; this->current_is_writable_ = false; +#if !defined (ACE_LACKS_CDR_ALIGNMENT) this->current_alignment_ = (this->current_alignment_ + cont->length ()) % ACE_CDR::MAX_ALIGNMENT; +#endif /* ACE_LACKS_CDR_ALIGNMENT */ } else { @@ -723,10 +737,14 @@ ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs, wchar_translator_ (rhs.wchar_translator_) { +#if !defined (ACE_LACKS_CDR_ALIGNMENT) // Align the base pointer assuming that the incoming stream is also // aligned the way we are aligned char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (), ACE_CDR::MAX_ALIGNMENT); +#else + char *incoming_start = rhs.start_.base (); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ const size_t newpos = (rhs.start_.rd_ptr() - incoming_start) + offset; @@ -753,10 +771,14 @@ ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs, wchar_translator_ (rhs.wchar_translator_) { +#if !defined (ACE_LACKS_CDR_ALIGNMENT) // Align the base pointer assuming that the incoming stream is also // aligned the way we are aligned char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (), ACE_CDR::MAX_ALIGNMENT); +#else + char *incoming_start = rhs.start_.base (); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ const size_t newpos = rhs.start_.rd_ptr() - incoming_start; @@ -787,8 +809,12 @@ ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs) char_translator_ (rhs.char_translator_), wchar_translator_ (rhs.wchar_translator_) { +#if !defined (ACE_LACKS_CDR_ALIGNMENT) char *buf = ACE_ptr_align_binary (rhs.start_.base (), ACE_CDR::MAX_ALIGNMENT); +#else + char *buf = rhs.start_.base (); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ size_t rd_offset = rhs.start_.rd_ptr () - buf; size_t wr_offset = rhs.start_.wr_ptr () - buf; diff --git a/ace/CDR_Stream.h b/ace/CDR_Stream.h index 4a7c93b43fe..aaccca23cb9 100644 --- a/ace/CDR_Stream.h +++ b/ace/CDR_Stream.h @@ -18,6 +18,16 @@ * precision and double precision IEEE floats. * Those assumptions are pretty good these days, with Crays beign * the only known exception. + * + * Optimizations + * ------------- + * ACE_LACKS_CDR_ALIGNMENT + * @author Arvind S. Krishna <arvindk@dre.vanderbilt.edu> + * + * CDR stream ignores alignment when marshaling data. Use this option + * only when ACE_DISABLE_SWAP_ON_READ can enabled. This option requires + * ACE CDR engine to do both marshaling and demarshaling. + * * * @author TAO version by Aniruddha Gokhale <gokhale@cs.wustl.edu> * @author Carlos O'Ryan <coryan@cs.wustl.edu> @@ -431,6 +441,7 @@ private: /// The current block in the chain were we are writing. ACE_Message_Block *current_; +#if !defined (ACE_LACKS_CDR_IALIGNMENT) /** * The current alignment as measured from the start of the buffer. * Usually this coincides with the alignment of the buffer in @@ -440,6 +451,7 @@ private: * the stolen message block. */ size_t current_alignment_; +#endif /* ACE_LACKS_CDR_ALIGNMENT */ /** * Is the current block writable. When we steal a buffer from the diff --git a/ace/CDR_Stream.inl b/ace/CDR_Stream.inl index 6d68e938d15..47dc98f7da8 100644 --- a/ace/CDR_Stream.inl +++ b/ace/CDR_Stream.inl @@ -153,7 +153,10 @@ ACE_OutputCDR::reset (void) this->current_ = &this->start_; this->current_is_writable_ = true; ACE_CDR::mb_align (&this->start_); + +#if !defined (ACE_LACKS_CDR_ALIGNMENT) this->current_alignment_ = 0; +#endif /* ACE_LACKS_CDR_ALIGNMENT */ // It is tempting not to remove the memory, but we need to do so to // release any potential user buffers chained in the continuation @@ -416,17 +419,24 @@ ACE_OutputCDR::adjust (size_t size, if (!this->current_is_writable_) return this->grow_and_adjust (size, align, buf); +#if !defined (ACE_LACKS_CDR_ALIGNMENT) const size_t offset = ACE_align_binary (this->current_alignment_, align) - this->current_alignment_; buf = this->current_->wr_ptr () + offset; +#else + buf = this->current_->wr_ptr (); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + char *end = buf + size; if (end <= this->current_->end () && end >= buf) { +#if !defined (ACE_LACKS_CDR_ALIGNMENT) this->current_alignment_ += offset + size; +#endif /* ACE_LACKS_CDR_ALIGNMENT */ this->current_->wr_ptr (end); return 0; } @@ -518,14 +528,26 @@ ACE_OutputCDR::reset_byte_order (int byte_order) ACE_INLINE size_t ACE_OutputCDR::current_alignment (void) const { +#if !defined (ACE_LACKS_CDR_ALIGNMENT) return this->current_alignment_; +#else + // Default value set to 0 + return 0; +#endif /* ACE_LACKS_CDR_ALIGNMENT */ } ACE_INLINE int ACE_OutputCDR::align_write_ptr (size_t alignment) { +#if !defined (ACE_LACKS_CDR_ALIGNMENT) char *dummy; return this->adjust (0, alignment, dummy); +#else + ACE_UNUSED_ARG (alignment); + // A return value of -1 from this function is used + // to indicate failure, returning 0 + return 0; +#endif /* ACE_LACKS_CDR_ALIGNMENT */ } ACE_INLINE ACE_Char_Codeset_Translator * @@ -986,7 +1008,12 @@ ACE_InputCDR::adjust (size_t size, size_t align, char*& buf) { +#if !defined (ACE_LACKS_CDR_ALIGNMENT) buf = ACE_ptr_align_binary (this->rd_ptr (), align); +#else + buf = this->rd_ptr (); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + char *end = buf + size; if (end <= this->wr_ptr ()) { @@ -996,6 +1023,9 @@ ACE_InputCDR::adjust (size_t size, this->good_bit_ = false; return -1; +#if defined (ACE_LACKS_CDR_ALIGNMENT) + ACE_UNUSED_ARG (align); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ } ACE_INLINE int @@ -1436,8 +1466,12 @@ ACE_InputCDR::byte_order (void) const ACE_INLINE int ACE_InputCDR::align_read_ptr (size_t alignment) { +#if !defined (ACE_LACKS_CDR_ALIGNMENT) char *buf = ACE_ptr_align_binary (this->rd_ptr (), alignment); +#else + char *buf = this->rd_ptr (); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ if (buf <= this->wr_ptr ()) { diff --git a/ace/Message_Block.cpp b/ace/Message_Block.cpp index 6dfce19a0ec..ce66c19dcfc 100644 --- a/ace/Message_Block.cpp +++ b/ace/Message_Block.cpp @@ -582,10 +582,14 @@ ACE_Message_Block::ACE_Message_Block (const ACE_Message_Block &mb, mb.message_block_allocator_) == -1) ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_Message_Block"))); - +#if !defined (ACE_LACKS_CDR_ALIGNMENT) // Align ourselves char *start = ACE_ptr_align_binary (this->base (), align); +#else + char *start = this->base (); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + // Set our rd & wr pointers this->rd_ptr (start); this->wr_ptr (start); @@ -609,17 +613,25 @@ ACE_Message_Block::ACE_Message_Block (const ACE_Message_Block &mb, ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_Message_Block"))); +#if !defined (ACE_LACKS_CDR_ALIGNMENT) // Align ourselves char *start = ACE_ptr_align_binary (this->base (), align); +#else + char *start = this->base (); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + // Set our rd & wr pointers this->rd_ptr (start); this->wr_ptr (start); +#if !defined (ACE_LACKS_CDR_ALIGNMENT) // Get the alignment offset of the incoming ACE_Message_Block start = ACE_ptr_align_binary (mb.base (), align); - +#else + start = mb.base (); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ // Actual offset for the incoming message block assuming that it // is also aligned to the same "align" byte @@ -634,6 +646,9 @@ ACE_Message_Block::ACE_Message_Block (const ACE_Message_Block &mb, // to do what it wants } +#if defined (ACE_LACKS_CDR_ALIGNMENT) + ACE_UNUSED_ARG (align); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ } int |