From: g0dil Date: Fri, 25 Jan 2008 16:13:26 +0000 (+0000) Subject: Added SENF_NO_DEBUG symbol and removed dependency on NDEBUG X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=51044eb18f034c1a059ffe2fb109a422c1cbe251;p=senf.git Added SENF_NO_DEBUG symbol and removed dependency on NDEBUG Implemented SENF_ASSERT and replaced all occurences of BOOST_ASSERT with SENF_ASSERT Packets: Fixed compile-error (missing namespace prefix) in PacketParser.cci git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@639 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Examples/DVBAdapter/ULEdec.cc b/Examples/DVBAdapter/ULEdec.cc index 95a83a6..327943a 100644 --- a/Examples/DVBAdapter/ULEdec.cc +++ b/Examples/DVBAdapter/ULEdec.cc @@ -24,6 +24,7 @@ #include "ULEdec.hh" +#include #include #include #include @@ -115,7 +116,7 @@ void ULEdec::handleTSPacket(senf::TransportPacket ts_packet) if ( (*payload_iter++ << 8 | *payload_iter++) != ULE_END_INDICATOR ) std::cerr << "delimiting error\n"; } else { - BOOST_ASSERT( std::distance( payload_iter, payload_end ) == 0 ); + assert( std::distance( payload_iter, payload_end ) == 0 ); } } break; @@ -143,7 +144,7 @@ void ULEdec::handleTSPacket(senf::TransportPacket ts_packet) std::advance(payload_iter, payload_pointer); } else { payload_iter = readContSNDUPacket( payload_iter, payload_end ); - BOOST_ASSERT( isSDNUPacketComplete() ); + assert( isSDNUPacketComplete() ); try { handleSNDUPacket(); } catch (ULEdecException const & ex) { @@ -158,7 +159,7 @@ void ULEdec::handleTSPacket(senf::TransportPacket ts_packet) do { payload_iter = readNewSNDUPacket( payload_iter, payload_end ); if (! isSDNUPacketComplete()) { - BOOST_ASSERT( std::distance( payload_iter, payload_end ) == 0 ); + assert( std::distance( payload_iter, payload_end ) == 0 ); this->receiver_state = Reassembly; break; } diff --git a/PPI/Connectors.cci b/PPI/Connectors.cci index 74270ec..1680902 100644 --- a/PPI/Connectors.cci +++ b/PPI/Connectors.cci @@ -24,6 +24,7 @@ \brief Connectors inline non-template implementation */ // Custom includes +#include "../Utils/senfassert.hh" #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// @@ -34,14 +35,14 @@ prefix_ senf::ppi::connector::Connector & senf::ppi::connector::Connector::peer() const { - BOOST_ASSERT(peer_); + SENF_ASSERT(peer_); return *peer_; } prefix_ senf::ppi::module::Module & senf::ppi::connector::Connector::module() const { - BOOST_ASSERT(module_); + SENF_ASSERT(module_); return *module_; } @@ -60,7 +61,7 @@ prefix_ senf::ppi::connector::Connector::~Connector() prefix_ void senf::ppi::connector::Connector::connect(Connector & target) { - BOOST_ASSERT( ! peer_ && ! target.peer_ ); + SENF_ASSERT( ! peer_ && ! target.peer_ ); peer_ = & target; target.peer_ = this; } @@ -121,7 +122,7 @@ prefix_ senf::ppi::connector::PassiveConnector::PassiveConnector() prefix_ void senf::ppi::connector::PassiveConnector::emit() { - BOOST_ASSERT(callback_); + SENF_ASSERT(callback_); if (!throttled()) callback_(); } @@ -221,7 +222,7 @@ senf::ppi::connector::InputConnector::end() prefix_ senf::Packet senf::ppi::connector::InputConnector::peek() const { - BOOST_ASSERT( ! queue_.empty() ); + SENF_ASSERT( ! queue_.empty() ); return queue_.back(); } diff --git a/PPI/DebugModules.cci b/PPI/DebugModules.cci index 07a9c86..22fabd5 100644 --- a/PPI/DebugModules.cci +++ b/PPI/DebugModules.cci @@ -24,6 +24,7 @@ \brief DebugModules inline non-template implementation */ // Custom includes +#include "../Utils/senfassert.hh" #include "Setup.hh" #define prefix_ inline @@ -89,7 +90,7 @@ senf::ppi::module::debug::PassiveSource::size() prefix_ void senf::ppi::module::debug::PassiveSource::request() { - BOOST_ASSERT( ! packets_.empty() ); + SENF_ASSERT( ! packets_.empty() ); output(packets_.front()); packets_.pop_front(); if (packets_.empty()) diff --git a/PPI/Events.cci b/PPI/Events.cci index 17f5628..505ae4d 100644 --- a/PPI/Events.cci +++ b/PPI/Events.cci @@ -24,7 +24,7 @@ \brief Events inline non-template implementation */ // Custom includes -#include +#include <../Utils/senfassert.hh> #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// @@ -42,7 +42,7 @@ prefix_ bool senf::ppi::EventDescriptor::enabled() prefix_ void senf::ppi::EventDescriptor::enabled(bool v) { - BOOST_ASSERT(v_isRegistered()); + SENF_ASSERT(v_isRegistered()); if (v && ! enabled_) v_enable(); else if (! v && enabled_) diff --git a/PPI/Events.cti b/PPI/Events.cti index 66cb5fa..bc04723 100644 --- a/PPI/Events.cti +++ b/PPI/Events.cti @@ -26,6 +26,7 @@ #include "Events.ih" // Custom includes +#include "../Utils/senfassert.hh" #include "detail/EventBinding.hh" #define prefix_ inline @@ -58,7 +59,7 @@ template prefix_ senf::ppi::detail::EventBinding & senf::ppi::EventImplementationHelper::binding() { - BOOST_ASSERT( static_cast(this)->binding_ ); + SENF_ASSERT( static_cast(this)->binding_ ); return * static_cast(this)->binding_; } @@ -88,7 +89,7 @@ template prefix_ senf::ppi::detail::EventBinding & senf::ppi::EventImplementationHelper::binding() { - BOOST_ASSERT( static_cast(this)->binding_ ); + SENF_ASSERT( static_cast(this)->binding_ ); return * static_cast(this)->binding_; } diff --git a/PPI/IOEvent.cc b/PPI/IOEvent.cc index abb1974..a20e8eb 100644 --- a/PPI/IOEvent.cc +++ b/PPI/IOEvent.cc @@ -27,6 +27,7 @@ //#include "IOEvent.ih" // Custom includes +#include "../Utils/senfassert.hh" #include //#include "IOEvent.mpp" @@ -59,7 +60,7 @@ prefix_ void senf::ppi::IOEvent::cb(Scheduler::EventId event) throw HangupException(); else // This cannot happen. - BOOST_ASSERT(false); + SENF_ASSERT(false); } else { IOEventInfo info = { event }; callback(info); diff --git a/Packets/ArrayParser.cti b/Packets/ArrayParser.cti index a31d8ac..f60e05c 100644 --- a/Packets/ArrayParser.cti +++ b/Packets/ArrayParser.cti @@ -26,6 +26,7 @@ #include "ArrayParser.ih" // Custom includes +#include "../Utils/senfassert.hh" #define prefix_ inline ///////////////////////////////cti.p/////////////////////////////////////// @@ -68,7 +69,7 @@ prefix_ typename senf::ArrayParser::value_type senf::ArrayParser::operator[](difference_type i) const { - BOOST_ASSERT( i>=0 && i < difference_type(elements) ); + SENF_ASSERT( i>=0 && i < difference_type(elements) ); return begin()[i]; } diff --git a/Packets/DefaultBundle/LlcSnapPacket.cc b/Packets/DefaultBundle/LlcSnapPacket.cc index d6ced6a..93c1481 100644 --- a/Packets/DefaultBundle/LlcSnapPacket.cc +++ b/Packets/DefaultBundle/LlcSnapPacket.cc @@ -67,7 +67,7 @@ prefix_ void senf::LlcSnapPacketType::finalize(packet p) else if (p.next().is()) p->type_length() << p.next().data().size(); else - ///\fixme Is this correct ?? + ///\fixme Is this correct ?? we at least need an 'if (! p.next().is() )' p->type_length() << 0; } diff --git a/Packets/ListNParser.ct b/Packets/ListNParser.ct index 6d97545..4417e3b 100644 --- a/Packets/ListNParser.ct +++ b/Packets/ListNParser.ct @@ -26,6 +26,7 @@ #include "ListNParser.ih" // Custom includes +#include "../Utils/senfassert.hh" #define prefix_ ///////////////////////////////ct.p//////////////////////////////////////// @@ -45,7 +46,7 @@ setFromPosition(iterator i, state_type s, iterator p) for (; n_; --n_, j += ElementParser(j,s).bytes()) if (j==p) return; - BOOST_ASSERT( false ); + SENF_ASSERT( false ); } template diff --git a/Packets/ListParser.ct b/Packets/ListParser.ct index 7e8f3f1..609048e 100644 --- a/Packets/ListParser.ct +++ b/Packets/ListParser.ct @@ -26,6 +26,7 @@ #include "ListParser.ih" // Custom includes +#include "../Utils/senfassert.hh" #define prefix_ ///////////////////////////////ct.p//////////////////////////////////////// @@ -49,7 +50,7 @@ prefix_ typename senf::ListParser::value_type senf::ListParser::back() const { - BOOST_ASSERT( ! empty() ); + SENF_ASSERT( ! empty() ); iterator i (begin()), j; iterator const e (end()); for (j=i; i!=e; j=i, ++i) ; @@ -64,7 +65,7 @@ prefix_ typename senf::ListParser_Container::value_type senf::ListParser_Container::back() const { - BOOST_ASSERT( ! empty() ); + SENF_ASSERT( ! empty() ); iterator i (begin()), j; iterator const e (end()); for (j=i; i!=e; j=i, ++i) ; diff --git a/Packets/ListParser.cti b/Packets/ListParser.cti index a00915f..af89e13 100644 --- a/Packets/ListParser.cti +++ b/Packets/ListParser.cti @@ -26,6 +26,7 @@ #include "ListParser.ih" // Custom includes +#include "../Utils/senfassert.hh" #define prefix_ inline ///////////////////////////////cti.p/////////////////////////////////////// @@ -91,7 +92,7 @@ prefix_ typename senf::ListParser::value_type senf::ListParser::front() const { - BOOST_ASSERT( ! empty() ); + SENF_ASSERT( ! empty() ); return *begin(); } @@ -263,7 +264,7 @@ prefix_ typename senf::ListParser_Container::value_type senf::ListParser_Container::front() const { - BOOST_ASSERT( ! empty() ); + SENF_ASSERT( ! empty() ); return *begin(); } diff --git a/Packets/Packet.cci b/Packets/Packet.cci index ea4f549..b026e16 100644 --- a/Packets/Packet.cci +++ b/Packets/Packet.cci @@ -24,6 +24,7 @@ \brief Packet inline non-template implementation */ // Custom includes +#include "../Utils/senfassert.hh" #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// @@ -162,7 +163,7 @@ prefix_ senf::Packet::Packet(PacketInterpreterBase::ptr packet) prefix_ senf::PacketInterpreterBase::ptr senf::Packet::ptr() const { - BOOST_ASSERT(packet_); + SENF_ASSERT(packet_); return packet_; } diff --git a/Packets/PacketData.cci b/Packets/PacketData.cci index 7de154c..98d1bbe 100644 --- a/Packets/PacketData.cci +++ b/Packets/PacketData.cci @@ -24,6 +24,7 @@ \brief PacketData inline non-template implementation */ // Custom includes +#include "../Utils/senfassert.hh" #include #include "PacketImpl.hh" #include "PacketParser.hh" @@ -37,14 +38,14 @@ prefix_ senf::PacketData::iterator senf::PacketData::begin() const { - BOOST_ASSERT(begin_ <= impl().size()); + SENF_ASSERT(begin_ <= impl().size()); return boost::next(impl().begin(),begin_); } prefix_ senf::PacketData::iterator senf::PacketData::end() const { - BOOST_ASSERT(end_ <= impl().size()); + SENF_ASSERT(end_ <= impl().size()); return boost::next(impl().begin(),end_); } @@ -63,13 +64,13 @@ prefix_ bool senf::PacketData::empty() prefix_ senf::PacketData::byte senf::PacketData::operator[](size_type n) const { - BOOST_ASSERT( n < size() ); + SENF_ASSERT( n < size() ); return *( boost::next(begin(),n) ); } prefix_ senf::PacketData::byte & senf::PacketData::operator[](size_type n) { - BOOST_ASSERT( n < size() ); + SENF_ASSERT( n < size() ); return *( boost::next(begin(),n) ); } @@ -114,7 +115,7 @@ prefix_ senf::PacketData::PacketData(size_type b, size_type e) prefix_ senf::detail::PacketImpl & senf::PacketData::impl() const { - BOOST_ASSERT( impl_ ); + SENF_ASSERT( impl_ ); return *impl_; } @@ -139,7 +140,7 @@ prefix_ senf::safe_data_iterator::safe_data_iterator(PacketParserBase const & p prefix_ senf::safe_data_iterator & senf::safe_data_iterator::operator=(PacketData::iterator i) { - BOOST_ASSERT(data_); + SENF_ASSERT(data_); i_ = std::distance(data_->begin(),i); return *this; } @@ -167,7 +168,7 @@ prefix_ bool senf::safe_data_iterator::boolean_test() prefix_ senf::PacketData & senf::safe_data_iterator::data() const { - BOOST_ASSERT(data_); + SENF_ASSERT(data_); return *data_; } @@ -180,7 +181,7 @@ prefix_ senf::safe_data_iterator::value_type & senf::safe_data_iterator::derefer prefix_ bool senf::safe_data_iterator::equal(safe_data_iterator const & other) const { - BOOST_ASSERT(data_ == other.data_); + SENF_ASSERT(data_ == other.data_); return i_ == other.i_; } @@ -188,7 +189,7 @@ prefix_ senf::safe_data_iterator::difference_type senf::safe_data_iterator::distance_to(safe_data_iterator const & other) const { - BOOST_ASSERT(data_ == other.data_); + SENF_ASSERT(data_ == other.data_); return other.i_ - i_; } @@ -199,20 +200,20 @@ prefix_ void senf::safe_data_iterator::increment() prefix_ void senf::safe_data_iterator::decrement() { - BOOST_ASSERT(i_>0); + SENF_ASSERT(i_>0); --i_; } prefix_ void senf::safe_data_iterator::advance(difference_type n) { - BOOST_ASSERT( -n < difference_type(i_) ); + SENF_ASSERT( -n < difference_type(i_) ); i_ += n; } prefix_ senf::PacketData::iterator senf::safe_data_iterator::i() const { - BOOST_ASSERT(data_); + SENF_ASSERT(data_); return boost::next(data_->begin(),i_); } diff --git a/Packets/PacketImpl.cci b/Packets/PacketImpl.cci index bba136b..c4acd4d 100644 --- a/Packets/PacketImpl.cci +++ b/Packets/PacketImpl.cci @@ -24,6 +24,7 @@ \brief PacketImpl inline non-template implementation */ // Custom includes +#include "../Utils/senfassert.hh" #include "PacketInterpreter.hh" #define prefix_ inline @@ -79,7 +80,7 @@ prefix_ void senf::detail::PacketImpl::add_ref(refcount_t n) prefix_ void senf::detail::PacketImpl::release(refcount_t n) { - BOOST_ASSERT(refcount_ >= n); + SENF_ASSERT(refcount_ >= n); // uah ... we need to be extremely careful here. If refcount_ is n, we want to commit suicide, // however the destructor will remove all PacketInterpreters from the list and will thereby // decrement refcount -> only decrenebt refcount_ when *not* caling delete diff --git a/Packets/PacketImpl.test.cc b/Packets/PacketImpl.test.cc index 448c6ba..4b20e02 100644 --- a/Packets/PacketImpl.test.cc +++ b/Packets/PacketImpl.test.cc @@ -50,7 +50,7 @@ BOOST_AUTO_UNIT_TEST(packetImpl_mem) BOOST_CHECK_EQUAL(p->refcount(), 0); p->add_ref(); BOOST_CHECK_EQUAL(p->refcount(), 1); -#ifndef NDEBUG +#ifndef SENF_NO_DEBUG BOOST_CHECK_EQUAL( senf::pool_alloc_mixin::allocCounter(), 1u); #endif @@ -69,7 +69,7 @@ BOOST_AUTO_UNIT_TEST(packetImpl_mem) p,p->begin(),p->end(), senf::PacketInterpreterBase::Append)); // Hmm ... this check works as long as sizeof(PacketInterpreterBase> != // sizeof(PacketImpl) ... !! -#ifndef NDEBUG +#ifndef SENF_NO_DEBUG BOOST_CHECK_EQUAL( senf::pool_alloc_mixin< senf::PacketInterpreter >::allocCounter(), 1u); #endif @@ -84,7 +84,7 @@ BOOST_AUTO_UNIT_TEST(packetImpl_mem) p->truncateInterpreters(pi.get()); BOOST_CHECK_EQUAL(p->refcount(),1); } -#ifndef NDEBUG +#ifndef SENF_NO_DEBUG BOOST_CHECK_EQUAL( senf::pool_alloc_mixin::allocCounter(), 0u); #endif @@ -95,7 +95,7 @@ BOOST_AUTO_UNIT_TEST(packetImpl_mem) // Therefore we can safely delete the object. BOOST_CHECK_EQUAL(p->refcount(), 1); p->release(); -#ifndef NDEBUG +#ifndef SENF_NO_DEBUG BOOST_CHECK_EQUAL( senf::pool_alloc_mixin::allocCounter(), 0u); #endif @@ -201,7 +201,7 @@ BOOST_AUTO_UNIT_TEST(packetImpl_interpreters) BOOST_CHECK_EQUAL(p->refcount(), 1); p->release(); -#ifndef NDEBUG +#ifndef SENF_NO_DEBUG BOOST_CHECK_EQUAL( senf::pool_alloc_mixin::allocCounter(), 0u); #endif diff --git a/Packets/PacketInterpreter.cci b/Packets/PacketInterpreter.cci index 52c924d..3c5cee6 100644 --- a/Packets/PacketInterpreter.cci +++ b/Packets/PacketInterpreter.cci @@ -24,6 +24,7 @@ \brief PacketInterpreter inline non-template implementation */ // Custom includes +#include "../Utils/senfassert.hh" #include #define prefix_ inline @@ -155,14 +156,14 @@ prefix_ bool senf::PacketInterpreterBase::release() prefix_ void senf::PacketInterpreterBase::assignImpl(detail::PacketImpl * impl) { - BOOST_ASSERT(!impl_); + SENF_ASSERT(!impl_); impl_ = impl; impl_->add_ref(refcount()); } prefix_ void senf::PacketInterpreterBase::releaseImpl() { - BOOST_ASSERT(impl_); + SENF_ASSERT(impl_); refcount_t refc (refcount()); if (refc) { impl_->release(refc); diff --git a/Packets/PacketParser.cci b/Packets/PacketParser.cci index 8449145..c53e29a 100644 --- a/Packets/PacketParser.cci +++ b/Packets/PacketParser.cci @@ -39,7 +39,7 @@ prefix_ senf::PacketParserBase::data_iterator senf::PacketParserBase::i() return i_; } -prefix_ data_iterator senf::PacketParserBase::i(size_type offset) +prefix_ senf::PacketParserBase::data_iterator senf::PacketParserBase::i(size_type offset) const { validate(offset); diff --git a/Packets/PacketParser.cti b/Packets/PacketParser.cti index 52f13b9..3ab62e5 100644 --- a/Packets/PacketParser.cti +++ b/Packets/PacketParser.cti @@ -26,6 +26,7 @@ #include "PacketParser.ih" // Custom includes +#include "../Utils/senfassert.hh" #include "PacketData.hh" #define prefix_ inline @@ -129,7 +130,7 @@ template prefix_ Parser senf::SafePacketParserWrapper::operator*() const { - BOOST_ASSERT( i_ ); + SENF_ASSERT( i_ ); parser_->i_ = PacketParserBase::data_iterator(i_); return *parser_; } @@ -138,7 +139,7 @@ template prefix_ Parser const * senf::SafePacketParserWrapper::operator->() const { - BOOST_ASSERT( i_ ); + SENF_ASSERT( i_ ); parser_->i_ = PacketParserBase::data_iterator(i_); return & (*parser_); } diff --git a/Packets/PacketRegistry.ct b/Packets/PacketRegistry.ct index 4d68a92..ab97835 100644 --- a/Packets/PacketRegistry.ct +++ b/Packets/PacketRegistry.ct @@ -26,6 +26,7 @@ #include "PacketRegistry.ih" // Custom includes +#include "../Utils/senfassert.hh" #include #define prefix_ @@ -42,7 +43,7 @@ template template prefix_ void senf::detail::PacketRegistryImpl::registerPacket(key_t key) { -#ifdef NDEBUG +#ifdef SENF_NO_DEBUG registry_.insert(std::make_pair(key, Entry_ptr(new detail::PkReg_EntryImpl()))); reverseRegistry_.insert(std::make_pair(senf::typeIdValue(), key)); #else @@ -50,12 +51,12 @@ prefix_ void senf::detail::PacketRegistryImpl::registerPacket(key_t key registry_.insert( std::make_pair(key, Entry_ptr(new detail::PkReg_EntryImpl()))).second); // If this assertion fails, a Packet was registered with an already known key - BOOST_ASSERT( isUnique ); + SENF_ASSERT( isUnique ); bool isNew ( reverseRegistry_.insert( std::make_pair(senf::typeIdValue(), key)).second); // If this assertion fails, the same Packet was registered with two different keys - BOOST_ASSERT( isNew ); + SENF_ASSERT( isNew ); #endif } diff --git a/Packets/VariantParser.cti b/Packets/VariantParser.cti index d95e971..af9a651 100644 --- a/Packets/VariantParser.cti +++ b/Packets/VariantParser.cti @@ -26,6 +26,7 @@ #include "VariantParser.ih" // Custom includes +#include "../Utils/senfassert.hh" #include #define prefix_ inline @@ -78,7 +79,7 @@ prefix_ typename boost::mpl::at< senf::VariantParser::get() const { - BOOST_ASSERT( variant() == N ); + SENF_ASSERT( variant() == N ); return typename boost::mpl::at >::type( VariantPolicy::begin(i(), state()), state() ); } diff --git a/SConstruct b/SConstruct index cc4dc67..66cfbb4 100644 --- a/SConstruct +++ b/SConstruct @@ -39,11 +39,11 @@ def nonemptyFile(f): except OSError: return False def checkLocalConf(target, source, env): - if [ True for f in env['CONFIG_FILES'] if nonemptyFile(f) ]: + if [ True for f in env['LOCAL_CONFIG_FILES'] if nonemptyFile(f) ]: print print "You have made local modifications to one of the following local configuration" print "files:" - for f in env['CONFIG_FILES']: + for f in env['LOCAL_CONFIG_FILES']: print " ",f print print "Building a debian package would remove those files." @@ -125,7 +125,7 @@ if not logname: logname = pwd.getpwuid(os.getuid()).pw_name def configFilesOpts(target, source, env, for_signature): - return [ '-I%s' % os.path.split(f)[1] for f in env['CONFIG_FILES'] ] + return [ '-I%s' % os.path.split(f)[1] for f in env['LOCAL_CONFIG_FILES'] ] env.Append( CPPPATH = [ '#/include' ], @@ -138,7 +138,7 @@ env.Append( 'CONCURRENCY_LEVEL' : env.GetOption('num_jobs') or "1", 'SCONS' : 1, }, - CONFIG_FILES = [ 'Doxyfile.local', 'SConfig', 'local_config.hh' ], + LOCAL_CONFIG_FILES = [ 'Doxyfile.local', 'SConfig', 'local_config.hh' ], CONFIG_FILES_OPTS = configFilesOpts, CLEAN_PATTERNS = [ '*.pyc', 'semantic.cache', '.sconsign', '.sconsign.dblite' ], BUILDPACKAGE_COMMAND = "dpkg-buildpackage -us -uc -rfakeroot -I.svn $CONFIG_FILES_OPTS", diff --git a/Scheduler/Scheduler.cc b/Scheduler/Scheduler.cc index 96aa9a2..9ed26e2 100644 --- a/Scheduler/Scheduler.cc +++ b/Scheduler/Scheduler.cc @@ -42,6 +42,7 @@ //#include "Scheduler.ih" // Custom includes +#include "../Utils/senfassert.hh" #include #include #include @@ -301,15 +302,15 @@ prefix_ void senf::Scheduler::process() if (mask & EPOLLERR) extraFlags |= EV_ERR; if (mask & EPOLLIN) { - BOOST_ASSERT(spec.cb_read); + SENF_ASSERT(spec.cb_read); spec.cb_read(EventId(EV_READ | extraFlags)); } else if (mask & EPOLLPRI) { - BOOST_ASSERT(spec.cb_prio); + SENF_ASSERT(spec.cb_prio); spec.cb_prio(EventId(EV_PRIO | extraFlags)); } else if (mask & EPOLLOUT) { - BOOST_ASSERT(spec.cb_write); + SENF_ASSERT(spec.cb_write); spec.cb_write(EventId(EV_WRITE | extraFlags)); } else { diff --git a/Socket/FileHandle.cci b/Socket/FileHandle.cci index bcb6d50..4ace14c 100644 --- a/Socket/FileHandle.cci +++ b/Socket/FileHandle.cci @@ -27,6 +27,7 @@ //#include "FileHandle.ih" // Custom includes +#include "../Utils/senfassert.hh" #include #include "../Utils/Exception.hh" @@ -205,14 +206,14 @@ prefix_ senf::FileHandle::FileHandle(FileBody::ptr body) prefix_ senf::FileBody & senf::FileHandle::body() { - BOOST_ASSERT(body_); + SENF_ASSERT(body_); return *body_; } prefix_ senf::FileBody const & senf::FileHandle::body() const { - BOOST_ASSERT(body_); + SENF_ASSERT(body_); return *body_; } diff --git a/Socket/ProtocolClientSocketHandle.cti b/Socket/ProtocolClientSocketHandle.cti index 25a0ee4..9fe7718 100644 --- a/Socket/ProtocolClientSocketHandle.cti +++ b/Socket/ProtocolClientSocketHandle.cti @@ -30,6 +30,7 @@ //#include "ProtocolClientSocketHandle.ih" // Custom includes +#include "../Utils/senfassert.hh" #define prefix_ inline ///////////////////////////////cti.p/////////////////////////////////////// @@ -60,7 +61,7 @@ template prefix_ SocketProtocol const & senf::ProtocolClientSocketHandle::protocol() { - BOOST_ASSERT( dynamic_cast(&this->body().protocol()) ); + SENF_ASSERT( dynamic_cast(&this->body().protocol()) ); // Need dynamic_cast here, since senf::SocketProtocol is a // virtual base return dynamic_cast(this->body().protocol()); diff --git a/Socket/ProtocolServerSocketHandle.cti b/Socket/ProtocolServerSocketHandle.cti index 054ae50..c615b32 100644 --- a/Socket/ProtocolServerSocketHandle.cti +++ b/Socket/ProtocolServerSocketHandle.cti @@ -29,6 +29,7 @@ //#include "ProtocolServerSocketHandle.ih" // Custom includes +#include "../Utils/senfassert.hh" #include "ProtocolClientSocketHandle.hh" #define prefix_ inline @@ -52,7 +53,7 @@ template prefix_ SocketProtocol const & senf::ProtocolServerSocketHandle::protocol() { - BOOST_ASSERT( dynamic_cast(&this->body().protocol()) ); + SENF_ASSERT( dynamic_cast(&this->body().protocol()) ); // Need dynamic_cast here, since senf::SocketProtocol is a // virtual base return dynamic_cast(this->body().protocol()); diff --git a/Socket/Protocols/INet/INetAddressing.cc b/Socket/Protocols/INet/INetAddressing.cc index 4f6eb7a..d4f1149 100644 --- a/Socket/Protocols/INet/INetAddressing.cc +++ b/Socket/Protocols/INet/INetAddressing.cc @@ -34,6 +34,7 @@ #include #include #include +#include "../../../Utils/senfassert.hh" //#include "INetAddressing.mpp" #define prefix_ @@ -138,8 +139,8 @@ prefix_ std::string senf::INet6SocketAddress::iface() if (sockaddr_.sin6_scope_id == 0) return ""; char buffer[IFNAMSIZ]; -#ifndef NDEBUG - BOOST_ASSERT( if_indextoname(sockaddr_.sin6_scope_id,buffer) ); +#ifndef SENF_NO_DEBUG + SENF_ASSERT( if_indextoname(sockaddr_.sin6_scope_id,buffer) ); #else if_indextoname(sockaddr_.sin6_scope_id,buffer); #endif diff --git a/Socket/SocketHandle.cci b/Socket/SocketHandle.cci index 833b8b6..c25d09f 100644 --- a/Socket/SocketHandle.cci +++ b/Socket/SocketHandle.cci @@ -27,6 +27,7 @@ #include "SocketHandle.ih" // Custom includes +#include "../Utils/senfassert.hh" #include "../Utils/Exception.hh" #include "SocketProtocol.hh" @@ -37,7 +38,7 @@ prefix_ senf::SocketBody::SocketBody(std::auto_ptr protocol, bool isServer) : protocol_(protocol), isServer_(isServer) { - BOOST_ASSERT( ! protocol_->body_ ); + SENF_ASSERT( ! protocol_->body_ ); protocol_->body_ = this; } @@ -45,7 +46,7 @@ prefix_ senf::SocketBody::SocketBody(std::auto_ptr protocol, bool isServer, int fd) : FileBody(fd), protocol_(protocol), isServer_(isServer) { - BOOST_ASSERT( ! protocol_->body_ ); + SENF_ASSERT( ! protocol_->body_ ); protocol_->body_ = this; } diff --git a/Socket/SocketHandle.cti b/Socket/SocketHandle.cti index 018620b..852cc3f 100644 --- a/Socket/SocketHandle.cti +++ b/Socket/SocketHandle.cti @@ -27,6 +27,7 @@ #include "SocketHandle.ih" // Custom includes +#include "../Utils/senfassert.hh" #include #include #include "../Utils/TypeInfo.hh" @@ -65,14 +66,14 @@ template prefix_ senf::SocketHandle::SocketHandle(FileHandle other, bool isChecked) : FileHandle(other) { - BOOST_ASSERT( isChecked ); - BOOST_ASSERT( dynamic_cast(&FileHandle::body()) ); + SENF_ASSERT( isChecked ); + SENF_ASSERT( dynamic_cast(&FileHandle::body()) ); } template prefix_ senf::SocketBody & senf::SocketHandle::body() { - BOOST_ASSERT( dynamic_cast(&FileHandle::body()) ); + SENF_ASSERT( dynamic_cast(&FileHandle::body()) ); return static_cast(FileHandle::body()); } @@ -80,7 +81,7 @@ template prefix_ senf::SocketBody const & senf::SocketHandle::body() const { - BOOST_ASSERT( dynamic_cast(&FileHandle::body()) ); + SENF_ASSERT( dynamic_cast(&FileHandle::body()) ); return static_cast(FileHandle::body()); } @@ -123,7 +124,7 @@ prefix_ Target senf::static_socket_cast(Source handle) boost::is_convertible::value && ( boost::is_convertible::value || boost::is_convertible::value ) )); - BOOST_ASSERT( check_socket_cast(handle) ); + SENF_ASSERT( check_socket_cast(handle) ); return Target::cast_static(handle); } diff --git a/Socket/SocketProtocol.cci b/Socket/SocketProtocol.cci index 7c5f2ea..5f8bbb6 100644 --- a/Socket/SocketProtocol.cci +++ b/Socket/SocketProtocol.cci @@ -27,7 +27,7 @@ //#include "SocketProtocol.ih" // Custom includes -#include +#include <../Utils/senfassert.hh> #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// @@ -50,7 +50,7 @@ prefix_ int senf::SocketProtocol::fd() prefix_ void senf::SocketProtocol::fd(int fd) const { - BOOST_ASSERT(! body().valid()); + SENF_ASSERT(! body().valid()); body().fd(fd); } @@ -64,7 +64,7 @@ prefix_ senf::SocketProtocol::~SocketProtocol() prefix_ senf::SocketBody & senf::SocketProtocol::body() const { - BOOST_ASSERT( body_ ); + SENF_ASSERT( body_ ); return *body_; } diff --git a/Utils/Daemon/Daemon.cc b/Utils/Daemon/Daemon.cc index 2cba370..88b79a1 100644 --- a/Utils/Daemon/Daemon.cc +++ b/Utils/Daemon/Daemon.cc @@ -186,7 +186,7 @@ prefix_ int senf::Daemon::start(int argc, char const ** argv) return e.code; } -#ifdef NDEBUG +#ifdef SENF_NO_DEBUG catch (std::exception & e) { std::cerr << "\n*** Fatal exception: " << e.what() << std::endl; diff --git a/Utils/intrusive_refcount.cci b/Utils/intrusive_refcount.cci index 89274a8..c128363 100644 --- a/Utils/intrusive_refcount.cci +++ b/Utils/intrusive_refcount.cci @@ -26,7 +26,7 @@ //#include "intrusive_refcount.ih" // Custom includes -#include +#include "senfassert.hh" #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// @@ -55,7 +55,7 @@ prefix_ void senf::intrusive_refcount_base::add_ref() prefix_ bool senf::intrusive_refcount_base::release() { - BOOST_ASSERT(refcount_>0); + SENF_ASSERT(refcount_>0); return --refcount_ == 0; } diff --git a/Utils/pool_alloc_mixin.cti b/Utils/pool_alloc_mixin.cti index ce477d4..2e78ad2 100644 --- a/Utils/pool_alloc_mixin.cti +++ b/Utils/pool_alloc_mixin.cti @@ -26,7 +26,7 @@ //#include "pool_alloc_mixin.ih" // Custom includes -#include +#include <../Utils/senfassert.hh> #define prefix_ inline ///////////////////////////////cti.p/////////////////////////////////////// @@ -36,8 +36,8 @@ prefix_ void * senf::pool_alloc_mixin::operator new(size_t size) { // When deriving from Self you may not change the class's size without // inheriting from pool_alloc_mixin again. See pool_alloc_mixin documentation. - BOOST_ASSERT( size <= sizeof(Self) ); -#ifndef NDEBUG + SENF_ASSERT( size <= sizeof(Self) ); +#ifndef SENF_NO_DEBUG allocCounter(1); #endif return boost::singleton_pool< pool_alloc_mixin_tag, sizeof(Self) >::malloc(); @@ -46,13 +46,13 @@ prefix_ void * senf::pool_alloc_mixin::operator new(size_t size) template prefix_ void senf::pool_alloc_mixin::operator delete(void * p, size_t size) { -#ifndef NDEBUG +#ifndef SENF_NO_DEBUG allocCounter(-1); #endif boost::singleton_pool< pool_alloc_mixin_tag, sizeof(Self) >::free(p); } -#ifndef NDEBUG +#ifndef SENF_NO_DEBUG template prefix_ unsigned long senf::pool_alloc_mixin::allocCounter() diff --git a/Utils/pool_alloc_mixin.hh b/Utils/pool_alloc_mixin.hh index c49301d..3af419a 100644 --- a/Utils/pool_alloc_mixin.hh +++ b/Utils/pool_alloc_mixin.hh @@ -84,7 +84,7 @@ namespace senf { static void operator delete (void *p, size_t size); ///< Operator delete utilizing pool allocation -#ifndef NDEBUG +#ifndef SENF_NO_DEBUG static unsigned long allocCounter(); private: static unsigned long allocCounter(long delta); diff --git a/Utils/pool_alloc_mixin.test.cc b/Utils/pool_alloc_mixin.test.cc index 478e80b..90e6f7d 100644 --- a/Utils/pool_alloc_mixin.test.cc +++ b/Utils/pool_alloc_mixin.test.cc @@ -43,7 +43,7 @@ namespace { BOOST_AUTO_UNIT_TEST(poolAllocMixin) { -#ifndef NDEBUG +#ifndef SENF_NO_DEBUG BOOST_CHECK_EQUAL( Test::allocCounter(), 0u ); { diff --git a/Utils/senfassert.hh b/Utils/senfassert.hh new file mode 100644 index 0000000..771081a --- /dev/null +++ b/Utils/senfassert.hh @@ -0,0 +1,61 @@ +// $Id$ +// +// Copyright (C) 2008 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** \file + \brief senfassert public header */ + +#ifndef HH_senfassert_ +#define HH_senfassert_ 1 + +// Custom includes +#include "../Utils/senfassert.hh" + +//#include "senfassert.mpp" +///////////////////////////////hh.p//////////////////////////////////////// + +#ifdef SENF_NO_DEBUG + +# define SENF_ASSERT(x) + +#else + +# include +# define SENF_ASSERT(x) assert(x) + +#endif + +///////////////////////////////hh.e//////////////////////////////////////// +//#include "senfassert.cci" +//#include "senfassert.ct" +//#include "senfassert.cti" +#endif + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// comment-column: 40 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// End: diff --git a/config.hh b/config.hh index a69218e..5b77078 100644 --- a/config.hh +++ b/config.hh @@ -1,42 +1,41 @@ -// $Id$ -// -// Copyright (C) 2007 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY -// Stefan Bund -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -/** \file - \brief config public header */ - -#ifndef HH_config_ -#define HH_config_ 1 - -// Custom includes - -//#include "config.mpp" -///////////////////////////////hh.p//////////////////////////////////////// - +# // $Id$ +# // +# // Copyright (C) 2007 +# // Fraunhofer Institute for Open Communication Systems (FOKUS) +# // Competence Center NETwork research (NET), St. Augustin, GERMANY +# // Stefan Bund +# // +# // This program is free software; you can redistribute it and/or modify +# // it under the terms of the GNU General Public License as published by +# // the Free Software Foundation; either version 2 of the License, or +# // (at your option) any later version. +# // +# // This program is distributed in the hope that it will be useful, +# // but WITHOUT ANY WARRANTY; without even the implied warranty of +# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# // GNU General Public License for more details. +# // +# // You should have received a copy of the GNU General Public License +# // along with this program; if not, write to the +# // Free Software Foundation, Inc., +# // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# /** \file +# \brief config public header */ +# +# ifndef HH_config_ +# define HH_config_ 1 +# +# // Custom includes +# +# ///////////////////////////////hh.p//////////////////////////////////////// +# # include "local_config.hh" - +# # ifndef SENF_ABSOLUTE_INCLUDE_PATH # define SENF_ABSOLUTE_INCLUDE_PATH(senf_relative_include_file_path) # endif - +# # ifndef SENF_copy_n # include # if defined(__GNUC__) && ! defined(_STLP_ALGORITHM) && (__GNUC__>=4 || (__GNUC__==3 && __GNUC_MINOR__>=4)) @@ -46,11 +45,11 @@ # define SENF_copy_n std::copy_n # endif # endif - +# # ifndef SENF_MPL_RV_ALIGNMENT # define SENF_MPL_RV_ALIGNMENT 16 # endif - +# # if !defined(SENF_BUFFER_USE_LOCALS) && !defined(SENF_BUFFER_USE_ALLOCA) && !defined(SENF_BUFFER_USE_NEW) # # if defined(__GNUC__) @@ -69,17 +68,18 @@ # endif # # endif - +# # ifndef SENF_SENFLOG_LIMIT -# define SENF_SENFLOG_LIMIT senf::log::VERBOSE +# ifdef SENF_NO_DEBUG +# define SENF_SENFLOG_LIMIT senf::log::IMPORTANT +# else +# define SENF_SENFLOG_LIMIT senf::log::VERBOSE +# endif +# endif +# +# ///////////////////////////////hh.e//////////////////////////////////////// # endif - -///////////////////////////////hh.e//////////////////////////////////////// -//#include "config.cci" -//#include "config.ct" -//#include "config.cti" -#endif - + // Local Variables: // mode: c++ @@ -90,3 +90,4 @@ // ispell-local-dictionary: "american" // compile-command: "scons -u all_tests" // End: + diff --git a/senf.dict b/senf.dict index ec75335..eeb8343 100644 --- a/senf.dict +++ b/senf.dict @@ -17,7 +17,6 @@ addtogroup aListCollection alloc API -API's arg argc args diff --git a/senfscons/SENFSCons.py b/senfscons/SENFSCons.py index faa08ee..b6703ed 100644 --- a/senfscons/SENFSCons.py +++ b/senfscons/SENFSCons.py @@ -247,7 +247,7 @@ def MakeEnvironment(): if env['final']: env.Append(CXXFLAGS = [ '-O3' ], - CPPDEFINES = [ 'NDEBUG' ]) + CPPDEFINES = [ 'SENF_NO_DEBUG' ]) else: env.Append(CXXFLAGS = [ '-O0', '-g', '-fno-inline' ], # The boost-regex library is not compiled with _GLIBCXX_DEBUG so this fails.