diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-03-01 21:05:55 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-03-01 21:05:55 +0000 |
commit | 08680a039b6ffc922731d9a1cfdff20ef204dbba (patch) | |
tree | 25bb704377c624f2d63c4bb5ad1df332d44aa78a /nuttx/lib | |
parent | 129dd27cc4deb042d2f88c65927adc49c338756d (diff) | |
download | px4-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/lib')
-rw-r--r-- | nuttx/lib/lib_fclose.c | 5 | ||||
-rw-r--r-- | nuttx/lib/lib_fflush.c | 14 | ||||
-rw-r--r-- | nuttx/lib/lib_fopen.c | 10 | ||||
-rw-r--r-- | nuttx/lib/lib_fread.c | 5 | ||||
-rw-r--r-- | nuttx/lib/lib_init.c | 7 | ||||
-rw-r--r-- | nuttx/lib/lib_internal.h | 9 | ||||
-rw-r--r-- | nuttx/lib/lib_libfread.c | 4 | ||||
-rw-r--r-- | nuttx/lib/lib_libfwrite.c | 6 | ||||
-rw-r--r-- | nuttx/lib/lib_lowprintf.c | 38 | ||||
-rw-r--r-- | nuttx/lib/lib_memcmp.c | 2 | ||||
-rw-r--r-- | nuttx/lib/lib_memcpy.c | 2 | ||||
-rw-r--r-- | nuttx/lib/lib_memmove.c | 2 | ||||
-rw-r--r-- | nuttx/lib/lib_memset.c | 2 | ||||
-rw-r--r-- | nuttx/lib/lib_printf.c | 21 | ||||
-rw-r--r-- | nuttx/lib/lib_puts.c | 11 | ||||
-rw-r--r-- | nuttx/lib/lib_rawprintf.c | 33 | ||||
-rw-r--r-- | nuttx/lib/lib_rawstream.c | 4 | ||||
-rw-r--r-- | nuttx/lib/lib_streamsem.c | 7 | ||||
-rw-r--r-- | nuttx/lib/lib_ungetc.c | 4 | ||||
-rw-r--r-- | nuttx/lib/lib_vprintf.c | 5 |
20 files changed, 127 insertions, 64 deletions
diff --git a/nuttx/lib/lib_fclose.c b/nuttx/lib/lib_fclose.c index 9985c49c2..979e75a6f 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 dc2c99673..d0f74bd2b 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 11bce38a2..1d4b66ac8 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 b40febe3d..25461545e 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 d1672de06..90ccc358b 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 9d23e8bf0..5b72e7ce2 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 8c3deb655..069721d8f 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 cee26b194..d53f68e2c 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 ef9f9ff0f..6ce895e38 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 b433eda90..5de0b1c49 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 0953b4d28..417fdc82f 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 cad0fa2fc..c64045204 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 25b4929eb..33bead8db 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 c57000fd0..b51365dfa 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 711fd8195..365f726d6 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 537777665..9b65f5a8a 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 e7c194f47..dbb59ad82 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 515366766..4f349c90b 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 45cde1efc..6e246c814 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 6c731ca9a..1507851f7 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 */ + |