summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2007-03-01 21:05:55 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2007-03-01 21:05:55 +0000
commit4ff4eb2040825bbdc3a2df870c68b2c33582b615 (patch)
tree25bb704377c624f2d63c4bb5ad1df332d44aa78a
parent2cfa62f26210dcb37e3ec884bef5dfc9dc221fc7 (diff)
This creates a 8051 build that can run in 24Kb of RAM
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@26 7fd9a85b-ad96-42d3-883c-3090e2eb8679
-rw-r--r--nuttx/Documentation/NuttX.html12
-rw-r--r--nuttx/Makefile2
-rw-r--r--nuttx/arch/README.txt3
-rw-r--r--nuttx/arch/c5471/defconfig5
-rw-r--r--nuttx/arch/sim/defconfig5
-rw-r--r--nuttx/drivers/dev_null.c6
-rw-r--r--nuttx/examples/ostest/Makefile12
-rw-r--r--nuttx/examples/ostest/dev_null.c12
-rw-r--r--nuttx/examples/ostest/main.c34
-rw-r--r--nuttx/fs/fs_close.c11
-rw-r--r--nuttx/fs/fs_dup.c4
-rw-r--r--nuttx/fs/fs_files.c8
-rw-r--r--nuttx/fs/fs_ioctl.c4
-rw-r--r--nuttx/fs/fs_open.c9
-rw-r--r--nuttx/fs/fs_read.c5
-rw-r--r--nuttx/fs/fs_write.c5
-rw-r--r--nuttx/include/nuttx/compiler.h3
-rw-r--r--nuttx/include/sched.h4
-rw-r--r--nuttx/include/string.h8
-rw-r--r--nuttx/lib/lib_fclose.c5
-rw-r--r--nuttx/lib/lib_fflush.c14
-rw-r--r--nuttx/lib/lib_fopen.c10
-rw-r--r--nuttx/lib/lib_fread.c5
-rw-r--r--nuttx/lib/lib_init.c7
-rw-r--r--nuttx/lib/lib_internal.h9
-rw-r--r--nuttx/lib/lib_libfread.c4
-rw-r--r--nuttx/lib/lib_libfwrite.c6
-rw-r--r--nuttx/lib/lib_lowprintf.c38
-rw-r--r--nuttx/lib/lib_memcmp.c2
-rw-r--r--nuttx/lib/lib_memcpy.c2
-rw-r--r--nuttx/lib/lib_memmove.c2
-rw-r--r--nuttx/lib/lib_memset.c2
-rw-r--r--nuttx/lib/lib_printf.c21
-rw-r--r--nuttx/lib/lib_puts.c11
-rw-r--r--nuttx/lib/lib_rawprintf.c33
-rw-r--r--nuttx/lib/lib_rawstream.c4
-rw-r--r--nuttx/lib/lib_streamsem.c7
-rw-r--r--nuttx/lib/lib_ungetc.c4
-rw-r--r--nuttx/lib/lib_vprintf.c5
-rw-r--r--nuttx/sched/Makefile5
-rw-r--r--nuttx/sched/irq_initialize.c2
-rw-r--r--nuttx/sched/irq_internal.h2
-rw-r--r--nuttx/sched/os_internal.h13
-rw-r--r--nuttx/sched/os_start.c24
-rw-r--r--nuttx/sched/sched_getfiles.c5
-rw-r--r--nuttx/sched/sched_getstreams.c5
-rw-r--r--nuttx/sched/sched_releasefiles.c5
-rw-r--r--nuttx/sched/sched_setupidlefiles.c5
-rw-r--r--nuttx/sched/sched_setuppthreadfiles.c5
-rw-r--r--nuttx/sched/sched_setupstreams.c5
-rw-r--r--nuttx/sched/sched_setuptaskfiles.c5
-rw-r--r--nuttx/sched/task_create.c10
52 files changed, 278 insertions, 156 deletions
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index 4802c9e6de..1bf69dd70b 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -46,7 +46,17 @@ is available that be used to build a NuttX-compatible arm-elf toolchain.</blockq
<h1>Memory Footprint</h1>
-<p>To be provided</p>
+<p>Details to be provided</p>
+
+<p>
+ I have a complete build for an ARM7 target that includes most of the OS
+ features and a broad range of OS tests.
+ That builds to an executable that requires about 85Kb for .text, .data., and .bss.
+</p>
+<p>
+ I have a stripped down OS test for the 8051 target that requires only
+ 24Kb.
+</p>
<h1>Licensing</h1>
diff --git a/nuttx/Makefile b/nuttx/Makefile
index ba04418861..6a309f1591 100644
--- a/nuttx/Makefile
+++ b/nuttx/Makefile
@@ -108,7 +108,7 @@ clean:
done
$(MAKE) -C tools -f Makefile.mkconfig TOPDIR=$(TOPDIR) clean
$(MAKE) -C mm -f Makefile.test TOPDIR=$(TOPDIR) clean
- rm -f $(BIN) $(BIN).rr $(BIN).stripped $(BIN).flashimage mm_test System.map *~
+ rm -f $(BIN) $(BIN).* mm_test *.map *~
distclean: clean clean_context
@for dir in $(SUBDIRS) ; do \
diff --git a/nuttx/arch/README.txt b/nuttx/arch/README.txt
index e10393c9ff..629431a45b 100644
--- a/nuttx/arch/README.txt
+++ b/nuttx/arch/README.txt
@@ -94,6 +94,7 @@ defconfig -- This is a configuration file similar to the Linux
o pthread_condtimedwait() depends on signals to wake
up waiting tasks.
+ CONFIG_DISABLE_CLOCK, CONFIG_DISABLE_PTHREAD.
CONFIG_DISABLE_SIGNALS, CONFIG_DISABLE_MQUEUE
Allow for architecture optimized implementations
@@ -108,6 +109,8 @@ defconfig -- This is a configuration file similar to the Linux
Sizes of configurable things (0 disables)
+ CONFIG_MAX_TASKS - The maximum number of simultaneously
+ active tasks. This value must be a power of two.
CONFIG_NPTHREAD_KEYS - The number of items of thread-
specific data that can be retained
CONFIG_NFILE_DESCRIPTORS - The maximum number of file
diff --git a/nuttx/arch/c5471/defconfig b/nuttx/arch/c5471/defconfig
index 731f1d85cf..d0d7c755b3 100644
--- a/nuttx/arch/c5471/defconfig
+++ b/nuttx/arch/c5471/defconfig
@@ -125,6 +125,8 @@ CONFIG_DEV_CONSOLE=y
# o pthread_condtimedwait() depends on signals to wake
# up waiting tasks.
#
+CONFIG_DISABLE_CLOCK=n
+CONFIG_DISABLE_PTHREAD=n
CONFIG_DISABLE_SIGNALS=n
CONFIG_DISABLE_MQUEUE=n
@@ -158,6 +160,8 @@ CONFIG_RRLOAD_BINARY=y
#
# Sizes of configurable things (0 disables)
#
+# CONFIG_MAX_TASKS - The maximum number of simultaneously
+# active tasks. This value must be a power of two.
# CONFIG_NPTHREAD_KEYS - The number of items of thread-
# specific data that can be retained
# CONFIG_NFILE_DESCRIPTORS - The maximum number of file
@@ -180,6 +184,7 @@ CONFIG_RRLOAD_BINARY=y
# structures. The system manages a pool of preallocated
# watchdog structures to minimize dynamic allocations
#
+CONFIG_MAX_TASKS=64
CONFIG_NPTHREAD_KEYS=4
CONFIG_NFILE_DESCRIPTORS=32
CONFIG_NFILE_STREAMS=16
diff --git a/nuttx/arch/sim/defconfig b/nuttx/arch/sim/defconfig
index b20319e7ad..58648c5096 100644
--- a/nuttx/arch/sim/defconfig
+++ b/nuttx/arch/sim/defconfig
@@ -92,6 +92,8 @@ CONFIG_DEV_CONSOLE=y
# o pthread_condtimedwait() depends on signals to wake
# up waiting tasks.
#
+CONFIG_DISABLE_CLOCK=n
+CONFIG_DISABLE_PTHREAD=n
CONFIG_DISABLE_SIGNALS=n
CONFIG_DISABLE_MQUEUE=n
@@ -125,6 +127,8 @@ CONFIG_RRLOAD_BINARY=n
#
# Sizes of configurable things (0 disables)
#
+# CONFIG_MAX_TASKS - The maximum number of simultaneously
+# active tasks. This value must be a power of two.
# CONFIG_NPTHREAD_KEYS - The number of items of thread-
# specific data that can be retained
# CONFIG_NFILE_DESCRIPTORS - The maximum number of file
@@ -147,6 +151,7 @@ CONFIG_RRLOAD_BINARY=n
# structures. The system manages a pool of preallocated
# watchdog structures to minimize dynamic allocations
#
+CONFIG_MAX_TASKS=64
CONFIG_NPTHREAD_KEYS=4
CONFIG_NFILE_DESCRIPTORS=32
CONFIG_NFILE_STREAMS=16
diff --git a/nuttx/drivers/dev_null.c b/nuttx/drivers/dev_null.c
index 1d449df1f7..0998f424b1 100644
--- a/nuttx/drivers/dev_null.c
+++ b/nuttx/drivers/dev_null.c
@@ -61,11 +61,11 @@ static ssize_t devnull_write(struct file *, const char *, size_t);
static struct file_operations devnull_fops =
{
- NULL, /* open */
- NULL, /* close */
+ 0, /* open */
+ 0, /* close */
devnull_read, /* read */
devnull_write, /* write */
- NULL /* ioctl */
+ 0 /* ioctl */
};
/************************************************************
diff --git a/nuttx/examples/ostest/Makefile b/nuttx/examples/ostest/Makefile
index 860bc77467..3e071e146d 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 f9ca5623a6..28b4287fd2 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 06c6ad9f56..69d783c7f2 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;
}
diff --git a/nuttx/fs/fs_close.c b/nuttx/fs/fs_close.c
index d8195a6d4b..3d3c7ca5c8 100644
--- a/nuttx/fs/fs_close.c
+++ b/nuttx/fs/fs_close.c
@@ -34,30 +34,23 @@
************************************************************/
/************************************************************
- * Compilation Switches
- ************************************************************/
-
-/************************************************************
* Included Files
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS >0
-
#include <sys/types.h>
#include <stdio.h>
#include <sched.h>
#include <errno.h>
-
#include <nuttx/fs.h>
-
#include "fs_internal.h"
/************************************************************
* Global Functions
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
int close(int fd)
{
FAR struct filelist *list;
diff --git a/nuttx/fs/fs_dup.c b/nuttx/fs/fs_dup.c
index 1a012903c4..efa8f56ba5 100644
--- a/nuttx/fs/fs_dup.c
+++ b/nuttx/fs/fs_dup.c
@@ -43,8 +43,6 @@
#include <nuttx/config.h>
-#if CONFIG_NFILE_DESCRIPTORS > 0
-
#include <sys/types.h>
#include <unistd.h>
#include <sched.h>
@@ -67,6 +65,8 @@
* Global Functions
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
int dup(int fildes)
{
FAR struct filelist *list;
diff --git a/nuttx/fs/fs_files.c b/nuttx/fs/fs_files.c
index 63a3554aa1..30c2bbed3f 100644
--- a/nuttx/fs/fs_files.c
+++ b/nuttx/fs/fs_files.c
@@ -38,10 +38,6 @@
************************************************************/
#include <nuttx/config.h>
-
-
-#if CONFIG_NFILE_DESCRIPTORS >0
-
#include <string.h>
#include <semaphore.h>
#include <assert.h>
@@ -49,7 +45,6 @@
#include <errno.h>
#include <nuttx/fs.h>
#include <nuttx/kmalloc.h>
-
#include "fs_internal.h"
/************************************************************
@@ -72,6 +67,8 @@
* Private Functions
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS >0
+
static void _files_semtake(FAR struct filelist *list)
{
/* Take the semaphore (perhaps waiting) */
@@ -267,4 +264,5 @@ void files_release(int filedes)
}
}
}
+
#endif /* CONFIG_NFILE_DESCRIPTORS */
diff --git a/nuttx/fs/fs_ioctl.c b/nuttx/fs/fs_ioctl.c
index 4202ce8b32..c93311e638 100644
--- a/nuttx/fs/fs_ioctl.c
+++ b/nuttx/fs/fs_ioctl.c
@@ -51,6 +51,8 @@
* Global Functions
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
int ioctl(int fd, int req, unsigned long arg)
{
FAR struct filelist *list;
@@ -83,3 +85,5 @@ int ioctl(int fd, int req, unsigned long arg)
}
return ret;
}
+
+#endif /* CONFIG_NFILE_DESCRIPTORS */
diff --git a/nuttx/fs/fs_open.c b/nuttx/fs/fs_open.c
index 3703fecda2..ac6d39e439 100644
--- a/nuttx/fs/fs_open.c
+++ b/nuttx/fs/fs_open.c
@@ -42,22 +42,15 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS >0
-
#include <sys/types.h>
-
#include <stdio.h>
#include <sched.h>
#include <errno.h>
-
#ifdef CONFIG_FILE_MODE
#include <stdarg.h>
#endif
-
#include <nuttx/fs.h>
#include <errno.h>
-
#include "fs_internal.h"
/************************************************************
@@ -68,6 +61,8 @@
* Public Functions
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
int inode_checkflags(FAR struct inode *inode, int oflags)
{
if (((oflags & O_RDOK) != 0 && !inode->i_ops->read) ||
diff --git a/nuttx/fs/fs_read.c b/nuttx/fs/fs_read.c
index 1bbcdead05..f23ea016f2 100644
--- a/nuttx/fs/fs_read.c
+++ b/nuttx/fs/fs_read.c
@@ -42,9 +42,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS >0
-
#include <sys/types.h>
#include <stdio.h>
#include <sched.h>
@@ -55,6 +52,8 @@
* Global Functions
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
int read(int fd, void *buf, unsigned int nbytes)
{
FAR struct filelist *list;
diff --git a/nuttx/fs/fs_write.c b/nuttx/fs/fs_write.c
index 3928656ad9..764b887d86 100644
--- a/nuttx/fs/fs_write.c
+++ b/nuttx/fs/fs_write.c
@@ -42,9 +42,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS >0
-
#include <sys/types.h>
#include <stdio.h>
#include <sched.h>
@@ -55,6 +52,8 @@
* Global Functions
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
int write(int fd, const void *buf, unsigned int nbytes)
{
FAR struct filelist *list;
diff --git a/nuttx/include/nuttx/compiler.h b/nuttx/include/nuttx/compiler.h
index 1ba6515039..640129bedc 100644
--- a/nuttx/include/nuttx/compiler.h
+++ b/nuttx/include/nuttx/compiler.h
@@ -74,6 +74,7 @@
# define FAR
# define NEAR
# define DSEG
+# define CODE
/* Select the large, 32-bit addressing model */
@@ -127,6 +128,7 @@
#define FAR __xdata
#define NEAR __data
+#define CODE __code
#if defined(SDCC_MODEL_SMALL)
# define DSEG __data
@@ -167,6 +169,7 @@
# define FAR
# define NEAR
# define DSEG
+# define CODE
# undef CONFIG_SMALL_MEMORY
# undef CONFIG_HAVE_INLINE
diff --git a/nuttx/include/sched.h b/nuttx/include/sched.h
index feb1785e30..f83cfbe532 100644
--- a/nuttx/include/sched.h
+++ b/nuttx/include/sched.h
@@ -98,7 +98,7 @@ typedef enum tstate_e
TSTATE_TASK_PENDING = 1, /* READY_TO_RUN - Pending preemption unlock */
TSTATE_TASK_READYTORUN = 2, /* READY-TO-RUN - But not running */
- TSTATE_TASK_RUNNING = 3, /* READY_TO_RUN - Aand running */
+ TSTATE_TASK_RUNNING = 3, /* READY_TO_RUN - And running */
TSTATE_TASK_INACTIVE = 4, /* BLOCKED - Initialized but not yet activated */
TSTATE_WAIT_SEM = 5, /* BLOCKED - Waiting for a semaphore */
@@ -200,7 +200,7 @@ struct _TCB
/* POSIX thread Specific Data ***************************************/
-#if CONFIG_NPTHREAD_KEYS > 0
+#if !defined(CONFIG_DISABLE_PTHREAD) && CONFIG_NPTHREAD_KEYS > 0
FAR void *pthread_data[CONFIG_NPTHREAD_KEYS];
#endif
diff --git a/nuttx/include/string.h b/nuttx/include/string.h
index 0c8bd59b79..0b05eccc52 100644
--- a/nuttx/include/string.h
+++ b/nuttx/include/string.h
@@ -76,10 +76,10 @@ EXTERN size_t strcspn(const char *, const char *);
EXTERN char *strstr(const char *, const char *);
EXTERN char *strtok(FAR char *, const char *);
-EXTERN void *memset(void *s, int c, size_t n);
-EXTERN void *memcpy(void *dest, const void *src, size_t n);
-EXTERN int memcmp(const void *s1, const void *s2, size_t n);
-EXTERN void *memmove(void *dest, const void *src, size_t count);
+EXTERN void *memset(FAR void *s, int c, size_t n);
+EXTERN void *memcpy(FAR void *dest, FAR const void *src, size_t n);
+EXTERN int memcmp(FAR const void *s1, FAR const void *s2, size_t n);
+EXTERN void *memmove(FAR void *dest, FAR const void *src, size_t count);
#ifndef CONFIG_ARCH_BZERO
# define bzero(s,n) (void)memset(s,0,n)
diff --git a/nuttx/lib/lib_fclose.c b/nuttx/lib/lib_fclose.c
index 9985c49c24..979e75a6fe 100644
--- a/nuttx/lib/lib_fclose.c
+++ b/nuttx/lib/lib_fclose.c
@@ -42,9 +42,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_STREAMS > 0
-
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
@@ -55,6 +52,8 @@
* Global Functions
************************************************************/
+#if CONFIG_NFILE_STREAMS > 0
+
int fclose(FILE *stream)
{
int ret = OK;
diff --git a/nuttx/lib/lib_fflush.c b/nuttx/lib/lib_fflush.c
index dc2c99673c..d0f74bd2b1 100644
--- a/nuttx/lib/lib_fflush.c
+++ b/nuttx/lib/lib_fflush.c
@@ -42,9 +42,6 @@
************************************************************/
#include <nuttx/config.h> /* for CONFIG_STDIO_BUFFER_SIZE */
-
-#if CONFIG_NFILE_STREAMS > 0
-
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs.h>
@@ -83,10 +80,13 @@
************************************************************/
/************************************************************
- * fflush
+ * Name: lib_fflushall
+ *
+ * Description:
+ * Called by the OS when a task exits
************************************************************/
-/* Called by the OS when a task exits */
+#if CONFIG_NFILE_STREAMS > 0
void lib_flushall(FAR struct streamlist *list)
{
@@ -114,6 +114,10 @@ void lib_flushall(FAR struct streamlist *list)
}
}
+/************************************************************
+ * Name: fflush
+ ************************************************************/
+
int fflush(FILE *stream)
{
#if CONFIG_STDIO_BUFFER_SIZE > 0
diff --git a/nuttx/lib/lib_fopen.c b/nuttx/lib/lib_fopen.c
index 11bce38a27..1d4b66ac86 100644
--- a/nuttx/lib/lib_fopen.c
+++ b/nuttx/lib/lib_fopen.c
@@ -42,21 +42,19 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_STREAMS > 0
-
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-
#include "lib_internal.h"
/************************************************************
* Private Functions
************************************************************/
+#if CONFIG_NFILE_STREAMS > 0
+
static int lib_mode2oflags(const char *mode)
{
int oflags = 0;
@@ -126,10 +124,14 @@ static int lib_mode2oflags(const char *mode)
return oflags;
}
+#endif /* CONFIG_NFILE_STREAMS */
+
/************************************************************
* Public Functions
************************************************************/
+#if CONFIG_NFILE_STREAMS > 0
+
FAR struct file_struct *lib_fdopen(int fd, const char *mode,
FAR struct filelist *flist,
FAR struct streamlist *slist)
diff --git a/nuttx/lib/lib_fread.c b/nuttx/lib/lib_fread.c
index b40febe3d0..25461545e6 100644
--- a/nuttx/lib/lib_fread.c
+++ b/nuttx/lib/lib_fread.c
@@ -79,6 +79,8 @@
* fwrite
************************************************************/
+#if CONFIG_NFILE_STREAMS > 0
+
size_t fread(void *ptr, size_t size, size_t n_items, FILE *stream)
{
size_t full_size = n_items * (size_t)size;
@@ -96,3 +98,6 @@ size_t fread(void *ptr, size_t size, size_t n_items, FILE *stream)
}
return items_read;
}
+
+#endif /* CONFIG_NFILE_STREAMS */
+
diff --git a/nuttx/lib/lib_init.c b/nuttx/lib/lib_init.c
index d1672de062..90ccc358b8 100644
--- a/nuttx/lib/lib_init.c
+++ b/nuttx/lib/lib_init.c
@@ -57,6 +57,7 @@
* Private Functions
************************************************************/
+#if CONFIG_NFILE_STREAMS > 0
static void _lib_semtake(FAR struct streamlist *list)
{
/* Take the semaphore (perhaps waiting) */
@@ -71,7 +72,11 @@ static void _lib_semtake(FAR struct streamlist *list)
}
}
-#define _lib_semgive(list) sem_post(&list->sl_sem)
+# define _lib_semgive(list) sem_post(&list->sl_sem)
+#else
+# define _lib_semtake(list)
+# define _lib_semgive(list)
+#endif
/************************************************************
* Public Functions
diff --git a/nuttx/lib/lib_internal.h b/nuttx/lib/lib_internal.h
index 9d23e8bf07..5b72e7ce2b 100644
--- a/nuttx/lib/lib_internal.h
+++ b/nuttx/lib/lib_internal.h
@@ -138,6 +138,14 @@ extern int lib_sprintf (struct lib_stream_s *obj,
extern int lib_vsprintf(struct lib_stream_s *obj,
const char *src, va_list ap);
+/* Defined lib_rawprintf.c */
+
+extern int lib_rawvprintf(const char *src, va_list ap);
+
+/* Defined lib_lowprintf.c */
+
+extern int lib_lowvprintf(const char *src, va_list ap);
+
/* Defined in lib_libwrite.c */
extern ssize_t lib_fwrite(const void *ptr, size_t count, FILE *stream);
@@ -158,5 +166,4 @@ extern void lib_give_semaphore(FAR struct file_struct *stream);
extern int lib_getbase(const char *nptr, const char **endptr);
-
#endif /* __LIB_INTERNAL_H */
diff --git a/nuttx/lib/lib_libfread.c b/nuttx/lib/lib_libfread.c
index 8c3deb6559..069721d8f2 100644
--- a/nuttx/lib/lib_libfread.c
+++ b/nuttx/lib/lib_libfread.c
@@ -83,6 +83,8 @@
* lib_fread
************************************************************/
+#if CONFIG_NFILE_STREAMS > 0
+
ssize_t lib_fread(void *ptr, size_t count, FILE *stream)
{
unsigned char *dest = (unsigned char*)ptr;
@@ -255,3 +257,5 @@ ssize_t lib_fread(void *ptr, size_t count, FILE *stream)
}
return bytes_read;
}
+
+#endif /* CONFIG_NFILE_STREAMS */
diff --git a/nuttx/lib/lib_libfwrite.c b/nuttx/lib/lib_libfwrite.c
index cee26b1940..d53f68e2cf 100644
--- a/nuttx/lib/lib_libfwrite.c
+++ b/nuttx/lib/lib_libfwrite.c
@@ -82,6 +82,8 @@
* lib_fwrite
************************************************************/
+#if CONFIG_NFILE_STREAMS > 0
+
ssize_t lib_fwrite(const void *ptr, size_t count, FILE *stream)
#if CONFIG_STDIO_BUFFER_SIZE > 0
{
@@ -159,4 +161,6 @@ ssize_t lib_fwrite(const void *ptr, size_t count, FILE *stream)
{
return write(stream->fs_filedes, ptr, count);
}
-#endif
+#endif /* CONFIG_STDIO_BUFFER_SIZE */
+
+#endif /* CONFIG_NFILE_STREAMS */
diff --git a/nuttx/lib/lib_lowprintf.c b/nuttx/lib/lib_lowprintf.c
index ef9f9ff0fb..6ce895e387 100644
--- a/nuttx/lib/lib_lowprintf.c
+++ b/nuttx/lib/lib_lowprintf.c
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#ifdef CONFIG_ARCH_LOWPUTC
-
#include <stdio.h>
#include <debug.h>
#include "lib_internal.h"
@@ -61,44 +58,55 @@
* Global Function Prototypes
************************************************************/
-/**********************************************************
+/************************************************************
* Global Constant Data
- **********************************************************/
+ ************************************************************/
/************************************************************
* Global Variables
************************************************************/
-/**********************************************************
+/************************************************************
* Private Constant Data
- **********************************************************/
+ ************************************************************/
/************************************************************
* Private Variables
- **********************************************************/
+ ************************************************************/
/************************************************************
* Global Functions
- **********************************************************/
+ ************************************************************/
/************************************************************
- * lib_lowprintf
- **********************************************************/
+ * Name: lib_lowvprintf
+ ************************************************************/
-int lib_lowprintf(const char *fmt, ...)
+#ifdef CONFIG_ARCH_LOWPUTC
+
+int lib_lowvprintf(const char *fmt, va_list ap)
{
struct lib_stream_s stream;
- va_list ap;
- int ret;
/* Wrap the stdout in a stream object and let lib_vsprintf
* do the work.
*/
lib_lowstream(&stream);
+ return lib_vsprintf(&stream, fmt, ap);
+}
+
+/************************************************************
+ * Name: lib_lowprintf
+ ************************************************************/
+
+int lib_lowprintf(const char *fmt, ...)
+{
+ va_list ap;
+ int ret;
va_start(ap, fmt);
- ret= lib_vsprintf(&stream, fmt, ap);
+ ret= lib_lowvprintf(fmt, ap);
va_end(ap);
return ret;
}
diff --git a/nuttx/lib/lib_memcmp.c b/nuttx/lib/lib_memcmp.c
index b433eda90f..5de0b1c498 100644
--- a/nuttx/lib/lib_memcmp.c
+++ b/nuttx/lib/lib_memcmp.c
@@ -50,7 +50,7 @@
************************************************************/
#ifndef CONFIG_ARCH_MEMCMP
-int memcmp(const void *s1, const void *s2, size_t n)
+int memcmp(FAR const void *s1, FAR const void *s2, size_t n)
{
unsigned char *p1 = (unsigned char *)s1;
unsigned char *p2 = (unsigned char *)s2;
diff --git a/nuttx/lib/lib_memcpy.c b/nuttx/lib/lib_memcpy.c
index 0953b4d282..417fdc82f8 100644
--- a/nuttx/lib/lib_memcpy.c
+++ b/nuttx/lib/lib_memcpy.c
@@ -50,7 +50,7 @@
************************************************************/
#ifndef CONFIG_ARCH_MEMCPY
-void *memcpy(void *dest, const void *src, size_t n)
+void *memcpy(FAR void *dest, FAR const void *src, size_t n)
{
unsigned char *pout = (unsigned char*)dest;
unsigned char *pin = (unsigned char*)src;
diff --git a/nuttx/lib/lib_memmove.c b/nuttx/lib/lib_memmove.c
index cad0fa2fc4..c640452046 100644
--- a/nuttx/lib/lib_memmove.c
+++ b/nuttx/lib/lib_memmove.c
@@ -50,7 +50,7 @@
************************************************************/
#ifndef CONFIG_ARCH_MEMMOVE
-void *memmove(void *dest, const void *src, size_t count)
+void *memmove(FAR void *dest, FAR const void *src, size_t count)
{
char *tmp, *s;
if (dest <= src)
diff --git a/nuttx/lib/lib_memset.c b/nuttx/lib/lib_memset.c
index 25b4929ebd..33bead8db3 100644
--- a/nuttx/lib/lib_memset.c
+++ b/nuttx/lib/lib_memset.c
@@ -50,7 +50,7 @@
************************************************************/
#ifndef CONFIG_ARCH_MEMSET
-void *memset(void *s, int c, size_t n)
+void *memset(FAR void *s, int c, size_t n)
{
unsigned char *p = (unsigned char*)s;
while (n-- > 0) *p++ = c;
diff --git a/nuttx/lib/lib_printf.c b/nuttx/lib/lib_printf.c
index c57000fd0d..b51365dfa1 100644
--- a/nuttx/lib/lib_printf.c
+++ b/nuttx/lib/lib_printf.c
@@ -81,23 +81,26 @@
**********************************************************/
/************************************************************
- * printf
+ * Name: printf
**********************************************************/
int printf(const char *fmt, ...)
{
- struct lib_stdstream_s stdstream;
va_list ap;
int ret;
- /* Wrap the stdout in a stream object and let lib_vsprintf
- * do the work.
- */
-
- lib_stdstream(&stdstream, stdout);
-
va_start(ap, fmt);
- ret= lib_vsprintf(&stdstream.public, fmt, ap);
+#if CONFIG_NFILE_STREAMS > 0
+ ret = vfprintf(stdout, fmt, ap);
+#elif CONFIG_NFILE_DESCRIPTORS > 0
+ ret = lib_rawvprintf(fmt, ap);
+#elif defined(CONFIG_ARCH_LOWPUTC)
+ ret = lib_lowvprintf(fmt, ap);
+#else
+# warning "printf has no data sink"
+#endif
va_end(ap);
+
return ret;
}
+
diff --git a/nuttx/lib/lib_puts.c b/nuttx/lib/lib_puts.c
index 711fd81950..365f726d6c 100644
--- a/nuttx/lib/lib_puts.c
+++ b/nuttx/lib/lib_puts.c
@@ -81,10 +81,15 @@
************************************************************/
/************************************************************
- * puts
+ * Name: puts
+ *
+ * Description:
+ * puts() writes the string s and a trailing newline to
+ * stdout.
************************************************************/
-/* puts() writes the string s and a trailing newline to stdout. */
+#if CONFIG_NFILE_STREAMS > 0
+
int puts(const char *s)
{
int nwritten;
@@ -109,3 +114,5 @@ int puts(const char *s)
lib_give_semaphore(stdout);
return nput;
}
+
+#endif /* CONFIG_NFILE_STREAMS */
diff --git a/nuttx/lib/lib_rawprintf.c b/nuttx/lib/lib_rawprintf.c
index 5377776653..9b65f5a8aa 100644
--- a/nuttx/lib/lib_rawprintf.c
+++ b/nuttx/lib/lib_rawprintf.c
@@ -57,44 +57,53 @@
* Global Function Prototypes
************************************************************/
-/**********************************************************
+/************************************************************
* Global Constant Data
- **********************************************************/
+ ************************************************************/
/************************************************************
* Global Variables
************************************************************/
-/**********************************************************
+/************************************************************
* Private Constant Data
- **********************************************************/
+ ************************************************************/
/************************************************************
* Private Variables
- **********************************************************/
+ ************************************************************/
/************************************************************
* Global Functions
- **********************************************************/
+ ************************************************************/
/************************************************************
- * lib_rawprintf
- **********************************************************/
+ * Aame: lib_rawvprintf
+ ************************************************************/
-int lib_rawprintf(const char *fmt, ...)
+int lib_rawvprintf(const char *fmt, va_list ap)
{
struct lib_rawstream_s rawstream;
- va_list ap;
- int ret;
/* Wrap the stdout in a stream object and let lib_vsprintf
* do the work.
*/
lib_rawstream(&rawstream, 1);
+ return lib_vsprintf(&rawstream.public, fmt, ap);
+}
+
+/************************************************************
+ * Name: lib_rawprintf
+ ************************************************************/
+
+int lib_rawprintf(const char *fmt, ...)
+{
+ va_list ap;
+ int ret;
va_start(ap, fmt);
- ret= lib_vsprintf(&rawstream.public, fmt, ap);
+ ret= lib_rawvprintf(fmt, ap);
va_end(ap);
return ret;
}
diff --git a/nuttx/lib/lib_rawstream.c b/nuttx/lib/lib_rawstream.c
index e7c194f477..dbb59ad826 100644
--- a/nuttx/lib/lib_rawstream.c
+++ b/nuttx/lib/lib_rawstream.c
@@ -45,6 +45,8 @@
* Private Functions
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
static void rawstream_putc(struct lib_stream_s *this, int ch)
{
struct lib_rawstream_s *rthis = (struct lib_rawstream_s *)this;
@@ -75,4 +77,6 @@ void lib_rawstream(struct lib_rawstream_s *rawstream, int fd)
rawstream->fd = fd;
}
+#endif /* CONFIG_NFILE_DESCRIPTORS */
+
diff --git a/nuttx/lib/lib_streamsem.c b/nuttx/lib/lib_streamsem.c
index 5153667662..4f349c90b5 100644
--- a/nuttx/lib/lib_streamsem.c
+++ b/nuttx/lib/lib_streamsem.c
@@ -42,17 +42,12 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_STREAMS > 0
-
#include <sys/types.h>
-
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <semaphore.h>
#include <errno.h>
-
#include <nuttx/fs.h>
#include "lib_internal.h"
@@ -76,6 +71,8 @@
* Public Functions
************************************************************/
+#if CONFIG_NFILE_STREAMS > 0
+
void stream_semtake(FAR struct streamlist *list)
{
/* Take the semaphore (perhaps waiting) */
diff --git a/nuttx/lib/lib_ungetc.c b/nuttx/lib/lib_ungetc.c
index 45cde1efc9..6e246c8147 100644
--- a/nuttx/lib/lib_ungetc.c
+++ b/nuttx/lib/lib_ungetc.c
@@ -43,8 +43,6 @@
#include <nuttx/config.h>
-#if CONFIG_NFILE_STREAMS > 0
-
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs.h>
@@ -90,6 +88,8 @@
* fgetc
**********************************************************/
+#if CONFIG_NFILE_STREAMS > 0
+
int ungetc(int c, FILE *stream)
{
#if CONFIG_NUNGET_CHARS > 0
diff --git a/nuttx/lib/lib_vprintf.c b/nuttx/lib/lib_vprintf.c
index 6c731ca9aa..1507851f73 100644
--- a/nuttx/lib/lib_vprintf.c
+++ b/nuttx/lib/lib_vprintf.c
@@ -83,9 +83,14 @@
* vprintf
**********************************************************/
+#if CONFIG_NFILE_STREAMS > 0
+
int vprintf(const char *fmt, va_list ap)
{
/* vfprintf into stdout */
return vfprintf(stdout, fmt, ap);
}
+
+#endif /* CONFIG_NFILE_STREAMS */
+
diff --git a/nuttx/sched/Makefile b/nuttx/sched/Makefile
index fa69c60b51..43868d4fba 100644
--- a/nuttx/sched/Makefile
+++ b/nuttx/sched/Makefile
@@ -100,7 +100,10 @@ SEM_SRCS = sem_initialize.c sem_init.c sem_destroy.c\
IRQ_SRCS = irq_initialize.c irq_attach.c irq_dispatch.c irq_unexpectedisr.c
CSRCS = $(MISC_SRCS) $(TSK_SRCS) $(SCHED_SRCS) $(WDOG_SRCS) $(TIME_SRCS) \
- $(PTHREAD_SRCS) $(SEM_SRCS) $(IRQ_SRCS)
+ $(SEM_SRCS) $(IRQ_SRCS)
+ifneq ($(CONFIG_DISABLE_PTHREAD),y)
+CSRCS += $(PTHREAD_SRCS)
+endif
ifneq ($(CONFIG_DISABLE_SIGNALS),y)
CSRCS += $(SIGNAL_SRCS)
endif
diff --git a/nuttx/sched/irq_initialize.c b/nuttx/sched/irq_initialize.c
index b213a5b09f..445bb3e2c5 100644
--- a/nuttx/sched/irq_initialize.c
+++ b/nuttx/sched/irq_initialize.c
@@ -54,7 +54,7 @@
* Global Variables
************************************************************/
-xcpt_t g_irqvector[NR_IRQS+1];
+FAR xcpt_t g_irqvector[NR_IRQS+1];
/************************************************************
* Private Variables
diff --git a/nuttx/sched/irq_internal.h b/nuttx/sched/irq_internal.h
index a1216fa9d2..6cac68ecf2 100644
--- a/nuttx/sched/irq_internal.h
+++ b/nuttx/sched/irq_internal.h
@@ -53,7 +53,7 @@
* Public Type Declarations
************************************************************/
-extern xcpt_t g_irqvector[NR_IRQS+1];
+extern FAR xcpt_t g_irqvector[NR_IRQS+1];
/************************************************************
* Public Variables
diff --git a/nuttx/sched/os_internal.h b/nuttx/sched/os_internal.h
index d829783bd7..900484d9bd 100644
--- a/nuttx/sched/os_internal.h
+++ b/nuttx/sched/os_internal.h
@@ -85,14 +85,13 @@ enum os_crash_codes_e
/* Although task IDs can take the (positive, non-zero)
* range of pid_t, the number of tasks that will be supported
- * at any one time is (artificially) limited by the following
- * definition. Limiting the number of tasks speeds certain
+ * at any one time is (artificially) limited by the CONFIG_MAX_TASKS
+ * configuration setting. Limiting the number of tasks speeds certain
* OS functions (this is the only limitation in the number of
* tasks built into the design).
*/
-#define MAX_TASKS_ALLOWED 64
-#define MAX_TASKS_MASK 0x3f
+#define MAX_TASKS_MASK (CONFIG_MAX_TASKS-1)
#define PIDHASH(pid) ((pid) & MAX_TASKS_MASK)
/* Stubs used when there are no file descriptors */
@@ -216,14 +215,16 @@ extern sq_queue_t g_delayeddeallocations;
extern pid_t g_lastpid;
/* The following hash table is used for two things:
+ *
* 1. This hash table greatly speeds the determination of
* a new unique process ID for a task, and
* 2. Is used to quickly map a process ID into a TCB.
+ *
* It has the side effects of using more memory and limiting
- * the number of tasks to MAX_TASKS_ALLOWED.
+ * the number of tasks to CONFIG_MAX_TASKS.
*/
-extern pidhash_t g_pidhash[MAX_TASKS_ALLOWED];
+extern pidhash_t g_pidhash[CONFIG_MAX_TASKS];
/* This is a table of task lists. This table is indexed by
* the task state enumeration type (tstate_t) and provides
diff --git a/nuttx/sched/os_start.c b/nuttx/sched/os_start.c
index d8106ed163..5cf7c940fd 100644
--- a/nuttx/sched/os_start.c
+++ b/nuttx/sched/os_start.c
@@ -53,7 +53,9 @@
#ifndef CONFIG_DISABLE_MQUEUE
# include "mq_internal.h"
#endif
-#include "pthread_internal.h"
+#ifndef CONFIG_DISABLE_PTHREAD
+# include "pthread_internal.h"
+#endif
#include "clock_internal.h"
#include "irq_internal.h"
@@ -140,14 +142,16 @@ sq_queue_t g_delayeddeallocations;
pid_t g_lastpid;
/* The following hash table is used for two things:
+ *
* 1. This hash table greatly speeds the determination of
* a new unique process ID for a task, and
* 2. Is used to quickly map a process ID into a TCB.
* It has the side effects of using more memory and limiting
- * the number of tasks to MAX_TASKS_ALLOWED.
+ *
+ * the number of tasks to CONFIG_MAX_TASKS.
*/
-pidhash_t g_pidhash[MAX_TASKS_ALLOWED];
+pidhash_t g_pidhash[CONFIG_MAX_TASKS];
/* This is a table of task lists. This table is indexed by
* the task state enumeration type (tstate_t) and provides
@@ -185,6 +189,10 @@ const tasklist_t g_tasklisttable[NUM_TASK_STATES] =
static FAR _TCB g_idletcb;
+/* This is the name of the idle task */
+
+static FAR char g_idlename[] = "Idle Task";
+
/************************************************************
* Private Function Prototypes
************************************************************/
@@ -225,7 +233,7 @@ void os_start(void)
/* Initialize the logic that determine unique process IDs. */
g_lastpid = 0;
- for (i = 0; i < MAX_TASKS_ALLOWED; i++)
+ for (i = 0; i < CONFIG_MAX_TASKS; i++)
{
g_pidhash[i].tcb = NULL;
g_pidhash[i].pid = INVALID_PROCESS_ID;
@@ -248,10 +256,10 @@ void os_start(void)
g_idletcb.entry.main = (main_t)os_start;
#if CONFIG_TASK_NAME_SIZE > 0
- strncpy(g_idletcb.name, "Idle Task", CONFIG_TASK_NAME_SIZE-1);
+ strncpy(g_idletcb.name, g_idlename, CONFIG_TASK_NAME_SIZE-1);
g_idletcb.argv[0] = g_idletcb.name;
#else
- g_idletcb.argv[0] = "Idle Task";
+ g_idletcb.argv[0] = g_idlename;
#endif /* CONFIG_TASK_NAME_SIZE */
/* Then add the idle task's TCB to the head of the ready to run list */
@@ -347,21 +355,25 @@ void os_start(void)
/* Initialize the thread-specific data facility (if in link) */
+#ifndef CONFIG_DISABLE_PTHREAD
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
if (pthread_initialize != NULL)
#endif
{
pthread_initialize();
}
+#endif
/* Initialize the file system (needed to support device drivers) */
+#if CONFIG_NFILE_DESCRIPTORS > 0
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
if (fs_initialize != NULL)
#endif
{
fs_initialize();
}
+#endif
/* The processor specific details of running the operating system
* will be handled here. Such things as setting up interrupt
diff --git a/nuttx/sched/sched_getfiles.c b/nuttx/sched/sched_getfiles.c
index 7478e7cf08..76c209b6e1 100644
--- a/nuttx/sched/sched_getfiles.c
+++ b/nuttx/sched/sched_getfiles.c
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS > 0
-
#include <sched.h>
#include "os_internal.h"
@@ -68,6 +65,8 @@
*
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
FAR struct filelist *sched_getfiles(void)
{
FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head;
diff --git a/nuttx/sched/sched_getstreams.c b/nuttx/sched/sched_getstreams.c
index ba7f3a23db..cc21339cc2 100644
--- a/nuttx/sched/sched_getstreams.c
+++ b/nuttx/sched/sched_getstreams.c
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
-
#include <sched.h>
#include "os_internal.h"
@@ -68,6 +65,8 @@
*
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
+
FAR struct streamlist *sched_getstreams(void)
{
FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head;
diff --git a/nuttx/sched/sched_releasefiles.c b/nuttx/sched/sched_releasefiles.c
index 979aca22d1..c511bdb546 100644
--- a/nuttx/sched/sched_releasefiles.c
+++ b/nuttx/sched/sched_releasefiles.c
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS > 0
-
#include <sched.h>
#include <nuttx/fs.h>
#include <nuttx/lib.h>
@@ -69,6 +66,8 @@
*
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
int sched_releasefiles(_TCB *tcb)
{
if (tcb)
diff --git a/nuttx/sched/sched_setupidlefiles.c b/nuttx/sched/sched_setupidlefiles.c
index 29d5dd3e04..871a445bd5 100644
--- a/nuttx/sched/sched_setupidlefiles.c
+++ b/nuttx/sched/sched_setupidlefiles.c
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS > 0
-
#include <stdio.h>
#include <unistd.h>
#include <sched.h>
@@ -71,6 +68,8 @@
*
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
int sched_setupidlefiles(FAR _TCB *tcb)
{
int fd;
diff --git a/nuttx/sched/sched_setuppthreadfiles.c b/nuttx/sched/sched_setuppthreadfiles.c
index 5cc20c6d14..91dfd850fa 100644
--- a/nuttx/sched/sched_setuppthreadfiles.c
+++ b/nuttx/sched/sched_setuppthreadfiles.c
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS > 0
-
#include <sched.h>
#include <nuttx/fs.h>
#include <nuttx/lib.h>
@@ -71,6 +68,8 @@
*
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
int sched_setuppthreadfiles(FAR _TCB *tcb)
{
FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head;
diff --git a/nuttx/sched/sched_setupstreams.c b/nuttx/sched/sched_setupstreams.c
index 97509fc68c..a19dd0bf1e 100644
--- a/nuttx/sched/sched_setupstreams.c
+++ b/nuttx/sched/sched_setupstreams.c
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
-
#include <sched.h>
#include <nuttx/fs.h>
#include <nuttx/lib.h>
@@ -53,6 +50,8 @@
* Public Functions
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
+
int sched_setupstreams(FAR _TCB *tcb)
{
/* Allocate file strems for the TCB */
diff --git a/nuttx/sched/sched_setuptaskfiles.c b/nuttx/sched/sched_setuptaskfiles.c
index 1753980313..25275e89b6 100644
--- a/nuttx/sched/sched_setuptaskfiles.c
+++ b/nuttx/sched/sched_setuptaskfiles.c
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS > 0
-
#include <sched.h>
#include <errno.h>
#include <nuttx/fs.h>
@@ -71,6 +68,8 @@
*
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
int sched_setuptaskfiles(FAR _TCB *tcb)
{
#ifdef CONFIG_DEV_CONSOLE
diff --git a/nuttx/sched/task_create.c b/nuttx/sched/task_create.c
index daf42af2fd..399bba20c4 100644
--- a/nuttx/sched/task_create.c
+++ b/nuttx/sched/task_create.c
@@ -62,6 +62,10 @@
* Private Variables
************************************************************/
+/* This is the name for un-named tasks */
+
+static FAR char g_noname[] = "no name";
+
/************************************************************
* Private Function Prototypes
************************************************************/
@@ -141,7 +145,7 @@ static STATUS task_assignpid(FAR _TCB *tcb)
/* We'll try every allowable pid */
- for (tries = 0; tries < MAX_TASKS_ALLOWED; tries++)
+ for (tries = 0; tries < CONFIG_MAX_TASKS; tries++)
{
/* Get the next process ID candidate */
@@ -244,7 +248,7 @@ STATUS _task_init(FAR _TCB *tcb, const char *name, int priority,
if (!name)
{
- name = "no name";
+ name = g_noname;
}
/* copy the name into the TCB */
@@ -257,7 +261,7 @@ STATUS _task_init(FAR _TCB *tcb, const char *name, int priority,
#if CONFIG_TASK_NAME_SIZE > 0
tcb->argv[0] = tcb->name;
#else
- tcb->argv[0] = "no name";
+ tcb->argv[0] = g_noname;
#endif
/* For pthreads, args are strictly pass-by-value; the char*