summaryrefslogtreecommitdiff
path: root/nuttx/examples/ostest
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-03-01 21:05:55 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-03-01 21:05:55 +0000
commit08680a039b6ffc922731d9a1cfdff20ef204dbba (patch)
tree25bb704377c624f2d63c4bb5ad1df332d44aa78a /nuttx/examples/ostest
parent129dd27cc4deb042d2f88c65927adc49c338756d (diff)
downloadpx4-nuttx-08680a039b6ffc922731d9a1cfdff20ef204dbba.tar.gz
px4-nuttx-08680a039b6ffc922731d9a1cfdff20ef204dbba.tar.bz2
px4-nuttx-08680a039b6ffc922731d9a1cfdff20ef204dbba.zip
This creates a 8051 build that can run in 24Kb of RAM
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@26 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/ostest')
-rw-r--r--nuttx/examples/ostest/Makefile12
-rw-r--r--nuttx/examples/ostest/dev_null.c12
-rw-r--r--nuttx/examples/ostest/main.c34
3 files changed, 45 insertions, 13 deletions
diff --git a/nuttx/examples/ostest/Makefile b/nuttx/examples/ostest/Makefile
index 860bc7746..3e071e146 100644
--- a/nuttx/examples/ostest/Makefile
+++ b/nuttx/examples/ostest/Makefile
@@ -40,13 +40,21 @@ MKDEP = $(TOPDIR)/tools/mkdeps.sh
ASRCS =
AOBJS = $(ASRCS:.S=$(OBJEXT))
-CSRCS = main.c dev_null.c mutex.c cancel.c sem.c cond.c
+CSRCS = main.c dev_null.c
+ifneq ($(CONFIG_DISABLE_PTHREAD),y)
+CSRCS += cancel.c cond.c mutex.c sem.c
+endif
ifneq ($(CONFIG_DISABLE_SIGNALS),y)
-CSRCS += timedwait.c sighand.c
+CSRCS += sighand.c
+ifneq ($(CONFIG_DISABLE_PTHREAD),y)
+CSRCS += timedwait.c
+endif
endif
ifneq ($(CONFIG_DISABLE_MQUEUE),y)
+ifneq ($(CONFIG_DISABLE_PTHREAD),y)
CSRCS += mqueue.c
endif
+endif
COBJS = $(CSRCS:.c=$(OBJEXT))
diff --git a/nuttx/examples/ostest/dev_null.c b/nuttx/examples/ostest/dev_null.c
index f9ca5623a..28b4287fd 100644
--- a/nuttx/examples/ostest/dev_null.c
+++ b/nuttx/examples/ostest/dev_null.c
@@ -50,7 +50,9 @@
* Private Data
************************************************************/
-static char buffer[1024];
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
+static FAR char buffer[1024];
/************************************************************
* Public Functions
@@ -64,14 +66,14 @@ int dev_null(void)
fd = open("/dev/null", O_RDWR);
if (fd < 0)
{
- fprintf(stderr, "dev_null: Failed to open /dev/null\n");
+ printf("dev_null: ERROR Failed to open /dev/null\n");
return -1;
}
nbytes = read(fd, buffer, 1024);
if (nbytes < 0)
{
- fprintf(stderr, "dev_null: Failed to read from /dev/null\n");
+ printf("dev_null: ERROR Failed to read from /dev/null\n");
close(fd);
return -1;
}
@@ -80,7 +82,7 @@ int dev_null(void)
nbytes = write(fd, buffer, 1024);
if (nbytes < 0)
{
- fprintf(stderr, "dev_null: Failed to write to /dev/null\n");
+ printf("dev_null: ERROR Failed to write to /dev/null\n");
close(fd);
return -1;
}
@@ -89,3 +91,5 @@ int dev_null(void)
close(fd);
return 0;
}
+
+#endif /*CONFIG_NFILE_DESCRIPTORS */
diff --git a/nuttx/examples/ostest/main.c b/nuttx/examples/ostest/main.c
index 06c6ad9f5..69d783c7f 100644
--- a/nuttx/examples/ostest/main.c
+++ b/nuttx/examples/ostest/main.c
@@ -64,8 +64,10 @@ static FAR char arg2[] = "Arg2";
static FAR char arg3[] = "Arg3";
static FAR char arg4[] = "Arg4";
+#if CONFIG_NFILE_DESCRIPTORS > 0
static char write_data1[] = "Standard I/O Check: write fd=1\n";
static char write_data2[] = "Standard I/O Check: write fd=2\n";
+#endif
static char *args[NARGS] = { arg1, arg2, arg3, arg4 };
/************************************************************
@@ -82,8 +84,8 @@ static int user_main(int argc, char *argv[])
if (argc != NARGS + 1)
{
- fprintf(stderr, "user_main: Error expected argc=%d got argc=%d\n",
- NARGS+1, argc);
+ printf("user_main: Error expected argc=%d got argc=%d\n",
+ NARGS+1, argc);
}
for (i = 0; i <= NARGS; i++)
@@ -95,38 +97,48 @@ static int user_main(int argc, char *argv[])
{
if (strcmp(argv[i], args[i-1]) != 0)
{
- fprintf(stderr, "user_main: ERROR argv[%d]: Expected \"%s\" found \"%s\"\n",
- i, argv[i], args[i-1]);
+ printf("user_main: ERROR argv[%d]: Expected \"%s\" found \"%s\"\n",
+ i, argv[i], args[i-1]);
}
}
+#if CONFIG_NFILE_DESCRIPTORS > 0
/* Checkout /dev/null */
dev_null();
+#endif
+#ifndef CONFIG_DISABLE_PTHREAD
/* Verify pthreads and pthread mutex */
mutex_test();
+#endif
+#ifndef CONFIG_DISABLE_PTHREAD
/* Verify pthread cancellation */
cancel_test();
+#endif
+#ifndef CONFIG_DISABLE_PTHREAD
/* Verify pthreads and semaphores */
sem_test();
+#endif
+#ifndef CONFIG_DISABLE_PTHREAD
/* Verify pthreads and condition variables */
cond_test();
+#endif
-#ifndef CONFIG_DISABLE_SIGNALS
+#if !defined(CONFIG_DISABLE_SIGNALS) && !defined(CONFIG_DISABLE_PTHREAD)
/* Verify pthreads and condition variable timed waits */
timedwait_test();
#endif
-#ifndef CONFIG_DISABLE_MQUEUE
+#if !defined(CONFIG_DISABLE_MQUEUE) && !defined(CONFIG_DISABLE_PTHREAD)
/* Verify pthreads and message queues */
mqueue_test();
@@ -165,10 +177,17 @@ int user_start(int parm1, int parm2, int parm3, int parm4)
/* Verify that we can communicate */
+#if CONFIG_NFILE_DESCRIPTORS > 0
write(1, write_data1, sizeof(write_data1));
+#endif
printf("user_start: Standard I/O Check: printf\n");
+
+#if CONFIG_NFILE_DESCRIPTORS > 1
write(2, write_data2, sizeof(write_data2));
+#endif
+#if CONFIG_NFILE_STREAMS > 0
fprintf(stderr, "user_start: Standard I/O Check: fprintf to stderr\n");
+#endif
/* Verify that we can spawn a new task */
@@ -176,11 +195,12 @@ int user_start(int parm1, int parm2, int parm3, int parm4)
arg1, arg2, arg3, arg4);
if (result == ERROR)
{
- fprintf(stderr, "user_start: Failed to start user_main\n");
+ printf("user_start: ERROR Failed to start user_main\n");
}
else
{
printf("user_start: Started user_main at PID=%d\n", result);
}
+
return 0;
}