From: tho Date: Wed, 7 Dec 2011 13:00:19 +0000 (+0000) Subject: several fixes for clang/llvm X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=74febc7a9abc84c4939269b3443d15fc27f4e960;p=senf.git several fixes for clang/llvm git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1833 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/SConfigure b/SConfigure index b7f1a2f..64044a8 100644 --- a/SConfigure +++ b/SConfigure @@ -14,7 +14,7 @@ def CheckSTLCopyN(context): ('', '__gnu_cxx::copy_n', 'GNUCXX') ] for include, name, define in versions: ret = context.TryCompile("#include %s\n" - "int main(int,char**) { int *a,*b; %s(a,0,b); }\n" + "int main(int,char**) { int *a (NULL); int *b (NULL); %s(a,0,b); }\n" % (include, name), ".cc") if ret: diff --git a/SConstruct b/SConstruct index 67fdc5d..8566c0f 100644 --- a/SConstruct +++ b/SConstruct @@ -101,11 +101,13 @@ env.Append( '--param','large-function-growth=10000', '--param', 'large-function-insns=10000', '--param','inline-unit-growth=10000' ], - INLINE_OPTS_NORMAL = [ '-finline-limit=5000', '--param', 'inline-unit-growth=60' ], - INLINE_OPTS = [ '$INLINE_OPTS_NORMAL' ], + INLINE_OPTS_GCC = [ '-finline-limit=5000', '--param', 'inline-unit-growth=60' ], + INLINE_OPTS = [ '${str(CXX).split("/")[-1] == "g++" and "$INLINE_OPTS_GCC" or None}' ], + CXXFLAGS_CLANG = [ '-Wno-unneeded-internal-declaration' ], # needed for BOOST_PARAMETER_KEYWORD CXXFLAGS = [ '-Wall', '-Woverloaded-virtual', '-Wno-long-long', '$INLINE_OPTS', '-pipe', '$CXXFLAGS_', '-fno-strict-aliasing', - "${profile and '-pg' or None}" ], + "${profile and '-pg' or None}", + '${str(CXX).split("/")[-1] == "clang++" and "$CXXFLAGS_CLANG" or None}' ], CXXFLAGS_final = [ '-O3', '-fno-threadsafe-statics','-fno-stack-protector', "${profile and ' ' or '-ffunction-sections'}" ], CXXFLAGS_normal = [ '-O2', '-g' ], @@ -183,7 +185,7 @@ SConscript('SConfigure') env.Append(LIBS = [ '$LIBSENF$LIBADDSUFFIX', '$BOOSTREGEXLIB', '$BOOSTSIGNALSLIB', - '$BOOSTFSLIB', '$BOOSTSYSTEMLIB' ]) + '$BOOSTFSLIB', '$BOOSTSYSTEMLIB', '$BOOSTDATETIMELIB' ]) ########################################################################### diff --git a/senf/PPI/Module.hh b/senf/PPI/Module.hh index a2741ec..8b60a5e 100644 --- a/senf/PPI/Module.hh +++ b/senf/PPI/Module.hh @@ -343,7 +343,7 @@ namespace module { RouteInfoBase routes_; template - friend class detail::RouteHelper; + friend struct detail::RouteHelper; friend class senf::ppi::ModuleManager; friend class connector::Connector; friend class senf::ppi::detail::EventBindingBase; diff --git a/senf/PPI/ModuleManager.hh b/senf/PPI/ModuleManager.hh index cc66892..d5d6105 100644 --- a/senf/PPI/ModuleManager.hh +++ b/senf/PPI/ModuleManager.hh @@ -107,7 +107,7 @@ namespace ppi { #ifndef DOXYGEN struct RunGuard; - friend class RunGuard; + friend struct RunGuard; #endif ModuleRegistry moduleRegistry_; @@ -121,7 +121,7 @@ namespace ppi { senf::console::ScopedDirectory<> consoleDir_; friend class module::Module; - friend class Initializable; + friend struct Initializable; }; }} diff --git a/senf/PPI/MultiConnectorMixin.hh b/senf/PPI/MultiConnectorMixin.hh index 4db6ebd..135c517 100644 --- a/senf/PPI/MultiConnectorMixin.hh +++ b/senf/PPI/MultiConnectorMixin.hh @@ -95,7 +95,7 @@ namespace ppi { namespace module { - namespace detail { class MultiConnectorMixinAccess; } + namespace detail { struct MultiConnectorMixinAccess; } /** \brief Multi-Connector management @@ -287,7 +287,7 @@ namespace module { void disconnected(ConnectorType_ const & c); - friend class detail::MultiConnectorMixinAccess; + friend struct detail::MultiConnectorMixinAccess; friend class detail::MultiConnectorWrapper; ContainerType_ connectors_; @@ -324,7 +324,7 @@ namespace module { void disconnected(ConnectorType_ const & c); - friend class detail::MultiConnectorMixinAccess; + friend struct detail::MultiConnectorMixinAccess; friend class detail::MultiConnectorWrapper; ContainerType_ connectors_; @@ -350,7 +350,7 @@ namespace module { void disconnected(ConnectorType_ const & c); - friend class detail::MultiConnectorMixinAccess; + friend struct detail::MultiConnectorMixinAccess; friend class detail::MultiConnectorWrapper; }; diff --git a/senf/PPI/QueueingSocketSink.test.cc b/senf/PPI/QueueingSocketSink.test.cc index 04b14aa..a2d60b4 100644 --- a/senf/PPI/QueueingSocketSink.test.cc +++ b/senf/PPI/QueueingSocketSink.test.cc @@ -138,7 +138,7 @@ SENF_AUTO_UNIT_TEST(passiveQueueingSocketSink) BOOST_CHECK_EQUAL( data, input ); } - runPPI( senf::ClockService::milliseconds(250)); + runPPI( senf::ClockService::milliseconds(500)); BOOST_CHECK_EQUAL( udpSink.qAlgorithm().size(), 0); } diff --git a/senf/PPI/RateAnalyzer.test.cc b/senf/PPI/RateAnalyzer.test.cc index 8478393..cafaf11 100644 --- a/senf/PPI/RateAnalyzer.test.cc +++ b/senf/PPI/RateAnalyzer.test.cc @@ -47,13 +47,13 @@ namespace { unsigned calls (0u); - float ppss[] = { 13.333333f, 20.f, 13.333333f, 20.f, 13.333333f, 20.f }; float pps; float bps; void collectPPS(float packetsPerSecond) { + static float ppss[] = { 13.333333f, 20.f, 13.333333f, 20.f, 13.333333f, 20.f }; // 2 + 3 + 2 + 3 + 2 + 3 packets / interval // -> 13.333333 + 20. + 13.333333 + 20. + 13.333333 + 20. / 6 pps // -> 16.666666 pps diff --git a/senf/PPI/Route.cti b/senf/PPI/Route.cti index 8458ac6..db9612e 100644 --- a/senf/PPI/Route.cti +++ b/senf/PPI/Route.cti @@ -163,8 +163,8 @@ senf::ppi::detail::ForwardingRouteImplementation:: ForwardingRouteImplementation(module::Module & module, Source & source, Target & target) : Base(module,source,target) { - registerRoute(source); - registerRoute(target); + Base::registerRoute(source); + Base::registerRoute(target); } template @@ -172,8 +172,8 @@ prefix_ senf::ppi::detail::ForwardingRouteImplementation:: ~ForwardingRouteImplementation() { - unregisterRoute(this->source()); - unregisterRoute(this->target()); + Base::unregisterRoute(this->source()); + Base::unregisterRoute(this->target()); } //-///////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/senf/PPI/SocketSink.test.cc b/senf/PPI/SocketSink.test.cc index 4d9256b..6b55e36 100644 --- a/senf/PPI/SocketSink.test.cc +++ b/senf/PPI/SocketSink.test.cc @@ -67,10 +67,6 @@ namespace { return (boost::format("localhost:%d") % port(i)).str(); } - std::string localhost6str(unsigned i) - { - return (boost::format("[::1]:%d") % port(i)).str(); - } } SENF_AUTO_UNIT_TEST(passiveSocketSink) diff --git a/senf/PPI/SocketSource.test.cc b/senf/PPI/SocketSource.test.cc index 52f34d3..f7b416c 100644 --- a/senf/PPI/SocketSource.test.cc +++ b/senf/PPI/SocketSource.test.cc @@ -71,10 +71,6 @@ namespace { return (boost::format("localhost:%d") % port(i)).str(); } - std::string localhost6str(unsigned i) - { - return (boost::format("[::1]:%d") % port(i)).str(); - } } SENF_AUTO_UNIT_TEST(socketSource) diff --git a/senf/PPI/predecl.hh b/senf/PPI/predecl.hh index fc0fb62..80ba4aa 100644 --- a/senf/PPI/predecl.hh +++ b/senf/PPI/predecl.hh @@ -74,7 +74,7 @@ namespace ppi { namespace module { class Module; namespace detail { - template class RouteHelper; + template struct RouteHelper; } class PassiveJoin; class PriorityJoin; diff --git a/senf/Packets/80211Bundle/RadiotapPacket.hh b/senf/Packets/80211Bundle/RadiotapPacket.hh index a292428..04e1f9c 100644 --- a/senf/Packets/80211Bundle/RadiotapPacket.hh +++ b/senf/Packets/80211Bundle/RadiotapPacket.hh @@ -58,7 +58,7 @@ namespace senf { SENF_PARSER_FINALIZE ( RadiotapPacketParser_Flags ); - friend class RadiotapPacketParser; + friend struct RadiotapPacketParser; }; /** \brief Parse in Radiotap Header channel frequency and flag field @@ -300,7 +300,7 @@ namespace senf { static OffsetMap offsetMap_; OffsetTable const * currentTable_; - friend class RadiotapPacketType; + friend struct RadiotapPacketType; }; /** \brief Radiotap packet diff --git a/senf/Packets/80211Bundle/WLANPacket.hh b/senf/Packets/80211Bundle/WLANPacket.hh index 0db8889..d56f9c9 100644 --- a/senf/Packets/80211Bundle/WLANPacket.hh +++ b/senf/Packets/80211Bundle/WLANPacket.hh @@ -255,7 +255,7 @@ namespace senf MACAddressParser destinationAddress() const; MACAddressParser bssid() const; - friend class WLANPacket_DataFrameType; + friend struct WLANPacket_DataFrameType; }; /** \brief WLAN Data frame packet diff --git a/senf/Packets/80221Bundle/MIHPacket.hh b/senf/Packets/80221Bundle/MIHPacket.hh index af90a4b..87bf23a 100644 --- a/senf/Packets/80221Bundle/MIHPacket.hh +++ b/senf/Packets/80221Bundle/MIHPacket.hh @@ -85,7 +85,7 @@ namespace senf { version_() = 1; } - friend class MIHPacketType; + friend struct MIHPacketType; }; /** \brief MIH packet diff --git a/senf/Packets/GenericTLV.ct b/senf/Packets/GenericTLV.ct index a2df5c0..fd798b6 100644 --- a/senf/Packets/GenericTLV.ct +++ b/senf/Packets/GenericTLV.ct @@ -87,7 +87,7 @@ prefix_ void senf::GenericTLVParserBase::value_(ForwardReadableRange const //typename boost::range_difference::type rangeSize ( boost::size(range)); unsigned rangeSize ( boost::size(range)); if ( rangeSize != this->length() ) - resize( bytes(), rangeSize + senf::bytes(self()) ); + Base::resize( bytes(), rangeSize + senf::bytes(self()) ); std::copy( boost::begin(range), boost::end(range), boost::next( this->i(), senf::bytes( self())) ); this->length_() = rangeSize; diff --git a/senf/Packets/ListBParser.cti b/senf/Packets/ListBParser.cti index 1129e88..5c2deb9 100644 --- a/senf/Packets/ListBParser.cti +++ b/senf/Packets/ListBParser.cti @@ -155,9 +155,9 @@ update(container_type const & c) data_iterator i (AuxPolicy::WrapperPolicy::adjust(c.i(), c.state())); data_iterator j (i); for (size_type n (n_); n; --n, std::advance(j,senf::bytes(ElementParser(j,c.state())))) ; - aux( std::distance(i,j), c.i(), c.state() ); + AuxPolicy::WrapperPolicy::aux( std::distance(i,j), c.i(), c.state() ); #else - aux ( aux(c.i(),c.state()) + c.data().size() - container_size_, c.i(), c.state() ); + AuxPolicy::WrapperPolicy::aux( aux(c.i(),c.state()) + c.data().size() - container_size_, c.i(), c.state() ); #endif container_size_ = c.data().size(); } @@ -177,7 +177,7 @@ senf::detail::ListBParser_Policy::container_policy:: setEnd(container_type const & c, iterator_data & d) const { - return boost::next(AuxPolicy::WrapperPolicy::adjust(c.i(), c.state()),aux(c.i(),c.state())); + return boost::next(AuxPolicy::WrapperPolicy::adjust(c.i(), c.state()),AuxPolicy::WrapperPolicy::aux(c.i(),c.state())); } template diff --git a/senf/Packets/ListParser.ih b/senf/Packets/ListParser.ih index 291c88b..428ff72 100644 --- a/senf/Packets/ListParser.ih +++ b/senf/Packets/ListParser.ih @@ -67,7 +67,7 @@ namespace detail { private: friend class boost::iterator_core_access; - template friend class ListParser_Container; + friend class ListParser_Container; value_type dereference() const; bool equal(ListParser_Iterator const & other) const; diff --git a/senf/Packets/MPEGDVBBundle/MPESection.hh b/senf/Packets/MPEGDVBBundle/MPESection.hh index a384c2e..0286242 100644 --- a/senf/Packets/MPEGDVBBundle/MPESection.hh +++ b/senf/Packets/MPEGDVBBundle/MPESection.hh @@ -103,7 +103,7 @@ namespace senf { UInt32Parser crc() const { return parse( data().size()-4 ); } boost::uint32_t calcCrc() const; - friend class MPESectionType; + friend struct MPESectionType; private: typedef boost::crc_optimal<32, 0x04C11DB7, 0xFFFFFFFF, 0, false, false> crc32_t; diff --git a/senf/Packets/Packet.test.cc b/senf/Packets/Packet.test.cc index c714924..776dbfd 100644 --- a/senf/Packets/Packet.test.cc +++ b/senf/Packets/Packet.test.cc @@ -149,14 +149,6 @@ namespace { std::ostream & operator<<(std::ostream & os, ComplexEmptyAnnotation const & v) { os << "(empty)"; return os; } - struct InvalidAnnotation - { - std::string value; - }; - - std::ostream & operator<<(std::ostream & os, InvalidAnnotation const & v) - { os << v.value; return os; } - } SENF_AUTO_UNIT_TEST(packet) @@ -388,6 +380,16 @@ SENF_AUTO_UNIT_TEST(packetAnnotation) #ifdef COMPILE_CHECK +namespace { + struct InvalidAnnotation + { + std::string value; + }; + + std::ostream & operator<<(std::ostream & os, InvalidAnnotation const & v) + { os << v.value; return os; } +} + COMPILE_FAIL(invalidAnnotation) { #if 0 // The traits check fails for user defined but trivial constructors so ... diff --git a/senf/Packets/PacketInterpreter.ct b/senf/Packets/PacketInterpreter.ct index 1225872..3499dd3 100644 --- a/senf/Packets/PacketInterpreter.ct +++ b/senf/Packets/PacketInterpreter.ct @@ -180,7 +180,7 @@ senf::PacketInterpreter::createInsertBefore(PacketInterpreterBase::p // virtual interface template -prefix_ typename senf::PacketInterpreter::optional_range +prefix_ senf::PacketInterpreterBase::optional_range senf::PacketInterpreter::v_nextPacketRange() { return type::nextPacketRange(ConcretePacket(ptr(this))); @@ -223,14 +223,14 @@ prefix_ senf::TypeIdValue senf::PacketInterpreter::v_type() } template -prefix_ typename senf::PacketInterpreter::factory_t +prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreter::v_factory() { return factory(); } template -prefix_ typename senf::PacketInterpreter::factory_t +prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreter::v_nextPacketType() { return type::nextPacketType(ConcretePacket(ptr(this))); diff --git a/senf/Packets/PacketInterpreter.cti b/senf/Packets/PacketInterpreter.cti index 459580b..e4604e4 100644 --- a/senf/Packets/PacketInterpreter.cti +++ b/senf/Packets/PacketInterpreter.cti @@ -59,7 +59,7 @@ prefix_ Annotation & senf::PacketInterpreterBase::annotation() // senf::PacketInterpreter template -prefix_ typename senf::PacketInterpreter::factory_t +prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreter::factory() { return & factory_; @@ -177,14 +177,14 @@ senf::PacketInterpreter::PacketInterpreter(detail::PacketImpl * impl // PacketType access template -prefix_ typename senf::PacketInterpreter::size_type +prefix_ senf::PacketInterpreterBase::size_type senf::PacketInterpreter::initSize() { return type::initSize(); } template -prefix_ typename senf::PacketInterpreter::size_type +prefix_ senf::PacketInterpreterBase::size_type senf::PacketInterpreter::initHeadSize() { size_type sz (type::initHeadSize()); diff --git a/senf/Packets/PacketInterpreter.hh b/senf/Packets/PacketInterpreter.hh index 5696bd2..d7fb09b 100644 --- a/senf/Packets/PacketInterpreter.hh +++ b/senf/Packets/PacketInterpreter.hh @@ -47,7 +47,11 @@ namespace senf { template class PacketInterpreter; + + void intrusive_ptr_add_ref(PacketInterpreterBase const * p); + void intrusive_ptr_release(PacketInterpreterBase const * p); + /** \brief Internal: Base packet interpreter class \internal @@ -232,16 +236,13 @@ namespace senf { friend class detail::PacketImpl; friend class intrusive_refcount_base; template friend class PacketInterpreter; - friend class detail::packet::test::TestDriver; + friend struct detail::packet::test::TestDriver; friend class PacketParserBase; friend void senf::intrusive_ptr_add_ref(PacketInterpreterBase const *); friend void senf::intrusive_ptr_release(PacketInterpreterBase const *); }; - void intrusive_ptr_add_ref(PacketInterpreterBase const * p); - void intrusive_ptr_release(PacketInterpreterBase const * p); - /** \brief Internal: Concrete packet interpreter \internal @@ -401,9 +402,9 @@ namespace senf { static const FactoryImpl factory_; - friend class detail::packet::test::TestDriver; + friend struct detail::packet::test::TestDriver; friend class PacketInterpreterBase; - friend class FactoryImpl; + friend struct FactoryImpl; }; /** \brief Invalid packet chain operation diff --git a/senf/Packets/PacketParser.hh b/senf/Packets/PacketParser.hh index fb41642..3f09e61 100644 --- a/senf/Packets/PacketParser.hh +++ b/senf/Packets/PacketParser.hh @@ -388,7 +388,7 @@ namespace senf { PacketData * data_; template friend class SafePacketParserWrapper; - friend class ParserProtector; + friend struct ParserProtector; }; /** \brief Return raw size parsed by the given parser object @@ -408,8 +408,8 @@ namespace senf { template PacketParserBase::size_type bytes(Parser const & p); - namespace detail { template class ParserInitBytes; } - namespace detail { template class ParserIsFixed; } + namespace detail { template struct ParserInitBytes; } + namespace detail { template struct ParserIsFixed; } /** \brief Return number of bytes to allocate to new object of given type diff --git a/senf/Packets/PacketRegistry.ih b/senf/Packets/PacketRegistry.ih index c5d3ac4..322153a 100644 --- a/senf/Packets/PacketRegistry.ih +++ b/senf/Packets/PacketRegistry.ih @@ -120,7 +120,7 @@ namespace detail { std::greater > >, boost::multi_index::ordered_unique< boost::multi_index::tag, - boost::multi_index::mem_fun, + boost::multi_index::const_mem_fun, TypeInfoCompare> > {}; diff --git a/senf/Packets/PacketTypes.hh b/senf/Packets/PacketTypes.hh index 1d6c16b..3672ddf 100644 --- a/senf/Packets/PacketTypes.hh +++ b/senf/Packets/PacketTypes.hh @@ -78,7 +78,7 @@ namespace packet { namespace test { - class TestDriver; + struct TestDriver; }}}} diff --git a/senf/Packets/VariantParser.ct b/senf/Packets/VariantParser.ct index 587b054..34e3866 100644 --- a/senf/Packets/VariantParser.ct +++ b/senf/Packets/VariantParser.ct @@ -43,7 +43,7 @@ prefix_ void senf::VariantParser::init() size_type oldSize( bytes() ); typedef typename boost::mpl::at >::type NewParser; - if (oldSize < senf::init_bytes::value) { + if (oldSize <= senf::init_bytes::value) { data_iterator j (i()); std::advance(j, oldSize); std::fill(i(), j, 0u); diff --git a/senf/Packets/VariantParser.ih b/senf/Packets/VariantParser.ih index f7361e4..039b1a8 100644 --- a/senf/Packets/VariantParser.ih +++ b/senf/Packets/VariantParser.ih @@ -155,7 +155,7 @@ namespace detail { template \ struct BOOST_PP_CAT(name, _key_value_template) \ : public senf::detail::VariantKey {}; \ - template friend class senf::detail::VariantKey; \ + template friend struct senf::detail::VariantKey; \ typedef senf::detail::VariantKeyTransform< \ BOOST_PP_CAT(name,_chooser_value_type), \ boost::mpl::vector< \ diff --git a/senf/Packets/VectorParser.ct b/senf/Packets/VectorParser.ct index 9df474b..dbc2644 100644 --- a/senf/Packets/VectorParser.ct +++ b/senf/Packets/VectorParser.ct @@ -42,7 +42,7 @@ template prefix_ void senf::VectorParser::init() const { - aux(0, i(), state()); + AuxPolicy::aux(0, i(), state()); iterator i (begin()); iterator const e (end()); for (; i!=e; ++i) diff --git a/senf/Packets/VectorParser.cti b/senf/Packets/VectorParser.cti index f6a2650..1a4efe3 100644 --- a/senf/Packets/VectorParser.cti +++ b/senf/Packets/VectorParser.cti @@ -50,7 +50,7 @@ prefix_ senf::VectorParser::VectorParser(AuxPolicy poli {} template -prefix_ typename senf::VectorParser::size_type +prefix_ senf::PacketInterpreterBase::size_type senf::VectorParser::bytes() const { @@ -60,11 +60,11 @@ senf::VectorParser::bytes() // Container interface template -prefix_ typename senf::VectorParser::size_type +prefix_ senf::PacketInterpreterBase::size_type senf::VectorParser::size() const { - return aux(i(),state()); + return AuxPolicy::aux(i(),state()); } template @@ -79,7 +79,7 @@ prefix_ typename senf::VectorParser::iterator senf::VectorParser::begin() const { - return iterator(adjust(i(),state()),state()); + return iterator(AuxPolicy::adjust(i(),state()),state()); } template @@ -191,7 +191,7 @@ prefix_ typename senf::VectorParser_Container::size_typ senf::VectorParser_Container::size() const { - return aux(i(),state()); + return AuxPolicy::WrapperPolicy::aux(i(),state()); } template @@ -206,7 +206,7 @@ prefix_ typename senf::VectorParser_Container::iterator senf::VectorParser_Container::begin() const { - return iterator(adjust(i(),state()),state()); + return iterator( AuxPolicy::WrapperPolicy::adjust(i(),state()),state()); } template @@ -347,7 +347,7 @@ senf::VectorParser_Container::bytes() template prefix_ void senf::VectorParser_Container::setSize(size_type value) { - aux(value, i(),state()); + AuxPolicy::WrapperPolicy::aux(value, i(),state()); } //-///////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/senf/Scheduler/FIFORunner.hh b/senf/Scheduler/FIFORunner.hh index 3265fc1..733d05a 100644 --- a/senf/Scheduler/FIFORunner.hh +++ b/senf/Scheduler/FIFORunner.hh @@ -53,7 +53,7 @@ namespace detail { : public singleton { public: - struct TaskInfo; + class TaskInfo; private: struct TaskListTag; diff --git a/senf/Scheduler/FdEvent.hh b/senf/Scheduler/FdEvent.hh index 8d3209d..24c4997 100644 --- a/senf/Scheduler/FdEvent.hh +++ b/senf/Scheduler/FdEvent.hh @@ -170,7 +170,7 @@ namespace scheduler { int events_; int signaledEvents_; - friend class detail::FdSetCompare; + friend struct detail::FdSetCompare; friend class detail::FdDispatcher; friend class detail::FileDispatcher; }; diff --git a/senf/Scheduler/SignalEvent.hh b/senf/Scheduler/SignalEvent.hh index e9fa890..f2d3b45 100644 --- a/senf/Scheduler/SignalEvent.hh +++ b/senf/Scheduler/SignalEvent.hh @@ -51,7 +51,7 @@ namespace scheduler { typedef boost::intrusive::iset_base_hook SignalSetBase; struct SignalSetCompare; struct FindNumericSignal; - struct SignalDispatcher; + class SignalDispatcher; } /** \brief UNIX signal event @@ -108,8 +108,8 @@ namespace scheduler { Callback cb_; siginfo_t siginfo_; - friend class detail::SignalSetCompare; - friend class detail::FindNumericSignal; + friend struct detail::SignalSetCompare; + friend struct detail::FindNumericSignal; friend class detail::SignalDispatcher; }; diff --git a/senf/Scheduler/TimerEvent.hh b/senf/Scheduler/TimerEvent.hh index fcf20d0..396d8fd 100644 --- a/senf/Scheduler/TimerEvent.hh +++ b/senf/Scheduler/TimerEvent.hh @@ -131,7 +131,7 @@ namespace scheduler { ClockService::clock_type timeout_; friend class detail::TimerDispatcher; - friend class detail::TimerSetCompare; + friend struct detail::TimerSetCompare; }; }} diff --git a/senf/Scheduler/TimerEvent.test.cc b/senf/Scheduler/TimerEvent.test.cc index 878b740..5f47c3c 100644 --- a/senf/Scheduler/TimerEvent.test.cc +++ b/senf/Scheduler/TimerEvent.test.cc @@ -117,21 +117,21 @@ namespace { tm.timeout(randomDelay()); } - void preCb() - { - haveCb = false; - } - - void postCb() - { - if (! haveCb) - std::cerr << senf::scheduler::now() << '\n'; - } - - void idleCb(senf::scheduler::TimerEvent & tm) - { - tm.timeout( senf::scheduler::now()); - } +// void preCb() +// { +// haveCb = false; +// } +// +// void postCb() +// { +// if (! haveCb) +// std::cerr << senf::scheduler::now() << '\n'; +// } +// +// void idleCb(senf::scheduler::TimerEvent & tm) +// { +// tm.timeout( senf::scheduler::now()); +// } void jitterTest() { diff --git a/senf/Socket/ClientSocketHandle.cti b/senf/Socket/ClientSocketHandle.cti index 7ab7a70..66d8d83 100644 --- a/senf/Socket/ClientSocketHandle.cti +++ b/senf/Socket/ClientSocketHandle.cti @@ -156,12 +156,12 @@ senf::ClientSocketHandle::operator=(ClientSocketHandle oth // senf::ClientSocketHandle::read #ifndef DOXYGEN + template template -prefix_ typename boost::range_iterator::type -senf::ClientSocketHandle:: -read(ForwardWritableRange const & range, - typename boost::disable_if< boost::is_convertible >::type *) +prefix_ typename boost::disable_if, +typename boost::range_iterator::type>::type +senf::ClientSocketHandle::read(ForwardWritableRange const & range) { return detail::ReadRange< ClientSocketHandle, @@ -183,10 +183,9 @@ read(ForwardWritableRange const & range) #ifndef DOXYGEN template template -prefix_ typename boost::range_iterator::type -senf::ClientSocketHandle:: -read(ForwardWritableRange & range, - typename boost::disable_if< boost::is_convertible >::type *) +prefix_ typename boost::disable_if, +typename boost::range_iterator::type>::type +senf::ClientSocketHandle::read(ForwardWritableRange & range) { return detail::ReadRange< ClientSocketHandle, diff --git a/senf/Socket/ClientSocketHandle.hh b/senf/Socket/ClientSocketHandle.hh index 67539b3..6c8fb93 100644 --- a/senf/Socket/ClientSocketHandle.hh +++ b/senf/Socket/ClientSocketHandle.hh @@ -181,12 +181,14 @@ namespace senf { \c recv. */ std::string read (unsigned limit=0); - template + # ifndef DOXYGEN - typename boost::range_iterator::type - read (ForwardWritableRange const & range, - typename boost::disable_if< boost::is_convertible >::type * = 0); + template + typename boost::disable_if< boost::is_convertible, + typename boost::range_iterator::type>::type + read(ForwardWritableRange const & range); # else + template typename boost::range_iterator::type read (ForwardWritableRange const & range); ///< Read data into range @@ -204,9 +206,9 @@ namespace senf { # endif # ifndef DOXYGEN template - typename boost::range_iterator::type - read (ForwardWritableRange & range, - typename boost::disable_if< boost::is_convertible >::type * = 0); + typename boost::disable_if< boost::is_convertible, + typename boost::range_iterator::type>::type + read(ForwardWritableRange & range); # else template typename boost::range_iterator::type diff --git a/senf/Socket/NetdeviceController.hh b/senf/Socket/NetdeviceController.hh index 7c146f7..98897ff 100644 --- a/senf/Socket/NetdeviceController.hh +++ b/senf/Socket/NetdeviceController.hh @@ -43,7 +43,7 @@ struct ifreq; namespace senf { - class MACAddress; + struct MACAddress; /** \brief Netdevice Controller diff --git a/senf/Socket/ProtocolClientSocketHandle.cti b/senf/Socket/ProtocolClientSocketHandle.cti index 4a98bc1..5a3c70e 100644 --- a/senf/Socket/ProtocolClientSocketHandle.cti +++ b/senf/Socket/ProtocolClientSocketHandle.cti @@ -85,10 +85,10 @@ template prefix_ senf::ProtocolClientSocketHandle senf::ProtocolClientSocketHandle::cast_dynamic(FileHandle handle) { - ClientSocketHandle h( + ClientSocketHandle h ( ClientSocketHandle::cast_dynamic(handle)); // throw std::bad_cast if the protocol is invalid - dynamic_cast(static_cast(FileHandle::body(h)).protocol()); + IGNORE( dynamic_cast(static_cast(FileHandle::body(h)).protocol()) ); return cast_static(handle); } diff --git a/senf/Socket/ProtocolServerSocketHandle.cti b/senf/Socket/ProtocolServerSocketHandle.cti index 5b02eae..2e99444 100644 --- a/senf/Socket/ProtocolServerSocketHandle.cti +++ b/senf/Socket/ProtocolServerSocketHandle.cti @@ -85,10 +85,10 @@ template prefix_ senf::ProtocolServerSocketHandle senf::ProtocolServerSocketHandle::cast_dynamic(FileHandle handle) { - ServerSocketHandle h( + ServerSocketHandle h ( ServerSocketHandle::cast_dynamic(handle)); // throw std::bad_cast if the protocol is invalid - dynamic_cast(static_cast(FileHandle::body(h)).protocol()); + IGNORE( dynamic_cast(static_cast(FileHandle::body(h)).protocol()) ); return cast_static(handle); } diff --git a/senf/Socket/Protocols/INet/INet6Address.hh b/senf/Socket/Protocols/INet/INet6Address.hh index 505ca3d..ea6767e 100644 --- a/senf/Socket/Protocols/INet/INet6Address.hh +++ b/senf/Socket/Protocols/INet/INet6Address.hh @@ -48,8 +48,8 @@ namespace senf { - class EUI64; - class MACAddress; + struct EUI64; + struct MACAddress; class INet6Network; /** \brief INet6 network address diff --git a/senf/Socket/Protocols/INet/RawINetSocketHandle.test.cc b/senf/Socket/Protocols/INet/RawINetSocketHandle.test.cc index 2526f54..cbac5cb 100644 --- a/senf/Socket/Protocols/INet/RawINetSocketHandle.test.cc +++ b/senf/Socket/Protocols/INet/RawINetSocketHandle.test.cc @@ -29,62 +29,19 @@ #include #include -#include #include #include #include #include "RawINetSocketHandle.hh" -#include +#include "net.test.hh" #include #include -namespace { - - void error(char const * fn, char const * proc="") - { - std::cerr << "\n" << proc << ((*proc)?": ":"") << fn << ": " << strerror(errno) << std::endl; - } - - void fail(char const * proc, char const * fn) - { - error(fn,proc); - _exit(1); - } - - int server_pid = 0; - - void start(void (*fn)()) - { - server_pid = ::fork(); - if (server_pid < 0) BOOST_FAIL("fork()"); - if (server_pid == 0) { - (*fn)(); - _exit(0); - } - } - - void wait() - { - int status; - if (waitpid(server_pid,&status,0)<0) - BOOST_FAIL("waitpid()"); - BOOST_CHECK_EQUAL( status , 0 ); - } - - void stop() - { - if (server_pid) { - kill(server_pid,9); - wait(); - server_pid = 0; - } - } - -} - //-///////////////////////////////////////////////////////////////////////////////////////////////// +using namespace senf::test; + namespace { void server_v4() //listen for packets with proto=47 (GRE) and resend them with proto=48 diff --git a/senf/Socket/Protocols/INet/TCPSocketHandle.test.cc b/senf/Socket/Protocols/INet/TCPSocketHandle.test.cc index 4bb827b..ccb413a 100644 --- a/senf/Socket/Protocols/INet/TCPSocketHandle.test.cc +++ b/senf/Socket/Protocols/INet/TCPSocketHandle.test.cc @@ -48,7 +48,7 @@ #define prefix_ //-///////////////////////////////////////////////////////////////////////////////////////////////// -//-///////////////////////////////////////////////////////////////////////////////////////////////// +using namespace senf::test; namespace { diff --git a/senf/Socket/Protocols/INet/UDPSocketHandle.test.cc b/senf/Socket/Protocols/INet/UDPSocketHandle.test.cc index 2efb5a4..2d4186a 100644 --- a/senf/Socket/Protocols/INet/UDPSocketHandle.test.cc +++ b/senf/Socket/Protocols/INet/UDPSocketHandle.test.cc @@ -48,7 +48,7 @@ #define prefix_ //-///////////////////////////////////////////////////////////////////////////////////////////////// -//-///////////////////////////////////////////////////////////////////////////////////////////////// +using namespace senf::test; namespace { @@ -75,28 +75,28 @@ namespace { if (close(sock) < 0) fail("server_v4","close()"); } - void server_v6() - { - int sock = socket(PF_INET6,SOCK_DGRAM,0); - if (sock<0) fail("server_v6","socket()"); - struct sockaddr_in6 sin; - ::memset(&sin,0,sizeof(sin)); - sin.sin6_family = AF_INET6; - sin.sin6_port = htons(port(0)); - sin.sin6_addr = in6addr_loopback; - if (bind(sock,(struct sockaddr *)&sin,sizeof(sin))<0) fail("server_v6","bind()"); - - sin.sin6_port = htons(port(1)); - char buffer[1024]; - while (1) { - int n = read(sock,buffer,1024); - if (n == 4 && strncmp(buffer,"QUIT",4) == 0) - break; - sendto(sock,buffer,n,0,(struct sockaddr *)&sin,sizeof(sin)); - } - - if (close(sock) < 0) fail("server_v6","close()"); - } +// void server_v6() +// { +// int sock = socket(PF_INET6,SOCK_DGRAM,0); +// if (sock<0) fail("server_v6","socket()"); +// struct sockaddr_in6 sin; +// ::memset(&sin,0,sizeof(sin)); +// sin.sin6_family = AF_INET6; +// sin.sin6_port = htons(port(0)); +// sin.sin6_addr = in6addr_loopback; +// if (bind(sock,(struct sockaddr *)&sin,sizeof(sin))<0) fail("server_v6","bind()"); +// +// sin.sin6_port = htons(port(1)); +// char buffer[1024]; +// while (1) { +// int n = read(sock,buffer,1024); +// if (n == 4 && strncmp(buffer,"QUIT",4) == 0) +// break; +// sendto(sock,buffer,n,0,(struct sockaddr *)&sin,sizeof(sin)); +// } +// +// if (close(sock) < 0) fail("server_v6","close()"); +// } } diff --git a/senf/Socket/Protocols/INet/net.test.cc b/senf/Socket/Protocols/INet/net.test.cc new file mode 100644 index 0000000..aee08d1 --- /dev/null +++ b/senf/Socket/Protocols/INet/net.test.cc @@ -0,0 +1,124 @@ +// $Id$ +// +// Copyright (C) 2009 +// 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 net.test public header */ + +#include "net.test.hh" + +// Custom includes +#include +#include +#include +#include +#include +#include +#include +#include + +//-///////////////////////////////////////////////////////////////////////////////////////////////// +namespace { + int base_pid = 0; + int server_pid = 0; +} + +void senf::test::error(char const * fn, char const * proc) +{ + std::cerr << "\n" << proc << ((*proc)?": ":"") << fn << ": " << strerror(errno) << std::endl; +} + +void senf::test::fail(char const * proc, char const * fn) +{ + error(fn,proc); + _exit(1); +} + +void senf::test::start(void (*fn)()) +{ + if (! base_pid) + base_pid = ::getpid(); + server_pid = ::fork(); + if (server_pid < 0) BOOST_FAIL("fork()"); + if (server_pid == 0) { + signal(SIGCHLD, SIG_IGN); + (*fn)(); + _exit(0); + } + signal(SIGCHLD, SIG_DFL); + sleep(1); +} + +void senf::test::wait() +{ + int status; + if (waitpid(server_pid,&status,0)<0) + BOOST_FAIL("waitpid()"); + BOOST_CHECK_EQUAL( status , 0 ); +} + +void senf::test::stop() +{ + if (server_pid) { + kill(server_pid,9); + wait(); + server_pid = 0; + } +} + +unsigned senf::test::port(unsigned i) +{ + if (! base_pid) + base_pid = ::getpid(); + return 23456u + (((base_pid^(base_pid>>8)^(base_pid>>16)^(base_pid>>24))&0xff)<<2) + i; +} + +std::string senf::test::localhost4str(unsigned i) +{ + return (boost::format("localhost:%d") % port(i)).str(); +} + +std::string senf::test::localhost6str(unsigned i) +{ + return (boost::format("[::1]:%d") % port(i)).str(); +} + + +//-///////////////////////////////////////////////////////////////////////////////////////////////// +//#include "net.test.cci" +//#include "net.test.ct" +//#include "net.test.cti" + + +// 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/Socket/Protocols/INet/net.test.hh b/senf/Socket/Protocols/INet/net.test.hh index 325a9bf..7818a5e 100644 --- a/senf/Socket/Protocols/INet/net.test.hh +++ b/senf/Socket/Protocols/INet/net.test.hh @@ -32,78 +32,30 @@ #define HH_SENF_senf_Socket_Protocols_INet_net_test_ 1 // Custom includes -#include -#include +#include -//#include "net.test.mpp" //-///////////////////////////////////////////////////////////////////////////////////////////////// -namespace { - - void error(char const * fn, char const * proc="") - { - std::cerr << "\n" << proc << ((*proc)?": ":"") << fn << ": " << strerror(errno) << std::endl; - } - - void fail(char const * proc, char const * fn) - { - error(fn,proc); - _exit(1); - } - - int base_pid = 0; - int server_pid = 0; - - void start(void (*fn)()) - { - if (! base_pid) - base_pid = ::getpid(); - server_pid = ::fork(); - if (server_pid < 0) BOOST_FAIL("fork()"); - if (server_pid == 0) { - signal(SIGCHLD, SIG_IGN); - (*fn)(); - _exit(0); - } - signal(SIGCHLD, SIG_DFL); - sleep(1); - } - - void wait() - { - int status; - if (waitpid(server_pid,&status,0)<0) - BOOST_FAIL("waitpid()"); - BOOST_CHECK_EQUAL( status , 0 ); - } - - void stop() - { - if (server_pid) { - kill(server_pid,9); - wait(); - server_pid = 0; - } - } - - unsigned port(unsigned i) - { - if (! base_pid) - base_pid = ::getpid(); - return 23456u + (((base_pid^(base_pid>>8)^(base_pid>>16)^(base_pid>>24))&0xff)<<2) + i; - } - - std::string localhost4str(unsigned i) - { - return (boost::format("localhost:%d") % port(i)).str(); - } - - std::string localhost6str(unsigned i) - { - return (boost::format("[::1]:%d") % port(i)).str(); - } - -} +namespace senf { +namespace test { + + void error(char const * fn, char const * proc=""); + + void fail(char const * proc, char const * fn); + + void start(void (*fn)()); + + void wait(); + + void stop(); + + unsigned port(unsigned i); + + std::string localhost4str(unsigned i); + + std::string localhost6str(unsigned i); + +}} //-///////////////////////////////////////////////////////////////////////////////////////////////// //#include "net.test.cci" diff --git a/senf/Socket/Protocols/Raw/EUI64.hh b/senf/Socket/Protocols/Raw/EUI64.hh index 2acb090..0866f85 100644 --- a/senf/Socket/Protocols/Raw/EUI64.hh +++ b/senf/Socket/Protocols/Raw/EUI64.hh @@ -43,7 +43,7 @@ namespace senf { - class MACAddress; + struct MACAddress; /** \brief EUI-64 data type @@ -78,22 +78,16 @@ namespace senf { \ingroup addr_group */ - class EUI64 + struct EUI64 : public boost::array, public senf::comparable_safe_bool { - public: //-//////////////////////////////////////////////////////////////////////// ///\name Structors and default members //\{ static EUI64 const None; ///< The empty (0) address - // default copy constructor - // default copy assignment - // default destructor - // no conversion constructors - explicit EUI64(boost::uint64_t v=0u); ///< Construct EUI-64 explicit EUI64(senf::NoInit_t); ///< Construct uninitialized EUI-64 diff --git a/senf/Socket/Protocols/Raw/MACAddress.hh b/senf/Socket/Protocols/Raw/MACAddress.hh index 154d9f0..c28c048 100644 --- a/senf/Socket/Protocols/Raw/MACAddress.hh +++ b/senf/Socket/Protocols/Raw/MACAddress.hh @@ -45,7 +45,7 @@ namespace senf { - class EUI64; + struct EUI64; /** \brief Ethernet MAC address diff --git a/senf/Socket/SocketHandle.cc b/senf/Socket/SocketHandle.cc index 7f42415..2eea009 100644 --- a/senf/Socket/SocketHandle.cc +++ b/senf/Socket/SocketHandle.cc @@ -72,16 +72,6 @@ prefix_ bool senf::SocketBody::v_eof() //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::detail::StateMapOrdering -namespace { - bool contains(std::string::const_iterator b, std::string::const_iterator e, char c) - { - for (; b != e; ++b) - if (*b == c) - return true; - return false; - } -} - prefix_ std::string senf::detail::dumpState(SocketStateMap const & map) { std::stringstream s; diff --git a/senf/Socket/SocketHandle.cti b/senf/Socket/SocketHandle.cti index b2d9f7c..73c808f 100644 --- a/senf/Socket/SocketHandle.cti +++ b/senf/Socket/SocketHandle.cti @@ -164,7 +164,7 @@ prefix_ bool senf::check_socket_cast(Source handle) // for two reasons: // a) since the handle is passed back by value, we cannot return // something like a null handle - // b) it is simpler to implement cast_dynamic throwig bad_cast on + // b) it is simpler to implement cast_dynamic throwing bad_cast on // failure than implementing cast_check try { Target::cast_dynamic(handle); diff --git a/senf/Socket/SocketProtocol.hh b/senf/Socket/SocketProtocol.hh index 4d6346c..d12c562 100644 --- a/senf/Socket/SocketProtocol.hh +++ b/senf/Socket/SocketProtocol.hh @@ -99,7 +99,7 @@ namespace senf { /// \addtogroup protocol_group //\{ - class SocketPolicyBase; + struct SocketPolicyBase; /** \brief Socket Protocol base class diff --git a/senf/Utils/Console/ConfigFile.hh b/senf/Utils/Console/ConfigFile.hh index 9b1504a..b4237fd 100644 --- a/senf/Utils/Console/ConfigFile.hh +++ b/senf/Utils/Console/ConfigFile.hh @@ -70,7 +70,7 @@ namespace console { ///\name Structors and default members //\{ - explicit ConfigFile(std::string const & filename, DirectoryNode & root = root()); + explicit ConfigFile(std::string const & filename, DirectoryNode & root = senf::console::root()); ///< Create ConfigFile object for \a filename /**< The \a filename configuration file will be parsed using parse() calls. All configuration statements will be @@ -94,7 +94,7 @@ namespace console { \related ConfigFile */ - void parseFile(std::string const & filename, DirectoryNode & root = root()); + void parseFile(std::string const & filename, DirectoryNode & root = senf::console::root()); /** \brief ConfigBundle source reading a configuration file diff --git a/senf/Utils/Console/OverloadedCommand.cc b/senf/Utils/Console/OverloadedCommand.cc index e311adf..3c8f47b 100644 --- a/senf/Utils/Console/OverloadedCommand.cc +++ b/senf/Utils/Console/OverloadedCommand.cc @@ -120,7 +120,7 @@ prefix_ void senf::console::OverloadedCommandNode::v_help(std::ostream & os) for (; k != k_end; ++k) if (k->name == arg.name && k->defaultValue == arg.defaultValue) { if (! arg.doc.empty() && k->doc.empty()) { - k->doc == arg.doc; + k->doc = arg.doc; haveDocumentedArg = true; } break; diff --git a/senf/Utils/Console/Parse.cc b/senf/Utils/Console/Parse.cc index ff3bc51..e36c7c5 100644 --- a/senf/Utils/Console/Parse.cc +++ b/senf/Utils/Console/Parse.cc @@ -297,9 +297,10 @@ namespace classic { #endif template <> - struct position_policy + class position_policy : public position_policy { + public: typedef position_policy Base; void next_line(senf::console::detail::FilePositionWithIndex & pos) @@ -481,27 +482,27 @@ senf::console::CommandParser::parseIncremental(std::string const & commands, Cal prefix_ bool senf::console::CommandParser::isSpecialChar(char ch) { - return Impl::Grammar::special_p.test(ch); + return Impl::Grammar::special_p().test(ch); } prefix_ bool senf::console::CommandParser::isPunctuationChar(char ch) { - return Impl::Grammar::punctuation_p.test(ch); + return Impl::Grammar::punctuation_p().test(ch); } prefix_ bool senf::console::CommandParser::isSpaceChar(char ch) { - return Impl::Grammar::space_p.test(ch); + return Impl::Grammar::space_p().test(ch); } prefix_ bool senf::console::CommandParser::isInvalidChar(char ch) { - return Impl::Grammar::invalid_p.test(ch); + return Impl::Grammar::invalid_p().test(ch); } prefix_ bool senf::console::CommandParser::isWordChar(char ch) { - return Impl::Grammar::word_p.test(ch); + return Impl::Grammar::word_p().test(ch); } //-///////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/senf/Utils/Console/Parse.hh b/senf/Utils/Console/Parse.hh index a49c473..4be39ff 100644 --- a/senf/Utils/Console/Parse.hh +++ b/senf/Utils/Console/Parse.hh @@ -211,7 +211,7 @@ namespace senf { namespace console { - namespace detail { class FilePositionWithIndex; } + namespace detail { struct FilePositionWithIndex; } namespace detail { struct ParserAccess; } @@ -656,7 +656,7 @@ namespace console { boost::scoped_ptr impl_; - friend class SetIncremental; + friend struct SetIncremental; }; }} diff --git a/senf/Utils/Console/Parse.ih b/senf/Utils/Console/Parse.ih index 5fc5c5c..a2dc6b3 100644 --- a/senf/Utils/Console/Parse.ih +++ b/senf/Utils/Console/Parse.ih @@ -126,12 +126,30 @@ namespace detail { //-///////////////////////////////////////////////////////////////////////////////////////// // charachter sets - static boost_spirit::chset<> special_p; - static boost_spirit::chset<> punctuation_p; - static boost_spirit::chset<> space_p; - static boost_spirit::chset<> invalid_p; - static boost_spirit::chset<> word_p; - static boost_spirit::distinct_parser<> keyword_p; + static boost_spirit::chset<> & special_p() { + static boost_spirit::chset<> p ("/(){};\""); + return p; + } + static boost_spirit::chset<> & punctuation_p() { + static boost_spirit::chset<> p (",="); + return p; + } + static boost_spirit::chset<> & space_p() { + static boost_spirit::chset<> p (" \t\n\r"); + return p; + } + static boost_spirit::chset<> & invalid_p() { + static boost_spirit::chset<> p ((boost_spirit::chset<>('\0') | boost_spirit::chset<>("\x01-\x20")) - space_p() ); + return p; + } + static boost_spirit::chset<> & word_p() { + static boost_spirit::chset<> p (boost_spirit::anychar_p - special_p() - punctuation_p() - space_p() - invalid_p()); + return p; + } + static boost_spirit::distinct_parser<> & keyword_p() { + static boost_spirit::distinct_parser<> p (word_p() | boost_spirit::ch_p('/')); + return p; + } //-///////////////////////////////////////////////////////////////////////////////////////// // Errors @@ -234,20 +252,20 @@ namespace detail { ; builtin - = self.keyword_p("cd") + = self.keyword_p()("cd") >> path_expected(path) >> eps_p [ bind(&PD::builtin_cd)(d_, path_) ] - | self.keyword_p("ls") + | self.keyword_p()("ls") >> ! path >> eps_p [ bind(&PD::builtin_ls)(d_, path_) ] - | self.keyword_p("ll") + | self.keyword_p()("ll") >> ! path >> eps_p [ bind(&PD::builtin_ll)(d_, path_) ] - | self.keyword_p("lr") + | self.keyword_p()("lr") >> ! path >> eps_p [ bind(&PD::builtin_lr)(d_, path_) ] - | self.keyword_p("exit") [ bind(&PD::builtin_exit)(d_) ] - | self.keyword_p("help") + | self.keyword_p()("exit") [ bind(&PD::builtin_exit)(d_) ] + | self.keyword_p()("help") >> ! path >> eps_p [ bind(&PD::builtin_help)(d_, path_) ] ; @@ -361,7 +379,7 @@ namespace detail { | ch_p(';') [ token_ = construct_( Token::CommandTerminator, ";") ] - | self.punctuation_p [ token_ = construct_( + | self.punctuation_p() [ token_ = construct_( Token::OtherPunctuation, construct_(1u, arg1), pos_) ] @@ -372,7 +390,7 @@ namespace detail { = eps_p [ pos_ = positionOf(arg1) ] >> lexeme_d [ - (+ self.word_p) [ str_ = construct_(arg1, arg2) ] + (+ self.word_p()) [ str_ = construct_(arg1, arg2) ] ] >> eps_p [ token_ = construct_( Token::Word, @@ -401,12 +419,12 @@ namespace detail { ; skip - = self.space_p | comment_p('#') + = self.space_p() | comment_p('#') ; //-///////////////////////////////////////////////////////////////////////////////// - start_parsers( + this->start_parsers( command, // CommandParser skip, // SkipParser arguments, // ArgumentsParser @@ -435,19 +453,6 @@ namespace detail { }; }; - template boost_spirit::chset<> CommandGrammar::special_p ( - "/(){};\""); - template boost_spirit::chset<> CommandGrammar::punctuation_p ( - ",="); - template boost_spirit::chset<> CommandGrammar::space_p ( - " \t\n\r"); - template boost_spirit::chset<> CommandGrammar::invalid_p ( - (boost_spirit::chset<>('\0') | boost_spirit::chset<>("\x01-\x20")) - space_p ); - template boost_spirit::chset<> CommandGrammar::word_p ( - boost_spirit::anychar_p - special_p - punctuation_p - space_p - invalid_p); - template boost_spirit::distinct_parser<> CommandGrammar::keyword_p ( - word_p | boost_spirit::ch_p('/')); - #endif }}} diff --git a/senf/Utils/Console/ParsedCommand.hh b/senf/Utils/Console/ParsedCommand.hh index 7b34dd9..6a6e56b 100644 --- a/senf/Utils/Console/ParsedCommand.hh +++ b/senf/Utils/Console/ParsedCommand.hh @@ -54,7 +54,7 @@ namespace senf { namespace console { - namespace detail { class ArgumentInfoBase; } + namespace detail { struct ArgumentInfoBase; } /** \brief CommandOverload implementation with automatic argument parsing @@ -552,7 +552,7 @@ namespace console { template friend class ParsedArgumentAttributor; - friend class detail::ParsedCommandAddNodeAccess; + friend struct detail::ParsedCommandAddNodeAccess; }; #ifndef DOXYGEN @@ -573,7 +573,7 @@ namespace console { template friend class ParsedArgumentAttributor; - friend class detail::ParsedCommandAddNodeAccess; + friend struct detail::ParsedCommandAddNodeAccess; }; #endif diff --git a/senf/Utils/Console/ProgramOptions.hh b/senf/Utils/Console/ProgramOptions.hh index f5e1c9d..1a69357 100644 --- a/senf/Utils/Console/ProgramOptions.hh +++ b/senf/Utils/Console/ProgramOptions.hh @@ -77,7 +77,7 @@ namespace console { ///\name Structors and default members //\{ - ProgramOptions(int argc, char const ** argv, DirectoryNode & root = root()); + ProgramOptions(int argc, char const ** argv, DirectoryNode & root = senf::console::root()); ///< Create ProgramOptions parser for given options /**< The given argc/argv values are those passed to main by the operating system. Especially argv[0] is \e not an @@ -118,7 +118,7 @@ namespace console { \related ProgramOptions */ - void parseOptions(int argc, char const ** argv, DirectoryNode & root = root()); + void parseOptions(int argc, char const ** argv, DirectoryNode & root = senf::console::root()); /** \brief ConfigBundle source reading command line options diff --git a/senf/Utils/Console/SysInfo.cc b/senf/Utils/Console/SysInfo.cc index 052d06e..24fe120 100644 --- a/senf/Utils/Console/SysInfo.cc +++ b/senf/Utils/Console/SysInfo.cc @@ -39,7 +39,7 @@ #define prefix_ //-///////////////////////////////////////////////////////////////////////////////////////////////// -prefix_ senf::console::SysInfo::Proxy::Proxy(std::string const & descr, unsigned pos) +prefix_ senf::console::SysInfo::Proxy::Proxy(std::string const & descr, int pos) { SysInfo::instance().addEntry( descr, pos); } @@ -49,7 +49,7 @@ prefix_ senf::console::SysInfo::SysInfo() sysdir().add("info", factory::Command(&SysInfo::dump, this)); } -prefix_ void senf::console::SysInfo::addEntry(std::string const & descr, unsigned pos) +prefix_ void senf::console::SysInfo::addEntry(std::string const & descr, int pos) { if (pos < 0) descr_.push_back( descr); diff --git a/senf/Utils/Console/SysInfo.hh b/senf/Utils/Console/SysInfo.hh index 16970f0..354aa82 100644 --- a/senf/Utils/Console/SysInfo.hh +++ b/senf/Utils/Console/SysInfo.hh @@ -46,11 +46,11 @@ namespace console { friend class singleton; using singleton::instance; - void addEntry(std::string const & descr, unsigned pos=-1); + void addEntry(std::string const & descr, int pos=-1); void dump(std::ostream & os) const; struct Proxy { - Proxy(std::string const & descr, unsigned pos=-1); + Proxy(std::string const & descr, int pos=-1); }; private: diff --git a/senf/Utils/Console/UDPServer.test.cc b/senf/Utils/Console/UDPServer.test.cc index 5c4ec85..c335765 100644 --- a/senf/Utils/Console/UDPServer.test.cc +++ b/senf/Utils/Console/UDPServer.test.cc @@ -62,11 +62,6 @@ namespace { return (boost::format("localhost:%d") % port(i)).str(); } - std::string localhost6str(unsigned i) - { - return (boost::format("[::1]:%d") % port(i)).str(); - } - unsigned nread (0); unsigned flags (0); std::string data; diff --git a/senf/Utils/Logger/AreaRegistry.hh b/senf/Utils/Logger/AreaRegistry.hh index 41640d3..927f922 100644 --- a/senf/Utils/Logger/AreaRegistry.hh +++ b/senf/Utils/Logger/AreaRegistry.hh @@ -91,7 +91,7 @@ namespace log { Registry registry_; friend class senf::singleton; - friend class detail::AreaBase; + friend struct detail::AreaBase; friend class Target; }; diff --git a/senf/Utils/Logger/AreaRegistry.ih b/senf/Utils/Logger/AreaRegistry.ih index bb587d3..73c0662 100644 --- a/senf/Utils/Logger/AreaRegistry.ih +++ b/senf/Utils/Logger/AreaRegistry.ih @@ -47,7 +47,7 @@ namespace log { namespace detail { - class StreamBase; + struct StreamBase; /** \brief Internal: Area base class */ struct AreaBase diff --git a/senf/Utils/Logger/Config.ih b/senf/Utils/Logger/Config.ih index 8ed7edf..9607133 100644 --- a/senf/Utils/Logger/Config.ih +++ b/senf/Utils/Logger/Config.ih @@ -98,11 +98,11 @@ namespace detail { #define SENF_LOG_PREDECL_long(seq) \ BOOST_PP_SEQ_FOLD_RIGHT( SENF_LOG_PREDECL_, \ - class SENF_PP_SEQ_BACK(seq);, \ + struct SENF_PP_SEQ_BACK(seq);, \ BOOST_PP_SEQ_POP_BACK(seq) ) #define SENF_LOG_PREDECL_short(seq) \ - BOOST_PP_IF( SENF_LOG_IS_NA( SENF_PP_SEQ_BACK(seq) ), ; , class SENF_PP_SEQ_BACK(seq); ) + BOOST_PP_IF( SENF_LOG_IS_NA( SENF_PP_SEQ_BACK(seq) ), ; , struct SENF_PP_SEQ_BACK(seq); ) #define SENF_LOG_PREDECL(seq) \ BOOST_PP_CAT(SENF_LOG_PREDECL_, \ diff --git a/senf/Utils/Logger/Parameters.ih b/senf/Utils/Logger/Parameters.ih index 7c16f3d..9ea6675 100644 --- a/senf/Utils/Logger/Parameters.ih +++ b/senf/Utils/Logger/Parameters.ih @@ -50,16 +50,16 @@ namespace senf { namespace log { - class DefaultArea; - class Debug; - class NONE; + struct DefaultArea; + struct Debug; + struct NONE; namespace detail { - class StreamBase; - class AreaBase; - class LevelBase; - class AliasBase; + struct StreamBase; + struct AreaBase; + struct LevelBase; + struct AliasBase; /// Internal: Parameter extractor template diff --git a/senf/Utils/Logger/StreamRegistry.hh b/senf/Utils/Logger/StreamRegistry.hh index acabace..0dcf900 100644 --- a/senf/Utils/Logger/StreamRegistry.hh +++ b/senf/Utils/Logger/StreamRegistry.hh @@ -84,7 +84,7 @@ namespace log { Registry registry_; friend class senf::singleton; - friend class detail::StreamBase; + friend struct detail::StreamBase; friend class Target; }; diff --git a/senf/Utils/Logger/SyslogUDPTarget.test.cc b/senf/Utils/Logger/SyslogUDPTarget.test.cc index e496935..94d9c8b 100644 --- a/senf/Utils/Logger/SyslogUDPTarget.test.cc +++ b/senf/Utils/Logger/SyslogUDPTarget.test.cc @@ -55,16 +55,6 @@ namespace { return 23456u + (((base_pid^(base_pid>>8)^(base_pid>>16)^(base_pid>>24))&0xff)<<2) + i; } - std::string localhost4str(unsigned i) - { - return (boost::format("localhost:%d") % port(i)).str(); - } - - std::string localhost6str(unsigned i) - { - return (boost::format("[::1]:%d") % port(i)).str(); - } - } SENF_AUTO_UNIT_TEST(syslogUDPTarget) diff --git a/senf/Utils/Logger/Target.hh b/senf/Utils/Logger/Target.hh index 8fa2177..2f91814 100644 --- a/senf/Utils/Logger/Target.hh +++ b/senf/Utils/Logger/Target.hh @@ -56,7 +56,7 @@ namespace senf { namespace log { namespace detail { class TargetRegistry; } - namespace detail { class AreaBase; } + namespace detail { struct AreaBase; } namespace detail { struct LogParameters; } namespace detail { struct StreamBase; } @@ -409,7 +409,7 @@ namespace log { console::LazyDirectory consoleDir_; - friend class detail::AreaBase; + friend struct detail::AreaBase; friend class detail::TargetRegistry; }; diff --git a/senf/Utils/Termlib/Telnet.hh b/senf/Utils/Termlib/Telnet.hh index 8314743..e8d41ca 100644 --- a/senf/Utils/Termlib/Telnet.hh +++ b/senf/Utils/Termlib/Telnet.hh @@ -332,7 +332,7 @@ namespace term { ClockService::clock_type requestTimeout_; scheduler::TimerEvent timeout_; - friend class TelnetHandler; + friend struct TelnetHandler; }; /** \brief Telnet handler base class diff --git a/senf/Utils/intrusive_refcount.hh b/senf/Utils/intrusive_refcount.hh index e7ba553..897b21b 100644 --- a/senf/Utils/intrusive_refcount.hh +++ b/senf/Utils/intrusive_refcount.hh @@ -40,6 +40,12 @@ namespace senf { template class intrusive_refcount_t; + + template + void intrusive_ptr_add_ref(intrusive_refcount_t const * p); + template + void intrusive_ptr_release(intrusive_refcount_t const * p); + /** \brief Reference count mixin interface baseclass @@ -162,11 +168,6 @@ namespace senf { intrusive_refcount(); }; - template - void intrusive_ptr_add_ref(intrusive_refcount_t const * p); - template - void intrusive_ptr_release(intrusive_refcount_t const * p); - } //-///////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/senf/Utils/mpl.test.cc b/senf/Utils/mpl.test.cc index 806e39f..01ac225 100644 --- a/senf/Utils/mpl.test.cc +++ b/senf/Utils/mpl.test.cc @@ -91,7 +91,7 @@ namespace { # define Begin() SENF_MPL_SLOT_DEF(accum, 0) # define Add(n) SENF_MPL_SLOT_SET(accum, SENF_MPL_SLOT_GET(accum)+n) -# define End() BOOST_STATIC_CONSTANT(unsigned, total = SENF_MPL_SLOT_GET(accum)) +# define End() BOOST_STATIC_CONSTANT(unsigned long, total = SENF_MPL_SLOT_GET(accum)) struct Test { diff --git a/senf/Utils/senfassert.hh b/senf/Utils/senfassert.hh index ef27006..7b86d5e 100644 --- a/senf/Utils/senfassert.hh +++ b/senf/Utils/senfassert.hh @@ -32,6 +32,7 @@ #define HH_SENF_Utils_senfassert_ 1 // Custom includes +#include "IgnoreValue.hh" //#include "senfassert.mpp" //-///////////////////////////////////////////////////////////////////////////////////////////////// @@ -39,7 +40,7 @@ #ifndef SENF_DEBUG # define SENF_ASSERT(x, comment) -# define SENF_ASSERT_EXPRESSION(expression, comment) expression +# define SENF_ASSERT_EXPRESSION(expression, comment) senf::IGNORE( expression ) #else diff --git a/site_scons/SparseTestHack.py b/site_scons/SparseTestHack.py index 7242786..56cbada 100644 --- a/site_scons/SparseTestHack.py +++ b/site_scons/SparseTestHack.py @@ -81,7 +81,7 @@ def setup(env): env['BUILDERS']['BoostUnitTest'] = AutoObjectBoostUnitTest env['_UNIT_TEST_LIST'] = [] env.Append(EXTRA_LIBS = [ '$BOOSTREGEXLIB', '$BOOSTSIGNALSLIB', - '$BOOSTFSLIB', '$BOOSTSYSTEMLIB' ]) + '$BOOSTFSLIB', '$BOOSTSYSTEMLIB', '$BOOSTDATETIMELIB' ]) # This needs to be called after all build targets have been set # up. This is important since the list of object targets needs to be diff --git a/site_scons/senfutil.py b/site_scons/senfutil.py index 9ec7dc6..8216902 100644 --- a/site_scons/senfutil.py +++ b/site_scons/senfutil.py @@ -169,7 +169,8 @@ def SetupForSENF(env, senf_path = [], flavor=None): CXXFLAGS = [ '-Wno-long-long', '-fno-strict-aliasing' ], LINKFLAGS = [ '-rdynamic' ], LIBS = [ 'senf$LIBADDSUFFIX', 'rt', '$BOOSTREGEXLIB', - '$BOOSTSIGNALSLIB', '$BOOSTFSLIB', '$BOOSTSYSTEMLIB' ], + '$BOOSTSIGNALSLIB', '$BOOSTFSLIB', '$BOOSTSYSTEMLIB', + '$BOOSTDATETIMELIB' ], ) try: diff --git a/site_scons/site_tools/Boost.py b/site_scons/site_tools/Boost.py index 202ed96..326bf5f 100644 --- a/site_scons/site_tools/Boost.py +++ b/site_scons/site_tools/Boost.py @@ -212,6 +212,7 @@ def generate(env): BOOSTFSLIB = 'boost_filesystem$_BOOST_VARIANT', BOOSTIOSTREAMSLIB = 'boost_iostreams$_BOOST_VARIANT', BOOSTSIGNALSLIB = 'boost_signals$_BOOST_VARIANT', + BOOSTDATETIMELIB = 'boost_date_time$_BOOST_VARIANT', _BOOSTSYSTEMLIB = '${HAS_BOOST_SYSTEM and "boost_system" or ""}', BOOSTSYSTEMLIB = '$_BOOSTSYSTEMLIB',