From 8286ac511144e4f17d34eac9affb97e50646344a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 23 Jul 2014 15:25:44 +0200 Subject: Imported Upstream version 4.0.0 --- libcult/examples/cli/cli.cxx | 65 ---------- libcult/examples/cli/makefile | 48 -------- libcult/examples/dr/xdr/makefile | 49 -------- libcult/examples/dr/xdr/xdr.cxx | 87 ------------- libcult/examples/makefile | 36 ------ libcult/examples/mm/shptr/makefile | 48 -------- libcult/examples/mm/shptr/shptr.cxx | 73 ----------- libcult/examples/mm/transfer/makefile | 48 -------- libcult/examples/mm/transfer/transfer.cxx | 117 ------------------ libcult/examples/os/net/ipv4/datagram/client.cxx | 66 ---------- libcult/examples/os/net/ipv4/datagram/makefile | 55 --------- libcult/examples/os/net/ipv4/datagram/protocol.hxx | 20 --- libcult/examples/os/net/ipv4/datagram/server.cxx | 123 ------------------- libcult/examples/os/net/ipv4/multicast/client.cxx | 66 ---------- libcult/examples/os/net/ipv4/multicast/makefile | 55 --------- .../examples/os/net/ipv4/multicast/protocol.hxx | 20 --- libcult/examples/os/net/ipv4/multicast/server.cxx | 134 --------------------- libcult/examples/sched/cancel/cancel.cxx | 63 ---------- libcult/examples/sched/cancel/makefile | 48 -------- libcult/examples/sched/main/main.cxx | 43 ------- libcult/examples/sched/main/makefile | 48 -------- libcult/examples/trace/makefile | 48 -------- libcult/examples/trace/trace.cxx | 51 -------- 23 files changed, 1411 deletions(-) delete mode 100644 libcult/examples/cli/cli.cxx delete mode 100644 libcult/examples/cli/makefile delete mode 100644 libcult/examples/dr/xdr/makefile delete mode 100644 libcult/examples/dr/xdr/xdr.cxx delete mode 100644 libcult/examples/makefile delete mode 100644 libcult/examples/mm/shptr/makefile delete mode 100644 libcult/examples/mm/shptr/shptr.cxx delete mode 100644 libcult/examples/mm/transfer/makefile delete mode 100644 libcult/examples/mm/transfer/transfer.cxx delete mode 100644 libcult/examples/os/net/ipv4/datagram/client.cxx delete mode 100644 libcult/examples/os/net/ipv4/datagram/makefile delete mode 100644 libcult/examples/os/net/ipv4/datagram/protocol.hxx delete mode 100644 libcult/examples/os/net/ipv4/datagram/server.cxx delete mode 100644 libcult/examples/os/net/ipv4/multicast/client.cxx delete mode 100644 libcult/examples/os/net/ipv4/multicast/makefile delete mode 100644 libcult/examples/os/net/ipv4/multicast/protocol.hxx delete mode 100644 libcult/examples/os/net/ipv4/multicast/server.cxx delete mode 100644 libcult/examples/sched/cancel/cancel.cxx delete mode 100644 libcult/examples/sched/cancel/makefile delete mode 100644 libcult/examples/sched/main/main.cxx delete mode 100644 libcult/examples/sched/main/makefile delete mode 100644 libcult/examples/trace/makefile delete mode 100644 libcult/examples/trace/trace.cxx (limited to 'libcult/examples') diff --git a/libcult/examples/cli/cli.cxx b/libcult/examples/cli/cli.cxx deleted file mode 100644 index 922a23d..0000000 --- a/libcult/examples/cli/cli.cxx +++ /dev/null @@ -1,65 +0,0 @@ -// file : examples/cli/cli.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Boris Kolpackov -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include -#include -#include - -#include - -using std::cerr; -using std::endl; - -using namespace Cult; - -namespace -{ - extern Char const help[] = "help"; - extern Char const version[] = "version"; - extern Char const outdir[] = "outdir"; -} - -typedef -CLI::Options -Options; - -Int -main (Int argc, Char* argv[]) -{ - try - { - Options options (CLI::parse (argc, argv)); - - if (options.value ()) - { - cerr << "usage: " << argv[0] << " [--help] [--version] [--outdir ]" - << endl; - return 0; - } - - if (options.value ()) - { - cerr << argv[0] << " 1.2.3" << endl; - return 0; - } - - if (String dir = options.value ()) - { - cerr << "outdir: " << dir << endl; - } - } - catch (CLI::UnexpectedOption const& e) - { - cerr << "unexpected option " << e.option () < -# copyright : Copyright (c) 2005-2010 Boris Kolpackov -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make - -cxx_tun := cli.cxx -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -cult.l := $(out_root)/cult/cult.l -cult.l.cpp-options := $(out_root)/cult/cult.l.cpp-options - -cli := $(out_base)/cli -clean := $(out_base)/.clean - - -# Build. -# -$(cli): $(cxx_obj) $(cult.l) - -$(cxx_obj) $(cxx_od): $(cult.l.cpp-options) - -$(call include-dep,$(cxx_od)) - - -# Convenience alias for default target. -# -$(out_base)/: $(cli) - - -# Clean. -# -$(clean): $(cli).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) - - -# How to. -# -$(call include,$(bld_root)/cxx/o-e.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/cxx-d.make) - -# Dependencies. -# -$(call import,$(src_root)/cult/makefile) diff --git a/libcult/examples/dr/xdr/makefile b/libcult/examples/dr/xdr/makefile deleted file mode 100644 index 6a4fa8f..0000000 --- a/libcult/examples/dr/xdr/makefile +++ /dev/null @@ -1,49 +0,0 @@ -# file : examples/dr/xdr/makefile -# author : Boris Kolpackov -# copyright : Copyright (c) 2005-2010 Boris Kolpackov -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -cxx_tun := xdr.cxx -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -cult.l := $(out_root)/cult/cult.l -cult.l.cpp-options := $(out_root)/cult/cult.l.cpp-options - -xdr := $(out_base)/xdr -clean := $(out_base)/.clean - - -# Build. -# -$(xdr): $(cxx_obj) $(cult.l) - -$(cxx_obj) $(cxx_od): $(cult.l.cpp-options) - -$(call include-dep,$(cxx_od)) - - -# Convenience alias for default target. -# -$(out_base)/: $(xdr) - - -# Clean. -# -$(clean): $(xdr).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) - - -# How to. -# -$(call include,$(bld_root)/cxx/o-e.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/cxx-d.make) - - -# Dependencies. -# -$(call import,$(src_root)/cult/makefile) diff --git a/libcult/examples/dr/xdr/xdr.cxx b/libcult/examples/dr/xdr/xdr.cxx deleted file mode 100644 index 38e948d..0000000 --- a/libcult/examples/dr/xdr/xdr.cxx +++ /dev/null @@ -1,87 +0,0 @@ -// file : examples/dr/xdr/xdr.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Boris Kolpackov -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include -#include - -#include - -using namespace Cult; -using namespace DR::XDR; - -using std::cerr; -using std::endl; - -Int -main () -{ - try - { - OutputStream o (8); - - o << true << false; - - UnsignedInt8 a8 (0xDE); - UnsignedInt16 a16 (0xDEAD); - UnsignedInt32 a32 (0xDEADBEEF); - UnsignedInt64 a64 (0xDEADBEEFDEADBEEFULL); - - o << a8 << a16 << a32 << a64; - - Int8 b8 (-8); - Int16 b16 (-16); - Int32 b32 (-32); - Int64 b64 (-64); - - o << b8 << b16 << b32 << b64; - - String s ("reasonably loooooooooooooong string with some junk in it"); - - o << s; - - InputStream i (o.buffer ()); - - Boolean t, f; - String s1; - - i >> t >> f; - i >> a8 >> a16 >> a32 >> a64; - i >> b8 >> b16 >> b32 >> b64; - i >> s1; - - if (!t - || f - || a8 != 0xDE - || a16 != 0xDEAD - || a32 != 0xDEADBEEF - || a64 != 0xDEADBEEFDEADBEEFULL - || b8 != -8 - || b16 != -16 - || b32 != -32 - || b64 != -64 - || s1 != s) return 1; - - try - { - i >> t; - } - catch (Extraction const&) - { - return 0; - } - } - catch (Insertion const&) - { - cerr << "insertion" << endl; - } - catch (Extraction const&) - { - cerr << "extraction" << endl; - } - - return 1; -} diff --git a/libcult/examples/makefile b/libcult/examples/makefile deleted file mode 100644 index d264910..0000000 --- a/libcult/examples/makefile +++ /dev/null @@ -1,36 +0,0 @@ -# file : examples/makefile -# author : Boris Kolpackov -# copyright : Copyright (c) 2005-2010 Boris Kolpackov -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make -include $(scf_root)/configuration.make - -default := $(out_base)/ -clean := $(out_base)/.clean - -examples := $(out_base)/cli \ - $(out_base)/mm/shptr \ - $(out_base)/mm/transfer \ - $(out_base)/trace - -ifeq ($(cult_threads),y) -examples += $(out_base)/sched/main \ - $(out_base)/sched/cancel -endif - - -ifeq ($(cult_network),y) -examples += $(out_base)/os/net/ipv4/datagram \ - $(out_base)/os/net/ipv4/multicast -endif - -ifeq ($(cult_dr),y) -examples += $(out_base)/dr/xdr -endif - - -$(default): $(addsuffix /,$(examples)) -$(clean): $(addsuffix /.clean,$(examples)) - -$(foreach e,$(subst $(out_base),$(src_base),$(examples)),$(call import,$e/makefile)) diff --git a/libcult/examples/mm/shptr/makefile b/libcult/examples/mm/shptr/makefile deleted file mode 100644 index 2bf1598..0000000 --- a/libcult/examples/mm/shptr/makefile +++ /dev/null @@ -1,48 +0,0 @@ -# file : examples/mm/shptr/makefile -# author : Boris Kolpackov -# copyright : Copyright (c) 2005-2010 Boris Kolpackov -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -cxx_tun := shptr.cxx -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -cult.l := $(out_root)/cult/cult.l -cult.l.cpp-options := $(out_root)/cult/cult.l.cpp-options - -shptr := $(out_base)/shptr -clean := $(out_base)/.clean - - -# Build. -# -$(shptr): $(cxx_obj) $(cult.l) - -$(cxx_obj) $(cxx_od): $(cult.l.cpp-options) - -$(call include-dep,$(cxx_od)) - - -# Convenience alias for default target. -# -$(out_base)/: $(shptr) - - -# Clean. -# -$(clean): $(shptr).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) - - -# How to. -# -$(call include,$(bld_root)/cxx/o-e.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/cxx-d.make) - -# Dependencies. -# -$(call import,$(src_root)/cult/makefile) diff --git a/libcult/examples/mm/shptr/shptr.cxx b/libcult/examples/mm/shptr/shptr.cxx deleted file mode 100644 index cb026d4..0000000 --- a/libcult/examples/mm/shptr/shptr.cxx +++ /dev/null @@ -1,73 +0,0 @@ -// file : examples/mm/shptr/shptr.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Boris Kolpackov -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include -#include // MM::locate -#include // MM::inc_ref - -#include - -using std::cerr; -using std::endl; - -using namespace Cult; -using namespace MM; - -struct Foo -{ - virtual ~Foo () {} - char c; -}; - -struct Bar: virtual Foo {char c;}; - -struct Baz: virtual Foo {char c;}; - -struct Fox: Bar, Baz {}; - - -struct A -{ - char c[8]; -}; - -struct B -{ - char c[8]; -}; - -struct C : A, B -{ - char c[8]; -}; - -int -main () -{ - { - Baz* bp (new Fox); - Foo* fp (bp); - - Counter* cp (locate (fp, *counted)); - - inc_ref (bp); - - cp->dec_ref (); - - if (cp->dec_ref ()) cerr << "good: destroying" << endl; - else cerr << "bad: leaking" << endl; - - delete bp; - } - - { - Shptr pfox (new Fox); - Shptr pbar (pfox); - - Shptr pfoo; - - pfoo = pbar; - } -} diff --git a/libcult/examples/mm/transfer/makefile b/libcult/examples/mm/transfer/makefile deleted file mode 100644 index 3380f10..0000000 --- a/libcult/examples/mm/transfer/makefile +++ /dev/null @@ -1,48 +0,0 @@ -# file : examples/mm/transfer/makefile -# author : Boris Kolpackov -# copyright : Copyright (c) 2005-2010 Boris Kolpackov -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -cxx_tun := transfer.cxx -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -cult.l := $(out_root)/cult/cult.l -cult.l.cpp-options := $(out_root)/cult/cult.l.cpp-options - -transfer := $(out_base)/transfer -clean := $(out_base)/.clean - - -# Build. -# -$(transfer): $(cxx_obj) $(cult.l) - -$(cxx_obj) $(cxx_od): $(cult.l.cpp-options) - -$(call include-dep,$(cxx_od)) - - -# Convenience alias for default target. -# -$(out_base)/: $(transfer) - - -# Clean. -# -$(clean): $(transfer).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) - - -# How to. -# -$(call include,$(bld_root)/cxx/o-e.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/cxx-d.make) - -# Dependencies. -# -$(call import,$(src_root)/cult/makefile) diff --git a/libcult/examples/mm/transfer/transfer.cxx b/libcult/examples/mm/transfer/transfer.cxx deleted file mode 100644 index 81014d0..0000000 --- a/libcult/examples/mm/transfer/transfer.cxx +++ /dev/null @@ -1,117 +0,0 @@ -// file : examples/mm/transfer/transfer.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Boris Kolpackov -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include - -using std::cerr; -using std::endl; - -using namespace Cult; - -unsigned long count = 0; -unsigned long clone_count = 0; - -struct Type -{ - Type () - { - ++count; - } - - ~Type () - { - --count; - } - - Evptr - clone () const - { - ++clone_count; - return Evptr (new Type); - } - - Void - f () const - { - Int i = i_; - ++i; - } - - Int i_; -}; - - -Evptr -source () -{ - return Evptr (new Type); -} - -Void -sink (Evptr a, Boolean r = true) -{ - if (r) - { - sink (a, false); - } - else - { - Evptr b (a); - - cerr << "\tshare count: " << b.count () << endl; - - // Any of these will trigger cloning. - // - b->f (); - } -} - -Int -main () -{ - // case 1 - // - { - cerr << "sink (new type)" << endl; - - clone_count = 0; - sink (new Type); - - cerr << "\tclone count: " << clone_count << endl - << endl; - } - - // case 2 - // - { - cerr << "sink (source ())" << endl; - - clone_count = 0; - sink (source ()); - - cerr << "\tclone count: " << clone_count << endl - << endl; - } - - - // case 3 - // - { - cerr << "sink (p)" << endl; - - clone_count = 0; - - Evptr p (new Type); - sink (p); - - cerr << "\tclone count: " << clone_count << endl - << endl; - } - - - cerr << "balance: " << count << endl; -} diff --git a/libcult/examples/os/net/ipv4/datagram/client.cxx b/libcult/examples/os/net/ipv4/datagram/client.cxx deleted file mode 100644 index 863fc25..0000000 --- a/libcult/examples/os/net/ipv4/datagram/client.cxx +++ /dev/null @@ -1,66 +0,0 @@ -// file : examples/os/net/ipv4/datagram/client.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Boris Kolpackov -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include -#include - -#include -#include // usleep - -#include "protocol.hxx" - -using std::cerr; -using std::endl; - -using namespace Cult; -using namespace OS::Net::IPv4; - -class Args {}; - -Int -main (Int argc, Char* argv[]) -{ - try - { - if (argc < 2) - throw Args (); - - Address addr (argv[1], 10000); - - DatagramSocket socket; - - Message msg; - msg.sn = 0; - - cerr << "message size : " << sizeof (msg) << " bytes" << endl; - cerr << "send buffer : " << socket.send_buffer_size () << " bytes" << endl; - - for (Index i = 0; i < payload_size; i++) - { - msg.payload[i] = i; - } - - for (; msg.sn < message_count; msg.sn++) - { - socket.send (&msg, sizeof (msg), addr); - - // ::usleep (10); - } - - return 0; - } - catch (OS::Exception const& e) - { - cerr << "errno: " << strerror (e.code ()) << endl; - } - catch (Args const&) - { - cerr << "usage: client " << endl; - } - - return 1; -} diff --git a/libcult/examples/os/net/ipv4/datagram/makefile b/libcult/examples/os/net/ipv4/datagram/makefile deleted file mode 100644 index 2dc8e1b..0000000 --- a/libcult/examples/os/net/ipv4/datagram/makefile +++ /dev/null @@ -1,55 +0,0 @@ -# file : examples/os/net/ipv4/datagram/makefile -# author : Boris Kolpackov -# copyright : Copyright (c) 2005-2010 Boris Kolpackov -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -client_cxx_tun := client.cxx -server_cxx_tun := server.cxx - -client_cxx_obj := $(addprefix $(out_base)/,$(client_cxx_tun:.cxx=.o)) -server_cxx_obj := $(addprefix $(out_base)/,$(server_cxx_tun:.cxx=.o)) - -cxx_obj := $(client_cxx_obj) $(server_cxx_obj) -cxx_od := $(cxx_obj:.o=.o.d) - -cult.l := $(out_root)/cult/cult.l -cult.l.cpp-options := $(out_root)/cult/cult.l.cpp-options - -client := $(out_base)/client -server := $(out_base)/server -clean := $(out_base)/.clean - -# Convenience alias for default target. -# -$(out_base)/: $(client) $(server) - -# Build. -# - -$(client): $(client_cxx_obj) $(cult.l) -$(server): $(server_cxx_obj) $(cult.l) - -$(cxx_obj) $(cxx_od): $(cult.l.cpp-options) - -$(call include-dep,$(cxx_od)) - - -# Clean. -# -$(clean): $(client).o.clean \ - $(server).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) - - -# How to. -# -$(call include,$(bld_root)/cxx/o-e.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/cxx-d.make) - -# Dependencies. -# -$(call import,$(src_root)/cult/makefile) diff --git a/libcult/examples/os/net/ipv4/datagram/protocol.hxx b/libcult/examples/os/net/ipv4/datagram/protocol.hxx deleted file mode 100644 index 0f418e8..0000000 --- a/libcult/examples/os/net/ipv4/datagram/protocol.hxx +++ /dev/null @@ -1,20 +0,0 @@ -// file : examples/os/net/ipv4/datagram/protocol.hxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Boris Kolpackov -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef PROTOCOL_HXX -#define PROTOCOL_HXX - -#include - -Cult::UnsignedShort const payload_size = 256; -Cult::UnsignedLong const message_count = 100; - -struct Message -{ - Cult::UnsignedLong sn; - Cult::UnsignedShort payload[payload_size]; -}; - -#endif // PROTOCOL_HXX diff --git a/libcult/examples/os/net/ipv4/datagram/server.cxx b/libcult/examples/os/net/ipv4/datagram/server.cxx deleted file mode 100644 index e788056..0000000 --- a/libcult/examples/os/net/ipv4/datagram/server.cxx +++ /dev/null @@ -1,123 +0,0 @@ -// file : examples/os/net/ipv4/datagram/server.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Boris Kolpackov -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include -#include - -#include -#include - -#include -#include // memcmp - -#include "protocol.hxx" - -using std::cerr; -using std::endl; - -using namespace Cult; -using namespace OS::Net::IPv4; - -typedef Containers::Vector StatusList; - -Int -main () -{ - try - { - Address addr (INADDR_ANY, 10000); - - DatagramSocket socket (addr); - - Message expected_msg; - expected_msg.sn = 0; - - for (UnsignedShort i = 0; i < payload_size; ++i) - { - expected_msg.payload[i] = i; - } - - StatusList received (message_count, 0); - StatusList damaged (message_count, 0); - StatusList duplicate (message_count, 0); - - Message msg; - - while (true) - { - socket.recv (&msg, sizeof (msg)); - - if (received[msg.sn]) - { - duplicate[msg.sn] = true; - } - else - { - received[msg.sn] = true; - - if (std::memcmp (expected_msg.payload, msg.payload, payload_size) != 0) - { - damaged[msg.sn] = true; - } - } - - if (msg.sn + 1 == message_count) break; - } - - UnsignedLong lost_count (0), damaged_count (0), duplicate_count (0); - - for (StatusList::Iterator i (received.begin ()), end (received.end ()); - i != end; - ++i) - if (!*i) ++lost_count; - - for (StatusList::Iterator i (damaged.begin ()), end (damaged.end ()); - i != end; - ++i) - if (*i) ++damaged_count; - - for (StatusList::Iterator i (duplicate.begin ()), end (duplicate.end ()); - i != end; - ++i) - if (*i) ++duplicate_count; - - cerr << "lost : " << lost_count << endl - << "damaged : " << damaged_count << endl - << "duplicate : " << duplicate_count << endl << endl; - - if (lost_count != 0) - { - cerr << "lost message dump:" << endl; - - UnsignedLong total = 0; - - for (StatusList::Iterator - begin (received.begin ()), i (begin), end (received.end ()); - i != end;) - { - if (!*i) - { - UnsignedLong count = 1; - - for (StatusList::Iterator j = i + 1; j < end && !*j; j++, count++) ; - - cerr << '\t' << i - begin << " : " << count << endl; - - i += count; - total += count; - } - else - ++i; - } - - if (total != lost_count) - cerr << "trouble" << endl; - } - } - catch (OS::Exception const& e) - { - cerr << "errno: " << e.code () << endl; - } -} diff --git a/libcult/examples/os/net/ipv4/multicast/client.cxx b/libcult/examples/os/net/ipv4/multicast/client.cxx deleted file mode 100644 index 863fc25..0000000 --- a/libcult/examples/os/net/ipv4/multicast/client.cxx +++ /dev/null @@ -1,66 +0,0 @@ -// file : examples/os/net/ipv4/datagram/client.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Boris Kolpackov -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include -#include - -#include -#include // usleep - -#include "protocol.hxx" - -using std::cerr; -using std::endl; - -using namespace Cult; -using namespace OS::Net::IPv4; - -class Args {}; - -Int -main (Int argc, Char* argv[]) -{ - try - { - if (argc < 2) - throw Args (); - - Address addr (argv[1], 10000); - - DatagramSocket socket; - - Message msg; - msg.sn = 0; - - cerr << "message size : " << sizeof (msg) << " bytes" << endl; - cerr << "send buffer : " << socket.send_buffer_size () << " bytes" << endl; - - for (Index i = 0; i < payload_size; i++) - { - msg.payload[i] = i; - } - - for (; msg.sn < message_count; msg.sn++) - { - socket.send (&msg, sizeof (msg), addr); - - // ::usleep (10); - } - - return 0; - } - catch (OS::Exception const& e) - { - cerr << "errno: " << strerror (e.code ()) << endl; - } - catch (Args const&) - { - cerr << "usage: client " << endl; - } - - return 1; -} diff --git a/libcult/examples/os/net/ipv4/multicast/makefile b/libcult/examples/os/net/ipv4/multicast/makefile deleted file mode 100644 index cb35bf6..0000000 --- a/libcult/examples/os/net/ipv4/multicast/makefile +++ /dev/null @@ -1,55 +0,0 @@ -# file : examples/os/net/ipv4/multicast/makefile -# author : Boris Kolpackov -# copyright : Copyright (c) 2005-2010 Boris Kolpackov -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -client_cxx_tun := client.cxx -server_cxx_tun := server.cxx - -client_cxx_obj := $(addprefix $(out_base)/,$(client_cxx_tun:.cxx=.o)) -server_cxx_obj := $(addprefix $(out_base)/,$(server_cxx_tun:.cxx=.o)) - -cxx_obj := $(client_cxx_obj) $(server_cxx_obj) -cxx_od := $(cxx_obj:.o=.o.d) - -cult.l := $(out_root)/cult/cult.l -cult.l.cpp-options := $(out_root)/cult/cult.l.cpp-options - -client := $(out_base)/client -server := $(out_base)/server -clean := $(out_base)/.clean - -# Convenience alias for default target. -# -$(out_base)/: $(client) $(server) - -# Build. -# - -$(client): $(client_cxx_obj) $(cult.l) -$(server): $(server_cxx_obj) $(cult.l) - -$(cxx_obj) $(cxx_od): $(cult.l.cpp-options) - -$(call include-dep,$(cxx_od)) - - -# Clean. -# -$(clean): $(client).o.clean \ - $(server).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) - - -# How to. -# -$(call include,$(bld_root)/cxx/o-e.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/cxx-d.make) - -# Dependencies. -# -$(call import,$(src_root)/cult/makefile) diff --git a/libcult/examples/os/net/ipv4/multicast/protocol.hxx b/libcult/examples/os/net/ipv4/multicast/protocol.hxx deleted file mode 100644 index a4057de..0000000 --- a/libcult/examples/os/net/ipv4/multicast/protocol.hxx +++ /dev/null @@ -1,20 +0,0 @@ -// file : examples/os/net/ipv4/multicast/protocol.hxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Boris Kolpackov -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef PROTOCOL_HXX -#define PROTOCOL_HXX - -#include - -Cult::UnsignedShort const payload_size = 256; -Cult::UnsignedLong const message_count = 100; - -struct Message -{ - Cult::UnsignedLong sn; - Cult::UnsignedShort payload[payload_size]; -}; - -#endif // PROTOCOL_HXX diff --git a/libcult/examples/os/net/ipv4/multicast/server.cxx b/libcult/examples/os/net/ipv4/multicast/server.cxx deleted file mode 100644 index 5d8fe99..0000000 --- a/libcult/examples/os/net/ipv4/multicast/server.cxx +++ /dev/null @@ -1,134 +0,0 @@ -// file : examples/os/net/ipv4/datagram/server.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Boris Kolpackov -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include -#include - -#include -#include - -#include -#include // memcmp - -#include "protocol.hxx" - -using std::cerr; -using std::endl; - -using namespace Cult; -using namespace OS::Net::IPv4; - -typedef Containers::Vector StatusList; - -class Args {}; - -Int -main (Int argc, Char* argv[]) -{ - try - { - if (argc < 2) - throw Args (); - - Address addr (argv[1], 10000); - - MulticastSocket socket; - - socket.join (addr); - - Message expected_msg; - expected_msg.sn = 0; - - for (UnsignedShort i = 0; i < payload_size; ++i) - { - expected_msg.payload[i] = i; - } - - StatusList received (message_count, 0); - StatusList damaged (message_count, 0); - StatusList duplicate (message_count, 0); - - Message msg; - - while (true) - { - socket.recv (&msg, sizeof (msg)); - - if (received[msg.sn]) - { - duplicate[msg.sn] = true; - } - else - { - received[msg.sn] = true; - - if (std::memcmp (expected_msg.payload, msg.payload, payload_size) != 0) - { - damaged[msg.sn] = true; - } - } - - if (msg.sn + 1 == message_count) break; - } - - UnsignedLong lost_count (0), damaged_count (0), duplicate_count (0); - - for (StatusList::Iterator i (received.begin ()), end (received.end ()); - i != end; - ++i) - if (!*i) ++lost_count; - - for (StatusList::Iterator i (damaged.begin ()), end (damaged.end ()); - i != end; - ++i) - if (*i) ++damaged_count; - - for (StatusList::Iterator i (duplicate.begin ()), end (duplicate.end ()); - i != end; - ++i) - if (*i) ++duplicate_count; - - cerr << "lost : " << lost_count << endl - << "damaged : " << damaged_count << endl - << "duplicate : " << duplicate_count << endl << endl; - - if (lost_count != 0) - { - cerr << "lost message dump:" << endl; - - UnsignedLong total = 0; - - for (StatusList::Iterator - begin (received.begin ()), i (begin), end (received.end ()); - i != end;) - { - if (!*i) - { - UnsignedLong count = 1; - - for (StatusList::Iterator j = i + 1; j < end && !*j; j++, count++) ; - - cerr << '\t' << i - begin << " : " << count << endl; - - i += count; - total += count; - } - else - ++i; - } - - if (total != lost_count) - cerr << "trouble" << endl; - } - } - catch (OS::Exception const& e) - { - cerr << "errno: " << e.code () << endl; - } - catch (Args const&) - { - cerr << "usage: client " << endl; - } -} diff --git a/libcult/examples/sched/cancel/cancel.cxx b/libcult/examples/sched/cancel/cancel.cxx deleted file mode 100644 index ee71449..0000000 --- a/libcult/examples/sched/cancel/cancel.cxx +++ /dev/null @@ -1,63 +0,0 @@ -// file : examples/sched/cancel/cancel.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Boris Kolpackov -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include - -#include -#include -#include -#include - - -#include -#include // sleep - -using std::cerr; -using std::endl; - -using namespace Cult; -using namespace Sched; - -Void* -cond_wait_thread_proc (Void*) -{ - try - { - Mutex mutex; - Condition cond (mutex); - - Lock lock (mutex); - - cond.wait (); - } - /* - catch (std::thread_canceled const& e) - { - cerr << "caught thread_canceled" << endl; - throw; - } - */ - catch (...) - { - cerr << "presumably caught thread_canceled" << endl; - throw; - } - - return 0; -} - - -Int -main () -{ - Shptr thread (new Thread (cond_wait_thread_proc)); - - sleep (1); - - thread->cancel (); - thread->join (); -} diff --git a/libcult/examples/sched/cancel/makefile b/libcult/examples/sched/cancel/makefile deleted file mode 100644 index 38a96bd..0000000 --- a/libcult/examples/sched/cancel/makefile +++ /dev/null @@ -1,48 +0,0 @@ -# file : examples/sched/cancel/makefile -# author : Boris Kolpackov -# copyright : Copyright (c) 2005-2010 Boris Kolpackov -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -cxx_tun := cancel.cxx -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -cult.l := $(out_root)/cult/cult.l -cult.l.cpp-options := $(out_root)/cult/cult.l.cpp-options - -cancel := $(out_base)/cancel -clean := $(out_base)/.clean - - -# Build. -# -$(cancel): $(cxx_obj) $(cult.l) - -$(cxx_obj) $(cxx_od): $(cult.l.cpp-options) - -$(call include-dep,$(cxx_od)) - - -# Convenience alias for default target. -# -$(out_base)/: $(cancel) - - -# clean -# -$(clean): $(cancel).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) - - -# How to. -# -$(call include,$(bld_root)/cxx/o-e.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/cxx-d.make) - -# Dependencies. -# -$(call import,$(src_root)/cult/makefile) diff --git a/libcult/examples/sched/main/main.cxx b/libcult/examples/sched/main/main.cxx deleted file mode 100644 index 58cc2cc..0000000 --- a/libcult/examples/sched/main/main.cxx +++ /dev/null @@ -1,43 +0,0 @@ -// file : examples/sched/main/main.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Boris Kolpackov -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include -#include - -#include -#include // sleep - -using namespace Cult; -using namespace Sched; - -using std::cerr; -using std::endl; - -Void* -thread_func (Void*) -{ - cerr << "second thread: going to sleep for a few seconds" << endl; - - sleep (2); - - cerr << "second thread: woke up, now exiting" << endl; - - return 0; -} - - -Int -main () -{ - Shptr self (new Thread); - - Shptr other (new Thread (thread_func)); - - cerr << "initial thread: exiting" << endl; - - Thread::exit (0); -} diff --git a/libcult/examples/sched/main/makefile b/libcult/examples/sched/main/makefile deleted file mode 100644 index 945237f..0000000 --- a/libcult/examples/sched/main/makefile +++ /dev/null @@ -1,48 +0,0 @@ -# file : examples/sched/main/makefile -# author : Boris Kolpackov -# copyright : Copyright (c) 2005-2010 Boris Kolpackov -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -cxx_tun := main.cxx -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -cult.l := $(out_root)/cult/cult.l -cult.l.cpp-options := $(out_root)/cult/cult.l.cpp-options - -main := $(out_base)/main -clean := $(out_base)/.clean - - -# Build. -# -$(main): $(cxx_obj) $(cult.l) - -$(cxx_obj) $(cxx_od): $(cult.l.cpp-options) - -$(call include-dep,$(cxx_od)) - - -# Convenience alias for default target. -# -$(out_base)/: $(main) - - -# Clean. -# -$(clean): $(main).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) - - -# How to. -# -$(call include,$(bld_root)/cxx/o-e.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/cxx-d.make) - -# Dependencies. -# -$(call import,$(src_root)/cult/makefile) diff --git a/libcult/examples/trace/makefile b/libcult/examples/trace/makefile deleted file mode 100644 index 57e2b7b..0000000 --- a/libcult/examples/trace/makefile +++ /dev/null @@ -1,48 +0,0 @@ -# file : examples/trace/makefile -# author : Boris Kolpackov -# copyright : Copyright (c) 2005-2010 Boris Kolpackov -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make - -cxx_tun := trace.cxx -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -cult.l := $(out_root)/cult/cult.l -cult.l.cpp-options := $(out_root)/cult/cult.l.cpp-options - -trace := $(out_base)/trace -clean := $(out_base)/.clean - - -# Build. -# -$(trace): $(cxx_obj) $(cult.l) - -$(cxx_obj) $(cxx_od): $(cult.l.cpp-options) - -$(call include-dep,$(cxx_od)) - - -# Convenience alias for default target. -# -$(out_base)/: $(trace) - - -# Clean. -# -$(clean): $(trace).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) - - -# How to. -# -$(call include,$(bld_root)/cxx/o-e.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/cxx-d.make) - -# Dependencies. -# -$(call import,$(src_root)/cult/makefile) diff --git a/libcult/examples/trace/trace.cxx b/libcult/examples/trace/trace.cxx deleted file mode 100644 index e2a09d4..0000000 --- a/libcult/examples/trace/trace.cxx +++ /dev/null @@ -1,51 +0,0 @@ -// file : examples/trace/trace.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Boris Kolpackov -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include -#include -#include - -#include - -using namespace Cult; - -struct Foo {}; - -std::ostream& -operator<< (std::ostream& o, Foo const&) -{ - return o << "::Foo"; -} - -Trace::Stream tout ("Examples::Trace", 4); - -Int -main () -{ - using Trace::Record; - - Trace::Log::instance ().level (9); - - Record a ("main", 2); - a << "notationally burdensome"; - tout << a; - - Record b ("main", 2); - tout << (b << "a bit better, but still burdensome"); - - tout << (Record ("main", 2) << "this is" - << " somewhat" - << " twisted but nice to be able to"); - - tout << "concise, using default level"; - - tout << 9 << "concise, using custom level"; - - Foo f; - - tout << 3 << f << " " << 5; -} -- cgit v1.2.3