summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/examples/Makefile3
-rw-r--r--apps/examples/README.txt36
-rw-r--r--[-rwxr-xr-x]apps/examples/helloxx/Makefile14
-rw-r--r--[-rwxr-xr-x]apps/examples/helloxx/main.cxx25
-rw-r--r--nuttx/TODO19
-rwxr-xr-xnuttx/libxx/libxx_new.cxx14
-rwxr-xr-xnuttx/libxx/libxx_newa.cxx16
7 files changed, 102 insertions, 25 deletions
diff --git a/apps/examples/Makefile b/apps/examples/Makefile
index e0af2bfc7..11925f91f 100644
--- a/apps/examples/Makefile
+++ b/apps/examples/Makefile
@@ -46,6 +46,9 @@ SUBDIRS = buttons dhcpd ftpc hello helloxx hidkbd igmp lcdrw mm mount \
CNTXTDIRS =
+ifeq ($(CONFIG_EXAMPLES_HELLOXX_BUILTIN),y)
+CNTXTDIRS += helloxx
+endif
ifeq ($(CONFIG_EXAMPLES_LCDRW_BUILTIN),y)
CNTXTDIRS += lcdrw
endif
diff --git a/apps/examples/README.txt b/apps/examples/README.txt
index d7da89152..0e7ad7b5c 100644
--- a/apps/examples/README.txt
+++ b/apps/examples/README.txt
@@ -131,24 +131,42 @@ examples/hello
^^^^^^^^^^^^^^
This is the mandatory, "Hello, World!!" example. It is little more
- than examples/null with a single printf statement. Again useful only
+ than examples/null with a single printf statement. Really useful only
for bringing up new NuttX architectures.
- NuttX configuration settings:
-
- CONFIG_EXAMPLE_HELLOXX_NOSTATICCONST - Set if system does not support
- static constructors.
- CONFIG_EXAMPLE_HELLOXX_NOSTACKCONST - Set if the systgem does not
- support constructionof objects on the stack.
-
examples/helloxx
^^^^^^^^^^^^^^^^
This is C++ version of the "Hello, World!!" example. It is intended
- only to verify that the C++ compiler is function, that basic C++
+ only to verify that the C++ compiler is functional, that basic C++
library suupport is available, and that class are instantiated
correctly.
+ NuttX configuration settings:
+
+ CONFIG_EXAMPLES_HELLOXX_BUILTIN -- Build the helloxx example as a
+ "built-in" that can be executed from the NSH command line.
+ CONFIG_EXAMPLE_HELLOXX_NOSTATICCONST - Set if system does not support
+ static constructors.
+ CONFIG_EXAMPLE_HELLOXX_NOSTACKCONST - Set if the system does not
+ support construction of objects on the stack.
+
+ Also needed:
+
+ CONFIG_HAVE_CXX=y
+
+ And you may have to tinker with the following to get libxx to compile
+ properly:
+
+ CONFIG_CXX_NEWLONG=y or =n
+
+ The argument of the 'new' operators should take a type of size_t. But size_t
+ has an unknown underlying. In the nuttx sys/types.h header file, size_t
+ is typed as uint32_t (which is determined by architecture-specific logic).
+ But the C++ compiler may believe that size_t is of a different type resulting
+ in compilation errors in the operator. Using the underlying integer type
+ Instead of size_t seems to resolve the compilation issues.
+
examples/hidkbd
^^^^^^^^^^^^^^^^
diff --git a/apps/examples/helloxx/Makefile b/apps/examples/helloxx/Makefile
index eeeae9ef0..5bc17014b 100755..100644
--- a/apps/examples/helloxx/Makefile
+++ b/apps/examples/helloxx/Makefile
@@ -58,6 +58,12 @@ endif
ROOTDEPPATH = --dep-path .
+# helloxx built-in application info
+
+APPNAME = helloxx
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
# Common build
VPATH =
@@ -92,7 +98,13 @@ $(CXXOBJS): %$(OBJEXT): %.cxx
done ; )
@touch .built
-context:
+.context:
+ifeq ($(CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+ @touch $@
+endif
+
+context: .context
.depend: Makefile $(SRCS)
@$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
diff --git a/apps/examples/helloxx/main.cxx b/apps/examples/helloxx/main.cxx
index 9470edf14..f6ec138e8 100755..100644
--- a/apps/examples/helloxx/main.cxx
+++ b/apps/examples/helloxx/main.cxx
@@ -60,12 +60,12 @@ class CHelloWorld
{
if (mSecret != 42)
{
- printf("CONSTRUCTION FAILED!\n");
+ printf("CHelloWorld::HelloWorld: CONSTRUCTION FAILED!\n");
return false;
}
else
{
- printf("Hello, World!!\n");
+ printf("CHelloWorld::HelloWorld: Hello, World!!\n");
return true;
}
};
@@ -90,23 +90,36 @@ static CHelloWorld g_HelloWorld;
// user_start
//***************************************************************************
-int user_start(int argc, char *argv[])
+/****************************************************************************
+ * Name: user_start/nxhello_main
+ ****************************************************************************/
+
+#ifdef CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN
+extern "C" int helloxx_main(int argc, char *argv[]);
+# define MAIN_NAME helloxx_main
+# define MAIN_STRING "helloxx_main: "
+#else
+# define MAIN_NAME user_start
+# define MAIN_STRING "user_start: "
+#endif
+
+int MAIN_NAME(int argc, char *argv[])
{
#ifndef CONFIG_EXAMPLE_HELLOXX_NOSTACKCONST
CHelloWorld HelloWorld;
#endif
CHelloWorld *pHelloWorld = new CHelloWorld;
- printf("Saying hello from the dynamically constructed instance\n");
+ printf(MAIN_STRING "Saying hello from the dynamically constructed instance\n");
pHelloWorld->HelloWorld();
#ifndef CONFIG_EXAMPLE_HELLOXX_NOSTACKCONST
- printf("Saying hello from the statically constructed instance\n");
+ printf(MAIN_STRING "Saying hello from the statically constructed instance\n");
HelloWorld.HelloWorld();
#endif
#ifndef CONFIG_EXAMPLE_HELLOXX_NOSTATICCONST
- printf("Saying hello from the statically constructed instance\n");
+ printf(MAIN_STRING "Saying hello from the statically constructed instance\n");
g_HelloWorld.HelloWorld();
#endif
diff --git a/nuttx/TODO b/nuttx/TODO
index 028dca512..256f67689 100644
--- a/nuttx/TODO
+++ b/nuttx/TODO
@@ -1,4 +1,4 @@
-NuttX TODO List (Last updated September 28, 2011)
+NuttX TODO List (Last updated October 3, 2011)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This file summarizes known NuttX bugs, limitations, inconsistencies with
@@ -11,7 +11,7 @@ nuttx/
(1) Memory Managment (mm/)
(2) Signals (sched/, arch/)
(1) pthreads (sched/)
- (1) C++ Support
+ (2) C++ Support
(5) Binary loaders (binfmt/)
(16) Network (net/, drivers/net)
(2) USB (drivers/usbdev, drivers/usbhost)
@@ -153,6 +153,21 @@ o pthreads (sched/)
o C++ Support
^^^^^^^^^^^
+ Description: The argument of the 'new' operators should take a type of
+ size_t (see libxx/libxx_new.cxx and libxx/libxx_newa.cxx). But
+ size_t has an unknown underlying. In the nuttx sys/types.h
+ header file, size_t is typed as uint32_t (which is determined by
+ architecture-specific logic). But the C++ compiler may believe
+ that size_t is of a different type resulting in compilation errors
+ in the operator. Using the underlying integer type Instead of
+ size_t seems to resolve the compilation issues.
+ Status: Kind of open. There is a workaround. Setting CONFIG_CXX_NEWLONG=y
+ will define the operators with argument of type unsigned long;
+ Setting CONFIG_CXX_NEWLONG=n will define the operators with argument
+ of type unsigned int. But this is pretty ugly! A better solution
+ would be to get ahold of the compilers definition of size_t.
+ Priority: Low.
+
Description: Need to call static constructors
Status: Open
Priority: Low, depends on toolchain. Call to gcc's built-in static
diff --git a/nuttx/libxx/libxx_new.cxx b/nuttx/libxx/libxx_new.cxx
index 49caf74f3..8ec725ca8 100755
--- a/nuttx/libxx/libxx_new.cxx
+++ b/nuttx/libxx/libxx_new.cxx
@@ -58,14 +58,22 @@
// Name: new
//
// NOTE:
-// This should take a type of size_t, which for ARM GCC is unsigned long.
-// but size_t may actually be a different different type, in sys/include.h,
-// it is typed as uint32_t. Need to REVISIT this.
+// This should take a type of size_t. But size_t has an unknown underlying
+// type. In the nuttx sys/types.h header file, size_t is typed as uint32_t
+// (which is determined by architecture-specific logic). But the C++
+// compiler may believe that size_t is of a different type resulting in
+// compilation errors in the operator. Using the underlying integer type
+// instead of size_t seems to resolve the compilation issues. Need to
+// REVISIT this.
//
//***************************************************************************
//void *operator new(size_t nbytes)
+#ifdef CONFIG_CXX_NEWLONG
void *operator new(unsigned long nbytes)
+#else
+void *operator new(unsigned int nbytes)
+#endif
{
// We have to allocate something
diff --git a/nuttx/libxx/libxx_newa.cxx b/nuttx/libxx/libxx_newa.cxx
index e8c214d4d..855160c41 100755
--- a/nuttx/libxx/libxx_newa.cxx
+++ b/nuttx/libxx/libxx_newa.cxx
@@ -58,18 +58,26 @@
// Name: new
//
// NOTE:
-// This should take a type of size_t, which for ARM GCC is unsigned long.
-// but size_t may actually be a different different type, in sys/include.h,
-// it is typed as uint32_t. Need to REVISIT this.
+// This should take a type of size_t. But size_t has an unknown underlying
+// type. In the nuttx sys/types.h header file, size_t is typed as uint32_t
+// (which is determined by architecture-specific logic). But the C++
+// compiler may believe that size_t is of a different type resulting in
+// compilation errors in the operator. Using the underlying integer type
+// instead of size_t seems to resolve the compilation issues. Need to
+// REVISIT this.
//
//***************************************************************************
//void *operator new[](size_t size)
+#ifdef CONFIG_CXX_NEWLONG
void *operator new[](unsigned long nbytes)
+#else
+void *operator new[](unsigned int nbytes)
+#endif
{
// We have to allocate something
- if (nbytes< 1)
+ if (nbytes < 1)
{
nbytes = 1;
}