From: Jason Dillaman Date: Fri, 9 Oct 2015 16:58:54 +0000 (-0400) Subject: buffer: restored pre-infernalis API compatibility X-Git-Tag: v9.2.0~15^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cac1d6f936c40003c5231d1051feb51198252715;p=ceph.git buffer: restored pre-infernalis API compatibility Fixes: #13429 Signed-off-by: Jason Dillaman --- diff --git a/src/common/buffer.cc b/src/common/buffer.cc index a7ed8883f0e..bca14d19317 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -843,7 +843,12 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER; _len += l; return _len + _off; } - + + void buffer::ptr::copy_in(unsigned o, unsigned l, const char *src) + { + copy_in(o, l, src, true); + } + void buffer::ptr::copy_in(unsigned o, unsigned l, const char *src, bool crc_reset) { assert(_raw); @@ -855,6 +860,11 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER; maybe_inline_memcpy(dest, src, l, 64); } + void buffer::ptr::zero() + { + zero(true); + } + void buffer::ptr::zero(bool crc_reset) { if (crc_reset) @@ -862,6 +872,11 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER; memset(c_str(), 0, _len); } + void buffer::ptr::zero(unsigned o, unsigned l) + { + zero(o, l, true); + } + void buffer::ptr::zero(unsigned o, unsigned l, bool crc_reset) { assert(o+l <= _len); @@ -1063,6 +1078,68 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER; template class buffer::list::iterator_impl; template class buffer::list::iterator_impl; + void buffer::list::iterator::advance(int o) + { + buffer::list::iterator_impl::advance(o); + } + + void buffer::list::iterator::seek(unsigned o) + { + buffer::list::iterator_impl::seek(o); + } + + char buffer::list::iterator::operator*() + { + if (p == ls->end()) { + throw end_of_buffer(); + } + return (*p)[p_off]; + } + + buffer::list::iterator& buffer::list::iterator::operator++() + { + buffer::list::iterator_impl::operator++(); + return *this; + } + + buffer::ptr buffer::list::iterator::get_current_ptr() + { + if (p == ls->end()) { + throw end_of_buffer(); + } + return ptr(*p, p_off, p->length() - p_off); + } + + void buffer::list::iterator::copy(unsigned len, char *dest) + { + return buffer::list::iterator_impl::copy(len, dest); + } + + void buffer::list::iterator::copy(unsigned len, ptr &dest) + { + buffer::list::iterator_impl::copy(len, dest); + } + + void buffer::list::iterator::copy(unsigned len, list &dest) + { + buffer::list::iterator_impl::copy(len, dest); + } + + void buffer::list::iterator::copy(unsigned len, std::string &dest) + { + buffer::list::iterator_impl::copy(len, dest); + } + + void buffer::list::iterator::copy_all(list &dest) + { + buffer::list::iterator_impl::copy_all(dest); + } + + void buffer::list::iterator::copy_in(unsigned len, const char *src) + { + copy_in(len, src, true); + } + // copy data in void buffer::list::iterator::copy_in(unsigned len, const char *src, bool crc_reset) { @@ -1125,6 +1202,11 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER; other.last_p = other.begin(); } + bool buffer::list::contents_equal(buffer::list& other) + { + return static_cast(this)->contents_equal(other); + } + bool buffer::list::contents_equal(const ceph::buffer::list& other) const { if (length() != other.length()) @@ -1403,6 +1485,11 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER; return last_p.copy(len, dest); } + void buffer::list::copy_in(unsigned off, unsigned len, const char *src) + { + copy_in(off, len, src, true); + } + void buffer::list::copy_in(unsigned off, unsigned len, const char *src, bool crc_reset) { if (off + len > length()) diff --git a/src/include/buffer.h b/src/include/buffer.h index 854a2863581..f28bc5e86a7 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -238,9 +238,12 @@ public: unsigned append(char c); unsigned append(const char *p, unsigned l); - void copy_in(unsigned o, unsigned l, const char *src, bool crc_reset = true); - void zero(bool crc_reset = true); - void zero(unsigned o, unsigned l, bool crc_reset = true); + void copy_in(unsigned o, unsigned l, const char *src); + void copy_in(unsigned o, unsigned l, const char *src, bool crc_reset); + void zero(); + void zero(bool crc_reset); + void zero(unsigned o, unsigned l); + void zero(unsigned o, unsigned l, bool crc_reset); }; @@ -258,7 +261,7 @@ public: ptr append_buffer; // where i put small appends. template - class iterator_impl: public std::iterator { + class iterator_impl: public std::iterator { protected: typedef typename std::conditional