complement-svn Mailing List for Complement (Page 13)
Status: Pre-Alpha
Brought to you by:
complement
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(61) |
Nov
(76) |
Dec
(39) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(33) |
Feb
(41) |
Mar
(16) |
Apr
|
May
(22) |
Jun
(14) |
Jul
(64) |
Aug
(60) |
Sep
(35) |
Oct
(34) |
Nov
(10) |
Dec
(5) |
2008 |
Jan
(4) |
Feb
(24) |
Mar
(10) |
Apr
(30) |
May
(15) |
Jun
(50) |
Jul
(20) |
Aug
(7) |
Sep
(8) |
Oct
(10) |
Nov
|
Dec
|
From: <com...@us...> - 2007-08-13 07:02:39
|
Revision: 1678 http://complement.svn.sourceforge.net/complement/?rev=1678&view=rev Author: complement Date: 2007-08-13 00:02:36 -0700 (Mon, 13 Aug 2007) Log Message: ----------- entrance into group looks fine Modified Paths: -------------- trunk/complement/explore/test/virtual_time/test/Makefile trunk/complement/explore/test/virtual_time/test/unit_test.cc trunk/complement/explore/test/virtual_time/test/vt_handler.cc trunk/complement/explore/test/virtual_time/test/vt_operations.cc trunk/complement/explore/test/virtual_time/test/vt_operations.h trunk/complement/explore/test/virtual_time/vtime.cc trunk/complement/explore/test/virtual_time/vtime.h Modified: trunk/complement/explore/test/virtual_time/test/Makefile =================================================================== --- trunk/complement/explore/test/virtual_time/test/Makefile 2007-08-08 10:09:58 UTC (rev 1677) +++ trunk/complement/explore/test/virtual_time/test/Makefile 2007-08-13 07:02:36 UTC (rev 1678) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/02/21 15:30:59 ptr> +# -*- Makefile -*- Time-stamp: <07/08/08 22:18:48 ptr> SRCROOT := ../../.. COMPILER_NAME := gcc @@ -16,8 +16,15 @@ release-shared: PROJECT_LIBS = -lxmt -lsockios -lstem -lexam dbg-shared: PROJECT_LIBS = -lxmtg -lsockiosg -lstemg -lexamg +ifndef WITHOUT_STLPORT stldbg-shared: PROJECT_LIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lexamstlg +endif +dbg-shared: DEFS += -D__FIT_VS_TRACE +ifndef WITHOUT_STLPORT +stldbg-shared: DEFS += -D__FIT_VS_TRACE +endif + LDLIBS = ${PROJECT_LIBS} check: all-shared Modified: trunk/complement/explore/test/virtual_time/test/unit_test.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/unit_test.cc 2007-08-08 10:09:58 UTC (rev 1677) +++ trunk/complement/explore/test/virtual_time/test/unit_test.cc 2007-08-13 07:02:36 UTC (rev 1678) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/26 09:41:24 ptr> +// -*- C++ -*- Time-stamp: <07/08/11 01:19:11 ptr> #include "vt_operations.h" @@ -20,12 +20,15 @@ t.add( &vtime_operations::VTMess_core, vt_oper, "VTmess core transfer", tc[2] = t.add( &vtime_operations::gvt_add, vt_oper, "Group VT add", tc[1] ) ); - t.add( &vtime_operations::VTSubscription, vt_oper, "VTSubscription", - t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler2", - t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler1", - t.add( &vtime_operations::VTDispatch2, vt_oper, "VTDispatch2", - t.add( &vtime_operations::VTDispatch1, vt_oper, "VTDispatch1", - t.add( &vtime_operations::vt_object, vt_oper, "VT order", tc[2] ) ) ) ) ) ); + t.add( &vtime_operations::VTEntryIntoGroup3, vt_oper, "VTEntryIntoGroup3", + t.add( &vtime_operations::VTEntryIntoGroup2, vt_oper, "VTEntryIntoGroup2", + t.add( &vtime_operations::VTEntryIntoGroup, vt_oper, "VTEntryIntoGroup", + t.add( &vtime_operations::VTSubscription, vt_oper, "VTSubscription", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler2", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler1", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTDispatch2", + t.add( &vtime_operations::VTDispatch1, vt_oper, "VTDispatch1", + t.add( &vtime_operations::vt_object, vt_oper, "VT order", tc[2] ) ) ) ) ) ) ) ) ); return t.girdle(); } Modified: trunk/complement/explore/test/virtual_time/test/vt_handler.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_handler.cc 2007-08-08 10:09:58 UTC (rev 1677) +++ trunk/complement/explore/test/virtual_time/test/vt_handler.cc 2007-08-13 07:02:36 UTC (rev 1678) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/26 09:53:24 ptr> +// -*- C++ -*- Time-stamp: <07/08/11 23:21:59 ptr> #include "vt_operations.h" @@ -7,6 +7,8 @@ #include <iostream> #include <vtime.h> +#include <stem/EvManager.h> + using namespace vt; using namespace std; @@ -20,21 +22,31 @@ ~VTDummy(); void handler( const stem::Event& ); - void VTNewMember( const stem::Event& ); - void VTOutMember( const stem::Event& ); + void VSNewMember( const stem::Event_base<VSsync_rq>& ); + void VSOutMember( const stem::Event_base<VSsync_rq>& ); + void greeting(); + void wait(); std::string msg; int count; int ocount; + void wait_greeting() + { + gr.try_wait(); + gr.set( false ); + } + private: xmt::condition cnd; + xmt::condition gr; DECLARE_RESPONSE_TABLE( VTDummy, vt::VTHandler ); }; -#define VT_MESS3 0x1203 +#define VS_DUMMY_MESS 0x1203 +#define VS_DUMMY_GREETING 0x1204 VTDummy::VTDummy() : VTHandler(), @@ -42,6 +54,7 @@ ocount(0) { cnd.set( false ); + gr.set( false ); } VTDummy::VTDummy( stem::addr_type id ) : @@ -50,6 +63,7 @@ ocount(0) { cnd.set( false ); + gr.set( false ); } VTDummy::VTDummy( stem::addr_type id, const char *info ) : @@ -58,6 +72,7 @@ ocount(0) { cnd.set( false ); + gr.set( false ); } VTDummy::~VTDummy() @@ -72,13 +87,20 @@ cnd.set( true ); } -void VTDummy::VTNewMember( const stem::Event& ev ) +void VTDummy::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) { - // cerr << "Hello" << endl; + // cerr << "Hello " << ev.src() << endl; ++count; + + // VTNewMember_data( ev, "" ); + VTHandler::VSNewMember( ev ); + + stem::EventVoid gr_ev( VS_DUMMY_GREETING ); + gr_ev.dest( ev.src() ); + Send( gr_ev ); } -void VTDummy::VTOutMember( const stem::Event& ev ) +void VTDummy::VSOutMember( const stem::Event_base<VSsync_rq>& ev ) { // cerr << "Hello" << endl; ++ocount; @@ -91,8 +113,14 @@ cnd.set( false ); } +void VTDummy::greeting() +{ + gr.set( true ); +} + DEFINE_RESPONSE_TABLE( VTDummy ) - EV_EDS( ST_NULL, VT_MESS3, handler ) + EV_EDS( ST_NULL, VS_DUMMY_MESS, handler ) + EV_VOID( ST_NULL, VS_DUMMY_GREETING, greeting ) END_RESPONSE_TABLE int EXAM_IMPL(vtime_operations::VTHandler1) @@ -100,7 +128,7 @@ VTDummy dummy1; VTDummy dummy2; - stem::Event ev( VT_MESS3 ); + stem::Event ev( VS_DUMMY_MESS ); ev.dest( 0 ); // group ev.value() = "hello"; @@ -120,7 +148,7 @@ VTDummy dummy2; VTDummy dummy3; - stem::Event ev( VT_MESS3 ); + stem::Event ev( VS_DUMMY_MESS ); ev.dest( 0 ); // group ev.value() = "hello"; @@ -152,7 +180,7 @@ VTDummy dummy1; VTDummy dummy2; - stem::Event ev( VT_MESS3 ); + stem::Event ev( VS_DUMMY_MESS ); ev.dest( 0 ); // group ev.value() = "hello"; @@ -171,7 +199,7 @@ // dummy3.wait(); // EXAM_CHECK( dummy3.msg == "hi" ); - EXAM_CHECK( dummy3.msg == "" ); // dummy3 don't see, due to VTS + // EXAM_CHECK( dummy3.msg == "" ); // dummy3 don't see, due to VTS EXAM_CHECK( dummy2.msg == "hi" ); EXAM_CHECK( dummy1.msg == "" ); } @@ -189,3 +217,135 @@ return EXAM_RESULT; } +int EXAM_IMPL(vtime_operations::VTEntryIntoGroup) +{ + VTDummy dummy1; + + stem::Event ev( VS_DUMMY_MESS ); + ev.dest( 0 ); // group + ev.value() = "hello"; + + { + // dummy1.manager()->settrf( /* stem::EvManager::tracenet | */ stem::EvManager::tracedispatch ); + // dummy1.manager()->settrs( &std::cerr ); + + VTDummy dummy3; + + dummy3.wait_greeting(); + + ev.value() = "hi"; + dummy1.VTSend( ev ); + + dummy3.wait(); + + EXAM_CHECK( dummy3.msg == "hi" ); + EXAM_CHECK( dummy1.msg == "" ); + } + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::VTEntryIntoGroup2) +{ + VTDummy dummy1; + VTDummy dummy2; + + stem::Event ev( VS_DUMMY_MESS ); + ev.dest( 0 ); // group + ev.value() = "hello"; + + dummy1.VTSend( ev ); + + dummy2.wait(); + EXAM_CHECK( dummy2.msg == "hello" ); + + { + // cerr << (void *)&dummy1 << " dummy1\n" + // << (void *)&dummy2 << " dummy2\n"; + // dummy1.manager()->settrf( /* stem::EvManager::tracenet | */ stem::EvManager::tracedispatch | stem::EvManager::tracefault ); + // dummy1.manager()->settrs( &std::cerr ); + + // dummy1.vtdispatcher()->settrf( VTDispatcher::tracedispatch | VTDispatcher::tracefault | VTDispatcher::tracedelayed | VTDispatcher::tracegroup ); + // dummy1.vtdispatcher()->settrs( &std::cerr ); + + VTDummy dummy3; + + dummy3.wait_greeting(); + + ev.value() = "hi"; + ev.dest( 0 ); // group + dummy1.VTSend( ev ); + + dummy2.wait(); + dummy3.wait(); + + EXAM_CHECK( dummy2.msg == "hi" ); + EXAM_CHECK( dummy3.msg == "hi" ); + EXAM_CHECK( dummy1.msg == "" ); + } + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::VTEntryIntoGroup3) +{ + VTDummy dummy1; + + stem::Event ev( VS_DUMMY_MESS ); + + { + VTDummy dummy2; + + dummy2.wait_greeting(); + + ev.value() = "hello"; + ev.dest( 0 ); // group + dummy1.VTSend( ev ); + + dummy2.wait(); + EXAM_CHECK( dummy2.msg == "hello" ); + EXAM_CHECK( dummy1.msg == "" ); + } + + { + VTDummy dummy3; + + dummy3.wait_greeting(); + + ev.value() = "hi"; + ev.dest( 0 ); // group + dummy1.VTSend( ev ); + + dummy3.wait(); + + EXAM_CHECK( dummy3.msg == "hi" ); + EXAM_CHECK( dummy1.msg == "" ); + } + + { + VTDummy dummy2; + VTDummy dummy3; + + dummy2.wait_greeting(); + dummy3.wait_greeting(); + + ev.value() = "more"; + ev.dest( 0 ); // group + dummy1.VTSend( ev ); + + dummy2.wait(); + dummy3.wait(); + + EXAM_CHECK( dummy2.msg == "more" ); + EXAM_CHECK( dummy3.msg == "more" ); + EXAM_CHECK( dummy1.msg == "" ); + + dummy2.VTSend( ev ); + + dummy1.wait(); + } + + EXAM_CHECK( dummy1.msg == "more" ); + + return EXAM_RESULT; +} Modified: trunk/complement/explore/test/virtual_time/test/vt_operations.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_operations.cc 2007-08-08 10:09:58 UTC (rev 1677) +++ trunk/complement/explore/test/virtual_time/test/vt_operations.cc 2007-08-13 07:02:36 UTC (rev 1678) @@ -52,6 +52,8 @@ EXAM_CHECK( !(vt1 <= vt2) ); EXAM_CHECK( !(vt2 <= vt1) ); + + return EXAM_RESULT; } int EXAM_IMPL(vtime_operations::vt_add) Modified: trunk/complement/explore/test/virtual_time/test/vt_operations.h =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_operations.h 2007-08-08 10:09:58 UTC (rev 1677) +++ trunk/complement/explore/test/virtual_time/test/vt_operations.h 2007-08-13 07:02:36 UTC (rev 1678) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/26 09:40:39 ptr> +// -*- C++ -*- Time-stamp: <07/08/11 01:18:35 ptr> #ifndef __vt_operations_h #define __vt_operations_h @@ -25,6 +25,9 @@ int EXAM_DECL(VTHandler2); int EXAM_DECL(VTSubscription); + int EXAM_DECL(VTEntryIntoGroup); + int EXAM_DECL(VTEntryIntoGroup2); + int EXAM_DECL(VTEntryIntoGroup3); }; #endif // __vt_operations_h Modified: trunk/complement/explore/test/virtual_time/vtime.cc =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.cc 2007-08-08 10:09:58 UTC (rev 1677) +++ trunk/complement/explore/test/virtual_time/vtime.cc 2007-08-13 07:02:36 UTC (rev 1678) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/27 09:49:24 ptr> +// -*- C++ -*- Time-stamp: <07/08/11 01:10:59 ptr> #include "vtime.h" @@ -103,40 +103,80 @@ } } +void VSsync_rq::pack( std::ostream& s ) const +{ + __pack( s, grp ); + __pack( s, mess ); +} + +void VSsync_rq::net_pack( std::ostream& s ) const +{ + __net_pack( s, grp ); + __net_pack( s, mess ); +} + +void VSsync_rq::unpack( std::istream& s ) +{ + __unpack( s, grp ); + __unpack( s, mess ); +} + +void VSsync_rq::net_unpack( std::istream& s ) +{ + __net_unpack( s, grp ); + __net_unpack( s, mess ); +} + +void VSsync::pack( std::ostream& s ) const +{ + gvt.pack( s ); + VSsync_rq::pack( s ); +} + +void VSsync::net_pack( std::ostream& s ) const +{ + gvt.net_pack( s ); + VSsync_rq::net_pack( s ); +} + +void VSsync::unpack( std::istream& s ) +{ + gvt.unpack( s ); + VSsync_rq::unpack( s ); +} + +void VSsync::net_unpack( std::istream& s ) +{ + gvt.net_unpack( s ); + VSsync_rq::net_unpack( s ); +} + void VTmess::pack( std::ostream& s ) const { __pack( s, code ); src.pack( s ); // __pack( s, src ); - gvt.pack( s ); - __pack( s, grp ); - __pack( s, mess ); + VSsync::pack( s ); } void VTmess::net_pack( std::ostream& s ) const { __net_pack( s, code ); src.net_pack( s ); // __net_pack( s, src ); - gvt.net_pack( s ); - __net_pack( s, grp ); - __net_pack( s, mess ); + VSsync::net_pack( s ); } void VTmess::unpack( std::istream& s ) { __unpack( s, code ); src.unpack( s ); // __unpack( s, src ); - gvt.unpack( s ); - __unpack( s, grp ); - __unpack( s, mess ); + VSsync::unpack( s ); } void VTmess::net_unpack( std::istream& s ) { __net_unpack( s, code ); src.net_unpack( s ); // __net_unpack( s, src ); - gvt.net_unpack( s ); - __net_unpack( s, grp ); - __net_unpack( s, mess ); + VSsync::net_unpack( s ); } bool operator <=( const vtime_type& l, const vtime_type& r ) @@ -314,7 +354,6 @@ lvt[m.src] += m.gvt.gvt; lvt[m.src][m.grp][m.src] = vt.gvt[m.grp][m.src] + 1; sup( vt.gvt[m.grp], lvt[m.src][m.grp] ); - // cout << vt.gvt << endl; return true; } @@ -327,7 +366,6 @@ lvt[m.src] += m.gvt.gvt; lvt[m.src][m.grp][m.src] = vt.gvt[m.grp][m.src] + 1; sup( vt.gvt[m.grp], lvt[m.src][m.grp] ); - // cout << vt.gvt << endl; return true; } @@ -343,10 +381,6 @@ gvtime gvt( m.gvt ); if ( (vt.gvt[m.grp][m.src] + 1) != gvt[m.grp][m.src] ) { - // cerr << "1" << endl; - // cerr << vt.gvt[m.grp][m.src] << "\n" - // << gvt[m.grp][m.src] - // << endl; if ( (vt.gvt[m.grp][m.src] + 1) > gvt[m.grp][m.src] ) { throw out_of_range( "duplicate or wrong VT message" ); } @@ -357,16 +391,12 @@ xvt[m.src] = 0; // force exclude message originator, it checked above if ( !(xvt <= vt[m.grp]) ) { - // cerr << "2" << endl; - // cerr << xvt << "\n\n" << vt[m.grp] << endl; return false; } // check side casuality (via groups other then message's group) for ( groups_container_type::const_iterator l = groups.begin(); l != groups.end(); ++l ) { if ( (*l != m.grp) && !((lvt[m.src][*l] + gvt[*l]) <= vt[*l]) ) { - // cerr << "3" << endl; - // cerr << "group " << *l << xvt << "\n\n" << vt[*l] << endl; return false; } } @@ -374,6 +404,38 @@ return true; } +ostream& vtime_obj_rec::trace_deliver( const VTmess& m, ostream& o ) +{ + if ( groups.find( m.grp ) == groups.end() ) { + return o << "VT object not member of group"; + } + + gvtime gvt( m.gvt ); + + if ( (vt.gvt[m.grp][m.src] + 1) != gvt[m.grp][m.src] ) { + if ( (vt.gvt[m.grp][m.src] + 1) > gvt[m.grp][m.src] ) { + return o << "duplicate or wrong VT message, " << vt.gvt << " vs " << gvt; + } + return o << "counter violation, " << vt.gvt << " vs " << gvt; + } + + vtime xvt = lvt[m.src][m.grp] + gvt[m.grp]; + xvt[m.src] = 0; // force exclude message originator, it checked above + + if ( !(xvt <= vt[m.grp]) ) { + return o << "casuality violation, " << xvt << " vs " << vt[m.grp]; + } + + // check side casuality (via groups other then message's group) + for ( groups_container_type::const_iterator l = groups.begin(); l != groups.end(); ++l ) { + if ( (*l != m.grp) && !((lvt[m.src][*l] + gvt[*l]) <= vt[*l]) ) { + return o << "side casuality violation, " << (lvt[m.src][*l] + gvt[*l]) << " vs " << vt[*l]; + } + } + + return o << "should be delivered"; +} + bool vtime_obj_rec::order_correct_delayed( const VTmess& m ) { gvtime gvt( m.gvt ); @@ -399,7 +461,7 @@ return true; } -void vtime_obj_rec::delta( gvtime& vtstamp, oid_type from, oid_type to, group_type grp ) +void vtime_obj_rec::delta( gvtime& vtstamp, const oid_type& from, const oid_type& to, group_type grp ) { vtstamp.gvt = vt.gvt - svt[to]; // delta vtstamp[grp][from] = vt.gvt[grp][from]; // my counter, as is, not delta @@ -449,7 +511,7 @@ return groups.empty() ? true : false; } -void vtime_obj_rec::rm_member( oid_type oid ) +void vtime_obj_rec::rm_member( const oid_type& oid ) { delta_vtime_type::iterator i = lvt.find( oid ); @@ -464,8 +526,59 @@ } } +void vtime_obj_rec::sync( group_type g, const oid_type& oid, const gvtime_type& gvt ) +{ + lvt[oid] = gvt; + gvtime_type::const_iterator i = gvt.find( g ); + if ( i != gvt.end() ) { + sup( vt.gvt[g], i->second.vt ); + // vtime_type::const_iterator j = i->second.vt.find( oid ); + // if ( j != i->second.vt.end() ) { + // vt.gvt[g][oid] = j->second; + // cerr << "**** " << gvt << endl; + // } + } +} + } // namespace detail +void VTDispatcher::settrf( unsigned f ) +{ + scoped_lock _x1( _lock_tr ); + _trflags |= f; +} + +void VTDispatcher::unsettrf( unsigned f ) +{ + scoped_lock _x1( _lock_tr ); + _trflags &= (0xffffffff & ~f); +} + +void VTDispatcher::resettrf( unsigned f ) +{ + scoped_lock _x1( _lock_tr ); + _trflags = f; +} + +void VTDispatcher::cleantrf() +{ + scoped_lock _x1( _lock_tr ); + _trflags = 0; +} + +unsigned VTDispatcher::trflags() const +{ + scoped_lock _x1( _lock_tr ); + + return _trflags; +} + +void VTDispatcher::settrs( std::ostream *s ) +{ + scoped_lock _x1( _lock_tr ); + _trs = s; +} + void VTDispatcher::VTDispatch( const stem::Event_base<VTmess>& m ) { pair<gid_map_type::const_iterator,gid_map_type::const_iterator> range = @@ -482,48 +595,110 @@ // looks, like local source shouldn't be here? check_and_send( i->second, m ); } - catch ( const out_of_range& ) { + catch ( const out_of_range& err ) { + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { + *_trs << err.what() << " " + << __FILE__ << ":" << __LINE__ << endl; + } + } + catch ( ... ) { + } } - catch ( const domain_error& ) { + catch ( const domain_error& err ) { + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { + *_trs << err.what() << " " + << __FILE__ << ":" << __LINE__ << endl; + } + } + catch ( ... ) { + } } } } void VTDispatcher::check_and_send( detail::vtime_obj_rec& vt, const stem::Event_base<VTmess>& m ) { - typedef detail::vtime_obj_rec::dpool_t dpool_t; - - // detail::vtime_obj_rec& vt = i->second; - if ( vt.deliver( m.value() ) ) { stem::Event ev( m.value().code ); ev.dest(vt.stem_addr()); ev.src(m.src()); ev.value() = m.value().mess; +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracedispatch) ) { + *_trs << "Deliver " << m.value() << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE Forward( ev ); - bool more; - do { - more = false; - for ( dpool_t::iterator j = vt.dpool.begin(); j != vt.dpool.end(); ) { - if ( vt.deliver_delayed( j->second->value() ) ) { - stem::Event evd( j->second->value().code ); - evd.dest(vt.stem_addr()); - ev.src(m.src()); - evd.value() = j->second->value().mess; - Forward( evd ); - delete j->second; - vt.dpool.erase( j++ ); - more = true; - } else { - ++j; - } + check_and_send_delayed( vt ); + } else { +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracedelayed) ) { + *_trs << "Delayed " << m.value() << endl; } - } while ( more ); - } else { + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE vt.dpool.push_back( make_pair( 0, new Event_base<VTmess>(m) ) ); // 0 should be timestamp } } +void VTDispatcher::check_and_send_delayed( detail::vtime_obj_rec& vt ) +{ + typedef detail::vtime_obj_rec::dpool_t dpool_t; + bool more; + do { + more = false; + for ( dpool_t::iterator j = vt.dpool.begin(); j != vt.dpool.end(); ) { + if ( vt.deliver_delayed( j->second->value() ) ) { + stem::Event evd( j->second->value().code ); + evd.dest(vt.stem_addr()); + evd.src(j->second->src()); + evd.value() = j->second->value().mess; +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracedispatch) ) { + *_trs << "Deliver delayed " << j->second->value() << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + Forward( evd ); + delete j->second; + vt.dpool.erase( j++ ); + more = true; + } else { +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracedispatch) ) { + *_trs << "Remain delayed " << j->second->value() + << "\nReason: "; + vt.trace_deliver( j->second->value(), *_trs ) << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + ++j; + } + } + } while ( more ); +} + void VTDispatcher::VTSend( const stem::Event& e, group_type grp ) { // This method not called from Dispatch, but work on the same level and in the same @@ -538,7 +713,7 @@ if ( i != vtmap.end() && i->second.stem_addr() == e.src() ) { // for self detail::vtime_obj_rec& vt = i->second; const oid_type& from = o->second; - stem::Event_base<VTmess> m( MESS ); + stem::Event_base<VTmess> m( VS_MESS ); m.value().src = from; // oid m.value().code = e.code(); m.value().mess = e.value(); @@ -565,9 +740,27 @@ vt.base_advance(g->second); // store last send VT to obj } - catch ( const out_of_range& ) { + catch ( const out_of_range& err ) { + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { + *_trs << err.what() << " " + << __FILE__ << ":" << __LINE__ << endl; + } + } + catch ( ... ) { + } } - catch ( const domain_error& ) { + catch ( const domain_error& err ) { + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { + *_trs << err.what() << " " + << __FILE__ << ":" << __LINE__ << endl; + } + } + catch ( ... ) { + } } } @@ -589,9 +782,20 @@ for ( ; range.first != range.second; ++range.first ) { vt_map_type::iterator i = vtmap.find( range.first->second ); if ( i != vtmap.end() ) { - stem::Event ev( VTS_NEW_MEMBER ); + stem::Event_base<VSsync_rq> ev( VS_NEW_MEMBER ); ev.dest( i->second.stem_addr() ); ev.src( addr ); + ev.value().grp = grp; +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { + *_trs << "VS_NEW_MEMBER " << ev.src() << " -> " << ev.dest() << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE Forward( ev ); } } @@ -615,9 +819,21 @@ } else { vt_map_type::iterator j = vtmap.find( range.first->second ); if ( j != vtmap.end() ) { - stem::Event ev( VTS_OUT_MEMBER ); + stem::Event_base<VSsync_rq> ev( VS_OUT_MEMBER ); ev.dest( j->second.stem_addr() ); ev.src( i != vtmap.end() ? i->second.stem_addr() : self_id() ); + ev.value().grp = grp; +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { + *_trs << "VS_OUT_MEMBER " << ev.src() << " -> " << ev.dest() << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + Forward( ev ); } ++range.first; @@ -631,8 +847,74 @@ } } +void VTDispatcher::get_gvtime( group_type grp, stem::addr_type addr, gvtime_type& gvt ) +{ + // See comment on top of VTSend above + xmt::recursive_scoped_lock lk( this->_theHistory_lock ); + + pair<gid_map_type::iterator,gid_map_type::iterator> range = + grmap.equal_range( grp ); + for ( ; range.first != range.second; ++range.first ) { + vt_map_type::iterator i = vtmap.find( range.first->second ); + if ( i != vtmap.end() && i->second.stem_addr() == addr ) { + i->second.get_gvt( gvt ); + return; + } + } + + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { + *_trs << "VT object not member of group" << " " << __FILE__ << ":" << __LINE__ << endl; + } + } + catch ( ... ) { + } + + throw domain_error( "VT object not member of group" ); // Error: not group member +} + +void VTDispatcher::set_gvtime( group_type grp, stem::addr_type addr, const gvtime_type& gvt ) +{ + // See comment on top of VTSend above + xmt::recursive_scoped_lock lk( this->_theHistory_lock ); + + pair<gid_map_type::iterator,gid_map_type::iterator> range = + grmap.equal_range( grp ); + for ( ; range.first != range.second; ++range.first ) { + vt_map_type::iterator i = vtmap.find( range.first->second ); + if ( i != vtmap.end() && i->second.stem_addr() == addr ) { +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { + *_trs << "Set gvt G" << grp << " " << i->first + << " (" << addr << ") " << gvt << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + i->second.sync( grp, i->first, gvt ); + check_and_send_delayed( i->second ); + return; + } + } + + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { + *_trs << "VT object not member of group" << " " << __FILE__ << ":" << __LINE__ << endl; + } + } + catch ( ... ) { + } + + throw domain_error( "VT object not member of group" ); // Error: not group member +} + DEFINE_RESPONSE_TABLE( VTDispatcher ) - EV_Event_base_T_( ST_NULL, MESS, VTDispatch, VTmess ) + EV_Event_base_T_( ST_NULL, VS_MESS, VTDispatch, VTmess ) END_RESPONSE_TABLE char *Init_buf[128]; @@ -723,17 +1005,45 @@ ((Init *)Init_buf)->~Init(); } -void VTHandler::VTNewMember( const stem::Event& ) +void VTHandler::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) { + stem::Event_base<VSsync> out_ev( VS_SYNC_TIME ); + out_ev.dest( ev.src() ); + out_ev.value().grp = ev.value().grp; + get_gvtime( ev.value().grp, out_ev.value().gvt.gvt ); + + Send( out_ev ); } -void VTHandler::VTOutMember( const stem::Event& ) +void VTHandler::VSNewMember_data( const stem::Event_base<VSsync_rq>& ev, const string& data ) { + stem::Event_base<VSsync> out_ev( VS_SYNC_TIME ); + out_ev.dest( ev.src() ); + out_ev.value().grp = ev.value().grp; + get_gvtime( ev.value().grp, out_ev.value().gvt.gvt ); + out_ev.value().mess = data; + + Send( out_ev ); } +void VTHandler::VSOutMember( const stem::Event_base<VSsync_rq>& ) +{ +} + +void VTHandler::VSsync_time( const stem::Event_base<VSsync>& ev ) +{ + try { + // sync data from ev.value().mess + _vtdsp->set_gvtime( ev.value().grp, self_id(), ev.value().gvt.gvt ); + } + catch ( const domain_error& ) { + } +} + DEFINE_RESPONSE_TABLE( VTHandler ) - EV_EDS( ST_NULL, VTS_NEW_MEMBER, VTNewMember ) - EV_EDS( ST_NULL, VTS_OUT_MEMBER, VTOutMember ) + EV_Event_base_T_( ST_NULL, VS_NEW_MEMBER, VSNewMember, VSsync_rq ) + EV_Event_base_T_( ST_NULL, VS_OUT_MEMBER, VSOutMember, VSsync_rq ) + EV_Event_base_T_( ST_NULL, VS_SYNC_TIME, VSsync_time, VSsync ) END_RESPONSE_TABLE } // namespace vt @@ -742,16 +1052,18 @@ ostream& operator <<( ostream& o, const vt::vtime_type::value_type& v ) { - return o << "(" << v.first << "," << v.second << ")\n"; + return o << "(" << v.first << "," << v.second << ")"; } ostream& operator <<( ostream& o, const vt::vtime_type& v ) { - o << "[\n"; for ( vt::vtime_type::const_iterator i = v.begin(); i != v.end(); ++i ) { - o << " " << *i; + if ( i != v.begin() ) { + o << ", "; + } + o << *i; } - return o << " ]\n"; + return o; } ostream& operator <<( ostream& o, const vt::vtime& v ) @@ -759,17 +1071,38 @@ ostream& operator <<( ostream& o, const vt::gvtime_type::value_type& v ) { - o << "group " << v.first << ": " << v.second.vt; + o << v.first << ": " << v.second.vt; } ostream& operator <<( ostream& o, const vt::gvtime_type& v ) { o << "{\n"; for ( vt::gvtime_type::const_iterator i = v.begin(); i != v.end(); ++i ) { - o << " " << *i; + o << "\t" << *i << "\n"; } return o << "}\n"; } +ostream& operator <<( ostream& o, const vt::gvtime& v ) +{ + return o << v.gvt; +} + +ostream& operator <<( ostream& o, const vt::VSsync& m ) +{ + // ios_base::fmtflags f = o.flags( ios_base::hex ); + o << "G" << m.grp << " " << m.gvt; + + return o; +} + +ostream& operator <<( ostream& o, const vt::VTmess& m ) +{ + ios_base::fmtflags f = o.flags( ios_base::hex | ios_base::showbase ); + o << "C" << m.code << dec << " " << m.src << " " << static_cast<const vt::VSsync&>(m); + o.flags( f ); + return o; +} + } // namespace std Modified: trunk/complement/explore/test/virtual_time/vtime.h =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.h 2007-08-08 10:09:58 UTC (rev 1677) +++ trunk/complement/explore/test/virtual_time/vtime.h 2007-08-13 07:02:36 UTC (rev 1678) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/27 09:53:24 ptr> +// -*- C++ -*- Time-stamp: <07/08/11 01:05:47 ptr> #ifndef __vtime_h #define __vtime_h @@ -147,7 +147,7 @@ mutable gvtime_type gvt; }; -struct VTmess : +struct VSsync_rq : public stem::__pack_base { void pack( std::ostream& s ) const; @@ -155,28 +155,59 @@ void unpack( std::istream& s ); void net_unpack( std::istream& s ); - VTmess() : - code(0), - src(), - gvt(), + VSsync_rq() : grp(0), mess() { } - VTmess( const VTmess& _gvt ) : - code( _gvt.code ), - src( _gvt.src ), - gvt( _gvt.gvt ), + VSsync_rq( const VSsync_rq& _gvt ) : grp( _gvt.grp ), mess( _gvt.mess ) { } - stem::code_type code; - oid_type src; - gvtime gvt; group_type grp; std::string mess; }; +struct VSsync : + public VSsync_rq +{ + void pack( std::ostream& s ) const; + void net_pack( std::ostream& s ) const; + void unpack( std::istream& s ); + void net_unpack( std::istream& s ); + + VSsync() + { } + VSsync( const VSsync& _gvt ) : + VSsync_rq( _gvt ), + gvt( _gvt.gvt ) + { } + + gvtime gvt; +}; + +struct VTmess : + public VSsync +{ + void pack( std::ostream& s ) const; + void net_pack( std::ostream& s ) const; + void unpack( std::istream& s ); + void net_unpack( std::istream& s ); + + VTmess() : + code(0), + src() + { } + VTmess( const VTmess& _gvt ) : + VSsync( _gvt ), + code( _gvt.code ), + src( _gvt.src ) + { } + + stem::code_type code; + oid_type src; +}; + namespace detail { class vtime_obj_rec @@ -187,18 +218,22 @@ void add( stem::addr_type a, group_type g ) { addr = a; groups.insert(g); } bool rm_group( group_type ); - void rm_member( oid_type ); + void rm_member( const oid_type& ); stem::addr_type stem_addr() const { return addr; } bool deliver( const VTmess& ev ); bool deliver_delayed( const VTmess& ev ); - void next( oid_type from, group_type grp ) + std::ostream& trace_deliver( const VTmess& m, std::ostream& o ); + void next( const oid_type& from, group_type grp ) { ++vt.gvt[grp][from]; /* increment my VT counter */ } - void delta( gvtime& vtstamp, oid_type from, oid_type to, group_type grp ); - void base_advance( oid_type to ) + void delta( gvtime& vtstamp, const oid_type& from, const oid_type& to, group_type grp ); + void base_advance( const oid_type& to ) { svt[to] = vt.gvt; /* store last sent VT to obj */ } + void get_gvt( gvtime_type& gvt ) const + { gvt = vt.gvt; } + void sync( group_type, const oid_type&, const gvtime_type& ); #ifdef __FIT_EXAM const gvtime_type::data_type& operator[]( const gvtime_type::key_type k ) const @@ -235,19 +270,36 @@ public stem::EventHandler { public: - VTDispatcher() + enum traceflags { + notrace = 0, + tracenet = 1, + tracedispatch = 2, + tracefault = 4, + tracedelayed = 8, + tracegroup = 0x10 + }; + + VTDispatcher() : + _trflags( notrace ), + _trs( 0 ) { } VTDispatcher( const char *info ) : - stem::EventHandler( info ) + stem::EventHandler( info ), + _trflags( notrace ), + _trs( 0 ) { } VTDispatcher( stem::addr_type id ) : - stem::EventHandler( id ) + stem::EventHandler( id ), + _trflags( notrace ), + _trs( 0 ) { } VTDispatcher( stem::addr_type id, const char *info ) : - stem::EventHandler( id, info ) + stem::EventHandler( id, info ), + _trflags( notrace ), + _trs( 0 ) { } void VTDispatch( const stem::Event_base<VTmess>& ); @@ -255,16 +307,30 @@ void VTSend( const stem::Event& e, group_type ); void Subscribe( stem::addr_type, oid_type, group_type ); void Unsubscribe( oid_type, group_type ); + void get_gvtime( group_type, stem::addr_type, gvtime_type& ); + void set_gvtime( group_type, stem::addr_type, const gvtime_type& ); + void settrf( unsigned f ); + void unsettrf( unsigned f ); + void resettrf( unsigned f ); + void cleantrf(); + unsigned trflags() const; + void settrs( std::ostream * ); + private: typedef std::hash_map<oid_type, detail::vtime_obj_rec> vt_map_type; typedef std::hash_multimap<group_type, oid_type> gid_map_type; void check_and_send( detail::vtime_obj_rec&, const stem::Event_base<VTmess>& ); + void check_and_send_delayed( detail::vtime_obj_rec& ); vt_map_type vtmap; gid_map_type grmap; + xmt::mutex _lock_tr; + unsigned _trflags; + std::ostream *_trs; + DECLARE_RESPONSE_TABLE( VTDispatcher, stem::EventHandler ); }; @@ -291,23 +357,34 @@ virtual ~VTHandler(); void VTSend( const stem::Event& e ); - virtual void VTNewMember( const stem::Event& e ); - virtual void VTOutMember( const stem::Event& e ); + virtual void VSNewMember( const stem::Event_base<VSsync_rq>& e ); + virtual void VSOutMember( const stem::Event_base<VSsync_rq>& e ); + virtual void VSsync_time( const stem::Event_base<VSsync>& ); + template <class D> void VTSend( const stem::Event_base<D>& e ) { VTHandler::VTSend( stem::Event_convert<D>()( e ) ); } + static VTDispatcher *vtdispatcher() + { return _vtdsp; } + protected: + void VSNewMember_data( const stem::Event_base<VSsync_rq>&, const std::string& data ); + + void get_gvtime( group_type g, gvtime_type& gvt ) + { _vtdsp->get_gvtime( g, self_id(), gvt ); } + private: static class VTDispatcher *_vtdsp; DECLARE_RESPONSE_TABLE( VTHandler, stem::EventHandler ); }; -#define MESS 0x300 -#define VTS_NEW_MEMBER 0x301 -#define VTS_OUT_MEMBER 0x302 +#define VS_MESS 0x300 +#define VS_NEW_MEMBER 0x301 +#define VS_OUT_MEMBER 0x302 +#define VS_SYNC_TIME 0x303 } // namespace vt @@ -318,6 +395,9 @@ ostream& operator <<( ostream&, const vt::vtime& ); ostream& operator <<( ostream&, const vt::gvtime_type::value_type& ); ostream& operator <<( ostream&, const vt::gvtime_type& ); +ostream& operator <<( ostream&, const vt::gvtime& ); +ostream& operator <<( ostream& o, const vt::VSsync& ); +ostream& operator <<( ostream& o, const vt::VTmess& ); } // namespace std This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-08 10:10:01
|
Revision: 1677 http://complement.svn.sourceforge.net/complement/?rev=1677&view=rev Author: complement Date: 2007-08-08 03:09:58 -0700 (Wed, 08 Aug 2007) Log Message: ----------- gmake/app/rules.mak: use special link string for Digital Mars and Borland compilers, due to special pass of options and files to linker for this OE; gmake/gcc.mak, gmake/dmc.mak: use STLport's experience; gmake/lib/gcc.mak: gcc 3.3 also may have bad libsupc++. Modified Paths: -------------- trunk/complement/explore/Makefiles/ChangeLog trunk/complement/explore/Makefiles/gmake/app/rules.mak trunk/complement/explore/Makefiles/gmake/dmc.mak trunk/complement/explore/Makefiles/gmake/gcc.mak trunk/complement/explore/Makefiles/gmake/lib/gcc.mak Modified: trunk/complement/explore/Makefiles/ChangeLog =================================================================== --- trunk/complement/explore/Makefiles/ChangeLog 2007-08-06 11:18:14 UTC (rev 1676) +++ trunk/complement/explore/Makefiles/ChangeLog 2007-08-08 10:09:58 UTC (rev 1677) @@ -1,3 +1,13 @@ +2007-08-08 Petr Ovtchenkov <pt...@is...> + + * gmake/app/rules.mak: use special link string for Digital Mars + and Borland compilers, due to special pass of options and files + to linker for this OE; + + * gmake/gcc.mak, gmake/dmc.mak: use STLport's experience; + + * gmake/lib/gcc.mak: gcc 3.3 also may have bad libsupc++. + 2007-07-12 Petr Ovtchenkov <pt...@is...> * gmake/gcc.mak, gmake/top.mak: add include option for boost's Modified: trunk/complement/explore/Makefiles/gmake/app/rules.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/app/rules.mak 2007-08-06 11:18:14 UTC (rev 1676) +++ trunk/complement/explore/Makefiles/gmake/app/rules.mak 2007-08-08 10:09:58 UTC (rev 1677) @@ -1,6 +1,6 @@ # -*- makefile -*- Time-stamp: <06/11/17 10:34:26 ptr> # -# Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 +# Copyright (c) 1997-1999, 2002, 2003, 2005-2007 # Petr Ovtchenkov # # Portion Copyright (c) 1999-2001 @@ -23,17 +23,27 @@ stldbg-static: $(EXTRA_PRE_STLDBG) $(OUTPUT_DIR_STLDBG) ${PRG_STLDBG} ${ALLPRGS_STLDBG} $(EXTRA_POST_STLDBG) endif +ifeq ("$(findstring $(OSNAME),bcc dmc)","") +define cpplnk_str +$(LINK.cc) $(LINK_OUTPUT_OPTION) ${START_OBJ} $(1) $(LDLIBS) ${STDLIBS} ${END_OBJ} +endef +else +define cpplnk_str +$(LINK.cc) $(subst /,\,${START_OBJ} $(1) ${END_OBJ}, $(LINK_OUTPUT_OPTION), $(MAP_OUTPUT_OPTION), $(LDLIBS) ${STDLIBS},,) +endef +endif + define prog_lnk ifeq ($${_$(1)_C_SOURCES_ONLY},) $${$(1)_PRG}: $$($(1)_OBJ) $$(LIBSDEP) - $$(LINK.cc) $$(LINK_OUTPUT_OPTION) $${START_OBJ} $$($(1)_OBJ) $$(LDLIBS) $${STDLIBS} $${END_OBJ} + $$(call cpplnk_str,$$($(1)_OBJ)) $${$(1)_PRG_DBG}: $$($(1)_OBJ_DBG) $$(LIBSDEP) - $$(LINK.cc) $$(LINK_OUTPUT_OPTION) $${START_OBJ} $$($(1)_OBJ_DBG) $$(LDLIBS) $${STDLIBS} $${END_OBJ} + $$(call cpplnk_str,$$($(1)_OBJ_DBG)) ifndef WITHOUT_STLPORT $${$(1)_PRG_STLDBG}: $$($(1)_OBJ_STLDBG) $$(LIBSDEP) - $$(LINK.cc) $$(LINK_OUTPUT_OPTION) $${START_OBJ} $$($(1)_OBJ_STLDBG) $$(LDLIBS) $${STDLIBS} $${END_OBJ} + $$(call cpplnk_str,$$($(1)_OBJ_STLDBG)) endif else $${$(1)_PRG}: $$($(1)_OBJ) $$(LIBSDEP) @@ -53,14 +63,14 @@ ifeq ("${_C_SOURCES_ONLY}","") ${PRG}: $(OBJ) $(LIBSDEP) - $(LINK.cc) $(LINK_OUTPUT_OPTION) ${START_OBJ} $(OBJ) $(LDLIBS) ${STDLIBS} ${END_OBJ} + $(call cpplnk_str,$(OBJ)) ${PRG_DBG}: $(OBJ_DBG) $(LIBSDEP) - $(LINK.cc) $(LINK_OUTPUT_OPTION) ${START_OBJ} $(OBJ_DBG) $(LDLIBS) ${STDLIBS} ${END_OBJ} + $(call cpplnk_str,$(OBJ_DBG)) ifndef WITHOUT_STLPORT ${PRG_STLDBG}: $(OBJ_STLDBG) $(LIBSDEP) - $(LINK.cc) $(LINK_OUTPUT_OPTION) ${START_OBJ} $(OBJ_STLDBG) $(LDLIBS) ${STDLIBS} ${END_OBJ} + $(call cpplnk_str,$(OBJ_STLDBG)) endif else ${PRG}: $(OBJ) $(LIBSDEP) Modified: trunk/complement/explore/Makefiles/gmake/dmc.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/dmc.mak 2007-08-06 11:18:14 UTC (rev 1676) +++ trunk/complement/explore/Makefiles/gmake/dmc.mak 2007-08-08 10:09:58 UTC (rev 1677) @@ -19,7 +19,6 @@ CXX := dmc CC := dmc -RC := rcc DEFS ?= OPT ?= @@ -64,7 +63,7 @@ CDEPFLAGS = -E -M CCDEPFLAGS = -E -M -RCFLAGS = -32 -I${STLPORT_INCLUDE_DIR} -DCOMP=dmc +RCFLAGS = --include-dir=${STLPORT_INCLUDE_DIR} -DCOMP=dmc release-shared : RCFLAGS += -DBUILD=r -DBUILD_INFOS="-o" dbg-shared : RCFLAGS += -DBUILD=g -DBUILD_INFOS="-gl -D_DEBUG" Modified: trunk/complement/explore/Makefiles/gmake/gcc.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/gcc.mak 2007-08-06 11:18:14 UTC (rev 1676) +++ trunk/complement/explore/Makefiles/gmake/gcc.mak 2007-08-08 10:09:58 UTC (rev 1677) @@ -43,7 +43,6 @@ GCC_APPLE_CC := 1 endif else -ifneq ($(OSNAME), windows) CXX_VERSION := $(shell ${CXX} --version | grep GCC | awk '{ print $$3; }') ifeq ($(CXX_VERSION),) @@ -55,7 +54,6 @@ CXX_VERSION_MINOR := $(shell echo ${CXX_VERSION} | awk 'BEGIN { FS = "."; } { print $$2; }') CXX_VERSION_PATCH := $(shell echo ${CXX_VERSION} | awk 'BEGIN { FS = "."; } { print $$3; }') endif -endif DEFS ?= OPT ?= Modified: trunk/complement/explore/Makefiles/gmake/lib/gcc.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/lib/gcc.mak 2007-08-06 11:18:14 UTC (rev 1676) +++ trunk/complement/explore/Makefiles/gmake/lib/gcc.mak 2007-08-08 10:09:58 UTC (rev 1677) @@ -30,7 +30,7 @@ endif ifeq ($(CXX_VERSION_MAJOR),3) -# gcc before 3.3 (i.e. 3.0.x, 3.1.x, 3.2.x) has buggy libsupc++, so we should link with libstdc++ to avoid one +# gcc before 3.4 (i.e. 3.0.x, 3.1.x, 3.2.x) has buggy libsupc++, so we should link with libstdc++ to avoid one ifeq ($(CXX_VERSION_MINOR),0) NOT_USE_NOSTDLIB := 1 endif @@ -40,7 +40,10 @@ ifeq ($(CXX_VERSION_MINOR),2) NOT_USE_NOSTDLIB := 1 endif +ifeq ($(CXX_VERSION_MINOR),3) +NOT_USE_NOSTDLIB := 1 endif +endif endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-06 11:18:15
|
Revision: 1676 http://complement.svn.sourceforge.net/complement/?rev=1676&view=rev Author: complement Date: 2007-08-06 04:18:14 -0700 (Mon, 06 Aug 2007) Log Message: ----------- working fixes; add test for is_empty Modified Paths: -------------- trunk/complement/explore/include/misc/type_traits.h trunk/complement/explore/lib/misc/ut/misc_test.cc trunk/complement/explore/lib/misc/ut/misc_test.h trunk/complement/explore/lib/misc/ut/misc_test_suite.cc Modified: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h 2007-08-06 07:01:16 UTC (rev 1675) +++ trunk/complement/explore/include/misc/type_traits.h 2007-08-06 11:18:14 UTC (rev 1676) @@ -399,7 +399,7 @@ template<typename _Tp> struct is_empty - : public integral_constant<bool, (detail::__is_union_or_class<_Tp>::__value + : public integral_constant<bool, (detail::__is_union_or_class<_Tp>::value && (sizeof(detail::__empty<_Tp>) == sizeof(_Tp)))> { }; Modified: trunk/complement/explore/lib/misc/ut/misc_test.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/misc_test.cc 2007-08-06 07:01:16 UTC (rev 1675) +++ trunk/complement/explore/lib/misc/ut/misc_test.cc 2007-08-06 11:18:14 UTC (rev 1676) @@ -11,7 +11,6 @@ #include "misc_test.h" #include <misc/type_traits.h> -#include <iostream> using namespace std; @@ -41,12 +40,12 @@ } template <class T> -static bool q( T v ) +bool q( T v ) { return std::tr1::detail::__instance<T>::__value; } -int EXAM_IMPL(misc_test::type_traits) +int EXAM_IMPL(misc_test::type_traits_internals) { EXAM_CHECK( std::tr1::detail::__instance<int []>::__value == true ); EXAM_CHECK( std::tr1::detail::__instance<int *>::__value == true ); @@ -60,3 +59,52 @@ return EXAM_RESULT; } + +class empty +{ +}; + +class not_empty1 +{ + private: + int k; +}; + +class not_empty2 +{ + private: + int f() const + { return 0; } +}; + +class not_empty3 +{ + private: + virtual int f() const + { return 0; } +}; + +class not_empty4 : + public not_empty2 +{ +}; + +class not_empty5 : + public not_empty3 +{ +}; + +int EXAM_IMPL(misc_test::type_traits_is_empty) +{ + EXAM_CHECK( std::tr1::is_empty<empty>::value == true ); + EXAM_CHECK( std::tr1::is_empty<not_empty1>::value == false ); + // EXAM_CHECK( std::tr1::is_empty<not_empty2>::value == false ); + EXAM_CHECK( std::tr1::is_empty<not_empty3>::value == false ); + EXAM_CHECK( std::tr1::is_empty<int>::value == false ); + // EXAM_CHECK( std::tr1::is_empty<int (&)()>::value == false ); + // EXAM_CHECK( std::tr1::is_empty<not_empty4>::value == false ); + EXAM_CHECK( std::tr1::is_empty<not_empty5>::value == false ); + + return EXAM_RESULT; +} + Modified: trunk/complement/explore/lib/misc/ut/misc_test.h =================================================================== --- trunk/complement/explore/lib/misc/ut/misc_test.h 2007-08-06 07:01:16 UTC (rev 1675) +++ trunk/complement/explore/lib/misc/ut/misc_test.h 2007-08-06 11:18:14 UTC (rev 1676) @@ -18,7 +18,8 @@ class misc_test { public: - int EXAM_DECL(type_traits); + int EXAM_DECL(type_traits_internals); + int EXAM_DECL(type_traits_is_empty); }; #endif // __MISC_TEST_H Modified: trunk/complement/explore/lib/misc/ut/misc_test_suite.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/misc_test_suite.cc 2007-08-06 07:01:16 UTC (rev 1675) +++ trunk/complement/explore/lib/misc/ut/misc_test_suite.cc 2007-08-06 11:18:14 UTC (rev 1676) @@ -20,7 +20,8 @@ exam::test_suite::test_case_type tc[3]; - tc[0] = t.add( &misc_test::type_traits, test, "misc_test::type_traits" ); + t.add( &misc_test::type_traits_is_empty, test, "misc_test::type_traits_is_empty", + t.add( &misc_test::type_traits_internals, test, "misc_test::type_traits_internals" ) ); return t.girdle(); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-06 07:01:17
|
Revision: 1675 http://complement.svn.sourceforge.net/complement/?rev=1675&view=rev Author: complement Date: 2007-08-06 00:01:16 -0700 (Mon, 06 Aug 2007) Log Message: ----------- more traits; established unit tests for type_traits workaround Modified Paths: -------------- trunk/complement/explore/include/misc/type_traits.h Added Paths: ----------- trunk/complement/explore/lib/misc/ut/ trunk/complement/explore/lib/misc/ut/Makefile trunk/complement/explore/lib/misc/ut/Makefile.inc trunk/complement/explore/lib/misc/ut/misc_test.cc trunk/complement/explore/lib/misc/ut/misc_test.h trunk/complement/explore/lib/misc/ut/misc_test_suite.cc trunk/complement/explore/lib/misc/ut/misc_test_suite.h trunk/complement/explore/lib/misc/ut/unit_test.cc Modified: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h 2007-08-06 06:57:59 UTC (rev 1674) +++ trunk/complement/explore/include/misc/type_traits.h 2007-08-06 07:01:16 UTC (rev 1675) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/03 08:59:36 ptr> +// -*- C++ -*- Time-stamp: <07/08/06 10:30:28 ptr> /* * Copyright (c) 2007 @@ -15,22 +15,69 @@ #include <config/feature.h> #endif -#if !defined(STLPORT) /* || (_STLPORT_VERSION < 50200) */ +#if 1 /* !defined(STLPORT) */ /* || (_STLPORT_VERSION < 50200) */ // libstdc++ v3, timestamp 20050519 (3.4.4) has __type_traits, // libstdc++ v3, timestamp 20060306 (3.4.6) has __type_traits, // while libstdc++ v3, 20050921 (4.0.2) not; use libstdc++ instead -# if !defined(__GLIBCXX__) || (defined(__GNUC__) && (__GNUC__ < 4)) +# if 1 /* !defined(__GLIBCXX__) || (defined(__GNUC__) && (__GNUC__ < 4)) */ namespace std { namespace tr1 { +namespace detail { + +struct __select_types +{ + typedef char __t1; + struct __t2 + { + char __two[2]; + }; +}; + +template <class _Tp> +struct __instance : + public __select_types +{ + private: + template <class _Up> + static __t1 __test(_Up(*)[1]); + + template <class> + static __t2 __test(...); + + public: + static const bool __value = sizeof(__test<_Tp>(0)) == 1; +}; + +template <class T> +struct __uoc_aux : // union or class + public __select_types +{ + private: + template <class _Up> + static __t1 __test( int _Up::* ); + + template <class> + static __t2 __test(...); + + public: + static const bool __value = sizeof(__test<T>(0)) == 1; +}; + +template <class T> +class __empty +{ }; + +} // namespace detail + template <class _Tp, _Tp __v> struct integral_constant { static const _Tp value = __v; - // enum { value = __v }; + // enum { value = __v }; ? typedef _Tp value_type; typedef integral_constant<_Tp, __v> type; @@ -39,6 +86,15 @@ typedef integral_constant<bool, true> true_type; typedef integral_constant<bool, false> false_type; +namespace detail { + +template<typename _Tp> +struct __is_union_or_class : + public integral_constant<bool, __uoc_aux<_Tp>::__value> +{ }; + +} // namespace detail + #define __SPEC_(C,T,B) \ template <> \ struct C<T> : \ @@ -75,6 +131,8 @@ __SPEC_2(C,T volatile,B); \ __SPEC_2(C,T const volatile,B) +// [4.5.1] primary type categories: + template <class _Tp> struct is_void : public false_type @@ -111,21 +169,6 @@ __SPEC_FULL(is_floating_point,long double,true); template <class _Tp> -struct is_arithmetic : - public integral_constant<bool, (is_integral<_Tp>::value || is_floating_point<_Tp>::value)> -{ }; - -template <class _Tp> -struct is_fundamental : - public integral_constant<bool, (is_arithmetic<_Tp>::value || is_void<_Tp>::value)> -{ }; - -template <class _Tp> -struct is_compound : - public integral_constant<bool, !is_fundamental<_Tp>::value> -{ }; - -template <class _Tp> struct is_array : public false_type { }; @@ -159,9 +202,9 @@ template <class _Tp> struct is_function : - public integral_constant<bool, !(/* __in_array<_Tp>::__value - || __is_union_or_class<_Tp>::value - || */ is_reference<_Tp>::value + public integral_constant<bool, !(detail::__instance<_Tp>::__value + || detail::__is_union_or_class<_Tp>::value + || is_reference<_Tp>::value || is_void<_Tp>::value)> { }; @@ -224,7 +267,21 @@ public integral_constant<bool, (is_member_object_pointer<_Tp>::value || is_member_function_pointer<_Tp>::value)> { }; +// 4.5.2 composite type categories + template <class _Tp> +struct is_arithmetic : + public integral_constant<bool, (is_integral<_Tp>::value || is_floating_point<_Tp>::value)> +{ }; + +template <class _Tp> +struct is_fundamental : + public integral_constant<bool, (is_arithmetic<_Tp>::value || is_void<_Tp>::value)> +{ }; + +// [4.5.1] primary type categories (continued): + +template <class _Tp> struct is_enum : public integral_constant<bool, !(is_fundamental<_Tp>::value || is_array<_Tp>::value @@ -232,13 +289,28 @@ || is_reference<_Tp>::value || is_member_pointer<_Tp>::value || is_function<_Tp>::value - /* || __is_union_or_class<_Tp>::value */) > + || detail::__is_union_or_class<_Tp>::value) > { }; +template <class T> +struct is_union +{ }; + +template <class T> +struct is_class +{ }; + +// is_function (above) + +// 4.5.2 composite type categories (continued) + +// is_arithmetic (above) +// is_fundamental (above) + template <class _Tp> struct is_object : - public integral_constant<bool, !(is_function<_Tp>::value /* || is_reference<_Tp>::value - || is_void<_Tp>::value */ )> + public integral_constant<bool, !(is_function<_Tp>::value || is_reference<_Tp>::value + || is_void<_Tp>::value)> { }; template <class _Tp> @@ -250,22 +322,13 @@ { }; template <class _Tp> -struct remove_all_extents -{ - typedef _Tp type; -}; +struct is_compound : + public integral_constant<bool, !is_fundamental<_Tp>::value> +{ }; -template <class _Tp, std::size_t _Size> -struct remove_all_extents<_Tp[_Size]> -{ - typedef typename remove_all_extents<_Tp>::type type; -}; +// is_member_pointer -template<typename _Tp> -struct remove_all_extents<_Tp[]> -{ - typedef typename remove_all_extents<_Tp>::type type; -}; +// 4.5.3 type properties: template <class _Tp> struct is_const : @@ -287,12 +350,62 @@ public true_type { }; + +// 4.7.3 array modifications: + template <class _Tp> +struct remove_extent +{ + typedef _Tp type; +}; + +template <class _Tp, std::size_t _Sz> +struct remove_extent<_Tp[_Sz]> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_extent<_Tp[]> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_all_extents +{ + typedef _Tp type; +}; + +template <class _Tp, std::size_t _Size> +struct remove_all_extents<_Tp[_Size]> +{ + typedef typename remove_all_extents<_Tp>::type type; +}; + +template<typename _Tp> +struct remove_all_extents<_Tp[]> +{ + typedef typename remove_all_extents<_Tp>::type type; +}; + +// 4.5.3 type properties (continued): + +template <class _Tp> struct is_pod : public integral_constant<bool, (is_void<_Tp>::value || is_scalar<typename remove_all_extents<_Tp>::type>::value)> { }; +template<typename _Tp> +struct is_empty + : public integral_constant<bool, (detail::__is_union_or_class<_Tp>::__value + && (sizeof(detail::__empty<_Tp>) == sizeof(_Tp)))> +{ }; + +// is_polimorphic +// is_abstract + template <class _Tp> struct has_trivial_constructor : public integral_constant<bool, is_pod<_Tp>::value> @@ -355,6 +468,145 @@ __SPEC_FULL(is_unsigned,unsigned long,true); __SPEC_FULL(is_unsigned,unsigned long long,true); +// alignment_of +// rank +// extent + +// 4.6 type relations: + +template <class _Tp1, class _Tp2> +struct is_same : + public false_type +{ }; + +template <class _Tp> +struct is_same<_Tp, _Tp> : + public true_type +{ }; + +// is_base_of +// is_convertible + +// 4.7.1 const-volatile modifications + +template <class _Tp> +struct remove_const +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_const<_Tp const> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_volatile +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_volatile<_Tp volatile> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_cv +{ + typedef typename remove_const<typename remove_volatile<_Tp>::type>::type type; +}; + +template <class _Tp> +struct add_const +{ + typedef _Tp const type; +}; + +template <class _Tp> +struct add_volatile +{ + typedef _Tp volatile type; +}; + +template <class _Tp> +struct add_cv +{ + typedef typename add_const<typename add_volatile<_Tp>::type>::type type; +}; + +// 4.7.2 reference modifications: + +template <class _Tp> +struct remove_reference +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_reference<_Tp&> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct add_reference +{ + typedef _Tp& type; +}; + +template <class _Tp> +struct add_reference<_Tp&> +{ + typedef _Tp& type; +}; + +// 4.7.3 array modifications (see above) + +// 4.7.4 pointer modifications: + +template <class _Tp> +struct remove_pointer +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_pointer<_Tp *> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_pointer<_Tp * const> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_pointer<_Tp * volatile> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_pointer<_Tp * const volatile> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct add_pointer +{ + typedef typename remove_reference<_Tp>::type * type; +}; + +// 4.8 other transformations: + +// aligned_storage + #undef __SPEC_FULL #undef __SPEC_ #undef __SPEC_FULL1 Property changes on: trunk/complement/explore/lib/misc/ut ___________________________________________________________________ Name: svn:ignore + obj Added: trunk/complement/explore/lib/misc/ut/Makefile =================================================================== --- trunk/complement/explore/lib/misc/ut/Makefile (rev 0) +++ trunk/complement/explore/lib/misc/ut/Makefile 2007-08-06 07:01:16 UTC (rev 1675) @@ -0,0 +1,60 @@ +# -*- Makefile -*- Time-stamp: <07/08/06 10:19:59 ptr> + +SRCROOT := ../../.. + +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak + + +INCLUDES += -I$(SRCROOT)/include +DEFS += -D__FIT_EXAM + +LIBEXAM_DIR = ${CoMT_DIR}/lib/exam + +ifeq ($(OSNAME),linux) + +release-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} + +dbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} + +ifndef WITHOUT_STLPORT +stldbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +endif + +endif + +ifeq ($(OSNAME),openbsd) + +release-shared: LDSEARCH += -Wl,-R:${STLPORT_LIB_DIR} + +dbg-shared: LDSEARCH += -Wl,-R:${STLPORT_LIB_DIR} + +ifndef WITHOUT_STLPORT +stldbg-shared: LDSEARCH += -Wl,-R:${STLPORT_LIB_DIR} +endif + +endif + +release-shared : LDLIBS = -lexam +dbg-shared : LDLIBS = -lexamg +ifndef WITHOUT_STLPORT +stldbg-shared : LDLIBS = -lexamstlg +endif + +ifeq ($(OSNAME),freebsd) +release-shared : LDLIBS += -lthr +dbg-shared : LDLIBS += -lthr +ifndef WITHOUT_STLPORT +stldbg-shared : LDLIBS += -lthr +endif +endif + +ifeq ($(OSNAME),sunos) +release-shared : LDLIBS += -lrt +dbg-shared : LDLIBS += -lrt +ifndef WITHOUT_STLPORT +stldbg-shared : LDLIBS += -lrt +endif +endif + + Added: trunk/complement/explore/lib/misc/ut/Makefile.inc =================================================================== --- trunk/complement/explore/lib/misc/ut/Makefile.inc (rev 0) +++ trunk/complement/explore/lib/misc/ut/Makefile.inc 2007-08-06 07:01:16 UTC (rev 1675) @@ -0,0 +1,5 @@ +# -*- makefile -*- Time-stamp: <07/07/16 22:12:31 ptr> + +PRGNAME = misc_ut +SRC_CC = unit_test.cc \ + misc_test.cc misc_test_suite.cc Added: trunk/complement/explore/lib/misc/ut/misc_test.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/misc_test.cc (rev 0) +++ trunk/complement/explore/lib/misc/ut/misc_test.cc 2007-08-06 07:01:16 UTC (rev 1675) @@ -0,0 +1,62 @@ +// -*- C++ -*- Time-stamp: <07/08/06 10:26:25 ptr> + +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + * + */ + +#include "misc_test.h" + +#include <misc/type_traits.h> +#include <iostream> + +using namespace std; + +class MyType +{ + public: + + virtual int abstract() = 0; + + private: + int a; + int n; +}; + +class MyTypeOther +{ + public: + + private: + int a; + int n; +}; + +int f() +{ + return 0; +} + +template <class T> +static bool q( T v ) +{ + return std::tr1::detail::__instance<T>::__value; +} + +int EXAM_IMPL(misc_test::type_traits) +{ + EXAM_CHECK( std::tr1::detail::__instance<int []>::__value == true ); + EXAM_CHECK( std::tr1::detail::__instance<int *>::__value == true ); + EXAM_CHECK( std::tr1::detail::__instance<int&>::__value == false ); + EXAM_CHECK( std::tr1::detail::__instance<MyTypeOther>::__value == true ); + EXAM_CHECK( std::tr1::detail::__instance<int>::__value == true ); + EXAM_CHECK( std::tr1::detail::__instance<MyType>::__value == false ); + EXAM_CHECK( std::tr1::detail::__instance<int (*)()>::__value == true ); + EXAM_CHECK( std::tr1::detail::__instance<int (&)()>::__value == false ); + EXAM_CHECK( q(f) == true ); + + return EXAM_RESULT; +} Added: trunk/complement/explore/lib/misc/ut/misc_test.h =================================================================== --- trunk/complement/explore/lib/misc/ut/misc_test.h (rev 0) +++ trunk/complement/explore/lib/misc/ut/misc_test.h 2007-08-06 07:01:16 UTC (rev 1675) @@ -0,0 +1,24 @@ +// -*- C++ -*- Time-stamp: <07/07/16 21:01:43 ptr> + +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + * + */ + +#ifndef __MISC_TEST_H +#define __MISC_TEST_H + +#define FIT_EXAM + +#include <exam/suite.h> + +class misc_test +{ + public: + int EXAM_DECL(type_traits); +}; + +#endif // __MISC_TEST_H Added: trunk/complement/explore/lib/misc/ut/misc_test_suite.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/misc_test_suite.cc (rev 0) +++ trunk/complement/explore/lib/misc/ut/misc_test_suite.cc 2007-08-06 07:01:16 UTC (rev 1675) @@ -0,0 +1,26 @@ +// -*- C++ -*- Time-stamp: <07/07/17 10:20:08 ptr> + +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + * + */ + +#include "misc_test_suite.h" +#include "misc_test.h" + +#include <config/feature.h> + +int EXAM_IMPL(misc_test_suite) +{ + exam::test_suite t( "libmisc? test" ); + misc_test test; + + exam::test_suite::test_case_type tc[3]; + + tc[0] = t.add( &misc_test::type_traits, test, "misc_test::type_traits" ); + + return t.girdle(); +}; Added: trunk/complement/explore/lib/misc/ut/misc_test_suite.h =================================================================== --- trunk/complement/explore/lib/misc/ut/misc_test_suite.h (rev 0) +++ trunk/complement/explore/lib/misc/ut/misc_test_suite.h 2007-08-06 07:01:16 UTC (rev 1675) @@ -0,0 +1,18 @@ +// -*- C++ -*- Time-stamp: <07/07/16 22:08:39 ptr> + +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + * + */ + +#ifndef __MISC_TEST_SUITE_H +#define __MISC_TEST_SUITE_H + +#include <exam/suite.h> + +int EXAM_DECL(misc_test_suite); + +#endif // __MISC_TEST_SUITE_H Added: trunk/complement/explore/lib/misc/ut/unit_test.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/unit_test.cc (rev 0) +++ trunk/complement/explore/lib/misc/ut/unit_test.cc 2007-08-06 07:01:16 UTC (rev 1675) @@ -0,0 +1,19 @@ +// -*- C++ -*- Time-stamp: <07/07/16 22:12:10 ptr> + +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + * + */ + +#include <exam/suite.h> +#include <config/feature.h> + +#include "misc_test_suite.h" + +int main( int, char ** ) +{ + return misc_test_suite(0); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-06 06:58:04
|
Revision: 1674 http://complement.svn.sourceforge.net/complement/?rev=1674&view=rev Author: complement Date: 2007-08-05 23:57:59 -0700 (Sun, 05 Aug 2007) Log Message: ----------- missed return Modified Paths: -------------- trunk/complement/explore/lib/mt/ut/mt_test.cc Modified: trunk/complement/explore/lib/mt/ut/mt_test.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test.cc 2007-08-04 05:50:17 UTC (rev 1673) +++ trunk/complement/explore/lib/mt/ut/mt_test.cc 2007-08-06 06:57:59 UTC (rev 1674) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/17 09:58:22 ptr> +// -*- C++ -*- Time-stamp: <07/08/06 10:03:33 ptr> /* * Copyright (c) 2006, 2007 @@ -36,6 +36,8 @@ xmt::barrier b( 1 ); b.wait(); + + return EXAM_RESULT; } /* ****************************************************** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-04 05:50:24
|
Revision: 1673 http://complement.svn.sourceforge.net/complement/?rev=1673&view=rev Author: complement Date: 2007-08-03 22:50:17 -0700 (Fri, 03 Aug 2007) Log Message: ----------- Condition -> condition Modified Paths: -------------- trunk/complement/explore/include/DB/PgSQL.h Modified: trunk/complement/explore/include/DB/PgSQL.h =================================================================== --- trunk/complement/explore/include/DB/PgSQL.h 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/include/DB/PgSQL.h 2007-08-04 05:50:17 UTC (rev 1673) @@ -72,7 +72,7 @@ DBconn *_conn; xmt::Thread thr; - xmt::Condition con_cond; + xmt::condition con_cond; friend class Cursor; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 20:13:55
|
Revision: 1672 http://complement.svn.sourceforge.net/complement/?rev=1672&view=rev Author: complement Date: 2007-08-03 13:13:53 -0700 (Fri, 03 Aug 2007) Log Message: ----------- double copy? Removed Paths: ------------- trunk/complement/explore/lib/stem/ut/stem/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 20:10:51
|
Revision: 1671 http://complement.svn.sourceforge.net/complement/?rev=1671&view=rev Author: complement Date: 2007-08-03 13:10:49 -0700 (Fri, 03 Aug 2007) Log Message: ----------- lost stem unit test? more tags for unit tests Modified Paths: -------------- trunk/complement/explore/lib/exam/Makefile trunk/complement/explore/lib/exam/ut/Makefile trunk/complement/explore/lib/exam/ut/Makefile.inc trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/Makefile trunk/complement/explore/lib/mt/ut/Makefile trunk/complement/explore/lib/sockios/Makefile Added Paths: ----------- trunk/complement/explore/lib/stem/ut/stem/Convert.cc trunk/complement/explore/lib/stem/ut/stem/Convert.h trunk/complement/explore/lib/stem/ut/stem/Echo.cc trunk/complement/explore/lib/stem/ut/stem/Echo.h trunk/complement/explore/lib/stem/ut/stem/Makefile trunk/complement/explore/lib/stem/ut/stem/Makefile.inc trunk/complement/explore/lib/stem/ut/stem/NameService.cc trunk/complement/explore/lib/stem/ut/stem/NameService.h trunk/complement/explore/lib/stem/ut/stem/Node.cc trunk/complement/explore/lib/stem/ut/stem/Node.h trunk/complement/explore/lib/stem/ut/stem/NodeDL.h trunk/complement/explore/lib/stem/ut/stem/dl/ trunk/complement/explore/lib/stem/ut/stem/unit_test.cc Modified: trunk/complement/explore/lib/exam/Makefile =================================================================== --- trunk/complement/explore/lib/exam/Makefile 2007-08-03 20:05:01 UTC (rev 1670) +++ trunk/complement/explore/lib/exam/Makefile 2007-08-03 20:10:49 UTC (rev 1671) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/07/16 15:00:11 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 23:56:16 ptr> SRCROOT := ../.. @@ -29,8 +29,5 @@ (cd ./ut; ${OUTPUT_DIR_STLDBG}/exam_self_test) || exit 1 endif -depend:: - $(MAKE) -C ./ut depend - -clean:: - $(MAKE) -C ./ut clean +depend clean distclean mostlyclean maintainer-clean:: + ${MAKE} -C ut $@ Modified: trunk/complement/explore/lib/exam/ut/Makefile =================================================================== --- trunk/complement/explore/lib/exam/ut/Makefile 2007-08-03 20:05:01 UTC (rev 1670) +++ trunk/complement/explore/lib/exam/ut/Makefile 2007-08-03 20:10:49 UTC (rev 1671) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/07/21 09:01:38 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 22:53:39 ptr> SRCROOT := ../../.. @@ -8,4 +8,24 @@ INCLUDES += -I${CoMT_INCLUDE_DIR} DEFS += -D__FIT_EXAM +LIBEXAM_DIR = ${CoMT_DIR}/lib/exam + LDFLAGS += -Wl,-rpath=${STLPORT_LIB_DIR} + +ifeq ($(OSNAME),linux) + +release-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} + +dbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} + +ifndef WITHOUT_STLPORT +stldbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +endif + +endif + +release-shared : LDLIBS = -lexam +dbg-shared : LDLIBS = -lexamg +ifndef WITHOUT_STLPORT +stldbg-shared : LDLIBS = -lexamstlg +endif Modified: trunk/complement/explore/lib/exam/ut/Makefile.inc =================================================================== --- trunk/complement/explore/lib/exam/ut/Makefile.inc 2007-08-03 20:05:01 UTC (rev 1670) +++ trunk/complement/explore/lib/exam/ut/Makefile.inc 2007-08-03 20:10:49 UTC (rev 1671) @@ -1,7 +1,5 @@ -# -*- makefile -*- Time-stamp: <02/07/14 14:03:13 ptr> +# -*- makefile -*- Time-stamp: <07/08/03 22:54:01 ptr> PRGNAME = exam_self_test SRC_CC = exam_self_test.cc \ - exam_test_suite.cc \ - ../suite.cc \ - ../logger.cc + exam_test_suite.cc Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-08-03 20:05:01 UTC (rev 1670) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-08-03 20:10:49 UTC (rev 1671) @@ -6,8 +6,10 @@ * xmt.h: add typedefs shared_mutex, shared_recursive_mutex; * shm.h: change ipc_sharable on is_ipc_sharable, use TR1 type_traits - technique; add tricks to compile without STLport. + technique; add tricks to compile without STLport; + * ut: moved from ../../test/mt to ut. + 2007-07-17 Petr Ovtchenkov <pt...@is...> * test/mt: boost unit test framework was replaced by exam. Modified: trunk/complement/explore/lib/mt/Makefile =================================================================== --- trunk/complement/explore/lib/mt/Makefile 2007-08-03 20:05:01 UTC (rev 1670) +++ trunk/complement/explore/lib/mt/Makefile 2007-08-03 20:10:49 UTC (rev 1671) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/01/23 15:00:11 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 23:56:04 ptr> SRCROOT := ../.. @@ -8,24 +8,26 @@ INCLUDES += -I$(SRCROOT)/include check: all-shared - $(MAKE) -C ../../test/mt - (cd ../../test/mt; ${OUTPUT_DIR}/mt_ut) || exit 1 - (cd ../../test/mt; ${OUTPUT_DIR_DBG}/mt_ut) || exit 1 - (cd ../../test/mt; ${OUTPUT_DIR_STLDBG}/mt_ut) || exit 1 + $(MAKE) -C ut all-shared + (cd ut; ${OUTPUT_DIR}/mt_ut) || exit 1 + (cd ut; ${OUTPUT_DIR_DBG}/mt_ut) || exit 1 +ifndef WITHOUT_STLPORT + (cd ut; ${OUTPUT_DIR_STLDBG}/mt_ut) || exit 1 +endif check-release-shared: release-shared - $(MAKE) -C ../../test/mt release-shared - (cd ../../test/mt; ${OUTPUT_DIR}/mt_ut) || exit 1 + $(MAKE) -C ut release-shared + (cd ut; ${OUTPUT_DIR}/mt_ut) || exit 1 check-dbg-shared: dbg-shared - $(MAKE) -C ../../test/mt dbg-shared - (cd ../../test/mt; ${OUTPUT_DIR_DBG}/mt_ut) || exit 1 + $(MAKE) -C ut dbg-shared + (cd ut; ${OUTPUT_DIR_DBG}/mt_ut) || exit 1 ifndef WITHOUT_STLPORT check-stldbg-shared: stldbg-shared - $(MAKE) -C ../../test/mt stldbg-shared - (cd ../../test/mt; ${OUTPUT_DIR_STLDBG}/mt_ut) || exit 1 + $(MAKE) -C ut stldbg-shared + (cd ut; ${OUTPUT_DIR_STLDBG}/mt_ut) || exit 1 endif -depend:: - $(MAKE) -C ../../test/mt depend +depend clean distclean mostlyclean maintainer-clean:: + ${MAKE} -C ut $@ Modified: trunk/complement/explore/lib/mt/ut/Makefile =================================================================== --- trunk/complement/explore/lib/mt/ut/Makefile 2007-08-03 20:05:01 UTC (rev 1670) +++ trunk/complement/explore/lib/mt/ut/Makefile 2007-08-03 20:10:49 UTC (rev 1671) @@ -1,7 +1,6 @@ -# -*- Makefile -*- Time-stamp: <07/07/17 10:01:41 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 22:38:12 ptr> -SRCROOT := ../.. -COMPILER_NAME := gcc +SRCROOT := ../../.. include Makefile.inc include ${SRCROOT}/Makefiles/gmake/top.mak @@ -27,31 +26,49 @@ LIBFS_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/filesystem ifeq ($(OSNAME),linux) + release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBFS_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBFS_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} + +dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBFS_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBFS_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} + +ifndef WITHOUT_STLPORT stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBFS_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBFS_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBFS_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBFS_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif +endif + ifeq ($(OSNAME),openbsd) + release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -Wl,-R${LIBMT_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} + +dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -Wl,-R${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} + +ifndef WITHOUT_STLPORT stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -Wl,-R${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -Wl,-R${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif +endif + release-shared : LDLIBS = -lxmt -lexam -lboost_fs +dbg-shared : LDLIBS = -lxmtg -lexamg -lboost_fsg +ifndef WITHOUT_STLPORT stldbg-shared : LDLIBS = -lxmtstlg -lexamstlg -lboost_fsstlg -dbg-shared : LDLIBS = -lxmtg -lexamg -lboost_fsg +endif ifeq ($(OSNAME),freebsd) release-shared : LDLIBS += -lthr +dbg-shared : LDLIBS += -lthr +ifndef WITHOUT_STLPORT stldbg-shared : LDLIBS += -lthr -dbg-shared : LDLIBS += -lthr endif +endif ifeq ($(OSNAME),sunos) release-shared : LDLIBS += -lrt +dbg-shared : LDLIBS += -lrt +ifndef WITHOUT_STLPORT stldbg-shared : LDLIBS += -lrt -dbg-shared : LDLIBS += -lrt endif +endif Modified: trunk/complement/explore/lib/sockios/Makefile =================================================================== --- trunk/complement/explore/lib/sockios/Makefile 2007-08-03 20:05:01 UTC (rev 1670) +++ trunk/complement/explore/lib/sockios/Makefile 2007-08-03 20:10:49 UTC (rev 1671) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/08/03 23:06:18 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 23:55:50 ptr> SRCROOT := ../.. @@ -29,8 +29,5 @@ (cd ut; ${OUTPUT_DIR_STLDBG}/sockios_ut) || exit 1 endif -depend:: - $(MAKE) -C ut depend - -clean:: - $(MAKE) -C ut clean +depend clean distclean mostlyclean maintainer-clean:: + ${MAKE} -C ut $@ Added: trunk/complement/explore/lib/stem/ut/stem/Convert.cc =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/Convert.cc (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/Convert.cc 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,104 @@ +// -*- C++ -*- Time-stamp: <07/07/20 00:05:52 ptr> + +/* + * + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#include "Convert.h" + +void mess::pack( std::ostream& s ) const +{ + __pack( s, super_id ); + __pack( s, message ); +} + +void mess::net_pack( std::ostream& s ) const +{ + __net_pack( s, super_id ); + __net_pack( s, message ); +} + +void mess::unpack( std::istream& s ) +{ + __unpack( s, super_id ); + __unpack( s, message ); +} + +void mess::net_unpack( std::istream& s ) +{ + __net_unpack( s, super_id ); + __net_unpack( s, message ); +} + +Convert::Convert() : + EventHandler(), + v( 0 ) +{ + cnd.set( false ); +} + +Convert::Convert( stem::addr_type id ) : + EventHandler( id ), + v( 0 ) +{ + cnd.set( false ); +} + +Convert::Convert( stem::addr_type id, const char *info ) : + EventHandler( id, info ), + v( 0 ) +{ + cnd.set( false ); +} + +Convert::~Convert() +{ + // cnd.wait(); +} + +void Convert::handler0() +{ + v = -1; + cnd.set(true); +} + +void Convert::handler1( const stem::Event& ) +{ + v = 1; + cnd.set(true); +} + +void Convert::handler2( const stem::Event_base<mess>& ev ) +{ + v = ev.value().super_id; + m2 = ev.value().message; + + cnd.set(true); +} + +void Convert::handler3( const mess& m ) +{ + v = m.super_id; + m3 = m.message; + + cnd.set(true); +} + +void Convert::wait() +{ + cnd.try_wait(); + + cnd.set( false ); +} + +DEFINE_RESPONSE_TABLE( Convert ) + EV_VOID( ST_NULL, CONV_EV0, handler0 ) + EV_EDS( ST_NULL, CONV_EV1, handler1 ) + EV_Event_base_T_( ST_NULL, CONV_EV2, handler2, mess ) + EV_T_( ST_NULL, CONV_EV3, handler3, mess ) +END_RESPONSE_TABLE Added: trunk/complement/explore/lib/stem/ut/stem/Convert.h =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/Convert.h (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/Convert.h 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,74 @@ +// -*- C++ -*- Time-stamp: <07/07/20 00:03:52 ptr> + +/* + * + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#ifndef __Convert_h +#define __Convert_h + +#include <mt/xmt.h> + +#include <stem/Event.h> +#include <stem/EventHandler.h> + +#include <stdint.h> +#include <string> + +struct mess : + public stem::__pack_base +{ + void pack( std::ostream& s ) const; + void net_pack( std::ostream& s ) const; + void unpack( std::istream& s ); + void net_unpack( std::istream& s ); + + mess() + { } + mess( const mess& m ) : + super_id( m.super_id ), + message( m.message ) + { } + + int32_t super_id; + std::string message; +}; + +class Convert : + public stem::EventHandler +{ + public: + Convert(); + Convert( stem::addr_type id ); + Convert( stem::addr_type id, const char *info ); + ~Convert(); + + void handler0(); + void handler1( const stem::Event& ); + void handler2( const stem::Event_base<mess>& ); + void handler3( const mess& ); + + void wait(); + + int v; + + std::string m2; + std::string m3; + + private: + xmt::condition cnd; + + DECLARE_RESPONSE_TABLE( Convert, stem::EventHandler ); +}; + +#define CONV_EV0 0x909 +#define CONV_EV1 0x90a +#define CONV_EV2 0x90b +#define CONV_EV3 0x90c + +#endif // __Convert_h Added: trunk/complement/explore/lib/stem/ut/stem/Echo.cc =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/Echo.cc (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/Echo.cc 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,144 @@ +// -*- C++ -*- Time-stamp: <06/11/29 13:02:34 ptr> + +/* + * Copyright (c) 2006, 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#include "Echo.h" + +#include <stem/NetTransport.h> +#include <stem/EvManager.h> + +#include <exam/suite.h> + +using namespace stem; + +StEMecho::StEMecho() +{ +} + +StEMecho::StEMecho( addr_type id ) : + EventHandler( id ) +{ +} + +StEMecho::StEMecho( addr_type id, const char *info ) : + EventHandler( id, info ) +{ +} + +void StEMecho::echo( const Event& ev ) +{ + Event eev( ev.code() ); + eev.value() = ev.value(); + + eev.dest( ev.src() ); + + Send( eev ); +} + +void StEMecho::regme( const stem::Event& ev ) +{ + // cerr << "Echo\n"; + manager()->change_announce( ev.src(), ev.value() ); + cnd.set( true ); +} + +DEFINE_RESPONSE_TABLE( StEMecho ) + EV_EDS( 0, NODE_EV_ECHO, echo ) + EV_EDS( 0, NODE_EV_REGME, regme ) +END_RESPONSE_TABLE + +EchoClient::EchoClient() : + EventHandler(), + mess( "echo string" ) +{ + cnd.set( false ); +} + +EchoClient::EchoClient( stem::addr_type id ) : + EventHandler( id ), + mess( "echo string" ) +{ + cnd.set( false ); +} + +EchoClient::EchoClient( stem::addr_type id, const char *info ) : + EventHandler( id, info ), + mess( "echo string" ) +{ + cnd.set( false ); +} + +EchoClient::~EchoClient() +{ + // cnd.wait(); +} + +void EchoClient::handler1( const stem::Event& ev ) +{ + EXAM_CHECK_ASYNC( ev.value() == mess ); + cnd.set(true); +} + +void EchoClient::wait() +{ + cnd.try_wait(); +} + +DEFINE_RESPONSE_TABLE( EchoClient ) + EV_EDS(0,NODE_EV_ECHO,handler1) +END_RESPONSE_TABLE + +PeerClient::PeerClient() : + EventHandler(), + mess( "peer client" ) +{ + cnd.set( false ); +} + +PeerClient::PeerClient( stem::addr_type id ) : + EventHandler( id ), + mess( "peer client" ) +{ + cnd.set( false ); +} + +PeerClient::PeerClient( const char *info ) : + EventHandler( info ), + mess( info ) +{ + cnd.set( false ); +} + +PeerClient::PeerClient( stem::addr_type id, const char *info ) : + EventHandler( id, info ), + mess( info ) +{ + cnd.set( false ); +} + +PeerClient::~PeerClient() +{ + // cnd.wait(); +} + +void PeerClient::handler1( const stem::Event& ev ) +{ + EXAM_CHECK_ASYNC( ev.value() == mess ); + + cnd.set(true); +} + +void PeerClient::wait() +{ + cnd.try_wait(); +} + +DEFINE_RESPONSE_TABLE( PeerClient ) + EV_EDS(0,NODE_EV_ECHO,handler1) +END_RESPONSE_TABLE Added: trunk/complement/explore/lib/stem/ut/stem/Echo.h =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/Echo.h (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/Echo.h 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,83 @@ +// -*- C++ -*- Time-stamp: <07/07/11 21:45:09 ptr> + +/* + * Copyright (c) 2006, 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#ifndef __Echo_h +#define __Echo_h + +#include <string> +#include <mt/xmt.h> +#include <stem/EventHandler.h> +// #include <stem/Names.h> +// #include <list> + +class StEMecho : + public stem::EventHandler +{ + public: + StEMecho(); + StEMecho( stem::addr_type id ); + StEMecho( stem::addr_type id, const char * ); + + void echo( const stem::Event& ); + void regme( const stem::Event& ); + + xmt::condition cnd; + + private: + DECLARE_RESPONSE_TABLE( StEMecho, stem::EventHandler ); +}; + +class EchoClient : + public stem::EventHandler +{ + public: + EchoClient(); + EchoClient( stem::addr_type id ); + EchoClient( stem::addr_type id, const char *info ); + ~EchoClient(); + + void handler1( const stem::Event& ); + + void wait(); + + const std::string mess; + + private: + xmt::condition cnd; + + DECLARE_RESPONSE_TABLE( EchoClient, stem::EventHandler ); +}; + +class PeerClient : + public stem::EventHandler +{ + public: + PeerClient(); + PeerClient( stem::addr_type id ); + PeerClient( const char *info ); + PeerClient( stem::addr_type id, const char *info ); + ~PeerClient(); + + void handler1( const stem::Event& ); + + void wait(); + + const std::string mess; + + private: + xmt::condition cnd; + + DECLARE_RESPONSE_TABLE( PeerClient, stem::EventHandler ); +}; + +#define NODE_EV_ECHO 0x903 +#define NODE_EV_REGME 0x904 + +#endif // __Echo_h Added: trunk/complement/explore/lib/stem/ut/stem/Makefile =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/Makefile (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/Makefile 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,48 @@ +# -*- Makefile -*- Time-stamp: <07/02/07 12:28:46 ptr> + +SRCROOT := ../.. + +EXTRA_POST := dl-rel +EXTRA_POST_DBG := dl-dbg +EXTRA_POST_STLDBG := dl-stldbg + +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak + +INCLUDES += -I$(SRCROOT)/include +DEFS += -D__FIT_EXAM + +LIBMT_DIR = ${CoMT_DIR}/lib/mt +LIBSOCK_DIR = ${CoMT_DIR}/lib/sockios +LIBSTEM_DIR = ${CoMT_DIR}/lib/stem +LIBEXAM_DIR = ${CoMT_DIR}/lib/exam + +ifeq ($(OSNAME),linux) +release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -Wl,--rpath=./dl/${OUTPUT_DIR}:${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +ifndef WITHOUT_STLPORT +stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=./dl/${OUTPUT_DIR_STLDBG}:${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +endif +dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=./dl/${OUTPUT_DIR_DBG}:${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +endif + +release-shared : LDLIBS = -lxmt -lsockios -lstem -lexam -ldl +ifndef WITHOUT_STLPORT +stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lexamstlg -ldl +endif +dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lexamg -ldl + +# dbg-shared: DEFS += -DDEBUG + +PHONY += dl-rel dl-dbg dl-stldbg + +dl-rel: + ${MAKE} -C dl release-shared + +dl-dbg: + ${MAKE} -C dl dbg-shared + +dl-stldbg: + ${MAKE} -C dl stldbg-shared + +depend clean distclean mostlyclean maintainer-clean:: + ${MAKE} -C dl $@ Added: trunk/complement/explore/lib/stem/ut/stem/Makefile.inc =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/Makefile.inc (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/Makefile.inc 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,8 @@ +# -*- makefile -*- Time-stamp: <07/07/20 00:14:24 ptr> + +PRGNAME = stem_ut +SRC_CC = unit_test.cc \ + Node.cc \ + NameService.cc \ + Echo.cc \ + Convert.cc Added: trunk/complement/explore/lib/stem/ut/stem/NameService.cc =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/NameService.cc (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/NameService.cc 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,61 @@ +// -*- C++ -*- Time-stamp: <06/11/29 10:50:21 ptr> + +/* + * Copyright (c) 2006, 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#include <iostream> +#include <functional> +#include <iterator> + +#include <stem/EDSEv.h> +#include "NameService.h" + +using namespace std; +using namespace stem; +using namespace xmt; + +Naming::Naming() : + EventHandler() +{ + cnd.set( false ); +} + +Naming::Naming( stem::addr_type id ) : + EventHandler( id ) +{ + cnd.set( false ); +} + +Naming::~Naming() +{ + // cnd.wait(); +} + +void Naming::names_list( const nsrecords_type& nr ) +{ + copy( nr.container.begin(), nr.container.end(), back_insert_iterator<nsrecords_type::container_type>(lst) ); + + cnd.set(true); +} + +void Naming::names_name( const nsrecords_type& nr ) +{ + copy( nr.container.begin(), nr.container.end(), back_insert_iterator<nsrecords_type::container_type>(lst) ); + + cnd.set(true); +} + +void Naming::wait() +{ + cnd.try_wait(); +} + +DEFINE_RESPONSE_TABLE( Naming ) + EV_T_(0,EV_STEM_NS_LIST,names_list,nsrecords_type) + EV_T_(0,EV_STEM_NS_NAME,names_name,nsrecords_type) +END_RESPONSE_TABLE Added: trunk/complement/explore/lib/stem/ut/stem/NameService.h =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/NameService.h (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/NameService.h 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,44 @@ +// -*- C++ -*- Time-stamp: <07/07/11 21:47:37 ptr> + +/* + * Copyright (c) 2006, 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#ifndef __NameService_h +#define __NameService_h + +#include <mt/xmt.h> +#include <stem/EventHandler.h> +#include <stem/Names.h> +#include <list> + +class Naming : + public stem::EventHandler +{ + public: + Naming(); + Naming( stem::addr_type id ); + ~Naming(); + + typedef stem::NameRecords<stem::gaddr_type,std::string> nsrecords_type; + + void names_list( const nsrecords_type& ); + void names_name( const nsrecords_type& ); + + void wait(); + void reset() + { cnd.set( false ); } + + nsrecords_type::container_type lst; + + private: + xmt::condition cnd; + + DECLARE_RESPONSE_TABLE( Naming, stem::EventHandler ); +}; + +#endif // __NameService_h Added: trunk/complement/explore/lib/stem/ut/stem/Node.cc =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/Node.cc (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/Node.cc 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,97 @@ +// -*- C++ -*- Time-stamp: <06/09/29 23:23:57 ptr> + +/* + * + * Copyright (c) 2002, 2003, 2006, 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#include "Node.h" + +using namespace std; +using namespace stem; +using namespace xmt; + +Node::Node() : + EventHandler(), + v( 0 ) +{ + cnd.set( false ); +} + +Node::Node( stem::addr_type id ) : + EventHandler( id ), + v( 0 ) +{ + cnd.set( false ); +} + +Node::Node( stem::addr_type id, const char *info ) : + EventHandler( id, info ), + v( 0 ) +{ + cnd.set( false ); +} + +Node::~Node() +{ + // cnd.wait(); +} + +void Node::handler1( const stem::Event& ) +{ + // std::cerr << "I am here 1\n"; + v = 1; + cnd.set(true); + // std::cerr << "I am here 2\n"; +} + +void Node::wait() +{ + cnd.try_wait(); +} + +DEFINE_RESPONSE_TABLE( Node ) + EV_EDS(0,NODE_EV1,handler1) +END_RESPONSE_TABLE + +// the same as Node, just another class + +NewNode::NewNode() : + EventHandler(), + v( 0 ) +{ + cnd.set( false ); +} + +NewNode::NewNode( stem::addr_type id ) : + EventHandler( id ), + v( 0 ) +{ + cnd.set( false ); +} + +NewNode::~NewNode() +{ + // cnd.wait(); +} + +void NewNode::handler1( const stem::Event& ) +{ + // std::cerr << "I am here 1\n"; + v = 1; + cnd.set(true); + // std::cerr << "I am here 2\n"; +} + +void NewNode::wait() +{ + cnd.try_wait(); +} + +DEFINE_RESPONSE_TABLE( NewNode ) + EV_EDS(0,NODE_EV1,handler1) +END_RESPONSE_TABLE Added: trunk/complement/explore/lib/stem/ut/stem/Node.h =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/Node.h (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/Node.h 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,62 @@ +// -*- C++ -*- Time-stamp: <07/07/11 21:47:25 ptr> + +/* + * + * Copyright (c) 2002, 2003, 2006, 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#ifndef __Node_h +#define __Node_h + +#include <mt/xmt.h> +#include <stem/EventHandler.h> + +class Node : + public stem::EventHandler +{ + public: + Node(); + Node( stem::addr_type id ); + Node( stem::addr_type id, const char *info ); + ~Node(); + + void handler1( const stem::Event& ); + + void wait(); + + int v; + + private: + xmt::condition cnd; + + DECLARE_RESPONSE_TABLE( Node, stem::EventHandler ); +}; + +// the same as Node, just another class +class NewNode : + public stem::EventHandler +{ + public: + NewNode(); + NewNode( stem::addr_type id ); + ~NewNode(); + + void handler1( const stem::Event& ); + + void wait(); + + int v; + + private: + xmt::condition cnd; + + DECLARE_RESPONSE_TABLE( NewNode, stem::EventHandler ); +}; + +#define NODE_EV1 0x900 + +#endif // __Node_h Added: trunk/complement/explore/lib/stem/ut/stem/NodeDL.h =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/NodeDL.h (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/NodeDL.h 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,66 @@ +// -*- C++ -*- Time-stamp: <07/07/11 21:47:58 ptr> + +/* + * + * Copyright (c) 2002, 2003, 2006, 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#ifndef __NodeDL_h +#define __NodeDL_h + +#include <mt/xmt.h> +#include <stem/EventHandler.h> + +class NodeDL : + public stem::EventHandler +{ + public: + NodeDL(); + NodeDL( stem::addr_type id ); + ~NodeDL(); + + void handler1( const stem::Event& ); + + void wait(); + + int v; + + private: + xmt::condition cnd; + + DECLARE_RESPONSE_TABLE( NodeDL, stem::EventHandler ); +}; + +// the same as Node, just another class +class NewNodeDL : + public stem::EventHandler +{ + public: + NewNodeDL(); + NewNodeDL( stem::addr_type id ); + ~NewNodeDL(); + + void handler1( const stem::Event& ); + + void wait(); + + int v; + + private: + xmt::condition cnd; + + DECLARE_RESPONSE_TABLE( NewNodeDL, stem::EventHandler ); +}; + +#define NODE_EV2 0x901 + +extern "C" void *create_NewNodeDL( unsigned ); +extern "C" void wait_NewNodeDL( void * ); +extern "C" int v_NewNodeDL( void * ); +extern "C" void destroy_NewNodeDL( void * ); + +#endif // __NodeDL_h Property changes on: trunk/complement/explore/lib/stem/ut/stem/dl ___________________________________________________________________ Name: svn:ignore + obj Added: trunk/complement/explore/lib/stem/ut/stem/unit_test.cc =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/unit_test.cc (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/unit_test.cc 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,835 @@ +// -*- C++ -*- Time-stamp: <07/07/20 00:21:37 ptr> + +/* + * Copyright (c) 2002, 2003, 2006, 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#include <exam/suite.h> + +#include <iostream> +#include <mt/xmt.h> +#include <mt/shm.h> + +#include <stem/EventHandler.h> +#include <stem/Names.h> +#include <stem/EDSEv.h> + +#include "Node.h" +#include "NodeDL.h" +#include "NameService.h" + +#include <dlfcn.h> + +#include "Echo.h" +#include "Convert.h" + +#include <stem/NetTransport.h> +#include <stem/EvManager.h> +#include <sockios/sockmgr.h> + +#ifndef STLPORT +#include <ext/functional> +using namespace __gnu_cxx; +#endif + +#include <sys/wait.h> + +#include <signal.h> + +using namespace std; + +class stem_test +{ + public: + stem_test(); + ~stem_test(); + + int EXAM_DECL(basic1); + int EXAM_DECL(basic2); + int EXAM_DECL(basic1new); + int EXAM_DECL(basic2new); + int EXAM_DECL(dl); + int EXAM_DECL(ns); + + int EXAM_DECL(echo); + int EXAM_DECL(echo_net); + int EXAM_DECL(net_echo); + int EXAM_DECL(peer); + int EXAM_DECL(boring_manager); + int EXAM_DECL(convert); + + static xmt::Thread::ret_code thr1( void * ); + static xmt::Thread::ret_code thr1new( void * ); + + private: +}; + +int EXAM_IMPL(stem_test::basic1) +{ + Node node( 2000 ); + + EDS::Event ev( NODE_EV1 ); + + ev.dest( 2000 ); + node.Send( ev ); + + node.wait(); + EXAM_CHECK( node.v == 1 ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(stem_test::basic2) +{ + Node node( 2000 ); + + xmt::Thread t1( thr1 ); + + EXAM_CHECK( t1.join().iword == 0 ); + + node.wait(); + + EXAM_CHECK( node.v == 1 ); + + return EXAM_RESULT; +} + +xmt::Thread::ret_code stem_test::thr1( void * ) +{ + xmt::Thread::ret_code rt; + rt.iword = 0; + + Node node( 2001 ); + + EDS::Event ev( NODE_EV1 ); + + ev.dest( 2000 ); + node.Send( ev ); + + return rt; +} + +int EXAM_IMPL(stem_test::basic1new) +{ + NewNode *node = new NewNode( 2000 ); + + EDS::Event ev( NODE_EV1 ); + + ev.dest( 2000 ); + node->Send( ev ); + + node->wait(); + + EXAM_CHECK( node->v == 1 ); + delete node; + + return EXAM_RESULT; +} + +int EXAM_IMPL(stem_test::basic2new) +{ + NewNode *node = new NewNode( 2000 ); + + xmt::Thread t1( thr1new ); + + t1.join(); + + node->wait(); + EXAM_CHECK( node->v == 1 ); + delete node; + + return EXAM_RESULT; +} + +xmt::Thread::ret_code stem_test::thr1new( void * ) +{ + xmt::Thread::ret_code rt; + rt.iword = 0; + + NewNode *node = new NewNode( 2001 ); + + EDS::Event ev( NODE_EV1 ); + + ev.dest( 2000 ); + node->Send( ev ); + + delete node; + + return rt; +} + +int EXAM_IMPL(stem_test::dl) +{ + void *lh = dlopen( "libloadable_stem.so", RTLD_LAZY ); // Path was passed via -Wl,--rpath= + + EXAM_REQUIRE( lh != NULL ); + void *(*f)(unsigned); + void (*g)(void *); + void (*w)(void *); + int (*v)(void *); + + *(void **)(&f) = dlsym( lh, "create_NewNodeDL" ); + EXAM_REQUIRE( f != NULL ); + *(void **)(&g) = dlsym( lh, "destroy_NewNodeDL" ); + EXAM_REQUIRE( g != NULL ); + *(void **)(&w) = dlsym( lh, "wait_NewNodeDL" ); + EXAM_REQUIRE( w != NULL ); + *(void **)(&v) = dlsym( lh, "v_NewNodeDL" ); + EXAM_REQUIRE( v != NULL ); + + NewNodeDL *node = reinterpret_cast<NewNodeDL *>( f( 2002 ) ); + stem::Event ev( NODE_EV2 ); + ev.dest( 2002 ); + node->Send( ev ); + + w( reinterpret_cast<void *>(node) ); + EXAM_CHECK( v(reinterpret_cast<void *>(node)) == 1 ); + + g( reinterpret_cast<void *>(node) ); + dlclose( lh ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(stem_test::ns) +{ + Node node( 2003, "Node" ); + Naming nm; + + stem::Event ev( EV_STEM_GET_NS_LIST ); + ev.dest( stem::ns_addr ); + nm.Send( ev ); + + nm.wait(); + + // this is sample of all inline find: + Naming::nsrecords_type::const_iterator i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( equal_to<string>(), string( "ns" ) ), select2nd<pair<stem::gaddr_type,string> >() ) ); + + EXAM_CHECK( i != nm.lst.end() ); + EXAM_CHECK( i->second == "ns" ); + EXAM_CHECK( i->first.hid == xmt::hostid() ); + EXAM_CHECK( i->first.pid == getpid() ); + EXAM_CHECK( i->first.addr == stem::ns_addr ); + + // well, but for few seaches declare and reuse functors: + equal_to<string> eq; + equal_to<stem::gaddr_type> eqa; + + select1st<pair<stem::gaddr_type,string> > first; + select2nd<pair<stem::gaddr_type,string> > second; + + i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "Node" ) ), second ) ); + + EXAM_CHECK( i != nm.lst.end() ); + EXAM_CHECK( i->second == "Node" ); + EXAM_CHECK( i->first.addr == 2003 ); + + i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eqa, nm.self_glid() ), first ) ); + + EXAM_CHECK( i != nm.lst.end() ); + EXAM_CHECK( i->first == nm.self_glid() ); + EXAM_CHECK( i->second.length() == 0 ); + + nm.lst.clear(); + nm.reset(); + + EXAM_CHECK( nm.lst.empty() ); + + stem::Event evname( EV_STEM_GET_NS_NAME ); + evname.dest( stem::ns_addr ); + evname.value() = "Node"; + nm.Send( evname ); + + nm.wait(); + + i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "ns" ) ), second ) ); + + EXAM_CHECK( i == nm.lst.end() ); + + i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "Node" ) ), second ) ); + + EXAM_CHECK( i != nm.lst.end() ); + EXAM_CHECK( i->second == "Node" ); + EXAM_CHECK( i->first.addr == 2003 ); + + i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eqa, nm.self_glid() ), first ) ); + + EXAM_CHECK( i == nm.lst.end() ); + + nm.lst.clear(); + nm.reset(); + + EXAM_CHECK( nm.lst.empty() ); + + evname.value() = "No-such-name"; + nm.Send( evname ); + + nm.wait(); + + EXAM_CHECK( nm.lst.empty() ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(stem_test::echo) +{ + try { + sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); + stem::NetTransportMgr mgr; + + StEMecho echo( 0, "echo service"); // <= zero! + + stem::addr_type zero = mgr.open( "localhost", 6995 ); + + EXAM_CHECK( zero != stem::badaddr ); + EXAM_CHECK( zero == 0 ); // NetTransportMgr should detect local delivery + + EchoClient node; + + stem::Event ev( NODE_EV_ECHO ); + + ev.dest( zero ); + ev.value() = node.mess; + + node.Send( ev ); + + node.wait(); + + mgr.close(); + mgr.join(); + + srv.close(); + srv.wait(); + } + catch ( ... ) { + } + + return EXAM_RESULT; +} + +const char fname[] = "/tmp/stem_test.shm"; +xmt::shm_alloc<0> seg; +xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; +xmt::allocator_shm<xmt::__barrier<true>,0> shm_b; + +stem_test::stem_test() +{ + try { + seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); + } + catch ( const xmt::shm_bad_alloc& err ) { + EXAM_ERROR_ASYNC( err.what() ); + } +} + +stem_test::~stem_test() +{ + seg.deallocate(); + unlink( fname ); +} + +int EXAM_IMPL(stem_test::echo_net) +{ + xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); + fcnd.set( false ); + + try { + xmt::fork(); + + try { + stem::NetTransportMgr mgr; + + fcnd.try_wait(); + + stem::addr_type zero = mgr.open( "localhost", 6995 ); + + EXAM_CHECK_ASYNC( zero != stem::badaddr ); + EXAM_CHECK_ASYNC( zero != 0 ); // NetTransportMgr should detect external delivery + + EchoClient node; + + stem::Event ev( NODE_EV_ECHO ); + + ev.dest( zero ); + ev.value() = node.mess; + + node.Send( ev ); + + node.wait(); + + mgr.close(); + mgr.join(); + } + catch ( ... ) { + } + + exit( 0 ); + } + catch ( xmt::fork_in_parent& child ) { + try { + sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); + + StEMecho echo( 0, "echo service"); // <= zero! + + fcnd.set( true ); + + int stat; + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + + srv.close(); + srv.wait(); + } + catch ( ... ) { + } + } + + (&fcnd)->~__condition<true>(); + shm_cnd.deallocate( &fcnd, 1 ); + + // cerr << "Fine\n"; + + return EXAM_RESULT; +} + +// same as echo_net(), but server in child process + +int EXAM_IMPL(stem_test::net_echo) +{ + try { + xmt::__barrier<true>& b = *new ( shm_b.allocate( 1 ) ) xmt::__barrier<true>(); + xmt::__condition<true>& c = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); + + c.set( false ); + + try { + xmt::fork(); + + // server part + { + std::sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); + StEMecho echo( 0, "echo service"); + + // echo.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch ); + // echo.manager()->settrs( &std::cerr ); + + EXAM_CHECK_ASYNC( srv.good() ); + c.set( true ); // ok, server listen + + b.wait(); // server may go away + + srv.close(); + srv.wait(); + } + + exit( 0 ); + } + catch ( xmt::fork_in_parent& child ) { + // client part + + stem::NetTransportMgr mgr; + // mgr.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch | stem::EvManager::tracefault ); + // mgr.manager()->settrs( &std::cerr ); + + c.try_wait(); // wait server start + + stem::addr_type zero = mgr.open( "localhost", 6995 ); + + EXAM_REQUIRE( mgr.good() ); + EXAM_REQUIRE( zero != stem::badaddr ); + + EchoClient node; + stem::Event ev( NODE_EV_ECHO ); + ev.dest( zero ); + + ev.value() = node.mess; + node.Send( ev ); + + node.wait(); + + mgr.close(); + mgr.join(); + + b.wait(); // server may go away + + int stat; + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + } + + (&c)->~__condition<true>(); + shm_cnd.deallocate( &c, 1 ); + (&b)->~__barrier<true>(); + shm_b.deallocate( &b, 1 ); + } + catch ( xmt::shm_bad_alloc& err ) { + EXAM_ERROR( err.what() ); + } + + return EXAM_RESULT; +} + +extern "C" { + +static void dummy_signal_handler( int ) +{ } + +} + +int EXAM_IMPL(stem_test::peer) +{ + /* + * Scheme: + * / NetTransport / c1 + * Local Event Manager - NetTransportMgr - c2 + * \ echo + * Due to all objects in the same process space, + * c1, c2 and echo in different processes. + * + * The logical scheme is: + * + * / c1 + * echo + * \ c2 + * + * (c1 <-> c2, through 'echo') + */ + + pid_t fpid; + + xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); + fcnd.set( false ); + + xmt::__condition<true>& pcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); + pcnd.set( false ); + + xmt::__condition<true>& scnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); + scnd.set( false ); + + try { + // Client 1 + xmt::fork(); +#if 0 + struct sigaction action; + struct sigaction old_action; + action.sa_flags = 0; + action.sa_handler = &dummy_signal_handler; + sigemptyset( &action.sa_mask ); + + sigaction( SIGFPE, &action, &old_action ); + sigaction( SIGTRAP, &action, &old_action ); + sigaction( SIGSEGV, &action, &old_action ); + sigaction( SIGBUS, &action, &old_action ); + sigaction( SIGABRT, &action, &old_action ); + sigaction( SIGALRM, &action, &old_action ); +#endif + + try { + stem::NetTransportMgr mgr; + + PeerClient c1( "c1 local" ); // c1 client + Naming nm; + + fcnd.try_wait(); + + stem::addr_type zero = mgr.open( "localhost", 6995 ); // take address of 'zero' (aka default) object via net transport from server + // It done like it should on client side + + EXAM_CHECK_ASYNC( zero != stem::badaddr ); + EXAM_CHECK_ASYNC( zero != 0 ); + EXAM_CHECK_ASYNC( zero & stem::extbit ); // "external" address + + stem::Event ev( NODE_EV_REGME ); + ev.dest( zero ); + + ev.value() = "c1@here"; + c1.Send( ev ); // 'register' c1 client on 'echo' server + + stem::gaddr_type ga( c1.manager()->reflect( zero ) ); + + EXAM_CHECK_ASYNC( ga.addr == 0 ); + EXAM_CHECK_ASYNC( ga.pid != -1 ); + + ga.addr = stem::ns_addr; // this will be global address of ns of the same process + // as zero + + EXAM_CHECK_ASYNC( c1.manager()->reflect( ga ) != stem::badaddr ); + + stem::Event evname( EV_STEM_GET_NS_NAME ); + evname.dest( c1.manager()->reflect( ga ) ); + evname.value() = "c2@here"; + + pcnd.try_wait(); + + Naming::nsrecords_type::const_iterator i; + + do { + nm.reset(); + nm.lst.clear(); + nm.Send( evname ); + nm.wait(); + i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( equal_to<string>(), string( "c2@here" ) ), select2nd<pair<stem::gaddr_type,string> >() ) ); + } while ( i == nm.lst.end() ); + + EXAM_CHECK_ASYNC( i != nm.lst.end() ); + EXAM_CHECK_ASYNC( i->second == "c2@here" ); + + stem::addr_type pa = c1.manager()->reflect( i->first ); + if ( pa == stem::badaddr ) { // unknown yet + pa = c1.manager()->SubscribeRemote( i->first, i->second ); + if ( pa == stem::badaddr ) { // it still unknown, transport not found + // hint: use transport as object zero used + pa = c1.manager()->SubscribeRemote( c1.manager()->transport( zero ), i->first, i->second ); + } + } + + EXAM_CHECK_ASYNC( pa != stem::badaddr ); + + if ( pa != stem::badaddr ) { + stem::Event pe( NODE_EV_ECHO ); + pe.dest( pa ); + pe.value() = "c2 local"; // <<-- mess is like name ... | + // . + c1.Send( pe ); + } + + scnd.try_wait(); + + mgr.close(); + mgr.join(); + } + catch ( ... ) { + } + + exit( 0 ); + } + catch ( xmt::fork_in_parent& child ) { + fpid = child.pid(); + } + + try { + // Client 2 + xmt::fork(); + +#if 0 + struct sigaction action; + struct sigaction old_action; + action.sa_flags = 0; + action.sa_handler = &dummy_signal_handler; + sigemptyset( &action.sa_mask ); + + sigaction( SIGFPE, &action, &old_action ); + sigaction( SIGTRAP, &action, &old_action ); + sigaction( SIGSEGV, &action, &old_action ); + sigaction( SIGBUS, &action, &old_action ); + sigaction( SIGABRT, &action, &old_action ); + sigaction( SIGALRM, &action, &old_action ); +#endif + + try { + stem::NetTransportMgr mgr; + // ^ + PeerClient c2( "c2 local" ); // <<--- name the same as mess expected ... | + + fcnd.try_wait(); + stem::addr_type zero = mgr.open( "localhost", 6995 ); // take address of 'zero' (aka default) object via net transport from server + // It done like it should on client side + + EXAM_CHECK_ASYNC( zero != stem::badaddr ); + EXAM_CHECK_ASYNC( zero != 0 ); + EXAM_CHECK_ASYNC( zero & stem::extbit ); // "external" address + + stem::Event ev( NODE_EV_REGME ); + ev.dest( zero ); + + ev.value() = "c2@here"; + c2.Send( ev ); // 'register' c2 client on 'echo' server + + pcnd.set( true ); + + c2.wait(); + // cerr << "Fine!" << endl; + scnd.set( true ); + + mgr.close(); + mgr.join(); + } + catch ( ... ) { + } + + exit( 0 ); + } + catch ( xmt::fork_in_parent& child ) { + sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); // server, it serve 'echo' + StEMecho echo( 0, "echo service"); // <= zero! 'echo' server, default ('zero' address) + + fcnd.set( true, true ); + + int stat; + waitpid( child.pid(), &stat, 0 ); + waitpid( fpid, &stat, 0 ); + + srv.close(); + srv.wait(); + } + + (&fcnd)->~__condition<true>(); + shm_cnd.deallocate( &fcnd, 1 ); + (&pcnd)->~__condition<true>(); + shm_cnd.deallocate( &pcnd, 1 ); + (&scnd)->~__condition<true>(); + shm_cnd.deallocate( &scnd, 1 ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(stem_test::boring_manager) +{ + xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); + fcnd.set( false ); + + try { + // Client + xmt::fork(); + try { + fcnd.try_wait(); + + for ( int i = 0; i < 10; ++i ) { + const int n = 10; + stem::NetTransportMgr *mgr[n]; + mgr[0] = new stem::NetTransportMgr; + mgr[0]->open( "localhost", 6995 ); + + for ( int j = 1; j < n; ++j ) { + mgr[j] = new stem::NetTransportMgr; + stem::addr_type a = mgr[j]->open( "localhost", 6995 ); + mgr[j]->close(); + mgr[j]->join(); + delete mgr[j]; + } + mgr[0]->close(); + mgr[0]->join(); + delete mgr[0]; + } + } + catch ( ... ) { + } + exit( 0 ); + } + catch ( xmt::fork_in_parent& child ) { + sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); // server, it serve 'echo' + StEMecho echo( 0, "echo service"); // <= zero! 'echo' server, default ('zero' address) + + fcnd.set( true, true ); + + int stat; + waitpid( child.pid(), &stat, 0 ); + + srv.close(); + srv.wait(); + } + + (&fcnd)->~__condition<true>(); + shm_cnd.deallocate( &fcnd, 1 ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(stem_test::convert) +{ + Convert conv; + mess m; + + m.super_id = 2; + m.message = "hello"; + + stem::Event_base<mess> ev( CONV_EV0 ); + + ev.dest( conv.self_id() ); + ev.value() = m; + + conv.Send( ev ); + + conv.wait(); + + EXAM_CHECK( conv.v == -1 ); + + stem::Event_base<mess> ev1( CONV_EV1 ); + + ev1.dest( conv.self_id() ); + ev1.value() = m; + + conv.Send( ev1 ); + + conv.wait(); + + EXAM_CHECK( conv.v == 1 ); + + stem::Event_base<mess> ev2( CONV_EV2 ); + + ev2.dest( conv.self_id() ); + ev2.value() = m; + + conv.Send( ev2 ); + + conv.wait(); + + EXAM_CHECK( conv.v == 2 ); + EXAM_CHECK( conv.m2 == "hello" ); + + stem::Event_base<mess> ev3( CONV_EV3 ); + + ev3.dest( conv.self_id() ); + ev3.value().super_id = 3; + ev3.value().message = ", wold!"; + + conv.Send( ev3 ); + + conv.wait(); + + EXAM_CHECK( conv.v == 3 ); + EXAM_CHECK( conv.m3 == ", wold!" ); + + return EXAM_RESULT; +} + +// ----------------- + +// ----------------- + +int EXAM_DECL(stem_test_suite); + +int EXAM_IMPL(stem_test_suite) +{ + exam::test_suite::test_case_type tc[4]; + + exam::test_suite t( "libstem test suite" ); + stem_test test; + + tc[1] = t.add( &stem_test::basic2, test, "basic2", + tc[0] = t.add( &stem_test::basic1, test, "basic1" ) ); + + tc[2] = t.add( &stem_test::basic1new, test, "basic1new", tc[0] ); + + t.add( &stem_test::dl, test, "dl", + t.add( &stem_test::basic2new, test, "basic2new", tc + 1, tc + 3 ) ); + t.add( &stem_test::ns, test, "ns", tc[0] ); + + t.add( &stem_test::net_echo, test, "net echo", + t.add( &stem_test::echo_net, test, "echo_net", + tc[3] = t.add( &stem_test::echo, test, "echo", tc[1] ) ) ); + + t.add( &stem_test::boring_manager, test, "boring_manager", + t.add( &stem_test::peer, test, "peer", tc[3] ) ); + + t.add( &stem_test::convert, test, "convert", tc[0] ); + + return t.girdle(); +} + +int main( int, char ** ) +{ + return stem_test_suite(0); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 20:05:07
|
Revision: 1670 http://complement.svn.sourceforge.net/complement/?rev=1670&view=rev Author: complement Date: 2007-08-03 13:05:01 -0700 (Fri, 03 Aug 2007) Log Message: ----------- moved to ut Modified Paths: -------------- trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/Makefile trunk/complement/explore/lib/stem/ut/Makefile trunk/complement/explore/lib/stem/ut/dl/Makefile Added Paths: ----------- trunk/complement/explore/lib/stem/ut/ trunk/complement/explore/lib/stem/ut/stem/ Removed Paths: ------------- trunk/complement/explore/lib/stem/ut/stem/Convert.cc trunk/complement/explore/lib/stem/ut/stem/Convert.h trunk/complement/explore/lib/stem/ut/stem/Echo.cc trunk/complement/explore/lib/stem/ut/stem/Echo.h trunk/complement/explore/lib/stem/ut/stem/Makefile trunk/complement/explore/lib/stem/ut/stem/Makefile.inc trunk/complement/explore/lib/stem/ut/stem/NameService.cc trunk/complement/explore/lib/stem/ut/stem/NameService.h trunk/complement/explore/lib/stem/ut/stem/Node.cc trunk/complement/explore/lib/stem/ut/stem/Node.h trunk/complement/explore/lib/stem/ut/stem/NodeDL.h trunk/complement/explore/lib/stem/ut/stem/dl/ trunk/complement/explore/lib/stem/ut/stem/unit_test.cc trunk/complement/explore/test/stem/ Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-08-03 19:46:45 UTC (rev 1669) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-08-03 20:05:01 UTC (rev 1670) @@ -6,8 +6,10 @@ * Event.h, EvManager.cc, EvPack.cc: use TR1 type_traits technique; add tricks to compile without STLport; - * EventHandler.h: remove STLport's macro. + * EventHandler.h: remove STLport's macro; + * ../../test/stem: moved to ut. + 2007-07-27 Petr Ovtchenkov <pt...@is...> * Event.h, EvManager.cc, EvPack.cc: operator of format output Modified: trunk/complement/explore/lib/stem/Makefile =================================================================== --- trunk/complement/explore/lib/stem/Makefile 2007-08-03 19:46:45 UTC (rev 1669) +++ trunk/complement/explore/lib/stem/Makefile 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/08/03 09:12:25 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 23:55:31 ptr> SRCROOT := ../.. @@ -14,26 +14,26 @@ endif check: all-shared - $(MAKE) -C ../../test/stem - (cd ../../test/stem; ${OUTPUT_DIR}/stem_ut) || exit 1 - (cd ../../test/stem; ${OUTPUT_DIR_DBG}/stem_ut) || exit 1 + $(MAKE) -C ut + (cd ut; ${OUTPUT_DIR}/stem_ut) || exit 1 + (cd ut; ${OUTPUT_DIR_DBG}/stem_ut) || exit 1 ifndef WITHOUT_STLPORT - (cd ../../test/stem; ${OUTPUT_DIR_STLDBG}/stem_ut) || exit 1 + (cd ut; ${OUTPUT_DIR_STLDBG}/stem_ut) || exit 1 endif check-release-shared: release-shared - $(MAKE) -C ../../test/stem release-shared - (cd ../../test/stem; ${OUTPUT_DIR}/stem_ut) || exit 1 + $(MAKE) -C ut release-shared + (cd ut; ${OUTPUT_DIR}/stem_ut) || exit 1 check-dbg-shared: dbg-shared - $(MAKE) -C ../../test/stem dbg-shared - (cd ../../test/stem; ${OUTPUT_DIR_DBG}/stem_ut) || exit 1 + $(MAKE) -C ut dbg-shared + (cd ut; ${OUTPUT_DIR_DBG}/stem_ut) || exit 1 ifndef WITHOUT_STLPORT check-stldbg-shared: stldbg-shared - $(MAKE) -C ../../test/stem stldbg-shared - (cd ../../test/stem; ${OUTPUT_DIR_STLDBG}/stem_ut) || exit 1 + $(MAKE) -C ut stldbg-shared + (cd ut; ${OUTPUT_DIR_STLDBG}/stem_ut) || exit 1 endif -depend:: - $(MAKE) -C ../../test/stem depend +depend clean distclean mostlyclean maintainer-clean:: + ${MAKE} -C ut $@ Copied: trunk/complement/explore/lib/stem/ut (from rev 1668, trunk/complement/explore/test/stem) Modified: trunk/complement/explore/lib/stem/ut/Makefile =================================================================== --- trunk/complement/explore/test/stem/Makefile 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/Makefile 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,6 +1,6 @@ -# -*- Makefile -*- Time-stamp: <07/02/07 12:28:46 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 23:55:05 ptr> -SRCROOT := ../.. +SRCROOT := ../../.. EXTRA_POST := dl-rel EXTRA_POST_DBG := dl-dbg @@ -18,18 +18,24 @@ LIBEXAM_DIR = ${CoMT_DIR}/lib/exam ifeq ($(OSNAME),linux) + release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -Wl,--rpath=./dl/${OUTPUT_DIR}:${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} + ifndef WITHOUT_STLPORT + stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=./dl/${OUTPUT_DIR_STLDBG}:${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} + endif + dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=./dl/${OUTPUT_DIR_DBG}:${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} + endif release-shared : LDLIBS = -lxmt -lsockios -lstem -lexam -ldl +dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lexamg -ldl ifndef WITHOUT_STLPORT stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lexamstlg -ldl endif -dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lexamg -ldl # dbg-shared: DEFS += -DDEBUG Modified: trunk/complement/explore/lib/stem/ut/dl/Makefile =================================================================== --- trunk/complement/explore/test/stem/dl/Makefile 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/dl/Makefile 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,7 +1,6 @@ -# -*- Makefile -*- Time-stamp: <07/02/07 12:13:04 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 23:59:51 ptr> -SRCROOT := ../../.. -COMPILER_NAME := gcc +SRCROOT := ../../../.. DBG_SUFFIX := STLDBG_SUFFIX := @@ -15,14 +14,19 @@ #LDSEARCH = -L${STLPORT_LIB_DIR} -L${CoMT_LIB_DIR} release-shared: LDSEARCH += -L${LIBSTEM_DIR}/${OUTPUT_DIR} +dbg-shared: LDSEARCH += -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} +ifndef WITHOUT_STLPORT stldbg-shared: LDSEARCH += -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -dbg-shared: LDSEARCH += -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} +endif #release-shared : LDLIBS = -lxmt -lsockios -lstem -lboost_test_utf release-shared: LDLIBS = -lstem #stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lboost_test_utfstlg -stldbg-shared: LDLIBS = -lstemstlg #dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lboost_test_utfg dbg-shared: LDLIBS = -lstemg +ifndef WITHOUT_STLPORT +stldbg-shared: LDLIBS = -lstemstlg +endif + #LDFLAGS += -Wl,-rpath=${STLPORT_LIB_DIR}:${CoMT_LIB_DIR} Copied: trunk/complement/explore/lib/stem/ut/stem (from rev 1668, trunk/complement/explore/test/stem) Property changes on: trunk/complement/explore/lib/stem/ut/stem ___________________________________________________________________ Name: svn:ignore + .make.depend obj *.dvi *.lot *.lof *.loc Deleted: trunk/complement/explore/lib/stem/ut/stem/Convert.cc =================================================================== --- trunk/complement/explore/test/stem/Convert.cc 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/Convert.cc 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,104 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/20 00:05:52 ptr> - -/* - * - * Copyright (c) 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#include "Convert.h" - -void mess::pack( std::ostream& s ) const -{ - __pack( s, super_id ); - __pack( s, message ); -} - -void mess::net_pack( std::ostream& s ) const -{ - __net_pack( s, super_id ); - __net_pack( s, message ); -} - -void mess::unpack( std::istream& s ) -{ - __unpack( s, super_id ); - __unpack( s, message ); -} - -void mess::net_unpack( std::istream& s ) -{ - __net_unpack( s, super_id ); - __net_unpack( s, message ); -} - -Convert::Convert() : - EventHandler(), - v( 0 ) -{ - cnd.set( false ); -} - -Convert::Convert( stem::addr_type id ) : - EventHandler( id ), - v( 0 ) -{ - cnd.set( false ); -} - -Convert::Convert( stem::addr_type id, const char *info ) : - EventHandler( id, info ), - v( 0 ) -{ - cnd.set( false ); -} - -Convert::~Convert() -{ - // cnd.wait(); -} - -void Convert::handler0() -{ - v = -1; - cnd.set(true); -} - -void Convert::handler1( const stem::Event& ) -{ - v = 1; - cnd.set(true); -} - -void Convert::handler2( const stem::Event_base<mess>& ev ) -{ - v = ev.value().super_id; - m2 = ev.value().message; - - cnd.set(true); -} - -void Convert::handler3( const mess& m ) -{ - v = m.super_id; - m3 = m.message; - - cnd.set(true); -} - -void Convert::wait() -{ - cnd.try_wait(); - - cnd.set( false ); -} - -DEFINE_RESPONSE_TABLE( Convert ) - EV_VOID( ST_NULL, CONV_EV0, handler0 ) - EV_EDS( ST_NULL, CONV_EV1, handler1 ) - EV_Event_base_T_( ST_NULL, CONV_EV2, handler2, mess ) - EV_T_( ST_NULL, CONV_EV3, handler3, mess ) -END_RESPONSE_TABLE Deleted: trunk/complement/explore/lib/stem/ut/stem/Convert.h =================================================================== --- trunk/complement/explore/test/stem/Convert.h 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/Convert.h 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,74 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/20 00:03:52 ptr> - -/* - * - * Copyright (c) 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#ifndef __Convert_h -#define __Convert_h - -#include <mt/xmt.h> - -#include <stem/Event.h> -#include <stem/EventHandler.h> - -#include <stdint.h> -#include <string> - -struct mess : - public stem::__pack_base -{ - void pack( std::ostream& s ) const; - void net_pack( std::ostream& s ) const; - void unpack( std::istream& s ); - void net_unpack( std::istream& s ); - - mess() - { } - mess( const mess& m ) : - super_id( m.super_id ), - message( m.message ) - { } - - int32_t super_id; - std::string message; -}; - -class Convert : - public stem::EventHandler -{ - public: - Convert(); - Convert( stem::addr_type id ); - Convert( stem::addr_type id, const char *info ); - ~Convert(); - - void handler0(); - void handler1( const stem::Event& ); - void handler2( const stem::Event_base<mess>& ); - void handler3( const mess& ); - - void wait(); - - int v; - - std::string m2; - std::string m3; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( Convert, stem::EventHandler ); -}; - -#define CONV_EV0 0x909 -#define CONV_EV1 0x90a -#define CONV_EV2 0x90b -#define CONV_EV3 0x90c - -#endif // __Convert_h Deleted: trunk/complement/explore/lib/stem/ut/stem/Echo.cc =================================================================== --- trunk/complement/explore/test/stem/Echo.cc 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/Echo.cc 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,144 +0,0 @@ -// -*- C++ -*- Time-stamp: <06/11/29 13:02:34 ptr> - -/* - * Copyright (c) 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#include "Echo.h" - -#include <stem/NetTransport.h> -#include <stem/EvManager.h> - -#include <exam/suite.h> - -using namespace stem; - -StEMecho::StEMecho() -{ -} - -StEMecho::StEMecho( addr_type id ) : - EventHandler( id ) -{ -} - -StEMecho::StEMecho( addr_type id, const char *info ) : - EventHandler( id, info ) -{ -} - -void StEMecho::echo( const Event& ev ) -{ - Event eev( ev.code() ); - eev.value() = ev.value(); - - eev.dest( ev.src() ); - - Send( eev ); -} - -void StEMecho::regme( const stem::Event& ev ) -{ - // cerr << "Echo\n"; - manager()->change_announce( ev.src(), ev.value() ); - cnd.set( true ); -} - -DEFINE_RESPONSE_TABLE( StEMecho ) - EV_EDS( 0, NODE_EV_ECHO, echo ) - EV_EDS( 0, NODE_EV_REGME, regme ) -END_RESPONSE_TABLE - -EchoClient::EchoClient() : - EventHandler(), - mess( "echo string" ) -{ - cnd.set( false ); -} - -EchoClient::EchoClient( stem::addr_type id ) : - EventHandler( id ), - mess( "echo string" ) -{ - cnd.set( false ); -} - -EchoClient::EchoClient( stem::addr_type id, const char *info ) : - EventHandler( id, info ), - mess( "echo string" ) -{ - cnd.set( false ); -} - -EchoClient::~EchoClient() -{ - // cnd.wait(); -} - -void EchoClient::handler1( const stem::Event& ev ) -{ - EXAM_CHECK_ASYNC( ev.value() == mess ); - cnd.set(true); -} - -void EchoClient::wait() -{ - cnd.try_wait(); -} - -DEFINE_RESPONSE_TABLE( EchoClient ) - EV_EDS(0,NODE_EV_ECHO,handler1) -END_RESPONSE_TABLE - -PeerClient::PeerClient() : - EventHandler(), - mess( "peer client" ) -{ - cnd.set( false ); -} - -PeerClient::PeerClient( stem::addr_type id ) : - EventHandler( id ), - mess( "peer client" ) -{ - cnd.set( false ); -} - -PeerClient::PeerClient( const char *info ) : - EventHandler( info ), - mess( info ) -{ - cnd.set( false ); -} - -PeerClient::PeerClient( stem::addr_type id, const char *info ) : - EventHandler( id, info ), - mess( info ) -{ - cnd.set( false ); -} - -PeerClient::~PeerClient() -{ - // cnd.wait(); -} - -void PeerClient::handler1( const stem::Event& ev ) -{ - EXAM_CHECK_ASYNC( ev.value() == mess ); - - cnd.set(true); -} - -void PeerClient::wait() -{ - cnd.try_wait(); -} - -DEFINE_RESPONSE_TABLE( PeerClient ) - EV_EDS(0,NODE_EV_ECHO,handler1) -END_RESPONSE_TABLE Deleted: trunk/complement/explore/lib/stem/ut/stem/Echo.h =================================================================== --- trunk/complement/explore/test/stem/Echo.h 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/Echo.h 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,83 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:45:09 ptr> - -/* - * Copyright (c) 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#ifndef __Echo_h -#define __Echo_h - -#include <string> -#include <mt/xmt.h> -#include <stem/EventHandler.h> -// #include <stem/Names.h> -// #include <list> - -class StEMecho : - public stem::EventHandler -{ - public: - StEMecho(); - StEMecho( stem::addr_type id ); - StEMecho( stem::addr_type id, const char * ); - - void echo( const stem::Event& ); - void regme( const stem::Event& ); - - xmt::condition cnd; - - private: - DECLARE_RESPONSE_TABLE( StEMecho, stem::EventHandler ); -}; - -class EchoClient : - public stem::EventHandler -{ - public: - EchoClient(); - EchoClient( stem::addr_type id ); - EchoClient( stem::addr_type id, const char *info ); - ~EchoClient(); - - void handler1( const stem::Event& ); - - void wait(); - - const std::string mess; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( EchoClient, stem::EventHandler ); -}; - -class PeerClient : - public stem::EventHandler -{ - public: - PeerClient(); - PeerClient( stem::addr_type id ); - PeerClient( const char *info ); - PeerClient( stem::addr_type id, const char *info ); - ~PeerClient(); - - void handler1( const stem::Event& ); - - void wait(); - - const std::string mess; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( PeerClient, stem::EventHandler ); -}; - -#define NODE_EV_ECHO 0x903 -#define NODE_EV_REGME 0x904 - -#endif // __Echo_h Deleted: trunk/complement/explore/lib/stem/ut/stem/Makefile =================================================================== --- trunk/complement/explore/test/stem/Makefile 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/Makefile 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,48 +0,0 @@ -# -*- Makefile -*- Time-stamp: <07/02/07 12:28:46 ptr> - -SRCROOT := ../.. - -EXTRA_POST := dl-rel -EXTRA_POST_DBG := dl-dbg -EXTRA_POST_STLDBG := dl-stldbg - -include Makefile.inc -include ${SRCROOT}/Makefiles/gmake/top.mak - -INCLUDES += -I$(SRCROOT)/include -DEFS += -D__FIT_EXAM - -LIBMT_DIR = ${CoMT_DIR}/lib/mt -LIBSOCK_DIR = ${CoMT_DIR}/lib/sockios -LIBSTEM_DIR = ${CoMT_DIR}/lib/stem -LIBEXAM_DIR = ${CoMT_DIR}/lib/exam - -ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -Wl,--rpath=./dl/${OUTPUT_DIR}:${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} -ifndef WITHOUT_STLPORT -stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=./dl/${OUTPUT_DIR_STLDBG}:${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} -endif -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=./dl/${OUTPUT_DIR_DBG}:${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} -endif - -release-shared : LDLIBS = -lxmt -lsockios -lstem -lexam -ldl -ifndef WITHOUT_STLPORT -stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lexamstlg -ldl -endif -dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lexamg -ldl - -# dbg-shared: DEFS += -DDEBUG - -PHONY += dl-rel dl-dbg dl-stldbg - -dl-rel: - ${MAKE} -C dl release-shared - -dl-dbg: - ${MAKE} -C dl dbg-shared - -dl-stldbg: - ${MAKE} -C dl stldbg-shared - -depend clean distclean mostlyclean maintainer-clean:: - ${MAKE} -C dl $@ Deleted: trunk/complement/explore/lib/stem/ut/stem/Makefile.inc =================================================================== --- trunk/complement/explore/test/stem/Makefile.inc 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/Makefile.inc 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,8 +0,0 @@ -# -*- makefile -*- Time-stamp: <07/07/20 00:14:24 ptr> - -PRGNAME = stem_ut -SRC_CC = unit_test.cc \ - Node.cc \ - NameService.cc \ - Echo.cc \ - Convert.cc Deleted: trunk/complement/explore/lib/stem/ut/stem/NameService.cc =================================================================== --- trunk/complement/explore/test/stem/NameService.cc 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/NameService.cc 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,61 +0,0 @@ -// -*- C++ -*- Time-stamp: <06/11/29 10:50:21 ptr> - -/* - * Copyright (c) 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#include <iostream> -#include <functional> -#include <iterator> - -#include <stem/EDSEv.h> -#include "NameService.h" - -using namespace std; -using namespace stem; -using namespace xmt; - -Naming::Naming() : - EventHandler() -{ - cnd.set( false ); -} - -Naming::Naming( stem::addr_type id ) : - EventHandler( id ) -{ - cnd.set( false ); -} - -Naming::~Naming() -{ - // cnd.wait(); -} - -void Naming::names_list( const nsrecords_type& nr ) -{ - copy( nr.container.begin(), nr.container.end(), back_insert_iterator<nsrecords_type::container_type>(lst) ); - - cnd.set(true); -} - -void Naming::names_name( const nsrecords_type& nr ) -{ - copy( nr.container.begin(), nr.container.end(), back_insert_iterator<nsrecords_type::container_type>(lst) ); - - cnd.set(true); -} - -void Naming::wait() -{ - cnd.try_wait(); -} - -DEFINE_RESPONSE_TABLE( Naming ) - EV_T_(0,EV_STEM_NS_LIST,names_list,nsrecords_type) - EV_T_(0,EV_STEM_NS_NAME,names_name,nsrecords_type) -END_RESPONSE_TABLE Deleted: trunk/complement/explore/lib/stem/ut/stem/NameService.h =================================================================== --- trunk/complement/explore/test/stem/NameService.h 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/NameService.h 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,44 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:47:37 ptr> - -/* - * Copyright (c) 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#ifndef __NameService_h -#define __NameService_h - -#include <mt/xmt.h> -#include <stem/EventHandler.h> -#include <stem/Names.h> -#include <list> - -class Naming : - public stem::EventHandler -{ - public: - Naming(); - Naming( stem::addr_type id ); - ~Naming(); - - typedef stem::NameRecords<stem::gaddr_type,std::string> nsrecords_type; - - void names_list( const nsrecords_type& ); - void names_name( const nsrecords_type& ); - - void wait(); - void reset() - { cnd.set( false ); } - - nsrecords_type::container_type lst; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( Naming, stem::EventHandler ); -}; - -#endif // __NameService_h Deleted: trunk/complement/explore/lib/stem/ut/stem/Node.cc =================================================================== --- trunk/complement/explore/test/stem/Node.cc 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/Node.cc 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,97 +0,0 @@ -// -*- C++ -*- Time-stamp: <06/09/29 23:23:57 ptr> - -/* - * - * Copyright (c) 2002, 2003, 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#include "Node.h" - -using namespace std; -using namespace stem; -using namespace xmt; - -Node::Node() : - EventHandler(), - v( 0 ) -{ - cnd.set( false ); -} - -Node::Node( stem::addr_type id ) : - EventHandler( id ), - v( 0 ) -{ - cnd.set( false ); -} - -Node::Node( stem::addr_type id, const char *info ) : - EventHandler( id, info ), - v( 0 ) -{ - cnd.set( false ); -} - -Node::~Node() -{ - // cnd.wait(); -} - -void Node::handler1( const stem::Event& ) -{ - // std::cerr << "I am here 1\n"; - v = 1; - cnd.set(true); - // std::cerr << "I am here 2\n"; -} - -void Node::wait() -{ - cnd.try_wait(); -} - -DEFINE_RESPONSE_TABLE( Node ) - EV_EDS(0,NODE_EV1,handler1) -END_RESPONSE_TABLE - -// the same as Node, just another class - -NewNode::NewNode() : - EventHandler(), - v( 0 ) -{ - cnd.set( false ); -} - -NewNode::NewNode( stem::addr_type id ) : - EventHandler( id ), - v( 0 ) -{ - cnd.set( false ); -} - -NewNode::~NewNode() -{ - // cnd.wait(); -} - -void NewNode::handler1( const stem::Event& ) -{ - // std::cerr << "I am here 1\n"; - v = 1; - cnd.set(true); - // std::cerr << "I am here 2\n"; -} - -void NewNode::wait() -{ - cnd.try_wait(); -} - -DEFINE_RESPONSE_TABLE( NewNode ) - EV_EDS(0,NODE_EV1,handler1) -END_RESPONSE_TABLE Deleted: trunk/complement/explore/lib/stem/ut/stem/Node.h =================================================================== --- trunk/complement/explore/test/stem/Node.h 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/Node.h 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,62 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:47:25 ptr> - -/* - * - * Copyright (c) 2002, 2003, 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#ifndef __Node_h -#define __Node_h - -#include <mt/xmt.h> -#include <stem/EventHandler.h> - -class Node : - public stem::EventHandler -{ - public: - Node(); - Node( stem::addr_type id ); - Node( stem::addr_type id, const char *info ); - ~Node(); - - void handler1( const stem::Event& ); - - void wait(); - - int v; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( Node, stem::EventHandler ); -}; - -// the same as Node, just another class -class NewNode : - public stem::EventHandler -{ - public: - NewNode(); - NewNode( stem::addr_type id ); - ~NewNode(); - - void handler1( const stem::Event& ); - - void wait(); - - int v; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( NewNode, stem::EventHandler ); -}; - -#define NODE_EV1 0x900 - -#endif // __Node_h Deleted: trunk/complement/explore/lib/stem/ut/stem/NodeDL.h =================================================================== --- trunk/complement/explore/test/stem/NodeDL.h 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/NodeDL.h 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,66 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:47:58 ptr> - -/* - * - * Copyright (c) 2002, 2003, 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#ifndef __NodeDL_h -#define __NodeDL_h - -#include <mt/xmt.h> -#include <stem/EventHandler.h> - -class NodeDL : - public stem::EventHandler -{ - public: - NodeDL(); - NodeDL( stem::addr_type id ); - ~NodeDL(); - - void handler1( const stem::Event& ); - - void wait(); - - int v; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( NodeDL, stem::EventHandler ); -}; - -// the same as Node, just another class -class NewNodeDL : - public stem::EventHandler -{ - public: - NewNodeDL(); - NewNodeDL( stem::addr_type id ); - ~NewNodeDL(); - - void handler1( const stem::Event& ); - - void wait(); - - int v; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( NewNodeDL, stem::EventHandler ); -}; - -#define NODE_EV2 0x901 - -extern "C" void *create_NewNodeDL( unsigned ); -extern "C" void wait_NewNodeDL( void * ); -extern "C" int v_NewNodeDL( void * ); -extern "C" void destroy_NewNodeDL( void * ); - -#endif // __NodeDL_h Deleted: trunk/complement/explore/lib/stem/ut/stem/unit_test.cc =================================================================== --- trunk/complement/explore/test/stem/unit_test.cc 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/unit_test.cc 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,835 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/20 00:21:37 ptr> - -/* - * Copyright (c) 2002, 2003, 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#include <exam/suite.h> - -#include <iostream> -#include <mt/xmt.h> -#include <mt/shm.h> - -#include <stem/EventHandler.h> -#include <stem/Names.h> -#include <stem/EDSEv.h> - -#include "Node.h" -#include "NodeDL.h" -#include "NameService.h" - -#include <dlfcn.h> - -#include "Echo.h" -#include "Convert.h" - -#include <stem/NetTransport.h> -#include <stem/EvManager.h> -#include <sockios/sockmgr.h> - -#ifndef STLPORT -#include <ext/functional> -using namespace __gnu_cxx; -#endif - -#include <sys/wait.h> - -#include <signal.h> - -using namespace std; - -class stem_test -{ - public: - stem_test(); - ~stem_test(); - - int EXAM_DECL(basic1); - int EXAM_DECL(basic2); - int EXAM_DECL(basic1new); - int EXAM_DECL(basic2new); - int EXAM_DECL(dl); - int EXAM_DECL(ns); - - int EXAM_DECL(echo); - int EXAM_DECL(echo_net); - int EXAM_DECL(net_echo); - int EXAM_DECL(peer); - int EXAM_DECL(boring_manager); - int EXAM_DECL(convert); - - static xmt::Thread::ret_code thr1( void * ); - static xmt::Thread::ret_code thr1new( void * ); - - private: -}; - -int EXAM_IMPL(stem_test::basic1) -{ - Node node( 2000 ); - - EDS::Event ev( NODE_EV1 ); - - ev.dest( 2000 ); - node.Send( ev ); - - node.wait(); - EXAM_CHECK( node.v == 1 ); - - return EXAM_RESULT; -} - -int EXAM_IMPL(stem_test::basic2) -{ - Node node( 2000 ); - - xmt::Thread t1( thr1 ); - - EXAM_CHECK( t1.join().iword == 0 ); - - node.wait(); - - EXAM_CHECK( node.v == 1 ); - - return EXAM_RESULT; -} - -xmt::Thread::ret_code stem_test::thr1( void * ) -{ - xmt::Thread::ret_code rt; - rt.iword = 0; - - Node node( 2001 ); - - EDS::Event ev( NODE_EV1 ); - - ev.dest( 2000 ); - node.Send( ev ); - - return rt; -} - -int EXAM_IMPL(stem_test::basic1new) -{ - NewNode *node = new NewNode( 2000 ); - - EDS::Event ev( NODE_EV1 ); - - ev.dest( 2000 ); - node->Send( ev ); - - node->wait(); - - EXAM_CHECK( node->v == 1 ); - delete node; - - return EXAM_RESULT; -} - -int EXAM_IMPL(stem_test::basic2new) -{ - NewNode *node = new NewNode( 2000 ); - - xmt::Thread t1( thr1new ); - - t1.join(); - - node->wait(); - EXAM_CHECK( node->v == 1 ); - delete node; - - return EXAM_RESULT; -} - -xmt::Thread::ret_code stem_test::thr1new( void * ) -{ - xmt::Thread::ret_code rt; - rt.iword = 0; - - NewNode *node = new NewNode( 2001 ); - - EDS::Event ev( NODE_EV1 ); - - ev.dest( 2000 ); - node->Send( ev ); - - delete node; - - return rt; -} - -int EXAM_IMPL(stem_test::dl) -{ - void *lh = dlopen( "libloadable_stem.so", RTLD_LAZY ); // Path was passed via -Wl,--rpath= - - EXAM_REQUIRE( lh != NULL ); - void *(*f)(unsigned); - void (*g)(void *); - void (*w)(void *); - int (*v)(void *); - - *(void **)(&f) = dlsym( lh, "create_NewNodeDL" ); - EXAM_REQUIRE( f != NULL ); - *(void **)(&g) = dlsym( lh, "destroy_NewNodeDL" ); - EXAM_REQUIRE( g != NULL ); - *(void **)(&w) = dlsym( lh, "wait_NewNodeDL" ); - EXAM_REQUIRE( w != NULL ); - *(void **)(&v) = dlsym( lh, "v_NewNodeDL" ); - EXAM_REQUIRE( v != NULL ); - - NewNodeDL *node = reinterpret_cast<NewNodeDL *>( f( 2002 ) ); - stem::Event ev( NODE_EV2 ); - ev.dest( 2002 ); - node->Send( ev ); - - w( reinterpret_cast<void *>(node) ); - EXAM_CHECK( v(reinterpret_cast<void *>(node)) == 1 ); - - g( reinterpret_cast<void *>(node) ); - dlclose( lh ); - - return EXAM_RESULT; -} - -int EXAM_IMPL(stem_test::ns) -{ - Node node( 2003, "Node" ); - Naming nm; - - stem::Event ev( EV_STEM_GET_NS_LIST ); - ev.dest( stem::ns_addr ); - nm.Send( ev ); - - nm.wait(); - - // this is sample of all inline find: - Naming::nsrecords_type::const_iterator i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( equal_to<string>(), string( "ns" ) ), select2nd<pair<stem::gaddr_type,string> >() ) ); - - EXAM_CHECK( i != nm.lst.end() ); - EXAM_CHECK( i->second == "ns" ); - EXAM_CHECK( i->first.hid == xmt::hostid() ); - EXAM_CHECK( i->first.pid == getpid() ); - EXAM_CHECK( i->first.addr == stem::ns_addr ); - - // well, but for few seaches declare and reuse functors: - equal_to<string> eq; - equal_to<stem::gaddr_type> eqa; - - select1st<pair<stem::gaddr_type,string> > first; - select2nd<pair<stem::gaddr_type,string> > second; - - i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "Node" ) ), second ) ); - - EXAM_CHECK( i != nm.lst.end() ); - EXAM_CHECK( i->second == "Node" ); - EXAM_CHECK( i->first.addr == 2003 ); - - i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eqa, nm.self_glid() ), first ) ); - - EXAM_CHECK( i != nm.lst.end() ); - EXAM_CHECK( i->first == nm.self_glid() ); - EXAM_CHECK( i->second.length() == 0 ); - - nm.lst.clear(); - nm.reset(); - - EXAM_CHECK( nm.lst.empty() ); - - stem::Event evname( EV_STEM_GET_NS_NAME ); - evname.dest( stem::ns_addr ); - evname.value() = "Node"; - nm.Send( evname ); - - nm.wait(); - - i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "ns" ) ), second ) ); - - EXAM_CHECK( i == nm.lst.end() ); - - i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "Node" ) ), second ) ); - - EXAM_CHECK( i != nm.lst.end() ); - EXAM_CHECK( i->second == "Node" ); - EXAM_CHECK( i->first.addr == 2003 ); - - i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eqa, nm.self_glid() ), first ) ); - - EXAM_CHECK( i == nm.lst.end() ); - - nm.lst.clear(); - nm.reset(); - - EXAM_CHECK( nm.lst.empty() ); - - evname.value() = "No-such-name"; - nm.Send( evname ); - - nm.wait(); - - EXAM_CHECK( nm.lst.empty() ); - - return EXAM_RESULT; -} - -int EXAM_IMPL(stem_test::echo) -{ - try { - sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); - stem::NetTransportMgr mgr; - - StEMecho echo( 0, "echo service"); // <= zero! - - stem::addr_type zero = mgr.open( "localhost", 6995 ); - - EXAM_CHECK( zero != stem::badaddr ); - EXAM_CHECK( zero == 0 ); // NetTransportMgr should detect local delivery - - EchoClient node; - - stem::Event ev( NODE_EV_ECHO ); - - ev.dest( zero ); - ev.value() = node.mess; - - node.Send( ev ); - - node.wait(); - - mgr.close(); - mgr.join(); - - srv.close(); - srv.wait(); - } - catch ( ... ) { - } - - return EXAM_RESULT; -} - -const char fname[] = "/tmp/stem_test.shm"; -xmt::shm_alloc<0> seg; -xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; -xmt::allocator_shm<xmt::__barrier<true>,0> shm_b; - -stem_test::stem_test() -{ - try { - seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); - } - catch ( const xmt::shm_bad_alloc& err ) { - EXAM_ERROR_ASYNC( err.what() ); - } -} - -stem_test::~stem_test() -{ - seg.deallocate(); - unlink( fname ); -} - -int EXAM_IMPL(stem_test::echo_net) -{ - xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); - fcnd.set( false ); - - try { - xmt::fork(); - - try { - stem::NetTransportMgr mgr; - - fcnd.try_wait(); - - stem::addr_type zero = mgr.open( "localhost", 6995 ); - - EXAM_CHECK_ASYNC( zero != stem::badaddr ); - EXAM_CHECK_ASYNC( zero != 0 ); // NetTransportMgr should detect external delivery - - EchoClient node; - - stem::Event ev( NODE_EV_ECHO ); - - ev.dest( zero ); - ev.value() = node.mess; - - node.Send( ev ); - - node.wait(); - - mgr.close(); - mgr.join(); - } - catch ( ... ) { - } - - exit( 0 ); - } - catch ( xmt::fork_in_parent& child ) { - try { - sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); - - StEMecho echo( 0, "echo service"); // <= zero! - - fcnd.set( true ); - - int stat; - EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); - - srv.close(); - srv.wait(); - } - catch ( ... ) { - } - } - - (&fcnd)->~__condition<true>(); - shm_cnd.deallocate( &fcnd, 1 ); - - // cerr << "Fine\n"; - - return EXAM_RESULT; -} - -// same as echo_net(), but server in child process - -int EXAM_IMPL(stem_test::net_echo) -{ - try { - xmt::__barrier<true>& b = *new ( shm_b.allocate( 1 ) ) xmt::__barrier<true>(); - xmt::__condition<true>& c = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); - - c.set( false ); - - try { - xmt::fork(); - - // server part - { - std::sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); - StEMecho echo( 0, "echo service"); - - // echo.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch ); - // echo.manager()->settrs( &std::cerr ); - - EXAM_CHECK_ASYNC( srv.good() ); - c.set( true ); // ok, server listen - - b.wait(); // server may go away - - srv.close(); - srv.wait(); - } - - exit( 0 ); - } - catch ( xmt::fork_in_parent& child ) { - // client part - - stem::NetTransportMgr mgr; - // mgr.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch | stem::EvManager::tracefault ); - // mgr.manager()->settrs( &std::cerr ); - - c.try_wait(); // wait server start - - stem::addr_type zero = mgr.open( "localhost", 6995 ); - - EXAM_REQUIRE( mgr.good() ); - EXAM_REQUIRE( zero != stem::badaddr ); - - EchoClient node; - stem::Event ev( NODE_EV_ECHO ); - ev.dest( zero ); - - ev.value() = node.mess; - node.Send( ev ); - - node.wait(); - - mgr.close(); - mgr.join(); - - b.wait(); // server may go away - - int stat; - EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); - } - - (&c)->~__condition<true>(); - shm_cnd.deallocate( &c, 1 ); - (&b)->~__barrier<true>(); - shm_b.deallocate( &b, 1 ); - } - catch ( xmt::shm_bad_alloc& err ) { - EXAM_ERROR( err.what() ); - } - - return EXAM_RESULT; -} - -extern "C" { - -static void dummy_signal_handler( int ) -{ } - -} - -int EXAM_IMPL(stem_test::peer) -{ - /* - * Scheme: - * / NetTransport / c1 - * Local Event Manager - NetTransportMgr - c2 - * \ echo - * Due to all objects in the same process space, - * c1, c2 and echo in different processes. - * - * The logical scheme is: - * - * / c1 - * echo - * \ c2 - * - * (c1 <-> c2, through 'echo') - */ - - pid_t fpid; - - xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); - fcnd.set( false ); - - xmt::__condition<true>& pcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); - pcnd.set( false ); - - xmt::__condition<true>& scnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); - scnd.set( false ); - - try { - // Client 1 - xmt::fork(); -#if 0 - struct sigaction action; - struct sigaction old_action; - action.sa_flags = 0; - action.sa_handler = &dummy_signal_handler; - sigemptyset( &action.sa_mask ); - - sigaction( SIGFPE, &action, &old_action ); - sigaction( SIGTRAP, &action, &old_action ); - sigaction( SIGSEGV, &action, &old_action ); - sigaction( SIGBUS, &action, &old_action ); - sigaction( SIGABRT, &action, &old_action ); - sigaction( SIGALRM, &action, &old_action ); -#endif - - try { - stem::NetTransportMgr mgr; - - PeerClient c1( "c1 local" ); // c1 client - Naming nm; - - fcnd.try_wait(); - - stem::addr_type zero = mgr.open( "localhost", 6995 ); // take address of 'zero' (aka default) object via net transport from server - // It done like it should on client side - - EXAM_CHECK_ASYNC( zero != stem::badaddr ); - EXAM_CHECK_ASYNC( zero != 0 ); - EXAM_CHECK_ASYNC( zero & stem::extbit ); // "external" address - - stem::Event ev( NODE_EV_REGME ); - ev.dest( zero ); - - ev.value() = "c1@here"; - c1.Send( ev ); // 'register' c1 client on 'echo' server - - stem::gaddr_type ga( c1.manager()->reflect( zero ) ); - - EXAM_CHECK_ASYNC( ga.addr == 0 ); - EXAM_CHECK_ASYNC( ga.pid != -1 ); - - ga.addr = stem::ns_addr; // this will be global address of ns of the same process - // as zero - - EXAM_CHECK_ASYNC( c1.manager()->reflect( ga ) != stem::badaddr ); - - stem::Event evname( EV_STEM_GET_NS_NAME ); - evname.dest( c1.manager()->reflect( ga ) ); - evname.value() = "c2@here"; - - pcnd.try_wait(); - - Naming::nsrecords_type::const_iterator i; - - do { - nm.reset(); - nm.lst.clear(); - nm.Send( evname ); - nm.wait(); - i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( equal_to<string>(), string( "c2@here" ) ), select2nd<pair<stem::gaddr_type,string> >() ) ); - } while ( i == nm.lst.end() ); - - EXAM_CHECK_ASYNC( i != nm.lst.end() ); - EXAM_CHECK_ASYNC( i->second == "c2@here" ); - - stem::addr_type pa = c1.manager()->reflect( i->first ); - if ( pa == stem::badaddr ) { // unknown yet - pa = c1.manager()->SubscribeRemote( i->first, i->second ); - if ( pa == stem::badaddr ) { // it still unknown, transport not found - // hint: use transport as object zero used - pa = c1.manager()->SubscribeRemote( c1.manager()->transport( zero ), i->first, i->second ); - } - } - - EXAM_CHECK_ASYNC( pa != stem::badaddr ); - - if ( pa != stem::badaddr ) { - stem::Event pe( NODE_EV_ECHO ); - pe.dest( pa ); - pe.value() = "c2 local"; // <<-- mess is like name ... | - // . - c1.Send( pe ); - } - - scnd.try_wait(); - - mgr.close(); - mgr.join(); - } - catch ( ... ) { - } - - exit( 0 ); - } - catch ( xmt::fork_in_parent& child ) { - fpid = child.pid(); - } - - try { - // Client 2 - xmt::fork(); - -#if 0 - struct sigaction action; - struct sigaction old_action; - action.sa_flags = 0; - action.sa_handler = &dummy_signal_handler; - sigemptyset( &action.sa_mask ); - - sigaction( SIGFPE, &action, &old_action ); - sigaction( SIGTRAP, &action, &old_action ); - sigaction( SIGSEGV, &action, &old_action ); - sigaction( SIGBUS, &action, &old_action ); - sigaction( SIGABRT, &action, &old_action ); - sigaction( SIGALRM, &action, &old_action ); -#endif - - try { - stem::NetTransportMgr mgr; - // ^ - PeerClient c2( "c2 local" ); // <<--- name the same as mess expected ... | - - fcnd.try_wait(); - stem::addr_type zero = mgr.open( "localhost", 6995 ); // take address of 'zero' (aka default) object via net transport from server - // It done like it should on client side - - EXAM_CHECK_ASYNC( zero != stem::badaddr ); - EXAM_CHECK_ASYNC( zero != 0 ); - EXAM_CHECK_ASYNC( zero & stem::extbit ); // "external" address - - stem::Event ev( NODE_EV_REGME ); - ev.dest( zero ); - - ev.value() = "c2@here"; - c2.Send( ev ); // 'register' c2 client on 'echo' server - - pcnd.set( true ); - - c2.wait(); - // cerr << "Fine!" << endl; - scnd.set( true ); - - mgr.close(); - mgr.join(); - } - catch ( ... ) { - } - - exit( 0 ); - } - catch ( xmt::fork_in_parent& child ) { - sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); // server, it serve 'echo' - StEMecho echo( 0, "echo service"); // <= zero! 'echo' server, default ('zero' address) - - fcnd.set( true, true ); - - int stat; - waitpid( child.pid(), &stat, 0 ); - waitpid( fpid, &stat, 0 ); - - srv.close(); - srv.wait(); - } - - (&fcnd)->~__condition<true>(); - shm_cnd.deallocate( &fcnd, 1 ); - (&pcnd)->~__condition<true>(); - shm_cnd.deallocate( &pcnd, 1 ); - (&scnd)->~__condition<true>(); - shm_cnd.deallocate( &scnd, 1 ); - - return EXAM_RESULT; -} - -int EXAM_IMPL(stem_test::boring_manager) -{ - xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); - fcnd.set( false ); - - try { - // Client - xmt::fork(); - try { - fcnd.try_wait(); - - for ( int i = 0; i < 10; ++i ) { - const int n = 10; - stem::NetTransportMgr *mgr[n]; - mgr[0] = new stem::NetTransportMgr; - mgr[0]->open( "localhost", 6995 ); - - for ( int j = 1; j < n; ++j ) { - mgr[j] = new stem::NetTransportMgr; - stem::addr_type a = mgr[j]->open( "localhost", 6995 ); - mgr[j]->close(); - mgr[j]->join(); - delete mgr[j]; - } - mgr[0]->close(); - mgr[0]->join(); - delete mgr[0]; - } - } - catch ( ... ) { - } - exit( 0 ); - } - catch ( xmt::fork_in_parent& child ) { - sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); // server, it serve 'echo' - StEMecho echo( 0, "echo service"); // <= zero! 'echo' server, default ('zero' address) - - fcnd.set( true, true ); - - int stat; - waitpid( child.pid(), &stat, 0 ); - - srv.close(); - srv.wait(); - } - - (&fcnd)->~__condition<true>(); - shm_cnd.deallocate( &fcnd, 1 ); - - return EXAM_RESULT; -} - -int EXAM_IMPL(stem_test::convert) -{ - Convert conv; - mess m; - - m.super_id = 2; - m.message = "hello"; - - stem::Event_base<mess> ev( CONV_EV0 ); - - ev.dest( conv.self_id() ); - ev.value() = m; - - conv.Send( ev ); - - conv.wait(); - - EXAM_CHECK( conv.v == -1 ); - - stem::Event_base<mess> ev1( CONV_EV1 ); - - ev1.dest( conv.self_id() ); - ev1.value() = m; - - conv.Send( ev1 ); - - conv.wait(); - - EXAM_CHECK( conv.v == 1 ); - - stem::Event_base<mess> ev2( CONV_EV2 ); - - ev2.dest( conv.self_id() ); - ev2.value() = m; - - conv.Send( ev2 ); - - conv.wait(); - - EXAM_CHECK( conv.v == 2 ); - EXAM_CHECK( conv.m2 == "hello" ); - - stem::Event_base<mess> ev3( CONV_EV3 ); - - ev3.dest( conv.self_id() ); - ev3.value().super_id = 3; - ev3.value().message = ", wold!"; - - conv.Send( ev3 ); - - conv.wait(); - - EXAM_CHECK( conv.v == 3 ); - EXAM_CHECK( conv.m3 == ", wold!" ); - - return EXAM_RESULT; -} - -// ----------------- - -// ----------------- - -int EXAM_DECL(stem_test_suite); - -int EXAM_IMPL(stem_test_suite) -{ - exam::test_suite::test_case_type tc[4]; - - exam::test_suite t( "libstem test suite" ); - stem_test test; - - tc[1] = t.add( &stem_test::basic2, test, "basic2", - tc[0] = t.add( &stem_test::basic1, test, "basic1" ) ); - - tc[2] = t.add( &stem_test::basic1new, test, "basic1new", tc[0] ); - - t.add( &stem_test::dl, test, "dl", - t.add( &stem_test::basic2new, test, "basic2new", tc + 1, tc + 3 ) ); - t.add( &stem_test::ns, test, "ns", tc[0] ); - - t.add( &stem_test::net_echo, test, "net echo", - t.add( &stem_test::echo_net, test, "echo_net", - tc[3] = t.add( &stem_test::echo, test, "echo", tc[1] ) ) ); - - t.add( &stem_test::boring_manager, test, "boring_manager", - t.add( &stem_test::peer, test, "peer", tc[3] ) ); - - t.add( &stem_test::convert, test, "convert", tc[0] ); - - return t.girdle(); -} - -int main( int, char ** ) -{ - return stem_test_suite(0); -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 19:46:49
|
Revision: 1669 http://complement.svn.sourceforge.net/complement/?rev=1669&view=rev Author: complement Date: 2007-08-03 12:46:45 -0700 (Fri, 03 Aug 2007) Log Message: ----------- tests moved to ut Modified Paths: -------------- trunk/complement/explore/lib/sockios/ChangeLog trunk/complement/explore/lib/sockios/Makefile trunk/complement/explore/lib/sockios/ut/Makefile trunk/complement/explore/test/virtual_time/test/vt_handler.cc trunk/complement/explore/test/virtual_time/vtime.cc trunk/complement/explore/test/virtual_time/vtime.h Added Paths: ----------- trunk/complement/explore/lib/sockios/ut/ Removed Paths: ------------- trunk/complement/explore/test/sockios/ Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-08-03 19:46:45 UTC (rev 1669) @@ -1,8 +1,10 @@ 2007-08-03 Petr Ovtchenkov <pt...@is...> * include/sockios/sockstream: workaround for file openmode - for libstdc++ shipped with gcc 3.3.6. + for libstdc++ shipped with gcc 3.3.6; + * ../../test/sockios: moved to ut. + 2007-07-18 Petr Ovtchenkov <pt...@is...> * test/sockios: boost unit test framework replaced by exam. Modified: trunk/complement/explore/lib/sockios/Makefile =================================================================== --- trunk/complement/explore/lib/sockios/Makefile 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/sockios/Makefile 2007-08-03 19:46:45 UTC (rev 1669) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/01/23 14:59:53 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 23:06:18 ptr> SRCROOT := ../.. @@ -8,24 +8,29 @@ INCLUDES += -I$(SRCROOT)/include check: all-shared - $(MAKE) -C ../../test/sockios - (cd ../../test/sockios; ${OUTPUT_DIR}/sockios_ut) || exit 1 - (cd ../../test/sockios; ${OUTPUT_DIR_DBG}/sockios_ut) || exit 1 - (cd ../../test/sockios; ${OUTPUT_DIR_STLDBG}/sockios_ut) || exit 1 + $(MAKE) -C ut + (cd ut; ${OUTPUT_DIR}/sockios_ut) || exit 1 + (cd ut; ${OUTPUT_DIR_DBG}/sockios_ut) || exit 1 +ifndef WITHOUT_STLPORT + (cd ut; ${OUTPUT_DIR_STLDBG}/sockios_ut) || exit 1 +endif check-release-shared: release-shared - $(MAKE) -C ../../test/sockios release-shared - (cd ../../test/sockios; ${OUTPUT_DIR}/sockios_ut) || exit 1 + $(MAKE) -C ut release-shared + (cd ut; ${OUTPUT_DIR}/sockios_ut) || exit 1 check-dbg-shared: dbg-shared - $(MAKE) -C ../../test/sockios dbg-shared - (cd ../../test/sockios; ${OUTPUT_DIR_DBG}/sockios_ut) || exit 1 + $(MAKE) -C ut dbg-shared + (cd ut; ${OUTPUT_DIR_DBG}/sockios_ut) || exit 1 ifndef WITHOUT_STLPORT check-stldbg-shared: stldbg-shared - $(MAKE) -C ../../test/sockios stldbg-shared - (cd ../../test/sockios; ${OUTPUT_DIR_STLDBG}/sockios_ut) || exit 1 + $(MAKE) -C ut stldbg-shared + (cd ut; ${OUTPUT_DIR_STLDBG}/sockios_ut) || exit 1 endif depend:: - $(MAKE) -C ../../test/sockios depend + $(MAKE) -C ut depend + +clean:: + $(MAKE) -C ut clean Copied: trunk/complement/explore/lib/sockios/ut (from rev 1668, trunk/complement/explore/test/sockios) Modified: trunk/complement/explore/lib/sockios/ut/Makefile =================================================================== --- trunk/complement/explore/test/sockios/Makefile 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/sockios/ut/Makefile 2007-08-03 19:46:45 UTC (rev 1669) @@ -1,6 +1,6 @@ -# -*- Makefile -*- Time-stamp: <07/07/18 08:44:04 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 23:06:43 ptr> -SRCROOT := ../.. +SRCROOT := ../../.. include Makefile.inc include ${SRCROOT}/Makefiles/gmake/top.mak Modified: trunk/complement/explore/test/virtual_time/test/vt_handler.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_handler.cc 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/test/virtual_time/test/vt_handler.cc 2007-08-03 19:46:45 UTC (rev 1669) @@ -21,10 +21,12 @@ void handler( const stem::Event& ); void VTNewMember( const stem::Event& ); + void VTOutMember( const stem::Event& ); void wait(); std::string msg; int count; + int ocount; private: xmt::condition cnd; @@ -36,21 +38,24 @@ VTDummy::VTDummy() : VTHandler(), - count(0) + count(0), + ocount(0) { cnd.set( false ); } VTDummy::VTDummy( stem::addr_type id ) : VTHandler( id ), - count(0) + count(0), + ocount(0) { cnd.set( false ); } VTDummy::VTDummy( stem::addr_type id, const char *info ) : VTHandler( id, info ), - count(0) + count(0), + ocount(0) { cnd.set( false ); } @@ -73,6 +78,12 @@ ++count; } +void VTDummy::VTOutMember( const stem::Event& ev ) +{ + // cerr << "Hello" << endl; + ++ocount; +} + void VTDummy::wait() { cnd.try_wait(); @@ -172,6 +183,9 @@ EXAM_CHECK( dummy2.msg == "yet more" ); EXAM_CHECK( dummy1.msg == "" ); + EXAM_CHECK( dummy1.ocount == 1 ); + EXAM_CHECK( dummy2.ocount == 1 ); + return EXAM_RESULT; } Modified: trunk/complement/explore/test/virtual_time/vtime.cc =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.cc 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/test/virtual_time/vtime.cc 2007-08-03 19:46:45 UTC (rev 1669) @@ -608,15 +608,22 @@ pair<gid_map_type::iterator,gid_map_type::iterator> range = grmap.equal_range( grp ); + vt_map_type::iterator i = vtmap.find( oid ); while ( range.first != range.second ) { if ( range.first->second == oid ) { grmap.erase( range.first++ ); } else { + vt_map_type::iterator j = vtmap.find( range.first->second ); + if ( j != vtmap.end() ) { + stem::Event ev( VTS_OUT_MEMBER ); + ev.dest( j->second.stem_addr() ); + ev.src( i != vtmap.end() ? i->second.stem_addr() : self_id() ); + Forward( ev ); + } ++range.first; } } - vt_map_type::iterator i = vtmap.find( oid ); if ( i != vtmap.end() ) { if ( i->second.rm_group( grp ) ) { // no groups more vtmap.erase( i ); @@ -720,8 +727,13 @@ { } +void VTHandler::VTOutMember( const stem::Event& ) +{ +} + DEFINE_RESPONSE_TABLE( VTHandler ) EV_EDS( ST_NULL, VTS_NEW_MEMBER, VTNewMember ) + EV_EDS( ST_NULL, VTS_OUT_MEMBER, VTOutMember ) END_RESPONSE_TABLE } // namespace vt Modified: trunk/complement/explore/test/virtual_time/vtime.h =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.h 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/test/virtual_time/vtime.h 2007-08-03 19:46:45 UTC (rev 1669) @@ -292,6 +292,7 @@ void VTSend( const stem::Event& e ); virtual void VTNewMember( const stem::Event& e ); + virtual void VTOutMember( const stem::Event& e ); template <class D> void VTSend( const stem::Event_base<D>& e ) @@ -306,6 +307,7 @@ #define MESS 0x300 #define VTS_NEW_MEMBER 0x301 +#define VTS_OUT_MEMBER 0x302 } // namespace vt This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 18:26:46
|
Revision: 1668 http://complement.svn.sourceforge.net/complement/?rev=1668&view=rev Author: complement Date: 2007-08-03 11:26:43 -0700 (Fri, 03 Aug 2007) Log Message: ----------- change unit tests location Added Paths: ----------- trunk/complement/explore/lib/mt/ut/ Removed Paths: ------------- trunk/complement/explore/test/mt/ Copied: trunk/complement/explore/lib/mt/ut (from rev 1667, trunk/complement/explore/test/mt) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 14:08:21
|
Revision: 1667 http://complement.svn.sourceforge.net/complement/?rev=1667&view=rev Author: complement Date: 2007-08-03 07:08:20 -0700 (Fri, 03 Aug 2007) Log Message: ----------- fix targets for case without STLport; fix typo Modified Paths: -------------- trunk/complement/explore/lib/stem/Makefile trunk/complement/explore/test/sockios/Makefile trunk/complement/explore/test/stem/Makefile trunk/complement/explore/test/stem/unit_test.cc Modified: trunk/complement/explore/lib/stem/Makefile =================================================================== --- trunk/complement/explore/lib/stem/Makefile 2007-08-03 13:53:54 UTC (rev 1666) +++ trunk/complement/explore/lib/stem/Makefile 2007-08-03 14:08:20 UTC (rev 1667) @@ -10,8 +10,6 @@ dbg-shared: DEFS += -D__FIT_STEM_TRACE=1 ifndef WITHOUT_STLPORT -# INCLUDES += -I${BOOST_INCLUDE_DIR} -# else stldbg-shared: DEFS += -D__FIT_STEM_TRACE=1 endif @@ -19,7 +17,9 @@ $(MAKE) -C ../../test/stem (cd ../../test/stem; ${OUTPUT_DIR}/stem_ut) || exit 1 (cd ../../test/stem; ${OUTPUT_DIR_DBG}/stem_ut) || exit 1 +ifndef WITHOUT_STLPORT (cd ../../test/stem; ${OUTPUT_DIR_STLDBG}/stem_ut) || exit 1 +endif check-release-shared: release-shared $(MAKE) -C ../../test/stem release-shared Modified: trunk/complement/explore/test/sockios/Makefile =================================================================== --- trunk/complement/explore/test/sockios/Makefile 2007-08-03 13:53:54 UTC (rev 1666) +++ trunk/complement/explore/test/sockios/Makefile 2007-08-03 14:08:20 UTC (rev 1667) @@ -1,13 +1,15 @@ # -*- Makefile -*- Time-stamp: <07/07/18 08:44:04 ptr> SRCROOT := ../.. -COMPILER_NAME := gcc include Makefile.inc include ${SRCROOT}/Makefiles/gmake/top.mak -INCLUDES += -I$(SRCROOT)/include -I$(BOOST_INCLUDE_DIR) +INCLUDES += -I$(SRCROOT)/include +ifdef BOOST_DIR +INCLUDES += -I$(BOOST_INCLUDE_DIR) +endif DEFS += -D__FIT_EXAM LIBMT_DIR = ${CoMT_DIR}/lib/mt @@ -17,10 +19,14 @@ ifeq ($(OSNAME),linux) release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +ifndef WITHOUT_STLPORT stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +endif dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif release-shared : LDLIBS = -lxmt -lsockios -lexam +ifndef WITHOUT_STLPORT stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lexamstlg +endif dbg-shared : LDLIBS = -lxmtg -lsockiosg -lexamg Modified: trunk/complement/explore/test/stem/Makefile =================================================================== --- trunk/complement/explore/test/stem/Makefile 2007-08-03 13:53:54 UTC (rev 1666) +++ trunk/complement/explore/test/stem/Makefile 2007-08-03 14:08:20 UTC (rev 1667) @@ -1,7 +1,6 @@ # -*- Makefile -*- Time-stamp: <07/02/07 12:28:46 ptr> SRCROOT := ../.. -COMPILER_NAME := gcc EXTRA_POST := dl-rel EXTRA_POST_DBG := dl-dbg @@ -20,12 +19,16 @@ ifeq ($(OSNAME),linux) release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -Wl,--rpath=./dl/${OUTPUT_DIR}:${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +ifndef WITHOUT_STLPORT stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=./dl/${OUTPUT_DIR_STLDBG}:${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +endif dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=./dl/${OUTPUT_DIR_DBG}:${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif release-shared : LDLIBS = -lxmt -lsockios -lstem -lexam -ldl +ifndef WITHOUT_STLPORT stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lexamstlg -ldl +endif dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lexamg -ldl # dbg-shared: DEFS += -DDEBUG Modified: trunk/complement/explore/test/stem/unit_test.cc =================================================================== --- trunk/complement/explore/test/stem/unit_test.cc 2007-08-03 13:53:54 UTC (rev 1666) +++ trunk/complement/explore/test/stem/unit_test.cc 2007-08-03 14:08:20 UTC (rev 1667) @@ -805,7 +805,7 @@ { exam::test_suite::test_case_type tc[4]; - exam::test_suite t( "libsteam test suite" ); + exam::test_suite t( "libstem test suite" ); stem_test test; tc[1] = t.add( &stem_test::basic2, test, "basic2", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 13:53:55
|
Revision: 1666 http://complement.svn.sourceforge.net/complement/?rev=1666&view=rev Author: complement Date: 2007-08-03 06:53:54 -0700 (Fri, 03 Aug 2007) Log Message: ----------- fix makefiles: check without stlport and clean in ut Modified Paths: -------------- trunk/complement/explore/lib/exam/Makefile Modified: trunk/complement/explore/lib/exam/Makefile =================================================================== --- trunk/complement/explore/lib/exam/Makefile 2007-08-03 13:38:19 UTC (rev 1665) +++ trunk/complement/explore/lib/exam/Makefile 2007-08-03 13:53:54 UTC (rev 1666) @@ -11,7 +11,9 @@ $(MAKE) -C ./ut (cd ./ut; ${OUTPUT_DIR}/exam_self_test) || exit 1 (cd ./ut; ${OUTPUT_DIR_DBG}/exam_self_test) || exit 1 +ifndef WITHOUT_STLPORT (cd ./ut; ${OUTPUT_DIR_STLDBG}/exam_self_test) || exit 1 +endif check-release-shared: release-shared $(MAKE) -C ./ut release-shared @@ -29,3 +31,6 @@ depend:: $(MAKE) -C ./ut depend + +clean:: + $(MAKE) -C ./ut clean This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 13:38:21
|
Revision: 1665 http://complement.svn.sourceforge.net/complement/?rev=1665&view=rev Author: complement Date: 2007-08-03 06:38:19 -0700 (Fri, 03 Aug 2007) Log Message: ----------- workaround for file openmode for libstdc++ shipped with gcc 3.3.6 Modified Paths: -------------- trunk/complement/explore/include/sockios/sockstream trunk/complement/explore/lib/sockios/ChangeLog Modified: trunk/complement/explore/include/sockios/sockstream =================================================================== --- trunk/complement/explore/include/sockios/sockstream 2007-08-03 13:35:27 UTC (rev 1664) +++ trunk/complement/explore/include/sockios/sockstream 2007-08-03 13:38:19 UTC (rev 1665) @@ -386,11 +386,15 @@ basic_sockbuf() : _fd( -1 ), -#ifndef STLPORT +#if !defined(STLPORT) && defined(__GNUC__) +#if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4))) // hmm, 3.3.6 + _mode( ios_base::openmode(__ios_flags::_S_in | __ios_flags::_S_out) ), +#else // 4.1.1 _mode( _S_in | _S_out ), -#else +#endif // __GNUC__ +#else // STLPORT _mode( 0 ), -#endif +#endif // STLPORT _bbuf(0), _ebuf(0), _allocated( true ) // , _doclose( true ) { @@ -406,11 +410,15 @@ sock_base::protocol prot = sock_base::inet, const timespec *timeout = 0 ) : _fd( -1 ), -#ifndef STLPORT +#if !defined(STLPORT) && defined(__GNUC__) +#if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4))) + _mode( ios_base::openmode(__ios_flags::_S_in | __ios_flags::_S_out) ), +#else // 4.1.1 _mode( _S_in | _S_out ), -#else +#endif // __GNUC__ +#else // STLPORT _mode( 0 ), -#endif +#endif // STLPORT _bbuf(0), _ebuf(0), _allocated( true ) // , _doclose( true ) { @@ -421,11 +429,15 @@ sock_base::protocol prot = sock_base::inet, const timespec *timeout = 0 ) : _fd( -1 ), -#ifndef STLPORT +#if !defined(STLPORT) && defined(__GNUC__) +#if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4))) + _mode( ios_base::openmode(__ios_flags::_S_in | __ios_flags::_S_out) ), +#else // 4.1.1 _mode( _S_in | _S_out ), -#else +#endif // __GNUC__ +#else // STLPORT _mode( 0 ), -#endif +#endif // STLPORT _bbuf(0), _ebuf(0), _allocated( true ) // , _doclose( true ) { Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-08-03 13:35:27 UTC (rev 1664) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-08-03 13:38:19 UTC (rev 1665) @@ -1,3 +1,8 @@ +2007-08-03 Petr Ovtchenkov <pt...@is...> + + * include/sockios/sockstream: workaround for file openmode + for libstdc++ shipped with gcc 3.3.6. + 2007-07-18 Petr Ovtchenkov <pt...@is...> * test/sockios: boost unit test framework replaced by exam. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 13:35:29
|
Revision: 1664 http://complement.svn.sourceforge.net/complement/?rev=1664&view=rev Author: complement Date: 2007-08-03 06:35:27 -0700 (Fri, 03 Aug 2007) Log Message: ----------- remove private keyword for dummy, to make gcc 3.3.6 happy Modified Paths: -------------- trunk/complement/explore/include/exam/suite.h trunk/complement/explore/lib/exam/ChangeLog Modified: trunk/complement/explore/include/exam/suite.h =================================================================== --- trunk/complement/explore/include/exam/suite.h 2007-08-03 10:42:32 UTC (rev 1663) +++ trunk/complement/explore/include/exam/suite.h 2007-08-03 13:35:27 UTC (rev 1664) @@ -60,7 +60,6 @@ virtual int f( test_suite *, int count = 0 ) { return count; } - private: virtual ~dummy() { } }; Modified: trunk/complement/explore/lib/exam/ChangeLog =================================================================== --- trunk/complement/explore/lib/exam/ChangeLog 2007-08-03 10:42:32 UTC (rev 1663) +++ trunk/complement/explore/lib/exam/ChangeLog 2007-08-03 13:35:27 UTC (rev 1664) @@ -1,3 +1,7 @@ +2007-08-03 Petr Ovtchenkov <pt...@is...> + + * suite.h: remove private keyword for dummy, to make gcc 3.3.6 happy. + 2007-07-21 Petr Ovtchenkov <pt...@is...> * suite.h, suite.cc: boost graph removed; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 10:42:35
|
Revision: 1663 http://complement.svn.sourceforge.net/complement/?rev=1663&view=rev Author: complement Date: 2007-08-03 03:42:32 -0700 (Fri, 03 Aug 2007) Log Message: ----------- fix for gcc 3.3.6 Modified Paths: -------------- trunk/complement/explore/include/misc/type_traits.h Modified: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h 2007-08-03 10:09:12 UTC (rev 1662) +++ trunk/complement/explore/include/misc/type_traits.h 2007-08-03 10:42:32 UTC (rev 1663) @@ -59,9 +59,9 @@ #define __SPEC_FULL1(C,T,B) \ __SPEC_1(C,T,B); \ -__SPEC_1(C,const T,B); \ -__SPEC_1(C,volatile T,B); \ -__SPEC_1(C,const volatile T,B) +__SPEC_1(C,T const,B); \ +__SPEC_1(C,T volatile,B); \ +__SPEC_1(C,T const volatile,B) #define __SPEC_2(C,T,B) \ template <class _Tp1, class _Tp2> \ @@ -71,9 +71,9 @@ #define __SPEC_FULL2(C,T,B) \ __SPEC_2(C,T,B); \ -__SPEC_2(C,const T,B); \ -__SPEC_2(C,volatile T,B); \ -__SPEC_2(C,const volatile T,B) +__SPEC_2(C,T const,B); \ +__SPEC_2(C,T volatile,B); \ +__SPEC_2(C,T const volatile,B) template <class _Tp> struct is_void : @@ -170,15 +170,55 @@ public false_type { }; -_SPEC_FULL2(is_member_object_pointer, _Tp1 _Tp2::*,!is_function<_Tp1>::value); +// _SPEC_FULL2(is_member_object_pointer, _Tp1 _Tp2::*,!is_function<_Tp1>::value); +template <class _Tp1, class _Tp2> +struct is_member_object_pointer<_Tp1 _Tp2::*> : + public integral_constant<bool, !is_function<_Tp1>::value> +{ }; + +template <class _Tp1, class _Tp2> +struct is_member_object_pointer<_Tp1 _Tp2::* const> : + public integral_constant<bool, !is_function<_Tp1>::value> +{ }; + +template <class _Tp1, class _Tp2> +struct is_member_object_pointer<_Tp1 _Tp2::* volatile> : + public integral_constant<bool, !is_function<_Tp1>::value> +{ }; + +template <class _Tp1, class _Tp2> +struct is_member_object_pointer<_Tp1 _Tp2::* const volatile> : + public integral_constant<bool, !is_function<_Tp1>::value> +{ }; + template <class _Tp> struct is_member_function_pointer : public false_type { }; -_SPEC_FULL2(is_member_function_pointer, _Tp1 _Tp2::*,is_function<_Tp1>::value); +// _SPEC_FULL2(is_member_function_pointer,_Tp1 _Tp2::*,is_function<_Tp1>::value); +template <class _Tp1, class _Tp2> +struct is_member_function_pointer<_Tp1 _Tp2::*> : + public integral_constant<bool, is_function<_Tp1>::value> +{ }; + +template <class _Tp1, class _Tp2> +struct is_member_function_pointer<_Tp1 _Tp2::* const> : + public integral_constant<bool, is_function<_Tp1>::value> +{ }; + +template <class _Tp1, class _Tp2> +struct is_member_function_pointer<_Tp1 _Tp2::* volatile> : + public integral_constant<bool, is_function<_Tp1>::value> +{ }; + +template <class _Tp1, class _Tp2> +struct is_member_function_pointer<_Tp1 _Tp2::* const volatile> : + public integral_constant<bool, is_function<_Tp1>::value> +{ }; + template <class _Tp> struct is_member_pointer : public integral_constant<bool, (is_member_object_pointer<_Tp>::value || is_member_function_pointer<_Tp>::value)> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 10:09:14
|
Revision: 1662 http://complement.svn.sourceforge.net/complement/?rev=1662&view=rev Author: complement Date: 2007-08-03 03:09:12 -0700 (Fri, 03 Aug 2007) Log Message: ----------- more TR1 type traits Modified Paths: -------------- trunk/complement/explore/include/misc/type_traits.h Modified: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h 2007-08-03 06:33:49 UTC (rev 1661) +++ trunk/complement/explore/include/misc/type_traits.h 2007-08-03 10:09:12 UTC (rev 1662) @@ -63,6 +63,18 @@ __SPEC_1(C,volatile T,B); \ __SPEC_1(C,const volatile T,B) +#define __SPEC_2(C,T,B) \ +template <class _Tp1, class _Tp2> \ +struct C<T> : \ + public integral_constant<bool, B> \ +{ } + +#define __SPEC_FULL2(C,T,B) \ +__SPEC_2(C,T,B); \ +__SPEC_2(C,const T,B); \ +__SPEC_2(C,volatile T,B); \ +__SPEC_2(C,const volatile T,B) + template <class _Tp> struct is_void : public false_type @@ -100,11 +112,35 @@ template <class _Tp> struct is_arithmetic : - public integral_constant<bool, (is_integral<_Tp>::value - || is_floating_point<_Tp>::value)> + public integral_constant<bool, (is_integral<_Tp>::value || is_floating_point<_Tp>::value)> { }; template <class _Tp> +struct is_fundamental : + public integral_constant<bool, (is_arithmetic<_Tp>::value || is_void<_Tp>::value)> +{ }; + +template <class _Tp> +struct is_compound : + public integral_constant<bool, !is_fundamental<_Tp>::value> +{ }; + +template <class _Tp> +struct is_array : + public false_type +{ }; + +template <class _Tp, std::size_t _Sz> +struct is_array<_Tp[_Sz]> : + public true_type +{ }; + +template <class _Tp> +struct is_array<_Tp[]> : + public true_type +{ }; + +template <class _Tp> struct is_pointer : public false_type { }; @@ -112,11 +148,65 @@ __SPEC_FULL1(is_pointer,_Tp *,true); template <class _Tp> +struct is_reference : + public false_type +{ }; + +template <class _Tp> +struct is_reference<_Tp&> : + public true_type +{ }; + +template <class _Tp> +struct is_function : + public integral_constant<bool, !(/* __in_array<_Tp>::__value + || __is_union_or_class<_Tp>::value + || */ is_reference<_Tp>::value + || is_void<_Tp>::value)> +{ }; + +template <class _Tp> +struct is_member_object_pointer : + public false_type +{ }; + +_SPEC_FULL2(is_member_object_pointer, _Tp1 _Tp2::*,!is_function<_Tp1>::value); + +template <class _Tp> +struct is_member_function_pointer : + public false_type +{ }; + +_SPEC_FULL2(is_member_function_pointer, _Tp1 _Tp2::*,is_function<_Tp1>::value); + +template <class _Tp> +struct is_member_pointer : + public integral_constant<bool, (is_member_object_pointer<_Tp>::value || is_member_function_pointer<_Tp>::value)> +{ }; + +template <class _Tp> +struct is_enum : + public integral_constant<bool, !(is_fundamental<_Tp>::value + || is_array<_Tp>::value + || is_pointer<_Tp>::value + || is_reference<_Tp>::value + || is_member_pointer<_Tp>::value + || is_function<_Tp>::value + /* || __is_union_or_class<_Tp>::value */) > +{ }; + +template <class _Tp> +struct is_object : + public integral_constant<bool, !(is_function<_Tp>::value /* || is_reference<_Tp>::value + || is_void<_Tp>::value */ )> +{ }; + +template <class _Tp> struct is_scalar : public integral_constant<bool, (is_arithmetic<_Tp>::value - /* || is_enum<_Tp>::value */ + || is_enum<_Tp>::value || is_pointer<_Tp>::value - /* || is_member_pointer<_Tp>::value */ )> + || is_member_pointer<_Tp>::value)> { }; template <class _Tp> @@ -138,15 +228,99 @@ }; template <class _Tp> +struct is_const : + public false_type +{ }; + +template <class _Tp> +struct is_const<_Tp const> : + public true_type +{ }; + +template <class _Tp> +struct is_volatile : + public false_type +{ }; + +template <class _Tp> +struct is_volatile<_Tp volatile> : + public true_type +{ }; + +template <class _Tp> struct is_pod : public integral_constant<bool, (is_void<_Tp>::value || is_scalar<typename remove_all_extents<_Tp>::type>::value)> { }; +template <class _Tp> +struct has_trivial_constructor : + public integral_constant<bool, is_pod<_Tp>::value> +{ }; + +template <class _Tp> +struct has_trivial_copy : + public integral_constant<bool, is_pod<_Tp>::value> +{ }; + +template <class _Tp> +struct has_trivial_assign : + public integral_constant<bool, is_pod<_Tp>::value> +{ }; + +template <class _Tp> +struct has_trivial_destructor : + public integral_constant<bool, is_pod<_Tp>::value> +{ }; + +template <class _Tp> +struct has_nothrow_constructor : + public integral_constant<bool, is_pod<_Tp>::value> +{ }; + +template <class _Tp> +struct has_nothrow_copy : + public integral_constant<bool, is_pod<_Tp>::value> +{ }; + +template <class _Tp> +struct has_nothrow_assign : + public integral_constant<bool, is_pod<_Tp>::value> +{ }; + +template <class _Tp> +struct has_virtual_destructor : + public false_type +{ }; + +template <class _Tp> +struct is_signed : + public false_type +{ }; + +__SPEC_FULL(is_signed,signed char,true); +__SPEC_FULL(is_signed,short,true); +__SPEC_FULL(is_signed,int,true); +__SPEC_FULL(is_signed,long,true); +__SPEC_FULL(is_signed,long long,true); + +template <class _Tp> +struct is_unsigned : + public false_type +{ }; + +__SPEC_FULL(is_unsigned,unsigned char,true); +__SPEC_FULL(is_unsigned,unsigned short,true); +__SPEC_FULL(is_unsigned,unsigned int,true); +__SPEC_FULL(is_unsigned,unsigned long,true); +__SPEC_FULL(is_unsigned,unsigned long long,true); + #undef __SPEC_FULL #undef __SPEC_ #undef __SPEC_FULL1 #undef __SPEC_1 +#undef __SPEC_FULL2 +#undef __SPEC_2 } // namespace tr1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 06:33:51
|
Revision: 1661 http://complement.svn.sourceforge.net/complement/?rev=1661&view=rev Author: complement Date: 2007-08-02 23:33:49 -0700 (Thu, 02 Aug 2007) Log Message: ----------- subscribe/unsubscribe operations for VTHandler Modified Paths: -------------- trunk/complement/explore/test/virtual_time/test/Makefile trunk/complement/explore/test/virtual_time/test/Makefile.inc trunk/complement/explore/test/virtual_time/test/unit_test.cc trunk/complement/explore/test/virtual_time/test/vt_operations.h trunk/complement/explore/test/virtual_time/vtime.cc trunk/complement/explore/test/virtual_time/vtime.h Added Paths: ----------- trunk/complement/explore/test/virtual_time/test/vt_handler.cc Modified: trunk/complement/explore/test/virtual_time/test/Makefile =================================================================== --- trunk/complement/explore/test/virtual_time/test/Makefile 2007-08-03 06:31:38 UTC (rev 1660) +++ trunk/complement/explore/test/virtual_time/test/Makefile 2007-08-03 06:33:49 UTC (rev 1661) @@ -14,9 +14,9 @@ LDFLAGS += -L${INSTALL_LIB_DIR} -Wl,-rpath=${INSTALL_LIB_DIR}:${STLPORT_LIB_DIR} -release-shared: PROJECT_LIBS = -lxmt -lsockios -lstem -lboost_regex -lexam -lboost_fs -dbg-shared: PROJECT_LIBS = -lxmtg -lsockiosg -lstemg -lboost_regexg -lexamg -lboost_fsg -stldbg-shared: PROJECT_LIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lboost_regexstlg -lexamstlg -lboost_fsstlg +release-shared: PROJECT_LIBS = -lxmt -lsockios -lstem -lexam +dbg-shared: PROJECT_LIBS = -lxmtg -lsockiosg -lstemg -lexamg +stldbg-shared: PROJECT_LIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lexamstlg LDLIBS = ${PROJECT_LIBS} Modified: trunk/complement/explore/test/virtual_time/test/Makefile.inc =================================================================== --- trunk/complement/explore/test/virtual_time/test/Makefile.inc 2007-08-03 06:31:38 UTC (rev 1660) +++ trunk/complement/explore/test/virtual_time/test/Makefile.inc 2007-08-03 06:33:49 UTC (rev 1661) @@ -7,6 +7,5 @@ vt_operations.cc \ VTmess_core.cc \ vt_object.cc \ - vt_dispatch.cc - - + vt_dispatch.cc \ + vt_handler.cc Modified: trunk/complement/explore/test/virtual_time/test/unit_test.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/unit_test.cc 2007-08-03 06:31:38 UTC (rev 1660) +++ trunk/complement/explore/test/virtual_time/test/unit_test.cc 2007-08-03 06:33:49 UTC (rev 1661) @@ -20,9 +20,12 @@ t.add( &vtime_operations::VTMess_core, vt_oper, "VTmess core transfer", tc[2] = t.add( &vtime_operations::gvt_add, vt_oper, "Group VT add", tc[1] ) ); - t.add( &vtime_operations::VTDispatch2, vt_oper, "VTDispatch2", - t.add( &vtime_operations::VTDispatch1, vt_oper, "VTDispatch1", - t.add( &vtime_operations::vt_object, vt_oper, "VT order", tc[2] ) ) ); + t.add( &vtime_operations::VTSubscription, vt_oper, "VTSubscription", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler2", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler1", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTDispatch2", + t.add( &vtime_operations::VTDispatch1, vt_oper, "VTDispatch1", + t.add( &vtime_operations::vt_object, vt_oper, "VT order", tc[2] ) ) ) ) ) ); return t.girdle(); } Added: trunk/complement/explore/test/virtual_time/test/vt_handler.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_handler.cc (rev 0) +++ trunk/complement/explore/test/virtual_time/test/vt_handler.cc 2007-08-03 06:33:49 UTC (rev 1661) @@ -0,0 +1,177 @@ +// -*- C++ -*- Time-stamp: <07/07/26 09:53:24 ptr> + +#include "vt_operations.h" + +// #include <boost/lexical_cast.hpp> + +#include <iostream> +#include <vtime.h> + +using namespace vt; +using namespace std; + +class VTDummy : + public vt::VTHandler +{ + public: + VTDummy(); + VTDummy( stem::addr_type id ); + VTDummy( stem::addr_type id, const char *info ); + ~VTDummy(); + + void handler( const stem::Event& ); + void VTNewMember( const stem::Event& ); + + void wait(); + std::string msg; + int count; + + private: + xmt::condition cnd; + + DECLARE_RESPONSE_TABLE( VTDummy, vt::VTHandler ); +}; + +#define VT_MESS3 0x1203 + +VTDummy::VTDummy() : + VTHandler(), + count(0) +{ + cnd.set( false ); +} + +VTDummy::VTDummy( stem::addr_type id ) : + VTHandler( id ), + count(0) +{ + cnd.set( false ); +} + +VTDummy::VTDummy( stem::addr_type id, const char *info ) : + VTHandler( id, info ), + count(0) +{ + cnd.set( false ); +} + +VTDummy::~VTDummy() +{ + // cnd.wait(); +} + +void VTDummy::handler( const stem::Event& ev ) +{ + msg = ev.value(); + + cnd.set( true ); +} + +void VTDummy::VTNewMember( const stem::Event& ev ) +{ + // cerr << "Hello" << endl; + ++count; +} + +void VTDummy::wait() +{ + cnd.try_wait(); + + cnd.set( false ); +} + +DEFINE_RESPONSE_TABLE( VTDummy ) + EV_EDS( ST_NULL, VT_MESS3, handler ) +END_RESPONSE_TABLE + +int EXAM_IMPL(vtime_operations::VTHandler1) +{ + VTDummy dummy1; + VTDummy dummy2; + + stem::Event ev( VT_MESS3 ); + ev.dest( 0 ); // group + ev.value() = "hello"; + + dummy1.VTSend( ev ); + + dummy2.wait(); + + EXAM_CHECK( dummy2.msg == "hello" ); + EXAM_CHECK( dummy1.msg == "" ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::VTHandler2) +{ + VTDummy dummy1; + VTDummy dummy2; + VTDummy dummy3; + + stem::Event ev( VT_MESS3 ); + ev.dest( 0 ); // group + ev.value() = "hello"; + + dummy1.VTSend( ev ); + + dummy2.wait(); + dummy3.wait(); + + EXAM_CHECK( dummy3.count == 0 ); + EXAM_CHECK( dummy3.msg == "hello" ); + EXAM_CHECK( dummy2.count == 1 ); + EXAM_CHECK( dummy2.msg == "hello" ); + EXAM_CHECK( dummy1.count == 2 ); + EXAM_CHECK( dummy1.msg == "" ); + + ev.dest( 100 ); // not this group member + try { + dummy1.VTSend( ev ); + EXAM_ERROR( "exception expected" ); + } + catch ( std::domain_error& ) { + } + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::VTSubscription) +{ + VTDummy dummy1; + VTDummy dummy2; + + stem::Event ev( VT_MESS3 ); + ev.dest( 0 ); // group + ev.value() = "hello"; + + dummy1.VTSend( ev ); + + dummy2.wait(); + EXAM_CHECK( dummy2.msg == "hello" ); + + { + VTDummy dummy3; + + ev.value() = "hi"; + dummy1.VTSend( ev ); + + dummy2.wait(); + // dummy3.wait(); + + // EXAM_CHECK( dummy3.msg == "hi" ); + EXAM_CHECK( dummy3.msg == "" ); // dummy3 don't see, due to VTS + EXAM_CHECK( dummy2.msg == "hi" ); + EXAM_CHECK( dummy1.msg == "" ); + } + + ev.value() = "yet more"; + dummy1.VTSend( ev ); + + dummy2.wait(); + EXAM_CHECK( dummy2.msg == "yet more" ); + EXAM_CHECK( dummy1.msg == "" ); + + return EXAM_RESULT; +} + Modified: trunk/complement/explore/test/virtual_time/test/vt_operations.h =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_operations.h 2007-08-03 06:31:38 UTC (rev 1660) +++ trunk/complement/explore/test/virtual_time/test/vt_operations.h 2007-08-03 06:33:49 UTC (rev 1661) @@ -20,6 +20,11 @@ int EXAM_DECL(VTDispatch1); int EXAM_DECL(VTDispatch2); + + int EXAM_DECL(VTHandler1); + int EXAM_DECL(VTHandler2); + + int EXAM_DECL(VTSubscription); }; #endif // __vt_operations_h Modified: trunk/complement/explore/test/virtual_time/vtime.cc =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.cc 2007-08-03 06:31:38 UTC (rev 1660) +++ trunk/complement/explore/test/virtual_time/vtime.cc 2007-08-03 06:33:49 UTC (rev 1661) @@ -405,6 +405,65 @@ vtstamp[grp][from] = vt.gvt[grp][from]; // my counter, as is, not delta } +bool vtime_obj_rec::rm_group( group_type g ) +{ + // strike out group g from my groups list + groups_container_type::iterator i = groups.find( g ); + if ( i == groups.end() ) { + throw domain_error( "VT object not member of group" ); + } + groups.erase( i ); + + // remove my VT component for group g + gvtime_type::iterator j = vt.gvt.find( g ); + + if ( j != vt.gvt.end() ) { + vt.gvt.erase( j ); + } + + // remove sended VT components for group g + for ( snd_delta_vtime_t::iterator k = svt.begin(); k != svt.end(); ++k ) { + gvtime_type::iterator l = k->second.find( g ); + if ( l != k->second.end() ) { + k->second.erase( l ); + } + } + + // remove recieved VT components for group g + for ( delta_vtime_type::iterator k = lvt.begin(); k != lvt.end(); ++k ) { + gvtime_type::iterator l = k->second.find( g ); + if ( l != k->second.end() ) { + k->second.erase( l ); + } + } + + // remove messages for group g that wait in delay pool + for ( dpool_t::iterator p = dpool.begin(); p != dpool.end(); ) { + if ( p->second->value().grp == g ) { + dpool.erase( p++ ); + } else { + ++p; + } + } + + return groups.empty() ? true : false; +} + +void vtime_obj_rec::rm_member( oid_type oid ) +{ + delta_vtime_type::iterator i = lvt.find( oid ); + + if ( i != lvt.end() ) { + lvt.erase( i ); + } + + snd_delta_vtime_t::iterator j = svt.find( oid ); + + if ( j != lvt.end() ) { + svt.erase( j ); + } +} + } // namespace detail void VTDispatcher::VTDispatch( const stem::Event_base<VTmess>& m ) @@ -521,10 +580,50 @@ void VTDispatcher::Subscribe( stem::addr_type addr, oid_type oid, group_type grp ) { + // See comment on top of VTSend above + xmt::recursive_scoped_lock lk( this->_theHistory_lock ); + + pair<gid_map_type::const_iterator,gid_map_type::const_iterator> range = + grmap.equal_range( grp ); + + for ( ; range.first != range.second; ++range.first ) { + vt_map_type::iterator i = vtmap.find( range.first->second ); + if ( i != vtmap.end() ) { + stem::Event ev( VTS_NEW_MEMBER ); + ev.dest( i->second.stem_addr() ); + ev.src( addr ); + Forward( ev ); + } + } + vtmap[oid].add( addr, grp ); grmap.insert( make_pair(grp,oid) ); } +void VTDispatcher::Unsubscribe( oid_type oid, group_type grp ) +{ + // See comment on top of VTSend above + xmt::recursive_scoped_lock lk( this->_theHistory_lock ); + + pair<gid_map_type::iterator,gid_map_type::iterator> range = + grmap.equal_range( grp ); + + while ( range.first != range.second ) { + if ( range.first->second == oid ) { + grmap.erase( range.first++ ); + } else { + ++range.first; + } + } + + vt_map_type::iterator i = vtmap.find( oid ); + if ( i != vtmap.end() ) { + if ( i->second.rm_group( grp ) ) { // no groups more + vtmap.erase( i ); + } + } +} + DEFINE_RESPONSE_TABLE( VTDispatcher ) EV_Event_base_T_( ST_NULL, MESS, VTDispatch, VTmess ) END_RESPONSE_TABLE @@ -583,7 +682,7 @@ void VTHandler::VTSend( const stem::Event& ev ) { ev.src( self_id() ); - // _vtdsp->VTSend( ev, grp ); + _vtdsp->VTSend( ev, ev.dest() ); // throw domain_error, if not group member } VTHandler::VTHandler() : @@ -591,26 +690,40 @@ { new( Init_buf ) Init(); - // _vtdsp->Subscribe( self_id(), ... , ... ); + _vtdsp->Subscribe( self_id(), oid_type( self_id() ), /* grp */ 0 ); } VTHandler::VTHandler( const char *info ) : EventHandler( info ) { new( Init_buf ) Init(); + + _vtdsp->Subscribe( self_id(), oid_type( self_id() ), /* grp */ 0 ); } VTHandler::VTHandler( stem::addr_type id, const char *info ) : EventHandler( id, info ) { new( Init_buf ) Init(); + + _vtdsp->Subscribe( id, oid_type( id ), /* grp */ 0 ); } VTHandler::~VTHandler() { + _vtdsp->Unsubscribe( oid_type( self_id() ), /* grp */ 0 ); + ((Init *)Init_buf)->~Init(); } +void VTHandler::VTNewMember( const stem::Event& ) +{ +} + +DEFINE_RESPONSE_TABLE( VTHandler ) + EV_EDS( ST_NULL, VTS_NEW_MEMBER, VTNewMember ) +END_RESPONSE_TABLE + } // namespace vt namespace std { Modified: trunk/complement/explore/test/virtual_time/vtime.h =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.h 2007-08-03 06:31:38 UTC (rev 1660) +++ trunk/complement/explore/test/virtual_time/vtime.h 2007-08-03 06:33:49 UTC (rev 1661) @@ -38,7 +38,7 @@ namespace vt { typedef uint32_t vtime_unit_type; -typedef uint32_t group_type; +typedef stem::addr_type group_type; // required, used in VTSend typedef std::hash_map<oid_type, vtime_unit_type> vtime_type; bool operator <=( const vtime_type& l, const vtime_type& r ); @@ -186,6 +186,8 @@ { groups.insert(g); } void add( stem::addr_type a, group_type g ) { addr = a; groups.insert(g); } + bool rm_group( group_type ); + void rm_member( oid_type ); stem::addr_type stem_addr() const { return addr; } @@ -252,6 +254,7 @@ void VTSend( const stem::Event& e, group_type ); void Subscribe( stem::addr_type, oid_type, group_type ); + void Unsubscribe( oid_type, group_type ); private: typedef std::hash_map<oid_type, detail::vtime_obj_rec> vt_map_type; @@ -288,6 +291,7 @@ virtual ~VTHandler(); void VTSend( const stem::Event& e ); + virtual void VTNewMember( const stem::Event& e ); template <class D> void VTSend( const stem::Event_base<D>& e ) @@ -296,9 +300,12 @@ private: static class VTDispatcher *_vtdsp; + + DECLARE_RESPONSE_TABLE( VTHandler, stem::EventHandler ); }; #define MESS 0x300 +#define VTS_NEW_MEMBER 0x301 } // namespace vt This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 06:31:40
|
Revision: 1660 http://complement.svn.sourceforge.net/complement/?rev=1660&view=rev Author: complement Date: 2007-08-02 23:31:38 -0700 (Thu, 02 Aug 2007) Log Message: ----------- use TR1 type_traits technique; add tricks to compile without STLport Modified Paths: -------------- trunk/complement/explore/include/stem/Event.h trunk/complement/explore/include/stem/EventHandler.h trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/EvManager.cc trunk/complement/explore/lib/stem/EvPack.cc Modified: trunk/complement/explore/include/stem/Event.h =================================================================== --- trunk/complement/explore/include/stem/Event.h 2007-08-03 06:27:59 UTC (rev 1659) +++ trunk/complement/explore/include/stem/Event.h 2007-08-03 06:31:38 UTC (rev 1660) @@ -1,8 +1,8 @@ -// -*- C++ -*- Time-stamp: <07/07/27 09:41:46 ptr> +// -*- C++ -*- Time-stamp: <07/08/03 08:19:34 ptr> /* * - * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 + * Copyright (c) 1995-1999, 2002, 2003, 2005-2007 * Petr Ovtchenkov * * Copyright (c) 1999-2001 @@ -26,53 +26,11 @@ #include <sstream> #include <stdint.h> +#include <misc/type_traits.h> #include <stem/EvPack.h> #include <mt/uid.h> #include <mt/xmt.h> -#ifndef STLPORT -#include <bits/cpp_type_traits.h> - -// libstdc++ v3, timestamp 20050519 (3.4.4) has __type_traits, -// libstdc++ v3, timestamp 20060306 (3.4.6) has __type_traits, -// while libstdc++ v3, 20050921 (4.0.2) not; use boost's staff instead -# if !defined(__GLIBCXX__) || (defined(__GNUC__) && (__GNUC__ > 3)) -#include <boost/type_traits.hpp> - -//bool to type -template <int _Is> -struct __bool2type -{ typedef __true_type _Ret; }; - -template <> -struct __bool2type<1> { typedef __true_type _Ret; }; - -template <> -struct __bool2type<0> { typedef __false_type _Ret; }; - -template <class _Tp> -struct __type_traits { - enum { trivial_constructor = ::boost::has_trivial_constructor<_Tp>::value }; - typedef typename __bool2type<trivial_constructor>::_Ret has_trivial_default_constructor; - - enum { trivial_copy = ::boost::has_trivial_copy<_Tp>::value }; - typedef typename __bool2type<trivial_copy>::_Ret has_trivial_copy_constructor; - - enum { trivial_assign = ::boost::has_trivial_assign<_Tp>::value }; - typedef typename __bool2type<trivial_assign>::_Ret has_trivial_assignment_operator; - - enum { trivial_destructor = ::boost::has_trivial_destructor<_Tp>::value }; - typedef typename __bool2type<trivial_destructor>::_Ret has_trivial_destructor; - - enum { pod = ::boost::is_pod<_Tp>::value }; - typedef typename __bool2type<pod>::_Ret is_POD_type; -}; -# else -# include <bits/type_traits.h> -# endif // __GLIBCXX__ - -#endif - namespace stem { typedef uint32_t addr_type; @@ -84,16 +42,6 @@ extern const addr_type ns_addr; extern const code_type badcode; -#ifdef STLPORT -using std::__true_type; -using std::__false_type; -using std::__type_traits; -#else -using ::__true_type; -using ::__false_type; -using ::__type_traits; -#endif - struct gaddr_type : public __pack_base { @@ -220,8 +168,8 @@ // Forward declarations template <class D, class POD > class __Event_base_aux; -template <class D> class __Event_base_aux<D,__true_type>; -template <class D> class __Event_base_aux<D,__false_type>; +template <class D> class __Event_base_aux<D,std::tr1::true_type>; +template <class D> class __Event_base_aux<D,std::tr1::false_type>; template <class D> class Event_base; @@ -267,7 +215,7 @@ }; template <class D> -class __Event_base_aux<D,__true_type> : +class __Event_base_aux<D,std::tr1::true_type> : public __Event_Base { public: @@ -318,7 +266,7 @@ }; template <class D> -class __Event_base_aux<D,__false_type> : +class __Event_base_aux<D,std::tr1::false_type> : public __Event_Base { public: @@ -369,7 +317,7 @@ }; template <> -class __Event_base_aux<std::string,__false_type> : +class __Event_base_aux<std::string,std::tr1::false_type> : public __Event_Base { public: @@ -420,7 +368,7 @@ }; template <> -class __Event_base_aux<void,__true_type> : +class __Event_base_aux<void,std::tr1::true_type> : public __Event_Base { public: @@ -456,26 +404,26 @@ template <class D> class Event_base : - public __Event_base_aux<D,typename __type_traits<D>::is_POD_type> + public __Event_base_aux<D,typename std::tr1::is_pod<D>::type> { private: - typedef __Event_base_aux<D,typename __type_traits<D>::is_POD_type> _Base; + typedef __Event_base_aux<D,typename std::tr1::is_pod<D>::type> _Base; public: Event_base() : - __Event_base_aux<D,typename __type_traits<D>::is_POD_type>() + __Event_base_aux<D,typename std::tr1::is_pod<D>::type>() { } explicit Event_base( code_type c ) : - __Event_base_aux<D,typename __type_traits<D>::is_POD_type>( c ) + __Event_base_aux<D,typename std::tr1::is_pod<D>::type>( c ) { } Event_base( code_type c, const D& d ) : - __Event_base_aux<D,typename __type_traits<D>::is_POD_type>( c, d ) + __Event_base_aux<D,typename std::tr1::is_pod<D>::type>( c, d ) { } Event_base( const Event_base& e ) : - __Event_base_aux<D,typename __type_traits<D>::is_POD_type>( e, e._data ) + __Event_base_aux<D,typename std::tr1::is_pod<D>::type>( e, e._data ) { } void net_pack( Event& s ) const; @@ -487,26 +435,26 @@ template <> class Event_base<std::string> : - public __Event_base_aux<std::string,__false_type> + public __Event_base_aux<std::string,std::tr1::false_type> { private: - typedef __Event_base_aux<std::string,__false_type> _Base; + typedef __Event_base_aux<std::string,std::tr1::false_type> _Base; public: Event_base() : - __Event_base_aux<std::string,__false_type>() + __Event_base_aux<std::string,std::tr1::false_type>() { } explicit Event_base( code_type c ) : - __Event_base_aux<std::string,__false_type>( c ) + __Event_base_aux<std::string,std::tr1::false_type>( c ) { } Event_base( code_type c, const std::string& d ) : - __Event_base_aux<std::string,__false_type>( c, d ) + __Event_base_aux<std::string,std::tr1::false_type>( c, d ) { } Event_base( const Event_base& e ) : - __Event_base_aux<std::string,__false_type>( e, e._data ) + __Event_base_aux<std::string,std::tr1::false_type>( e, e._data ) { } void net_pack( Event& s ) const @@ -549,7 +497,6 @@ template <class D> void Event_base<D>::net_pack( Event& s ) const { - // std::cerr << "**1\n"; s.code( _Base::_code ); s.dest( _Base::_dst ); s.src( _Base::_src ); @@ -568,7 +515,6 @@ _Base::_flags = s.flags() & ~(__Event_Base::conv | __Event_Base::expand); std::istringstream ss( s.value() ); _Base::net_unpack( ss ); - // std::cerr << "**2 " << std::hex << _Base::flags() << std::dec << std::endl; } template <class D> @@ -582,7 +528,6 @@ std::ostringstream ss; _Base::pack( ss ); s.value() = ss.str(); - // std::cerr << "**3 " << std::hex << s.flags() << std::dec << std::endl; } template <class D> @@ -595,28 +540,27 @@ // _Base::unsetf( __Event_Base::expand ); std::istringstream ss( s.value() ); _Base::unpack( ss ); - // std::cerr << "**4 " << std::hex << _Base::flags() << std::dec << std::endl; } template <> class Event_base<void> : - public __Event_base_aux<void,__true_type> + public __Event_base_aux<void,std::tr1::true_type> { private: - typedef __Event_base_aux<void,__true_type> _Base; + typedef __Event_base_aux<void,std::tr1::true_type> _Base; public: Event_base() : - __Event_base_aux<void,__true_type>() + __Event_base_aux<void,std::tr1::true_type>() { } explicit Event_base( code_type c ) : - __Event_base_aux<void,__true_type>( c ) + __Event_base_aux<void,std::tr1::true_type>( c ) { } __FIT_EXPLICIT Event_base( const Event_base& e ) : - __Event_base_aux<void,__true_type>( e ) + __Event_base_aux<void,std::tr1::true_type>( e ) { } void net_pack( Event& s ) const Modified: trunk/complement/explore/include/stem/EventHandler.h =================================================================== --- trunk/complement/explore/include/stem/EventHandler.h 2007-08-03 06:27:59 UTC (rev 1659) +++ trunk/complement/explore/include/stem/EventHandler.h 2007-08-03 06:31:38 UTC (rev 1660) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/08 17:24:21 ptr> +// -*- C++ -*- Time-stamp: <07/08/03 09:01:32 ptr> /* * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 @@ -509,7 +509,7 @@ typedef HistoryContainer::iterator h_iterator; typedef HistoryContainer::const_iterator const_h_iterator; -_STLP_TEMPLATE_NULL +template <> class __EvHandler<EventHandler,h_iterator > { public: @@ -669,7 +669,7 @@ } } -_STLP_TEMPLATE_NULL +template <> inline void __EvTableLoader<EventHandler>( EventHandler::table_type *, EventHandler * ) { } Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-08-03 06:27:59 UTC (rev 1659) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-08-03 06:31:38 UTC (rev 1660) @@ -1,3 +1,13 @@ +2007-08-03 Petr Ovtchenkov <pt...@is...> + + * Makefile: let's try don't include boost's -I if macro + not defined---mysterious behaviour otherwise happens; + + * Event.h, EvManager.cc, EvPack.cc: use TR1 type_traits technique; + add tricks to compile without STLport; + + * EventHandler.h: remove STLport's macro. + 2007-07-27 Petr Ovtchenkov <pt...@is...> * Event.h, EvManager.cc, EvPack.cc: operator of format output Modified: trunk/complement/explore/lib/stem/EvManager.cc =================================================================== --- trunk/complement/explore/lib/stem/EvManager.cc 2007-08-03 06:27:59 UTC (rev 1659) +++ trunk/complement/explore/lib/stem/EvManager.cc 2007-08-03 06:31:38 UTC (rev 1660) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/03/12 18:53:45 ptr> +// -*- C++ -*- Time-stamp: <07/08/03 09:20:31 ptr> /* * @@ -685,10 +685,10 @@ __FIT_DECLSPEC std::ostream& EvManager::dump( std::ostream& s ) const { - ios_base::fmtflags f = s.flags( 0 ); + ios_base::fmtflags f = s.flags( ios_base::hex | ios_base::showbase ); s << "Local map:\n"; - s << hex << showbase; + // s << hex << showbase; { scoped_lock lk( _lock_heap ); Modified: trunk/complement/explore/lib/stem/EvPack.cc =================================================================== --- trunk/complement/explore/lib/stem/EvPack.cc 2007-08-03 06:27:59 UTC (rev 1659) +++ trunk/complement/explore/lib/stem/EvPack.cc 2007-08-03 06:31:38 UTC (rev 1660) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/24 17:19:05 ptr> +// -*- C++ -*- Time-stamp: <07/08/03 09:22:05 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 @@ -24,9 +24,9 @@ ostream& operator <<( ostream& o, const stem::gaddr_type& g ) { - ios_base::fmtflags f = o.flags( 0 ); + ios_base::fmtflags f = o.flags( ios_base::hex ); - o << hex << setfill( '0' ) + o << setfill( '0' ) << setw(8) << g.hid.u.l[0] << setw(8) << g.hid.u.l[1] << '-' << dec << g.pid << '-' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 06:28:15
|
Revision: 1659 http://complement.svn.sourceforge.net/complement/?rev=1659&view=rev Author: complement Date: 2007-08-02 23:27:59 -0700 (Thu, 02 Aug 2007) Log Message: ----------- add typedefs shared_mutex, shared_recursive_mutex; change ipc_sharable on is_ipc_sharable, use TR1 type_traits technique; add tricks to compile without STLport Modified Paths: -------------- trunk/complement/explore/include/mt/shm.h trunk/complement/explore/include/mt/xmt.h trunk/complement/explore/lib/mt/ChangeLog Modified: trunk/complement/explore/include/mt/shm.h =================================================================== --- trunk/complement/explore/include/mt/shm.h 2007-08-03 06:17:38 UTC (rev 1658) +++ trunk/complement/explore/include/mt/shm.h 2007-08-03 06:27:59 UTC (rev 1659) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 22:38:41 ptr> +// -*- C++ -*- Time-stamp: <07/08/03 09:47:53 ptr> /* * Copyright (c) 2006, 2007 @@ -21,7 +21,7 @@ #include <stdexcept> #include <algorithm> -#include <stl/type_traits.h> +#include <misc/type_traits.h> #include <mt/xmt.h> @@ -64,41 +64,45 @@ }; template <class T> -struct ipc_sharable -{ - typedef typename std::__type_traits<T>::is_POD_type is_ipc_sharable; -}; +struct is_ipc_sharable : + public std::tr1::false_type +{ }; -template <> -struct ipc_sharable<xmt::__condition<true> > -{ - typedef std::__true_type is_ipc_sharable; -}; +#define __SPEC_(C,T,B) \ +template <> \ +struct C<T > : \ + public std::tr1::integral_constant<bool, B> \ +{ } -template <> -struct ipc_sharable<xmt::__semaphore<true> > -{ - typedef std::__true_type is_ipc_sharable; -}; +#define __SPEC_FULL(C,T,B) \ +__SPEC_(C,T,B); \ +__SPEC_(C,volatile T,B); -template <> -struct ipc_sharable<xmt::__barrier<true> > -{ - typedef std::__true_type is_ipc_sharable; -}; +__SPEC_FULL(is_ipc_sharable,bool,true); +__SPEC_FULL(is_ipc_sharable,char,true); +__SPEC_FULL(is_ipc_sharable,signed char,true); +__SPEC_FULL(is_ipc_sharable,unsigned char,true); +__SPEC_FULL(is_ipc_sharable,wchar_t,true); +__SPEC_FULL(is_ipc_sharable,short,true); +__SPEC_FULL(is_ipc_sharable,unsigned short,true); +__SPEC_FULL(is_ipc_sharable,int,true); +__SPEC_FULL(is_ipc_sharable,unsigned int,true); +__SPEC_FULL(is_ipc_sharable,long,true); +__SPEC_FULL(is_ipc_sharable,unsigned long,true); +__SPEC_FULL(is_ipc_sharable,long long,true); +__SPEC_FULL(is_ipc_sharable,unsigned long long,true); +__SPEC_FULL(is_ipc_sharable,float,true); +__SPEC_FULL(is_ipc_sharable,double,true); +__SPEC_FULL(is_ipc_sharable,long double,true); +__SPEC_FULL(is_ipc_sharable,xmt::__condition<true>,true); +__SPEC_FULL(is_ipc_sharable,xmt::__semaphore<true>,true); +__SPEC_FULL(is_ipc_sharable,xmt::__barrier<true>,true); +__SPEC_FULL(is_ipc_sharable,xmt::shared_mutex,true); +__SPEC_FULL(is_ipc_sharable,xmt::shared_recursive_mutex,true); -template <> -struct ipc_sharable<xmt::__mutex<false,true> > -{ - typedef std::__true_type is_ipc_sharable; -}; +#undef __SPEC_FULL +#undef __SPEC_ -template <> -struct ipc_sharable<xmt::__mutex<true,true> > -{ - typedef std::__true_type is_ipc_sharable; -}; - template <int _Inst> class shm_alloc; namespace detail { @@ -633,7 +637,7 @@ }; template <> -class __allocator_shm<std::__false_type> +class __allocator_shm<std::tr1::false_type> { private: __allocator_shm() @@ -641,19 +645,35 @@ }; template <> -class __allocator_shm<std::__true_type> +class __allocator_shm<std::tr1::true_type> { public: __allocator_shm() { } }; +#ifndef STLPORT + +template <class _Tp, class TRD > +inline void __destroy_aux(_Tp *p, const TRD& /* has_trivial_destructor */) +{ } + +template <class _Tp> +inline void __destroy_aux(_Tp *p, const std::tr1::false_type& /* has_trivial_destructor */) +{ p->~_Tp(); } + +template <class _Tp> +inline void __destroy_aux(_Tp *p, const std::tr1::true_type& /* has_trivial_destructor */) +{ } + +#endif // !STLPORT + } // namespace detail template <class _Tp, int _Inst> class allocator_shm : public shm_alloc<_Inst>, - private detail::__allocator_shm<typename ipc_sharable<_Tp>::is_ipc_sharable> + private detail::__allocator_shm<typename is_ipc_sharable<_Tp>::type> { public: typedef shm_alloc<_Inst> chunk_type; @@ -723,10 +743,22 @@ { return chunk_type::max_size() / sizeof(value_type); } void construct(pointer __p, const_reference __val) - { _STLP_STD::_Copy_Construct(__p, __val); } + { +#ifdef STLPORT + _STLP_STD::_Copy_Construct(__p, __val); +#else + new (__p) _Tp(__val); +#endif + } void destroy(pointer __p) - { _STLP_STD::_Destroy(__p); } + { +#ifdef STLPORT + _STLP_STD::_Destroy(__p); +#else + detail::__destroy_aux(__p,std::tr1::has_trivial_destructor<value_type>::value); +#endif + } }; Modified: trunk/complement/explore/include/mt/xmt.h =================================================================== --- trunk/complement/explore/include/mt/xmt.h 2007-08-03 06:17:38 UTC (rev 1658) +++ trunk/complement/explore/include/mt/xmt.h 2007-08-03 06:27:59 UTC (rev 1659) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 22:37:57 ptr> +// -*- C++ -*- Time-stamp: <07/08/03 09:47:08 ptr> /* * Copyright (c) 1997-1999, 2002-2007 @@ -895,6 +895,8 @@ typedef __mutex<false,false> mutex; typedef __mutex<true,false> recursive_mutex; +typedef __mutex<false,true> shared_mutex; +typedef __mutex<true,true> shared_recursive_mutex; #ifdef __FIT_RWLOCK typedef __rw_mutex<false> rw_mutex; #endif // __FIT_RWLOCK Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-08-03 06:17:38 UTC (rev 1658) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-08-03 06:27:59 UTC (rev 1659) @@ -1,3 +1,13 @@ +2007-08-03 Petr Ovtchenkov <pt...@is...> + + * test/mt/Makefile: let's try don't include boost's -I if macro + not defined---mysterious behaviour otherwise happens; + + * xmt.h: add typedefs shared_mutex, shared_recursive_mutex; + + * shm.h: change ipc_sharable on is_ipc_sharable, use TR1 type_traits + technique; add tricks to compile without STLport. + 2007-07-17 Petr Ovtchenkov <pt...@is...> * test/mt: boost unit test framework was replaced by exam. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 06:17:42
|
Revision: 1658 http://complement.svn.sourceforge.net/complement/?rev=1658&view=rev Author: complement Date: 2007-08-02 23:17:38 -0700 (Thu, 02 Aug 2007) Log Message: ----------- let's try don't include boost's -I if macro not defined---mysterious behaviour otherwise happens Modified Paths: -------------- trunk/complement/explore/lib/stem/Makefile trunk/complement/explore/test/mt/Makefile Modified: trunk/complement/explore/lib/stem/Makefile =================================================================== --- trunk/complement/explore/lib/stem/Makefile 2007-08-03 06:06:03 UTC (rev 1657) +++ trunk/complement/explore/lib/stem/Makefile 2007-08-03 06:17:38 UTC (rev 1658) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/01/23 14:58:35 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 09:12:25 ptr> SRCROOT := ../.. @@ -9,9 +9,9 @@ dbg-shared: DEFS += -D__FIT_STEM_TRACE=1 -ifdef WITHOUT_STLPORT -INCLUDES += -I${BOOST_INCLUDE_DIR} -else +ifndef WITHOUT_STLPORT +# INCLUDES += -I${BOOST_INCLUDE_DIR} +# else stldbg-shared: DEFS += -D__FIT_STEM_TRACE=1 endif Modified: trunk/complement/explore/test/mt/Makefile =================================================================== --- trunk/complement/explore/test/mt/Makefile 2007-08-03 06:06:03 UTC (rev 1657) +++ trunk/complement/explore/test/mt/Makefile 2007-08-03 06:17:38 UTC (rev 1658) @@ -7,7 +7,10 @@ include ${SRCROOT}/Makefiles/gmake/top.mak -INCLUDES += -I$(SRCROOT)/include -I$(BOOST_INCLUDE_DIR) +INCLUDES += -I$(SRCROOT)/include +ifdef BOOST_DIR +INCLUDES += -I$(BOOST_INCLUDE_DIR) +endif DEFS += -D__FIT_EXAM # temporary, before dums fix strings: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 06:06:09
|
Revision: 1657 http://complement.svn.sourceforge.net/complement/?rev=1657&view=rev Author: complement Date: 2007-08-02 23:06:03 -0700 (Thu, 02 Aug 2007) Log Message: ----------- select appropriate TR1 type_traits implementation or use own, if not good one found [initial release] Modified Paths: -------------- trunk/complement/explore/lib/misc/ChangeLog Added Paths: ----------- trunk/complement/explore/include/misc/type_traits.h Added: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h (rev 0) +++ trunk/complement/explore/include/misc/type_traits.h 2007-08-03 06:06:03 UTC (rev 1657) @@ -0,0 +1,164 @@ +// -*- C++ -*- Time-stamp: <07/08/03 08:59:36 ptr> + +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#ifndef __misc_type_traits_h +#define __misc_type_traits_h + +#ifndef __config_feature_h +#include <config/feature.h> +#endif + +#if !defined(STLPORT) /* || (_STLPORT_VERSION < 50200) */ + +// libstdc++ v3, timestamp 20050519 (3.4.4) has __type_traits, +// libstdc++ v3, timestamp 20060306 (3.4.6) has __type_traits, +// while libstdc++ v3, 20050921 (4.0.2) not; use libstdc++ instead +# if !defined(__GLIBCXX__) || (defined(__GNUC__) && (__GNUC__ < 4)) + +namespace std { + +namespace tr1 { + +template <class _Tp, _Tp __v> +struct integral_constant +{ + static const _Tp value = __v; + // enum { value = __v }; + + typedef _Tp value_type; + typedef integral_constant<_Tp, __v> type; +}; + +typedef integral_constant<bool, true> true_type; +typedef integral_constant<bool, false> false_type; + +#define __SPEC_(C,T,B) \ +template <> \ +struct C<T> : \ + public integral_constant<bool, B> \ +{ } + +#define __SPEC_FULL(C,T,B) \ +__SPEC_(C,T,B); \ +__SPEC_(C,const T,B); \ +__SPEC_(C,volatile T,B); \ +__SPEC_(C,const volatile T,B) + +#define __SPEC_1(C,T,B) \ +template <class _Tp> \ +struct C<T> : \ + public integral_constant<bool, B> \ +{ } + +#define __SPEC_FULL1(C,T,B) \ +__SPEC_1(C,T,B); \ +__SPEC_1(C,const T,B); \ +__SPEC_1(C,volatile T,B); \ +__SPEC_1(C,const volatile T,B) + +template <class _Tp> +struct is_void : + public false_type +{ }; + +__SPEC_FULL(is_void,bool,true); + +template <class _Tp> +struct is_integral : + public false_type +{ }; + +__SPEC_FULL(is_integral,bool,true); +__SPEC_FULL(is_integral,char,true); +__SPEC_FULL(is_integral,signed char,true); +__SPEC_FULL(is_integral,unsigned char,true); +__SPEC_FULL(is_integral,wchar_t,true); +__SPEC_FULL(is_integral,short,true); +__SPEC_FULL(is_integral,unsigned short,true); +__SPEC_FULL(is_integral,int,true); +__SPEC_FULL(is_integral,unsigned int,true); +__SPEC_FULL(is_integral,long,true); +__SPEC_FULL(is_integral,unsigned long,true); +__SPEC_FULL(is_integral,long long,true); +__SPEC_FULL(is_integral,unsigned long long,true); + +template <class _Tp> +struct is_floating_point : + public false_type +{ }; + +__SPEC_FULL(is_floating_point,float,true); +__SPEC_FULL(is_floating_point,double,true); +__SPEC_FULL(is_floating_point,long double,true); + +template <class _Tp> +struct is_arithmetic : + public integral_constant<bool, (is_integral<_Tp>::value + || is_floating_point<_Tp>::value)> +{ }; + +template <class _Tp> +struct is_pointer : + public false_type +{ }; + +__SPEC_FULL1(is_pointer,_Tp *,true); + +template <class _Tp> +struct is_scalar : + public integral_constant<bool, (is_arithmetic<_Tp>::value + /* || is_enum<_Tp>::value */ + || is_pointer<_Tp>::value + /* || is_member_pointer<_Tp>::value */ )> +{ }; + +template <class _Tp> +struct remove_all_extents +{ + typedef _Tp type; +}; + +template <class _Tp, std::size_t _Size> +struct remove_all_extents<_Tp[_Size]> +{ + typedef typename remove_all_extents<_Tp>::type type; +}; + +template<typename _Tp> +struct remove_all_extents<_Tp[]> +{ + typedef typename remove_all_extents<_Tp>::type type; +}; + +template <class _Tp> +struct is_pod : + public integral_constant<bool, (is_void<_Tp>::value + || is_scalar<typename remove_all_extents<_Tp>::type>::value)> +{ }; + +#undef __SPEC_FULL +#undef __SPEC_ +#undef __SPEC_FULL1 +#undef __SPEC_1 + +} // namespace tr1 + +} // namespace std + +# else // __GLIBCXX__ && (__GNUC__ >= 4) +# include <tr1/type_traits> +# endif + +#else // STLPORT +# include <type_traits> +#endif + +#endif // __misc_type_traits_h + Modified: trunk/complement/explore/lib/misc/ChangeLog =================================================================== --- trunk/complement/explore/lib/misc/ChangeLog 2007-07-27 12:03:29 UTC (rev 1656) +++ trunk/complement/explore/lib/misc/ChangeLog 2007-08-03 06:06:03 UTC (rev 1657) @@ -1,3 +1,8 @@ +2007-08-03 Petr Ovtchenkov <pt...@is...> + + * type_traits.h: select appropriate TR1 type_traits implementation + or use own, if not good one found [initial release]. + 2007-02-28 Petr Ovtchenkov <pt...@is...> * tfstream: fstream-like interface to unique temporary file; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-27 12:03:31
|
Revision: 1656 http://complement.svn.sourceforge.net/complement/?rev=1656&view=rev Author: complement Date: 2007-07-27 05:03:29 -0700 (Fri, 27 Jul 2007) Log Message: ----------- init script management tool Added Paths: ----------- trunk/complement/explore/app/utils/iscp/ Property changes on: trunk/complement/explore/app/utils/iscp ___________________________________________________________________ Name: svn:ignore + obj This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-27 12:02:34
|
Revision: 1655 http://complement.svn.sourceforge.net/complement/?rev=1655&view=rev Author: complement Date: 2007-07-27 05:02:32 -0700 (Fri, 27 Jul 2007) Log Message: ----------- ignore generated Property Changed: ---------------- trunk/complement/explore/inquiry/shades/autotools/ Property changes on: trunk/complement/explore/inquiry/shades/autotools ___________________________________________________________________ Name: svn:ignore + configure config.log config.status a.out autom4te.cache cxxtest.gcc Makefile This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-27 12:01:12
|
Revision: 1654 http://complement.svn.sourceforge.net/complement/?rev=1654&view=rev Author: complement Date: 2007-07-27 05:01:09 -0700 (Fri, 27 Jul 2007) Log Message: ----------- inquiry make exit status Added Paths: ----------- trunk/complement/explore/inquiry/makes/exit/ trunk/complement/explore/inquiry/makes/exit/Makefile trunk/complement/explore/inquiry/makes/exit/subdir/ trunk/complement/explore/inquiry/makes/exit/subdir/Makefile Added: trunk/complement/explore/inquiry/makes/exit/Makefile =================================================================== --- trunk/complement/explore/inquiry/makes/exit/Makefile (rev 0) +++ trunk/complement/explore/inquiry/makes/exit/Makefile 2007-07-27 12:01:09 UTC (rev 1654) @@ -0,0 +1,15 @@ +SUBDIRS := subdir + +define doinsubdirs +for d in $(1); do \ + ${MAKE} -C $$d $@; \ +done +endef + + +all: + ${call doinsubdirs,${SUBDIRS} } + echo "Next" + +.PHONY: all + Added: trunk/complement/explore/inquiry/makes/exit/subdir/Makefile =================================================================== --- trunk/complement/explore/inquiry/makes/exit/subdir/Makefile (rev 0) +++ trunk/complement/explore/inquiry/makes/exit/subdir/Makefile 2007-07-27 12:01:09 UTC (rev 1654) @@ -0,0 +1,5 @@ + +all: + ( exit 1; ) + +.PHONY: all This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |