diff options
author | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-12-30 06:50:29 +0000 |
---|---|---|
committer | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-12-30 06:50:29 +0000 |
commit | a4a7690c336d4c8a16b3041c86d501ba38226e96 (patch) | |
tree | 9e9f93a98edd2591453f092d178ad29a1c5fb519 /examples/Mem_Map | |
parent | a5c4d8047ab58df5c45092e18ae503ad40518f0e (diff) | |
download | ATCD-unlabeled-4.1.2.tar.gz |
This commit was manufactured by cvs2svn to create branchunlabeled-4.1.2
'unlabeled-4.1.2'.
Diffstat (limited to 'examples/Mem_Map')
-rw-r--r-- | examples/Mem_Map/IO-tests/IO_Test.cpp | 186 | ||||
-rw-r--r-- | examples/Mem_Map/IO-tests/IO_Test.h | 71 | ||||
-rw-r--r-- | examples/Mem_Map/IO-tests/Makefile | 63 | ||||
-rw-r--r-- | examples/Mem_Map/IO-tests/test_io.cpp | 156 | ||||
-rw-r--r-- | examples/Mem_Map/Makefile | 22 | ||||
-rw-r--r-- | examples/Mem_Map/file-reverse/Makefile | 59 | ||||
-rw-r--r-- | examples/Mem_Map/file-reverse/file-reverse.cpp | 45 |
7 files changed, 0 insertions, 602 deletions
diff --git a/examples/Mem_Map/IO-tests/IO_Test.cpp b/examples/Mem_Map/IO-tests/IO_Test.cpp deleted file mode 100644 index bed887dc2b1..00000000000 --- a/examples/Mem_Map/IO-tests/IO_Test.cpp +++ /dev/null @@ -1,186 +0,0 @@ -#include "ace/OS.h" -// $Id$ - -#include "ace/Mem_Map.h" -#include "IO_Test.h" - -IO_Test::IO_Test (const char *name, ACE_Profile_Timer &tm) - : name_ (name), tm_ (tm) -{ -} - -const char * -IO_Test::name (void) -{ - return this->name_; -} - -Slow_Read_Write_Test::Slow_Read_Write_Test (char *name, ACE_Profile_Timer &tm) - : IO_Test (name, tm) -{ -} - -int -Slow_Read_Write_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp) -{ - int ifd = fileno (input_fp); - int ofd = fileno (output_fp); - - this->tm_.start (); - - while (--iterations >= 0) - { - char c; - - while (ACE_OS::read (ifd, &c, sizeof c) > 0) - ::write (ofd, &c, sizeof c); - - ACE_OS::lseek (ifd, 0, SEEK_SET); - ACE_OS::lseek (ofd, 0, SEEK_SET); - } - - this->tm_.stop (); - return 0; -} - -Stdio_Test::Stdio_Test (char *name, ACE_Profile_Timer &tm) - : IO_Test (name, tm) -{ -} - -int -Stdio_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp) -{ - this->tm_.start (); - - while (--iterations >= 0) - { - int c; - - while ((c = getc (input_fp)) != EOF) - putc (c, output_fp); - - ACE_OS::rewind (input_fp); - ACE_OS::rewind (output_fp); - } - this->tm_.stop (); - return 0; -} - -Block_Read_Write_Test::Block_Read_Write_Test (char *name, ACE_Profile_Timer &tm) - : IO_Test (name, tm) -{ -} - -int -Block_Read_Write_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp) -{ - int ifd = fileno (input_fp); - int ofd = fileno (output_fp); - - this->tm_.start (); - - while (--iterations >= 0) - { - char buf[BUFSIZ]; - int n; - - while ((n = ACE_OS::read (ifd, buf, sizeof buf)) > 0) - ::write (ofd, buf, n); - - ACE_OS::lseek (ifd, 0, SEEK_SET); - ACE_OS::lseek (ofd, 0, SEEK_SET); - } - - this->tm_.stop (); - return 0; -} - -Block_Fread_Fwrite_Test::Block_Fread_Fwrite_Test (char *name, ACE_Profile_Timer &tm) - : IO_Test (name, tm) -{ -} - -int -Block_Fread_Fwrite_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp) -{ - this->tm_.start (); - - while (--iterations >= 0) - { - char buf[BUFSIZ]; - int n; - - while ((n = ACE_OS::fread (buf, 1, sizeof buf, input_fp)) != 0) - ::fwrite (buf, n, 1, output_fp); - - ACE_OS::rewind (input_fp); - ACE_OS::rewind (output_fp); - } - - this->tm_.stop (); - return 0; -} - -Mmap1_Test::Mmap1_Test (char *name, ACE_Profile_Timer &tm) - : IO_Test (name, tm) -{ -} - -int -Mmap1_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp) -{ - ACE_Mem_Map map_input (fileno (input_fp)); - void *src = 0; - - if (map_input (src) == -1) - return -1; - else - { - this->tm_.start (); - - while (--iterations >= 0) - if (ACE_OS::write (fileno (output_fp), src, map_input.size ()) == -1) - return -1; - - this->tm_.stop (); - } - - if (map_input.unmap () == -1) - return -1; - else - return 0; -} - -Mmap2_Test::Mmap2_Test (char *name, ACE_Profile_Timer &tm) - : IO_Test (name, tm) -{ -} - -int -Mmap2_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp) -{ - ACE_Mem_Map map_input (fileno (input_fp)); - int size = map_input.size (); - ACE_Mem_Map map_output (fileno (output_fp), size, PROT_WRITE, MAP_SHARED); - void *src = 0; - void *dst = 0; - - if (map_input (src) == -1 || map_output (dst) == -1) - return -1; - else - { - this->tm_.start (); - - while (--iterations >= 0) - ACE_OS::memcpy (dst, src, size); - - this->tm_.stop (); - } - - if (map_input.unmap () == -1 - || map_output.unmap () == -1) - return -1; - else - return 0; -} diff --git a/examples/Mem_Map/IO-tests/IO_Test.h b/examples/Mem_Map/IO-tests/IO_Test.h deleted file mode 100644 index 659a85eec15..00000000000 --- a/examples/Mem_Map/IO-tests/IO_Test.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -/* Class hierarchy for the File I/O tests. */ - -#include "ace/Profile_Timer.h" - -/* Base class for all the File I/O tests. */ - -class IO_Test -{ -public: - // Initialize the test name - IO_Test (const char *name, ACE_Profile_Timer &tm); - - // Return the name of the test - const char *name (void); - - // Execute the IO test (note this is a pure virtual function...) - virtual int run_test (int iterations, FILE *input_fp, FILE *output_fp) = 0; - -protected: - // Name of the test - const char *name_; - - // Reference to a timer - ACE_Profile_Timer &tm_; -}; - -class Slow_Read_Write_Test : public IO_Test -{ -public: - Slow_Read_Write_Test (char *name, ACE_Profile_Timer &tm); - virtual int run_test (int iterations, FILE *input_fp, FILE *output_fp); -}; - -class Stdio_Test : public IO_Test -{ -public: - Stdio_Test (char *name, ACE_Profile_Timer &tm); - virtual int run_test (int iterations, FILE *input_fp, FILE *output_fp); -}; - -class Block_Read_Write_Test : public IO_Test -{ -public: - Block_Read_Write_Test (char *name, ACE_Profile_Timer &tm); - virtual int run_test (int iterations, FILE *input_fp, FILE *output_fp); -}; - -class Block_Fread_Fwrite_Test : public IO_Test -{ -public: - Block_Fread_Fwrite_Test (char *name, ACE_Profile_Timer &tm); - virtual int run_test (int iterations, FILE *input_fp, FILE *output_fp); -}; - -class Mmap1_Test : public IO_Test -{ -public: - Mmap1_Test (char *name, ACE_Profile_Timer &tm); - virtual int run_test (int iterations, FILE *input_fp, FILE *output_fp); -}; - -class Mmap2_Test : public IO_Test -{ -public: - Mmap2_Test (char *name, ACE_Profile_Timer &tm); - virtual int run_test (int iterations, FILE *input_fp, FILE *output_fp); -}; - diff --git a/examples/Mem_Map/IO-tests/Makefile b/examples/Mem_Map/IO-tests/Makefile deleted file mode 100644 index f0e55da262c..00000000000 --- a/examples/Mem_Map/IO-tests/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -#---------------------------------------------------------------------------- -# @(#)Makefile 1.1 10/18/96 -# -# Makefile for Mem_Map IO tests -#---------------------------------------------------------------------------- - -#---------------------------------------------------------------------------- -# Local macros -#---------------------------------------------------------------------------- - -BIN = test_io - -FILES = IO_Test - -LSRC = $(addsuffix .cpp,$(FILES)) -LOBJ = $(addsuffix .o,$(FILES)) -SHOBJ = $(addsuffix .so,$(FILES)) - -LDLIBS = $(addprefix .shobj/,$(SHOBJ)) - -VLDLIBS = $(LDLIBS:%=%$(VAR)) - -BUILD = $(VBIN) - -#---------------------------------------------------------------------------- -# Include macros and targets -#---------------------------------------------------------------------------- - -include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU -include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU - -#---------------------------------------------------------------------------- -# Local targets -#---------------------------------------------------------------------------- - -#---------------------------------------------------------------------------- -# Dependencies -#---------------------------------------------------------------------------- - -# DO NOT DELETE THIS LINE -- g++dep uses it. -# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. - -.obj/IO_Test.o .shobj/IO_Test.so: IO_Test.cpp \ - $(WRAPPER_ROOT)/ace/OS.h \ - $(WRAPPER_ROOT)/ace/Time_Value.h \ - $(WRAPPER_ROOT)/ace/config.h \ - $(WRAPPER_ROOT)/ace/stdcpp.h \ - $(WRAPPER_ROOT)/ace/Trace.h \ - $(WRAPPER_ROOT)/ace/Log_Msg.h \ - $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ - $(WRAPPER_ROOT)/ace/ACE.h \ - $(WRAPPER_ROOT)/ace/ACE.i \ - $(WRAPPER_ROOT)/ace/Log_Record.i \ - $(WRAPPER_ROOT)/ace/Mem_Map.h IO_Test.h \ - $(WRAPPER_ROOT)/ace/Profile_Timer.h - -# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Mem_Map/IO-tests/test_io.cpp b/examples/Mem_Map/IO-tests/test_io.cpp deleted file mode 100644 index e209534929e..00000000000 --- a/examples/Mem_Map/IO-tests/test_io.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// $Id$ - -// Test program for different methods of copying files. - -#include "ace/OS.h" -#include "ace/Profile_Timer.h" -#include "ace/Get_Opt.h" -#include "ace/Signal.h" -#include "IO_Test.h" - -// Name of program. -static char *program_name; - -// Name of default input file. -static char *input_filename = "/usr/dict/words"; - -// Name of default output file. -static char *output_filename = "/tmp/foo"; - -// Check if removing output file upon completion... -static int remove_output = 1; - -// Count of the number of iterations to run the tests. -static int iteration_count = 100; - -// Profiler used to keep track of file I/O time. -static ACE_Profile_Timer tm; - -// Explain usage and exit. - -static void -print_usage_and_die (void) -{ - cerr << "usage: " - << program_name - << " [-i input_file] [-o output_file] [-n iteration_count] [-r]\n"; - ACE_OS::exit (1); -} - -// Clean up the output file on exit from a signal. - -extern "C" void -cleanup (int = 0) -{ - if (remove_output) - ACE_OS::unlink (output_filename); - ACE_OS::exit (0); -} - -// Set up the program name used in error messages. - -static void -set_program_name (char name[]) -{ - if ((name = strrchr (name, '/')) == 0) - program_name = name; - else - program_name = name + 1; -} - -// Parse the command-line arguments and set options. - -static void -parse_args (int argc, char *argv[]) -{ - ACE_Get_Opt get_opt (argc, argv, "i:n:o:r"); - - for (int c; ((c = get_opt ()) != -1); ) - switch (c) - { - case 'i': - input_filename = get_opt.optarg; - break; - case 'n': - iteration_count = ACE_OS::atoi (get_opt.optarg); - break; - case 'o': - output_filename = get_opt.optarg; - break; - case 'r': - remove_output = 0; - break; - default: - print_usage_and_die (); - break; - } -} - -// Vector of pointers to derived classes that inherit from IO_Test base class. - -static IO_Test *test_vector[100]; - -static void -run_tests (int iterations, FILE *input_fp, FILE *output_fp) -{ - // If HP/UX didn't suck so badly we could initialize in the global scope... - test_vector[0] = new Stdio_Test ("Stdio_Test", tm); - test_vector[1] = new Block_Fread_Fwrite_Test ("Block_Fread_Fwrite_Test", tm); - test_vector[2] = new Block_Read_Write_Test ("Block_Read_Write_Test", tm); - test_vector[3] = new Mmap1_Test ("Mmap1_Test", tm); - test_vector[4] = new Mmap2_Test ("Mmap2_Test", tm); - // test_vector[5] = new Slow_Read_Write_Test ("Slow"Read_Write_Test", tm) - test_vector[5] = (IO_Test *) 0; - - for (int i = 0; test_vector[i] != 0; i++) - { - if (ACE_OS::ftruncate (fileno (output_fp), 0) == -1) - ::perror ("ftruncate"); - - cerr << "--------------------\n" - << "starting " << test_vector[i]->name () << " for " << iterations - << " iteration(s):\n"; - - if (test_vector[i]->run_test (iterations, input_fp, output_fp) == -1) - ::perror (test_vector[i]->name ()); - - ACE_Profile_Timer::ACE_Elapsed_Time et; - tm.elapsed_time (et); - - cerr << "wallclock time = " << et.real_time - << ", user time = " << et.user_time - << ", system time = " << et.system_time << endl; - - delete test_vector[i]; - } - - cerr << "--------------------\n"; -} - -int -main (int argc, char *argv[]) -{ - FILE *input_fp; - FILE *output_fp; - - set_program_name (argv[0]); - parse_args (argc, argv); - - ACE_Sig_Action sa ((ACE_SignalHandler) cleanup, SIGINT); - - if ((input_fp = ACE_OS::fopen (input_filename, "r")) == 0) - ACE_OS::perror (input_filename), ACE_OS::exit (1); - - ACE_OS::unlink (output_filename); - - if ((output_fp = ACE_OS::fopen (output_filename, "w+")) == 0) - ACE_OS::perror (output_filename), ACE_OS::exit (1); - - run_tests (iteration_count, input_fp, output_fp); - - if (ACE_OS::fclose (input_fp) == -1 || ACE_OS::fclose (output_fp) == -1) - ACE_OS::perror ("fclose"), ACE_OS::exit (1); - - cleanup (); - return 0; -} diff --git a/examples/Mem_Map/Makefile b/examples/Mem_Map/Makefile deleted file mode 100644 index 3c5d5f2d800..00000000000 --- a/examples/Mem_Map/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -#---------------------------------------------------------------------------- -# @(#)Makefile 1.1 10/18/96 -# -# Makefile for the Mem_Map test directory -#---------------------------------------------------------------------------- - -#---------------------------------------------------------------------------- -# Local macros -#---------------------------------------------------------------------------- - -DIRS = IO-tests \ - file-reverse - -#---------------------------------------------------------------------------- -# macros and targets -#---------------------------------------------------------------------------- - -include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU -include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.nested.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.nolocal.GNU diff --git a/examples/Mem_Map/file-reverse/Makefile b/examples/Mem_Map/file-reverse/Makefile deleted file mode 100644 index 4056d367f39..00000000000 --- a/examples/Mem_Map/file-reverse/Makefile +++ /dev/null @@ -1,59 +0,0 @@ -#---------------------------------------------------------------------------- -# @(#)Makefile 1.1 10/18/96 -# -# Makefile for Mem_Map file reverse test -#---------------------------------------------------------------------------- - -#---------------------------------------------------------------------------- -# Local macros -#---------------------------------------------------------------------------- - -BIN = file-reverse - -LSRC = $(addsuffix .cpp,$(BIN)) - -LDLIBS = - -VLDLIBS = $(LDLIBS:%=%$(VAR)) - -BUILD = $(VBIN) - -INSTALL = - -#---------------------------------------------------------------------------- -# Include macros and targets -#---------------------------------------------------------------------------- - -include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU -include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU - -#---------------------------------------------------------------------------- -# Local targets -#---------------------------------------------------------------------------- - -#---------------------------------------------------------------------------- -# Dependencies -#---------------------------------------------------------------------------- - -# DO NOT DELETE THIS LINE -- g++dep uses it. -# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. - -.obj/file-reverse.o .shobj/file-reverse.so: file-reverse.cpp \ - $(WRAPPER_ROOT)/ace/Mem_Map.h \ - $(WRAPPER_ROOT)/ace/ACE.h \ - $(WRAPPER_ROOT)/ace/OS.h \ - $(WRAPPER_ROOT)/ace/Time_Value.h \ - $(WRAPPER_ROOT)/ace/config.h \ - $(WRAPPER_ROOT)/ace/stdcpp.h \ - $(WRAPPER_ROOT)/ace/Trace.h \ - $(WRAPPER_ROOT)/ace/Log_Msg.h \ - $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ - $(WRAPPER_ROOT)/ace/Log_Record.i \ - $(WRAPPER_ROOT)/ace/ACE.i - -# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Mem_Map/file-reverse/file-reverse.cpp b/examples/Mem_Map/file-reverse/file-reverse.cpp deleted file mode 100644 index 0e357ded29f..00000000000 --- a/examples/Mem_Map/file-reverse/file-reverse.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -// $Id$ - -#include "ace/Mem_Map.h" - -static void -putline (const char *s) -{ - while (putchar (*s++) != '\n') - continue; -} - -static void -print_array_in_reverse (char *array, int size) -{ - size--; - - if (array[size] == '\0') - array[size] = '\n'; - - while (--size >= 0) - if (array[size] == '\n') - putline (array + size + 1); - - putline (array); -} - -int -main (int argc, char **argv) -{ - ACE_LOG_MSG->open (argv[0]); - void *cp; - - if (argc != 2) - ACE_ERROR_RETURN ((LM_ERROR, "usage: %n file\n%a"), -1); - - ACE_Mem_Map mmap; - - if (mmap.map (argv[1]) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%n: %p\n%a", "mmap"), -1); - - print_array_in_reverse ((char *) mmap.addr (), mmap.size ()); - - return 0; -} |