summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-08-06 21:25:39 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-08-06 21:25:39 +0000
commitf65262f46b2cfdf205c636f633dffdf91589799d (patch)
tree9ece431f63aaff41a7de8767de33a5aa25806de6
parent14008681733a1d3999e660b0b5a8f706abaaabae (diff)
2009-08-06 Joel Sherrill <joel.sherrill@oarcorp.com>
* ChangeLog, Makefile, cxx_throw/MAIL, cxx_throw/Makefile, cxx_throw/init.cc, libcpp/Makefile, libcpp/README, libcpp/foo.cc, libcpp/foo.h, libcpp/foo1.cpp: New files.
-rw-r--r--cxx/ChangeLog6
-rw-r--r--cxx/Makefile12
-rw-r--r--cxx/cxx_throw/MAIL201
-rw-r--r--cxx/cxx_throw/Makefile44
-rw-r--r--cxx/cxx_throw/init.cc169
-rw-r--r--cxx/libcpp/Makefile74
-rw-r--r--cxx/libcpp/README1
-rw-r--r--cxx/libcpp/foo.cc8
-rw-r--r--cxx/libcpp/foo.h17
-rw-r--r--cxx/libcpp/foo1.cpp8
10 files changed, 540 insertions, 0 deletions
diff --git a/cxx/ChangeLog b/cxx/ChangeLog
new file mode 100644
index 0000000..1d36262
--- /dev/null
+++ b/cxx/ChangeLog
@@ -0,0 +1,6 @@
+2009-08-06 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * ChangeLog, Makefile, cxx_throw/MAIL, cxx_throw/Makefile,
+ cxx_throw/init.cc, libcpp/Makefile, libcpp/README, libcpp/foo.cc,
+ libcpp/foo.h, libcpp/foo1.cpp: New files.
+
diff --git a/cxx/Makefile b/cxx/Makefile
new file mode 100644
index 0000000..f373ac3
--- /dev/null
+++ b/cxx/Makefile
@@ -0,0 +1,12 @@
+#
+# $Id$
+#
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(RTEMS_ROOT)/make/directory.cfg
+
+# These tests require C++
+ifneq ($(CXX_FOR_TARGET),)
+ SUBDIRS= cxx_throw libcpp
+endif
diff --git a/cxx/cxx_throw/MAIL b/cxx/cxx_throw/MAIL
new file mode 100644
index 0000000..2741173
--- /dev/null
+++ b/cxx/cxx_throw/MAIL
@@ -0,0 +1,201 @@
+From rdasilva@connecttel.com Tue Mar 30 13:34:47 1999
+Date: Tue, 30 Mar 1999 12:37:43 -0600
+From: Rosimildo DaSilva <rdasilva@connecttel.com>
+To: joel@OARcorp.com
+Subject: Re: C++ exceptions AND RTEMS 4.0.0
+
+ [The following text is in the "iso-8859-1" character set]
+ [Your display is set for the "US-ASCII" character set]
+ [Some characters may be displayed incorrectly]
+
+From: joel@OARcorp.com <joel@OARcorp.com>
+To: Rosimildo DaSilva <rdasilva@connecttel.com>
+Date: Tuesday, March 30, 1999 7:43 AM
+Subject: Re: C++ exceptions AND RTEMS 4.0.0
+
+
+>
+>
+>Rosimildo, could you send me a test example of this built like 'hello
+>world"?
+>
+>I would like to see if I can duplicate it on another target. This would
+>eliminate some possible problems.
+>
+
+
+Joel,
+
+I have attached the main.cc form the examples ( tests\samples\cdtest ).
+I have added a little try block to the module, and the program terminates
+when the exception is raised.
+
+Rosimildo.
+
+
+/* cut
+here -----------------------------------------------------------------------
+---*/
+/*
+ * This routine is the initialization task for this test program.
+ * It is called from init_exec and has the responsibility for creating
+ * and starting the tasks that make up the test. If the time of day
+ * clock is required for the test, it should also be set to a known
+ * value by this function.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1994 by Division Incorporated
+ * Based in part on OAR works.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+// #define RTEMS_TEST_IO_STREAM
+
+#include <rtems.h>
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef RTEMS_TEST_IO_STREAM
+#include <iostream.h>
+#endif
+
+extern "C" {
+extern rtems_task main_task(rtems_task_argument);
+}
+
+static int num_inst = 0;
+
+class A {
+public:
+ A(void)
+ {
+ num_inst++;
+ printf(
+ "Hey I'm in base class constructor number %d for %p.\n",
+ num_inst,
+ this
+ );
+
+ /*
+ * Make sure we use some space
+ */
+
+ string = new char[50];
+ sprintf(string, "Instantiation order %d", num_inst);
+ };
+
+ virtual ~A()
+ {
+ printf(
+ "Hey I'm in base class destructor number %d for %p.\n",
+ num_inst,
+ this
+ );
+ print();
+ num_inst--;
+ };
+
+ virtual void print() { printf("%s\n", string); };
+
+protected:
+ char *string;
+};
+
+class B : public A {
+public:
+ B(void)
+ {
+ num_inst++;
+ printf(
+ "Hey I'm in derived class constructor number %d for %p.\n",
+ num_inst,
+ this
+ );
+
+ /*
+ * Make sure we use some space
+ */
+
+ string = new char[50];
+ sprintf(string, "Instantiation order %d", num_inst);
+ };
+
+ ~B()
+ {
+ printf(
+ "Hey I'm in derived class destructor number %d for %p.\n",
+ num_inst,
+ this
+ );
+ print();
+ num_inst--;
+ };
+
+ void print() { printf("Derived class - %s\n", string); }
+};
+
+
+A foo;
+B foobar;
+
+void
+cdtest(void)
+{
+ A bar, blech, blah;
+ B bleak;
+
+#ifdef RTEMS_TEST_IO_STREAM
+ cout << "Testing a C++ I/O stream" << endl;
+#else
+ printf("IO Stream not tested\n");
+#endif
+
+ bar = blech;
+
+ printf( "before try block\n" );
+ try
+ {
+ throw "Raising this";
+ }
+ catch( char *e)
+ {
+ printf( "Got it: %s\n", e );
+ }
+ printf( "catch got called, exception handling worked !!!\n" );
+}
+
+//
+// main equivalent
+// It can not be called 'main' since the bsp owns that name
+// in many implementations in order to get global constructors
+// run.
+//
+
+
+rtems_task main_task(
+ rtems_task_argument
+)
+{
+ printf( "\n\n*** CONSTRUCTOR/DESTRUCTOR TEST ***\n" );
+
+ cdtest();
+
+ printf( "*** END OF CONSTRUCTOR/DESTRUCTOR TEST ***\n\n\n" );
+
+ exit(0);
+}
+
+/*
+end ------------------------------------------------------------------------
+--*/
+
+
+
+
diff --git a/cxx/cxx_throw/Makefile b/cxx/cxx_throw/Makefile
new file mode 100644
index 0000000..24e5979
--- /dev/null
+++ b/cxx/cxx_throw/Makefile
@@ -0,0 +1,44 @@
+#
+# Makefile
+#
+
+#
+# RTEMS_MAKEFILE_PATH is typically set in an environment variable
+#
+
+EXEC=cxx_throw.exe
+PGM=${ARCH}/$(EXEC)
+
+# optional managers required
+MANAGERS=all
+
+# C source names
+CSRCS =
+COBJS_ = $(CSRCS:.c=.o)
+COBJS = $(COBJS_:%=${ARCH}/%)
+
+# C++ source names
+CXXSRCS = init.cc
+CXXOBJS_ = $(CXXSRCS:.cc=.o)
+CXXOBJS = $(CXXOBJS_:%=${ARCH}/%)
+
+# AS source names
+ASSRCS =
+ASOBJS_ = $(ASSRCS:.s=.o)
+ASOBJS = $(ASOBJS_:%=${ARCH}/%)
+
+# Libraries
+LIBS =
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+
+OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS)
+
+all: ${ARCH} $(PGM)
+
+$(PGM): $(OBJS)
+ $(make-cxx-exe)
+
diff --git a/cxx/cxx_throw/init.cc b/cxx/cxx_throw/init.cc
new file mode 100644
index 0000000..562e3f5
--- /dev/null
+++ b/cxx/cxx_throw/init.cc
@@ -0,0 +1,169 @@
+/*
+ * This routine is the initialization task for this test program.
+ * It is called from init_exec and has the responsibility for creating
+ * and starting the tasks that make up the test. If the time of day
+ * clock is required for the test, it should also be set to a known
+ * value by this function.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1994 by Division Incorporated
+ * Based in part on OAR works.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#define RTEMS_TEST_IO_STREAM
+
+#include <rtems.h>
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef RTEMS_TEST_IO_STREAM
+#include <iostream.h>
+#endif
+
+extern "C" {
+extern rtems_task main_task(rtems_task_argument);
+}
+
+static int num_inst = 0;
+
+class A {
+public:
+ A(void)
+ {
+ num_inst++;
+ printf(
+ "Hey I'm in base class constructor number %d for %p.\n",
+ num_inst,
+ this
+ );
+
+ /*
+ * Make sure we use some space
+ */
+
+ string = new char[50];
+ sprintf(string, "Instantiation order %d", num_inst);
+ };
+
+ virtual ~A()
+ {
+ printf(
+ "Hey I'm in base class destructor number %d for %p.\n",
+ num_inst,
+ this
+ );
+ print();
+ num_inst--;
+ };
+
+ virtual void print() { printf("%s\n", string); };
+
+protected:
+ char *string;
+};
+
+class B : public A {
+public:
+ B(void)
+ {
+ num_inst++;
+ printf(
+ "Hey I'm in derived class constructor number %d for %p.\n",
+ num_inst,
+ this
+ );
+
+ /*
+ * Make sure we use some space
+ */
+
+ string = new char[50];
+ sprintf(string, "Instantiation order %d", num_inst);
+ };
+
+ ~B()
+ {
+ printf(
+ "Hey I'm in derived class destructor number %d for %p.\n",
+ num_inst,
+ this
+ );
+ print();
+ num_inst--;
+ };
+
+ void print() { printf("Derived class - %s\n", string); }
+};
+
+
+A foo;
+B foobar;
+
+void
+cdtest(void)
+{
+ A bar, blech, blah;
+ B bleak;
+
+#ifdef RTEMS_TEST_IO_STREAM
+ cout << "Testing a C++ I/O stream" << endl;
+#else
+ printf("IO Stream not tested\n");
+#endif
+
+ bar = blech;
+
+ printf( "before try block\n" );
+ try
+ {
+ throw "Raising this";
+ }
+ catch( const char *e )
+ {
+ printf( "Got it: %s\n", e );
+ }
+ printf( "catch got called, exception handling worked !!!\n" );
+}
+
+//
+// main equivalent
+// It can not be called 'main' since the bsp owns that name
+// in many implementations in order to get global constructors
+// run.
+//
+
+
+rtems_task Init(
+ rtems_task_argument
+)
+{
+ printf( "\n\n*** CONSTRUCTOR/DESTRUCTOR TEST ***\n" );
+
+ cdtest();
+
+ printf( "*** END OF CONSTRUCTOR/DESTRUCTOR TEST ***\n\n\n" );
+
+ exit(0);
+}
+
+/* configuration information */
+
+#include <bsp.h>
+
+#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
diff --git a/cxx/libcpp/Makefile b/cxx/libcpp/Makefile
new file mode 100644
index 0000000..a3f9408
--- /dev/null
+++ b/cxx/libcpp/Makefile
@@ -0,0 +1,74 @@
+#
+# $Id$
+#
+# Templates/Makefile.lib
+# adapted for an external library
+#
+
+LIBNAME=libfoo.a # xxx- your library names goes here
+LIB=${ARCH}/${LIBNAME}
+
+# C and C++ source names, if any, go here -- minus the .c or .cc
+C_PIECES=
+C_FILES=$(C_PIECES:%=%.c)
+C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
+
+CC_PIECES=foo
+CC_FILES=$(CC_PIECES:%=%.cc)
+CC_O_FILES=$(CC_PIECES:%=${ARCH}/%.o)
+
+CPP_PIECES=foo1
+CPP_FILES=$(CPP_PIECES:%=%.cpp)
+CPP_O_FILES=$(CPP_PIECES:%=${ARCH}/%.o)
+
+H_FILES=foo.h
+
+# Assembly source names, if any, go here -- minus the .s
+S_PIECES=
+S_FILES=$(S_PIECES:%=%.s)
+S_O_FILES=$(S_FILES:%.s=${ARCH}/%.o)
+
+SRCS=$(C_FILES) $(CC_FILES) $(CPP_FILES) $(H_FILES) $(S_FILES)
+OBJS=$(C_O_FILES) $(CC_O_FILES) $(CPP_O_FILES) $(S_O_FILES)
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/lib.cfg
+
+#
+# Extra rules for other variations on C++ file name extensions
+#
+
+COMPILE.cpp=$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c
+
+${ARCH}/%.o: %.cpp
+ ${COMPILE.cc} -o $@ $<
+
+#
+# Add local stuff here using +=
+#
+
+DEFINES +=
+CPPFLAGS +=
+CFLAGS +=
+
+#
+# Add your list of files to delete here. The config files
+# already know how to delete some stuff, so you may want
+# to just run 'make clean' first to see what gets missed.
+# 'make clobber' already includes 'make clean'
+#
+
+CLEAN_ADDITIONS +=
+CLOBBER_ADDITIONS +=
+
+all: ${ARCH} $(SRCS) $(LIB)
+
+$(LIB): ${OBJS}
+ $(make-library)
+
+# Install the library, appending _g or _p as appropriate.
+# for include files, just use $(INSTALL)
+install: all
+ # $(INSTALL_VARIANT) -m 644 ${LIB} ${PROJECT_RELEASE}/lib
diff --git a/cxx/libcpp/README b/cxx/libcpp/README
new file mode 100644
index 0000000..1a172ad
--- /dev/null
+++ b/cxx/libcpp/README
@@ -0,0 +1 @@
+Example C++ library submitted by Ralf Corsepius <corsepiu@faw.uni-ulm.de>.
diff --git a/cxx/libcpp/foo.cc b/cxx/libcpp/foo.cc
new file mode 100644
index 0000000..b0da6d0
--- /dev/null
+++ b/cxx/libcpp/foo.cc
@@ -0,0 +1,8 @@
+
+#include "foo.h"
+
+ostream& operator << ( ostream & strm, const foo &f)
+{
+ strm << f.i ;
+ return strm ;
+}
diff --git a/cxx/libcpp/foo.h b/cxx/libcpp/foo.h
new file mode 100644
index 0000000..ba27d39
--- /dev/null
+++ b/cxx/libcpp/foo.h
@@ -0,0 +1,17 @@
+#ifndef _foo_h
+#define _foo_h
+
+#include <iostream>
+
+class foo {
+public :
+ int i ;
+
+ foo() : i(0) {} ;
+ foo( const int i0 ) : i(i0) {};
+
+ friend ostream& operator << (ostream&,const foo&);
+ friend ostream& operator << (ostream&,const foo&, const foo&);
+};
+
+#endif
diff --git a/cxx/libcpp/foo1.cpp b/cxx/libcpp/foo1.cpp
new file mode 100644
index 0000000..f77751f
--- /dev/null
+++ b/cxx/libcpp/foo1.cpp
@@ -0,0 +1,8 @@
+
+#include "foo.h"
+
+ostream& operator << ( ostream & strm, const foo &f, const foo &f1 )
+{
+ strm << f.i ;
+ return strm ;
+}