From: tho Date: Wed, 16 Nov 2011 11:00:40 +0000 (+0000) Subject: g++/final: don't add extra code to check for buffer overflows (-fno-stack-protector) X-Git-Url: http://g0dil.de/git?p=senf.git;a=commitdiff_plain;h=55b4c5a3afcf821031cef2ca7089fbdfd77d513a g++/final: don't add extra code to check for buffer overflows (-fno-stack-protector) (this is default for debian, but not for ubuntu) g++/final: to reduce binary sizes place each function into its own section (-ffunction-sections) and enable garbage collection of unused sections in the linker (--gc-sections) PPI: reduced Route<> template instantiations Console: removed unused detail::NodeTraverser git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1826 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/SConstruct b/SConstruct index be18565..f774989 100644 --- a/SConstruct +++ b/SConstruct @@ -106,17 +106,19 @@ env.Append( CXXFLAGS = [ '-Wall', '-Woverloaded-virtual', '-Wno-long-long', '$INLINE_OPTS', '-pipe', '$CXXFLAGS_', '-fno-strict-aliasing', "${profile and '-pg' or None}" ], - CXXFLAGS_final = [ '-O3', '-fno-threadsafe-statics' ], + CXXFLAGS_final = [ '-O3', '-fno-threadsafe-statics','-fno-stack-protector', + '-ffunction-sections' ], CXXFLAGS_normal = [ '-O2', '-g' ], CXXFLAGS_debug = [ '-O0', '-g' ], CPPDEFINES = [ '$expandLogOption', '$CPPDEFINES_' ], - CPPDEFINES_final = [ 'SENF_PPI_NOTRACE', 'BOOST_NO_MT', 'NDEBUG', 'BOOST_DISABLE_ASSERTS', 'BOOST_DISABLE_THREADS' ], + CPPDEFINES_final = [ 'SENF_PPI_NOTRACE', 'NDEBUG', + 'BOOST_NO_MT', 'BOOST_DISABLE_ASSERTS', 'BOOST_DISABLE_THREADS' ], CPPDEFINES_normal = [ 'SENF_DEBUG' ], CPPDEFINES_debug = [ '$CPPDEFINES_normal' ], LINKFLAGS = [ '-rdynamic', '$LINKFLAGS_', "${profile and '-pg' or None}" ], - LINKFLAGS_final = [ ], + LINKFLAGS_final = [ '-Wl,--gc-sections' ], LINKFLAGS_normal = [ '-Wl,-S' ], LINKFLAGS_debug = [ '-g' ], ) diff --git a/senf/PPI/Module.cc b/senf/PPI/Module.cc index fec8338..40f743b 100644 --- a/senf/PPI/Module.cc +++ b/senf/PPI/Module.cc @@ -32,6 +32,8 @@ #include "Module.ih" // Custom includes +#include "Events.hh" +#include "Connectors.hh" //#include "Module.mpp" #define prefix_ @@ -41,6 +43,47 @@ // senf::ppi::module::Module //-///////////////////////////////////////////////////////////////////////////////////////////////// +// public members + +#ifdef DOXYGEN + +prefix_ senf::ppi::Route & +senf::ppi::module::Module::route(connector::InputConnector & input, + connector::OutputConnector & output) +{} +prefix_ senf::ppi::Route & +senf::ppi::module::Module::route(connector::InputConnector & input, EventDescriptor & output) +{} + +prefix_ senf::ppi::RouteRoute & +senf::ppi::module::Module::route(EventDescriptor & input, connector::OutputConnector & output); + +#else + +#define route_impl( Source, Target ) \ + prefix_ senf::ppi::Route & \ + senf::ppi::module::Module::route(Source & source, Target & target) \ + { \ + detail::RouteHelper::route(*this, source, target, source, target); \ + return static_cast< Route & >( \ + addRoute(std::auto_ptr< RouteBase >( \ + new Route(*this, source, target)))); \ + } + +route_impl( connector::GenericPassiveInput, connector::GenericActiveOutput); +route_impl( connector::GenericActiveInput, connector::GenericPassiveOutput); +route_impl( connector::GenericActiveInput, connector::GenericActiveOutput); +route_impl( connector::GenericPassiveInput, connector::GenericPassiveOutput); +route_impl( connector::GenericPassiveInput, EventDescriptor); +route_impl( connector::GenericActiveInput, EventDescriptor); +route_impl( EventDescriptor, connector::GenericPassiveOutput); +route_impl( EventDescriptor, connector::GenericActiveOutput); + +#undef route_impl + +#endif + +//-///////////////////////////////////////////////////////////////////////////////////////////////// // private members prefix_ void senf::ppi::module::Module::registerConnector(connector::Connector & connector) diff --git a/senf/PPI/Module.ct b/senf/PPI/Module.ct index d14c893..33c8687 100644 --- a/senf/PPI/Module.ct +++ b/senf/PPI/Module.ct @@ -40,28 +40,6 @@ #ifndef DOXYGEN -template -prefix_ senf::ppi::Route & -senf::ppi::module::Module::route(Source & source, Target & target) -{ - detail::RouteHelper::route(*this, source, target, source, target); - return static_cast< Route & >( - addRoute(std::auto_ptr< RouteBase >( - new Route(*this, source, target)))); -} - -#else -prefix_ senf::ppi::Route & -senf::ppi::module::Module::route(connector::InputConnector & input, - connector::OutputConnector & output) -{} -prefix_ senf::ppi::Route & -senf::ppi::module::Module::route(connector::InputConnector & input, EventDescriptor & output) -{} -#endif - -#ifndef DOXYGEN - template prefix_ void senf::ppi::module::Module::registerEvent(Descriptor & descriptor, Target target) { diff --git a/senf/PPI/Module.hh b/senf/PPI/Module.hh index 1b4881d..a2741ec 100644 --- a/senf/PPI/Module.hh +++ b/senf/PPI/Module.hh @@ -189,10 +189,7 @@ namespace module { protected: Module(); -#ifndef DOXYGEN - template - Route & route(Source & source, Target & target); -#else +#ifdef DOXYGEN Route & route(connector::InputConnector & input, connector::OutputConnector & output); ///< Define flow information @@ -219,9 +216,7 @@ namespace module { \param[in] output Data target, object which controls outgoing data (connector or event) \returns Route instance describing this route - \see \ref ppi_throttling - \note The real implementation is not provided by three - overloads but by a single template member */ + \see \ref ppi_throttling */ Route & route(connector::InputConnector & input, EventDescriptor & output); @@ -253,6 +248,21 @@ namespace module { enable/disable the event on throttling notifications. \see \ref route() */ +#else +# define route_decl(Source, Target) \ + Route & \ + route(Source & source, Target & target); + + route_decl( connector::GenericPassiveInput, connector::GenericActiveOutput); + route_decl( connector::GenericPassiveInput, connector::GenericPassiveOutput); + route_decl( connector::GenericActiveInput, connector::GenericPassiveOutput); + route_decl( connector::GenericActiveInput, connector::GenericActiveOutput); + route_decl( connector::GenericPassiveInput, EventDescriptor); + route_decl( connector::GenericActiveInput, EventDescriptor); + route_decl( EventDescriptor, connector::GenericPassiveOutput); + route_decl( EventDescriptor, connector::GenericActiveOutput); + +#undef Route_decl #endif void noroute(connector::Connector & connector); ///< Define terminal connectors diff --git a/senf/PPI/Route.hh b/senf/PPI/Route.hh index bcbdad6..a2eb214 100644 --- a/senf/PPI/Route.hh +++ b/senf/PPI/Route.hh @@ -51,6 +51,14 @@ namespace ppi { public: virtual ~RouteBase(); + bool hasConnector(connector::Connector const & conn) const; + ///< \c true, if route has connector \a conn + bool hasEvent(EventDescriptor const & event) const; + ///< \c true, if route has event \a event + + protected: + RouteBase(module::Module & module); + #ifdef DOXYGEN Source & source() const; ///< Routing source /**< \note The real implementation is in the \c @@ -62,14 +70,6 @@ namespace ppi { class is internal and not documented. */ #endif - bool hasConnector(connector::Connector const & conn) const; - ///< \c true, if route has connector \a conn - bool hasEvent(EventDescriptor const & event) const; - ///< \c true, if route has event \a event - - protected: - RouteBase(module::Module & module); - private: virtual bool v_hasConnector(connector::Connector const & conn) const = 0; virtual bool v_hasEvent(EventDescriptor const & event) const = 0; diff --git a/senf/PPI/Route.ih b/senf/PPI/Route.ih index 5ee93e7..0431c80 100644 --- a/senf/PPI/Route.ih +++ b/senf/PPI/Route.ih @@ -85,8 +85,8 @@ namespace detail { }; // The RoutingTraits give routing related information about the argument type: - // - Wether the type is a notifySource or notifyTarget - // - Wether the type is dataSource or dataTarget + // - Whether the type is a notifySource or notifyTarget + // - Whether the type is dataSource or dataTarget // - Provide the generalized target type // // The real implementation is in RoutingTraitsImplementation which is appropriately specialized @@ -104,14 +104,13 @@ namespace detail { class BaseRouteImplementation : public Base { - public: + protected: typedef Source source_type; typedef Target target_type; Source & source() const; Target & target() const; - protected: BaseRouteImplementation(module::Module & module, Source & source, Target & target); private: @@ -168,7 +167,7 @@ namespace detail { // This helper class finds the base-class suitable for a specific route. Routes are classified // into two groups: // 1) A forwarding routes is a routed which forwards notifications from a notifySource to a - // notifyTarget. Forwarding routes are implemneted using ForwardingRouteImplementation + // notifyTarget. Forwarding routes are implemented using ForwardingRouteImplementation // 2) Non-forwarding routes don't forward notifications. They are implemented directly // using BaseRouteImplementation template diff --git a/senf/Packets/80211Bundle/RadiotapPacket.cc b/senf/Packets/80211Bundle/RadiotapPacket.cc index 8f02f2c..9fb679c 100644 --- a/senf/Packets/80211Bundle/RadiotapPacket.cc +++ b/senf/Packets/80211Bundle/RadiotapPacket.cc @@ -47,15 +47,14 @@ extern "C" { //-///////////////////////////////////////////////////////////////////////////////////////////////// // Offset table management +senf::RadiotapPacketParser::OffsetMap senf::RadiotapPacketParser::offsetMap_; + prefix_ senf::RadiotapPacketParser::OffsetTable & senf::RadiotapPacketParser::offsetTable(boost::uint32_t presentFlags) { - typedef std::map OffsetMap; - static OffsetMap offsetMap; - - OffsetMap::iterator i (offsetMap.find(presentFlags)); - if (i == offsetMap.end()) - i = offsetMap.insert(std::make_pair(presentFlags, OffsetTable())).first; + OffsetMap::iterator i (offsetMap_.find(presentFlags)); + if (i == offsetMap_.end()) + i = offsetMap_.insert(std::make_pair(presentFlags, OffsetTable())).first; return i->second; } diff --git a/senf/Packets/80211Bundle/RadiotapPacket.hh b/senf/Packets/80211Bundle/RadiotapPacket.hh index 9e0a795..a292428 100644 --- a/senf/Packets/80211Bundle/RadiotapPacket.hh +++ b/senf/Packets/80211Bundle/RadiotapPacket.hh @@ -271,6 +271,7 @@ namespace senf { static const size_type fixed_bytes = 0; // hide this member, just in case typedef boost::array OffsetTable; + typedef std::map OffsetMap; //-//////////////////////////////////////////////////////////////////////// // Offset table handling @@ -296,6 +297,7 @@ namespace senf { void updatePresentFlags(boost::uint32_t flags); void insertRemoveBytes(unsigned from, unsigned to, int bytes); + static OffsetMap offsetMap_; OffsetTable const * currentTable_; friend class RadiotapPacketType; diff --git a/senf/Packets/80221Bundle/MIHMessageRegistry.ih b/senf/Packets/80221Bundle/MIHMessageRegistry.ih index 190f646..a9cde10 100644 --- a/senf/Packets/80221Bundle/MIHMessageRegistry.ih +++ b/senf/Packets/80221Bundle/MIHMessageRegistry.ih @@ -54,7 +54,9 @@ namespace senf { }; - struct MIHMessageRegistry_EntryBase { + struct MIHMessageRegistry_EntryBase + : private boost::noncopyable + { virtual ~MIHMessageRegistry_EntryBase() {} virtual void validate(senf::Packet message) const = 0; }; diff --git a/senf/Packets/DefaultBundle/ListOptionTypeParser.cti b/senf/Packets/DefaultBundle/ListOptionTypeParser.cti index c1c5c65..48b1651 100644 --- a/senf/Packets/DefaultBundle/ListOptionTypeParser.cti +++ b/senf/Packets/DefaultBundle/ListOptionTypeParser.cti @@ -122,7 +122,7 @@ construct(container_type & c) realAux_ -= std::distance(i, e); c.data().erase(i, e); //delete padding e = i; //set end iterator - } else{ + } else { ++n_; std::advance(i, elByte); } @@ -142,7 +142,7 @@ destruct(container_type & c) unsigned int padBytes = 0; if (realAux_ == 0) //if list is empty, 6 padding bytes required! padBytes = 6; - else{ + else { padBytes = ( (realAux_+2) % 8); if (padBytes != 0) padBytes = 8 - padBytes; diff --git a/senf/Scheduler/FdEvent.hh b/senf/Scheduler/FdEvent.hh index 088e2d8..8d3209d 100644 --- a/senf/Scheduler/FdEvent.hh +++ b/senf/Scheduler/FdEvent.hh @@ -47,7 +47,6 @@ namespace scheduler { struct FdSetTag; typedef boost::intrusive::iset_base_hook FdSetBase; struct FdSetCompare; - struct FindFd; class FdDispatcher; class FileDispatcher; } @@ -172,7 +171,6 @@ namespace scheduler { int signaledEvents_; friend class detail::FdSetCompare; - friend class detail::FindFd; friend class detail::FdDispatcher; friend class detail::FileDispatcher; }; diff --git a/senf/Scheduler/FdEvent.ih b/senf/Scheduler/FdEvent.ih index b944f34..245d607 100644 --- a/senf/Scheduler/FdEvent.ih +++ b/senf/Scheduler/FdEvent.ih @@ -48,13 +48,6 @@ namespace detail { { return a.fd_ < b.fd_; } }; - struct FindFd { - bool operator()(FdEvent const & a, int b) const - { return a.fd_ < b; } - bool operator()(int a, FdEvent const & b) const - { return a < b.fd_; } - }; - class FdDispatcher : public senf::singleton { diff --git a/senf/Scheduler/TimerEventProxy.ct b/senf/Scheduler/TimerEventProxy.ct index 6c65cb7..20a9e19 100644 --- a/senf/Scheduler/TimerEventProxy.ct +++ b/senf/Scheduler/TimerEventProxy.ct @@ -66,9 +66,9 @@ prefix_ void senf::scheduler::TimerEventProxy::add( { // insert new entry or replace the timeout of an entry already indexed typename EntrySetById_t::iterator i = entrySetById.find(id); - if(i == entrySetById.end()) + if (i == entrySetById.end()) entrySetByTimeout.insert( Entry(timeout, id, cb)); - else{ + else { Entry tmp = *i; tmp.timeout = timeout; entrySetById.replace(i,tmp); diff --git a/senf/Utils/Console/Node.cc b/senf/Utils/Console/Node.cc index fcd7e66..965b798 100644 --- a/senf/Utils/Console/Node.cc +++ b/senf/Utils/Console/Node.cc @@ -29,7 +29,6 @@ \brief Node non-inline non-template implementation */ #include "Node.hh" -#include "Node.ih" // Custom includes #include @@ -205,55 +204,6 @@ prefix_ std::string senf::console::DirectoryNode::v_shorthelp() } //-///////////////////////////////////////////////////////////////////////////////////////////////// -// senf::console::detail::NodeTraverser -#ifndef DOXYGEN - -prefix_ void senf::console::detail::NodeTraverser::operator()(std::string const & name) -{ - if (! init_) { - init_ = true; - if (name == std::string("")) { - dir_ = root_.thisptr(); - return; - } - } - if (! elt_.empty()) { - if (elt_ == "..") { - dir_ = dir_->parent(); - if (! dir_ || ! dir_->isChildOf(root_)) - dir_ = root_.thisptr(); - } - else if (elt_ != "" && elt_ != ".") { - if (! dir_->hasChild(elt_) && autocomplete_) { - DirectoryNode::ChildrenRange completions (dir_->completions(elt_)); - if (has_one_elt(completions)) - elt_ = completions.begin()->first; - } - // Why does g++ give an error on this line ???? : - // dir = dynamic_cast( dir->get(name) ).thisptr(); - DirectoryNode & d (dynamic_cast( dir_->get(elt_) )); - dir_ = d.thisptr(); - } - } - elt_ = name; -} - -prefix_ senf::console::GenericNode & senf::console::detail::NodeTraverser::node() -{ - if (elt_ != "" && elt_ != ".") { - if (! dir_->hasChild(elt_) && autocomplete_) { - DirectoryNode::ChildrenRange completions (dir_->completions(elt_)); - if (has_one_elt(completions)) - elt_ = completions.begin()->first; - } - return dir_->get(elt_); - } - else - return * dir_; -} -#endif - -//-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::console::SimpleCommandNode prefix_ void senf::console::SimpleCommandNode::v_help(std::ostream & output) diff --git a/senf/Utils/Console/Node.cci b/senf/Utils/Console/Node.cci index a38a11f..0c02742 100644 --- a/senf/Utils/Console/Node.cci +++ b/senf/Utils/Console/Node.cci @@ -28,8 +28,6 @@ /** \file \brief Node inline non-template implementation */ -#include "Node.ih" - // Custom includes #define prefix_ inline @@ -259,18 +257,6 @@ prefix_ senf::console::DirectoryNode::cptr senf::console::DirectoryNode::thisptr } //-///////////////////////////////////////////////////////////////////////////////////////////////// -// senf::console::detail::NodeTraverser -#ifndef DOXYGEN - -prefix_ senf::console::detail::NodeTraverser::NodeTraverser(DirectoryNode & root, - DirectoryNode & dir, - bool autocomplete) - : root_ (root), dir_ (dir.thisptr()), autocomplete_ (autocomplete), init_ (false) -{} - -#endif - -//-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::console::CommandNode prefix_ senf::console::CommandNode::ptr senf::console::CommandNode::thisptr() diff --git a/senf/Utils/Console/Node.cti b/senf/Utils/Console/Node.cti index 5e41891..9a96846 100644 --- a/senf/Utils/Console/Node.cti +++ b/senf/Utils/Console/Node.cti @@ -28,8 +28,6 @@ /** \file \brief Node inline template implementation */ -#include "Node.ih" - // Custom includes #define prefix_ inline diff --git a/senf/Utils/Console/Node.ih b/senf/Utils/Console/Node.ih deleted file mode 100644 index 9336849..0000000 --- a/senf/Utils/Console/Node.ih +++ /dev/null @@ -1,77 +0,0 @@ -// $Id$ -// -// Copyright (C) 2008 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// -// The contents of this file are subject to the Fraunhofer FOKUS Public License -// Version 1.0 (the "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// http://senf.berlios.de/license.html -// -// The Fraunhofer FOKUS Public License Version 1.0 is based on, -// but modifies the Mozilla Public License Version 1.1. -// See the full license text for the amendments. -// -// Software distributed under the License is distributed on an "AS IS" basis, -// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -// for the specific language governing rights and limitations under the License. -// -// The Original Code is Fraunhofer FOKUS code. -// -// The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. -// (registered association), Hansastraße 27 c, 80686 Munich, Germany. -// All Rights Reserved. -// -// Contributor(s): -// Stefan Bund - -/** \file - \brief Node internal header */ - -#ifndef IH_SENF_Scheduler_Console_Node_ -#define IH_SENF_Scheduler_Console_Node_ 1 - -// Custom includes - -//-///////////////////////////////////////////////////////////////////////////////////////////////// - -namespace senf { -namespace console { -namespace detail { - -#ifndef DOXYGEN - - class NodeTraverser - { - public: - NodeTraverser(DirectoryNode & root, DirectoryNode & dir, bool autocomplete); - - void operator()(std::string const & name); - - GenericNode & node(); - - private: - DirectoryNode & root_; - DirectoryNode::ptr dir_; - bool autocomplete_; - std::string elt_; - bool init_; - }; - -#endif - -}}} - -//-///////////////////////////////////////////////////////////////////////////////////////////////// -#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/senf/Utils/Console/Server.cc b/senf/Utils/Console/Server.cc index fe7f351..7ea4bf1 100644 --- a/senf/Utils/Console/Server.cc +++ b/senf/Utils/Console/Server.cc @@ -56,7 +56,7 @@ namespace { senf::console::SysInfo::Proxy addSysInfo ( "SENF: The Simple and Extensible Network Framework\n" - " © 2006-2011 Fraunhofer Institute for Open Communication Systems, Network Research\n" + " (c) 2006-2011 Fraunhofer Institute for Open Communication Systems (FOKUS)\n" " Contact: senf-dev@lists.berlios.de\n" " Version: " SENF_LIB_VERSION " Revision number: " SENF_REVISION "\n" " Build-type: " BUILD_TYPE ", SenfLog compile time limit: " + @@ -262,7 +262,7 @@ senf::console::detail::NoninteractiveClientReader::streamBufferMaxSize() prefix_ void senf::console::detail::NoninteractiveClientReader::v_write(std::string const & data) { - if( sendQueue_.size() > streamBufferMaxSize_) + if (sendQueue_.size() > streamBufferMaxSize_) return; sendQueue_.insert( sendQueue_.end(), data.begin(), data.end()); writeHandler(scheduler::FdEvent::EV_WRITE); diff --git a/senf/Utils/Daemon/Daemon.cc b/senf/Utils/Daemon/Daemon.cc index e2f0fec..2b75836 100644 --- a/senf/Utils/Daemon/Daemon.cc +++ b/senf/Utils/Daemon/Daemon.cc @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -656,6 +657,13 @@ prefix_ void senf::detail::DaemonWatcher::childOk() //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::detail::DaemonWatcher::Forwarder +prefix_ senf::detail::DaemonWatcher::Forwarder::Target::Target(Forwarder & fwd, int fd_) + : fd (fd_), offset (0), + writeevent ("senf::detail::DaemonWatcher::Forwarder::Target::writeevent", + boost::bind(&Forwarder::writeData, &fwd, _1, this), + fd, scheduler::FdEvent::EV_WRITE, false) +{} + prefix_ senf::detail::DaemonWatcher::Forwarder::Forwarder(int src, Callback cb) : src_(src), cb_(cb), readevent_("senf::detail::DaemonWatcher::Forwarder::readevent", senf::membind(&Forwarder::readData, this), diff --git a/senf/Utils/Daemon/Daemon.cci b/senf/Utils/Daemon/Daemon.cci deleted file mode 100644 index 814a248..0000000 --- a/senf/Utils/Daemon/Daemon.cci +++ /dev/null @@ -1,58 +0,0 @@ -// $Id$ -// -// Copyright (C) 2008 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// -// The contents of this file are subject to the Fraunhofer FOKUS Public License -// Version 1.0 (the "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// http://senf.berlios.de/license.html -// -// The Fraunhofer FOKUS Public License Version 1.0 is based on, -// but modifies the Mozilla Public License Version 1.1. -// See the full license text for the amendments. -// -// Software distributed under the License is distributed on an "AS IS" basis, -// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -// for the specific language governing rights and limitations under the License. -// -// The Original Code is Fraunhofer FOKUS code. -// -// The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. -// (registered association), Hansastraße 27 c, 80686 Munich, Germany. -// All Rights Reserved. -// -// Contributor(s): -// Stefan Bund - -/** \file - \brief Daemon inline non-template implementation */ - -#include "Daemon.ih" - -// Custom includes -#include - -#define prefix_ inline -//-///////////////////////////////////////////////////////////////////////////////////////////////// - -prefix_ senf::detail::DaemonWatcher::Forwarder::Target::Target(Forwarder & fwd, int fd_) - : fd (fd_), offset (0), - writeevent ("senf::detail::DaemonWatcher::Forwarder::Target::writeevent", - boost::bind(&Forwarder::writeData, &fwd, _1, this), - fd, scheduler::FdEvent::EV_WRITE, false) -{} - -//-///////////////////////////////////////////////////////////////////////////////////////////////// -#undef prefix_ - - -// 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/senf/Utils/Daemon/Daemon.hh b/senf/Utils/Daemon/Daemon.hh index 3e15903..93d1fc4 100644 --- a/senf/Utils/Daemon/Daemon.hh +++ b/senf/Utils/Daemon/Daemon.hh @@ -247,7 +247,7 @@ namespace senf { } //-///////////////////////////////////////////////////////////////////////////////////////////////// -#include "Daemon.cci" +//#include "Daemon.cci" //#include "Daemon.ct" //#include "Daemon.cti" #endif diff --git a/senf/Utils/StatisticAccumulator.cc b/senf/Utils/StatisticAccumulator.cc index 0a146f3..95810ca 100644 --- a/senf/Utils/StatisticAccumulator.cc +++ b/senf/Utils/StatisticAccumulator.cc @@ -23,18 +23,27 @@ // All Rights Reserved. // // Contributor(s): -// Stefan Bund +// Mathias Kretschmer +// Jens Moedeker #include "StatisticAccumulator.hh" +// Custom includes + +#define prefix_ +//-///////////////////////////////////////////////////////////////////////////////////////////////// + std::ostream & senf::operator<<(std::ostream & os, senf::StatisticsData const & _data) - { - format::IndentHelper indent; - os << indent << "StatisticData:" << std::endl; - os << indent << "min: " << _data.min << std::endl; - os << indent << "avg: " << _data.avg << std::endl; - os << indent << "max: " << _data.max << std::endl; - os << indent << "stddev: " << _data.stddev << std::endl; - os << indent << "count: " << _data.count << std::endl; - return os; - }; +{ + format::IndentHelper indent; + os << indent << "StatisticData:" << std::endl + << indent << "min: " << _data.min << std::endl + << indent << "avg: " << _data.avg << std::endl + << indent << "max: " << _data.max << std::endl + << indent << "stddev: " << _data.stddev << std::endl + << indent << "count: " << _data.count << std::endl; + return os; +}; + +//-///////////////////////////////////////////////////////////////////////////////////////////////// +#undef prefix_ diff --git a/senf/Utils/StatisticAccumulator.ct b/senf/Utils/StatisticAccumulator.ct index b0fc9b2..c720d3f 100644 --- a/senf/Utils/StatisticAccumulator.ct +++ b/senf/Utils/StatisticAccumulator.ct @@ -23,7 +23,9 @@ // All Rights Reserved. // // Contributor(s): -// Thorsten Horstmann +// Mathias Kretschmer +// Jens Moedeker + /** \file \brief StatisticAccumulator non-inline template implementation */ @@ -36,19 +38,9 @@ // senf::StatisticAccumulator template -prefix_ senf::StatisticAccumulator::StatisticAccumulator( ) - : sum_squared_(0), - sum_(0), - min_(0), - max_(0), - last_avg_(0), - count_(0) -{ -} - -//template -//prefix_ senf::StatisticAccumulator::~StatisticAccumulator() -//{ } +prefix_ senf::StatisticAccumulator::StatisticAccumulator() + : sum_squared_(0), sum_(0), min_(0), max_(0), last_avg_(0), count_(0) +{ } template prefix_ float senf::StatisticAccumulator::stddev() @@ -91,29 +83,28 @@ prefix_ void senf::StatisticAccumulator::accumulate( T value) template prefix_ void senf::StatisticAccumulator::clear() { - if( count_ > 0){ - last_avg_ = avg(); - count_ = 0; - sum_squared_ = 0; - sum_ = min_ = max_ = 0; + if (count_ > 0) { + last_avg_ = avg(); + count_ = 0; + sum_squared_ = 0; + sum_ = min_ = max_ = 0; } } template prefix_ void senf::StatisticAccumulator::data( StatisticsData &data_) const { - if( count_ == 0){ - data_.min = data_.avg = data_.max = last_avg_; - data_.stddev = 0.0; - data_.count = 0; + if (count_ == 0) { + data_.min = data_.avg = data_.max = last_avg_; + data_.stddev = 0.0; + data_.count = 0; + } else { + data_.min = (float) min_; + data_.avg = avg(); + data_.max = (float) max_; + data_.stddev = stddev(); + data_.count = count_; } - else{ - data_.min = (float) min_; - data_.avg = avg(); - data_.max = (float) max_; - data_.stddev = stddev(); - data_.count = count_; - } } diff --git a/senf/Utils/StatisticAccumulator.cti b/senf/Utils/StatisticAccumulator.cti index 3234b53..d8ed082 100644 --- a/senf/Utils/StatisticAccumulator.cti +++ b/senf/Utils/StatisticAccumulator.cti @@ -23,7 +23,9 @@ // All Rights Reserved. // // Contributor(s): -// Thorsten Horstmann +// Mathias Kretschmer +// Jens Moedeker + /** \file \brief StatisticAccumulator inline template implementation */ @@ -56,12 +58,6 @@ prefix_ float senf::StatisticAccumulator::avg() return count_ == 0 ? NAN : (sum_ / float(count_)); } -//template -//prefix_ senf::Statistics & senf::StatisticAccumulator::statistics() -//{ -// return stats_; -//} - template prefix_ float senf::StatisticAccumulator::last_avg() const diff --git a/senf/Utils/StatisticAccumulator.hh b/senf/Utils/StatisticAccumulator.hh index ed64e89..ae35600 100644 --- a/senf/Utils/StatisticAccumulator.hh +++ b/senf/Utils/StatisticAccumulator.hh @@ -23,7 +23,9 @@ // All Rights Reserved. // // Contributor(s): -// Thorsten Horstmann +// Mathias Kretschmer +// Jens Moedeker + /** \file \brief StatisticAccumulator public header */ @@ -74,43 +76,39 @@ namespace senf { { public: StatisticAccumulator(); -// virtual ~StatisticAccumulator(); - - void clear(); - ///< Reset accumulated values. - /**< This member reset all values. */ - void accumulate(T value); - ///< Gather value to be accumulated. - /**< This method accumulates a value. - \param[in] value to be accumulated value*/ - void setLastAvg(T value); - ///< If no real data was collected, this method specifies the min/avg/max value to be returned. - /**< This method specifies the the min/avg/max value to be returned if no real data was colelcted - \param[in] value to be returned*/ - - public: - T min() const; - ///< Returns current minimal value. - /**< This method returns the minimal value of the current accumulation.*/ - T max() const; - ///< Returns current maximal value. - /**< This method returns the maximal value of the current accumulation.*/ - float avg() const; - ///< Returns average value. - /**< This method returns the average value of the current accumulation.*/ - float last_avg() const; - ///< Returns former average value. - /**< This method returns the average value of the former accumulation period.*/ - float stddev() const; - ///< Returns standard deviation value. - /**< This method returns the standard deviation value of the current accumulation.*/ - boost::uint32_t count() const; - ///< Returns count of accumulated values. - /**< This method returns count of accumulated values of the current accumulation.*/ - void data( StatisticsData & data_) const; - ///< Returns the accumulated data as a tuple - /**< This method returns the accumulated information as a tuple.*/ + void clear(); ///< Reset accumulated values. + /**< This member reset all values. */ + void accumulate(T value); ///< Gather value to be accumulated. + /**< This method accumulates a value. + \param[in] value to be accumulated value */ + void setLastAvg(T value); ///< If no real data was collected, this method specifies the min/avg/max value to be returned. + /**< This method specifies the the min/avg/max value to + be returned if no real data was collected + \param[in] value to be returned */ + + T min() const; ///< Returns current minimal value. + /**< This method returns the minimal value of the + current accumulation. */ + T max() const; ///< Returns current maximal value. + /**< This method returns the maximal value of the + current accumulation.*/ + float avg() const; ///< Returns average value. + /**< This method returns the average value of the + current accumulation.*/ + float last_avg() const; ///< Returns former average value. + /**< This method returns the average value of the + former accumulation period.*/ + float stddev() const; ///< Returns standard deviation value. + /**< This method returns the standard deviation + value of the current accumulation.*/ + boost::uint32_t count() const; ///< Returns count of accumulated values. + /**< This method returns count of accumulated + values of the current accumulation.*/ + void data(StatisticsData & data_) const; + ///< Returns the accumulated data as a tuple + /**< This method returns the accumulated information + as a tuple.*/ private: T sum_squared_; T sum_; @@ -118,14 +116,8 @@ namespace senf { T max_; float last_avg_; boost::uint32_t count_; - - }; - - typedef StatisticAccumulator StatisticAccumulatorInt; - typedef StatisticAccumulator StatisticAccumulatorFloat; - } ///////////////////////////////hh.e//////////////////////////////////////// //#include "StatisticAccumulator.cci" diff --git a/senf/Utils/StatisticAccumulator.test.cc b/senf/Utils/StatisticAccumulator.test.cc index ab9931f..81f38db 100644 --- a/senf/Utils/StatisticAccumulator.test.cc +++ b/senf/Utils/StatisticAccumulator.test.cc @@ -23,9 +23,8 @@ // All Rights Reserved. // // Contributor(s): -// Thorsten Horstmann -/** \file - \brief StatisticAccumulator non-inline template implementation */ +// Mathias Kretschmer +// Jens Moedeker // Custom includes @@ -34,7 +33,6 @@ #include "auto_unit_test.hh" #include #include -//#include #define prefix_ ///////////////////////////////ct.p//////////////////////////////////////// @@ -42,7 +40,7 @@ SENF_AUTO_UNIT_TEST(StatisticAccumulator) { senf::Statistics s; - senf::StatisticAccumulatorInt sa; + senf::StatisticAccumulator sa; sa.accumulate( 5); sa.accumulate( 3); @@ -66,10 +64,6 @@ SENF_AUTO_UNIT_TEST(StatisticAccumulator) BOOST_CHECK_EQUAL( sa.last_avg(), 5.0); BOOST_CHECK( ::isnan( sa.stddev())); BOOST_CHECK_EQUAL( sa.count(), 0); - - - - } ///////////////////////////////ct.e//////////////////////////////////////// #undef prefix_ diff --git a/site_scons/senfutil.py b/site_scons/senfutil.py index 0d7c30d..9b4065a 100644 --- a/site_scons/senfutil.py +++ b/site_scons/senfutil.py @@ -225,11 +225,13 @@ def DefaultOptions(env): # Set nice default options env.Append( CXXFLAGS = [ '-Wall', '-Woverloaded-virtual', "${profile and '-pg' or None}" ], - CXXFLAGS_final = [ '-O3', '-fno-threadsafe-statics' ], + CXXFLAGS_final = [ '-O3', '-fno-threadsafe-statics', '-fno-stack-protector', + '-ffunction-sections' ], CXXFLAGS_normal = [ '-O2', '-g' ], CXXFLAGS_debug = [ '-O0', '-g' ], LINKFLAGS = [ "${profile and '-pg' or None}" ], + LINKFLAGS_final = [ '-Wl,--gc-sections' ], LINKFLAGS_normal = [ '-Wl,-S' ], LINKFLAGS_debug = [ '-g' ], )