summaryrefslogtreecommitdiff
path: root/nuttx/lib
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-01-09 22:53:52 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-01-09 22:53:52 +0000
commit27bf9aa3312963e45f4721661ac1911d08ffc70a (patch)
tree701cdfce10e34e97b3d3d09e2f8148f9c648fb2b /nuttx/lib
parenta2c6c96d13de37908120dcae297530665836f8e8 (diff)
downloadpx4-nuttx-27bf9aa3312963e45f4721661ac1911d08ffc70a.tar.gz
px4-nuttx-27bf9aa3312963e45f4721661ac1911d08ffc70a.tar.bz2
px4-nuttx-27bf9aa3312963e45f4721661ac1911d08ffc70a.zip
Compiles with ZDS-II
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@540 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/lib')
-rw-r--r--nuttx/lib/lib_fclose.c4
-rw-r--r--nuttx/lib/lib_libvsprintf.c160
-rw-r--r--nuttx/lib/lib_printf.c61
-rw-r--r--nuttx/lib/lib_sscanf.c56
4 files changed, 145 insertions, 136 deletions
diff --git a/nuttx/lib/lib_fclose.c b/nuttx/lib/lib_fclose.c
index f6271e18c..57b5b5618 100644
--- a/nuttx/lib/lib_fclose.c
+++ b/nuttx/lib/lib_fclose.c
@@ -62,7 +62,9 @@ int fclose(FILE *stream)
{
ret = close(stream->fs_filedes);
}
-#warning REVIEW for race conditions
+#ifdef CONFIG_CPP_HAVE_WARNING
+# warning REVIEW for race conditions
+#endif
#if CONFIG_STDIO_BUFFER_SIZE > 0
/* Destroy the semaphore */
sem_destroy(&stream->fs_sem);
diff --git a/nuttx/lib/lib_libvsprintf.c b/nuttx/lib/lib_libvsprintf.c
index 827a1a05b..a7e1aab55 100644
--- a/nuttx/lib/lib_libvsprintf.c
+++ b/nuttx/lib/lib_libvsprintf.c
@@ -1,7 +1,7 @@
-/************************************************************
+/****************************************************************************
* lib_libvsprintf.c
*
- * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
- * 3. Neither the name Gregory Nutt nor the names of its contributors may be
+ * 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -31,15 +31,15 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Compilation Switches
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Included Files
- ************************************************************/
+ ****************************************************************************/
#include <nuttx/compiler.h>
#include <sys/types.h>
@@ -48,9 +48,9 @@
#include "lib_internal.h"
-/************************************************************
+/****************************************************************************
* Definitions
- ************************************************************/
+ ****************************************************************************/
enum
{
@@ -98,13 +98,13 @@ enum
#define IS_NEGATE(f) (((f) & FLAG_NEGATE) != 0)
#define IS_SIGNED(f) (((f) & (FLAG_SHOWPLUS|FLAG_NEGATE)) != 0)
-/************************************************************
+/****************************************************************************
* Private Type Declarations
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Function Prototypes
- ************************************************************/
+ ****************************************************************************/
/* Pointer to ASCII conversion */
@@ -166,31 +166,31 @@ static void postjustify(struct lib_stream_s *obj, ubyte fmt,
ubyte flags, int fieldwidth, int numwidth);
#endif
-/************************************************************
+/****************************************************************************
* Global Constant Data
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Global Variables
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Constant Data
- ************************************************************/
+ ****************************************************************************/
static const char g_nullstring[] = "(null)";
-/************************************************************
+/****************************************************************************
* Private Variables
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Functions
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Name: ptohex
- ************************************************************/
+ ****************************************************************************/
#ifdef CONFIG_PTR_IS_NOT_INT
static void ptohex(struct lib_stream_s *obj, ubyte flags, void *p)
@@ -229,9 +229,9 @@ static void ptohex(struct lib_stream_s *obj, ubyte flags, void *p)
}
}
-/************************************************************
+/****************************************************************************
* Name: getpsize
- ************************************************************/
+ ****************************************************************************/
#ifndef CONFIG_NOPRINTF_FIELDWIDTH
static int getpsize(ubyte flags, void *p)
@@ -247,9 +247,9 @@ static int getpsize(ubyte flags, void *p)
#endif /* CONFIG_NOPRINTF_FIELDWIDTH */
#endif /* CONFIG_PTR_IS_NOT_INT */
-/************************************************************
+/****************************************************************************
* Name: utodec
- ************************************************************/
+ ****************************************************************************/
static void utodec(struct lib_stream_s *obj, unsigned int n)
{
@@ -264,9 +264,9 @@ static void utodec(struct lib_stream_s *obj, unsigned int n)
obj->put(obj, (remainder + (unsigned int)'0'));
}
-/************************************************************
+/****************************************************************************
* Name: utohex
- ************************************************************/
+ ****************************************************************************/
static void utohex(struct lib_stream_s *obj, unsigned int n, ubyte a)
{
@@ -297,9 +297,9 @@ static void utohex(struct lib_stream_s *obj, unsigned int n, ubyte a)
}
}
-/************************************************************
+/****************************************************************************
* Name: utooct
- ************************************************************/
+ ****************************************************************************/
static void utooct(struct lib_stream_s *obj, unsigned int n)
{
@@ -314,9 +314,9 @@ static void utooct(struct lib_stream_s *obj, unsigned int n)
obj->put(obj, (remainder + (unsigned int)'0'));
}
-/************************************************************
+/****************************************************************************
* Name: utobin
- ************************************************************/
+ ****************************************************************************/
static void utobin(struct lib_stream_s *obj, unsigned int n)
{
@@ -331,9 +331,9 @@ static void utobin(struct lib_stream_s *obj, unsigned int n)
obj->put(obj, (remainder + (unsigned int)'0'));
}
-/************************************************************
+/****************************************************************************
* Name: lutoascii
- ************************************************************/
+ ****************************************************************************/
static void utoascii(struct lib_stream_s *obj, ubyte fmt, ubyte flags, unsigned int n)
{
@@ -442,9 +442,9 @@ static void utoascii(struct lib_stream_s *obj, ubyte fmt, ubyte flags, unsigned
}
}
-/************************************************************
+/****************************************************************************
* Name: fixup
- ************************************************************/
+ ****************************************************************************/
#ifndef CONFIG_NOPRINTF_FIELDWIDTH
static void fixup(ubyte fmt, ubyte *flags, int *n)
@@ -485,9 +485,9 @@ static void fixup(ubyte fmt, ubyte *flags, int *n)
}
}
-/************************************************************
+/****************************************************************************
* Name: getusize
- ************************************************************/
+ ****************************************************************************/
static int getusize(ubyte fmt, ubyte flags, unsigned int n)
{
@@ -500,9 +500,9 @@ static int getusize(ubyte fmt, ubyte flags, unsigned int n)
#endif /* CONFIG_NOPRINTF_FIELDWIDTH */
#ifdef CONFIG_LONG_IS_NOT_INT
-/************************************************************
+/****************************************************************************
* Name: lutodec
- ************************************************************/
+ ****************************************************************************/
static void lutodec(struct lib_stream_s *obj, unsigned long n)
{
@@ -517,9 +517,9 @@ static void lutodec(struct lib_stream_s *obj, unsigned long n)
obj->put(obj, (remainder + (unsigned int)'0'));
}
-/************************************************************
+/****************************************************************************
* Name: lutohex
- ************************************************************/
+ ****************************************************************************/
static void lutohex(struct lib_stream_s *obj, unsigned long n, ubyte a)
{
@@ -550,9 +550,9 @@ static void lutohex(struct lib_stream_s *obj, unsigned long n, ubyte a)
}
}
-/************************************************************
+/****************************************************************************
* Name: lutooct
- ************************************************************/
+ ****************************************************************************/
static void lutooct(struct lib_stream_s *obj, unsigned long n)
{
@@ -567,9 +567,9 @@ static void lutooct(struct lib_stream_s *obj, unsigned long n)
obj->put(obj, (remainder + (unsigned int)'0'));
}
-/************************************************************
+/****************************************************************************
* Name: lutobin
- ************************************************************/
+ ****************************************************************************/
static void lutobin(struct lib_stream_s *obj, unsigned long n)
{
@@ -584,9 +584,9 @@ static void lutobin(struct lib_stream_s *obj, unsigned long n)
obj->put(obj, (remainder + (unsigned int)'0'));
}
-/************************************************************
+/****************************************************************************
* Name: lutoascii
- ************************************************************/
+ ****************************************************************************/
static void lutoascii(struct lib_stream_s *obj, ubyte fmt, ubyte flags, unsigned long ln)
{
@@ -690,9 +690,9 @@ static void lutoascii(struct lib_stream_s *obj, ubyte fmt, ubyte flags, unsigned
}
}
-/************************************************************
+/****************************************************************************
* Name: lfixup
- ************************************************************/
+ ****************************************************************************/
#ifndef CONFIG_NOPRINTF_FIELDWIDTH
static void lfixup(ubyte fmt, ubyte *flags, long *ln)
@@ -733,9 +733,9 @@ static void lfixup(ubyte fmt, ubyte *flags, long *ln)
}
}
-/************************************************************
+/****************************************************************************
* Name: getlusize
- ************************************************************/
+ ****************************************************************************/
static int getlusize(ubyte fmt, ubyte flags, unsigned long ln)
{
@@ -750,9 +750,9 @@ static int getlusize(ubyte fmt, ubyte flags, unsigned long ln)
#endif /* CONFIG_LONG_IS_NOT_INT */
#ifdef CONFIG_HAVE_LONG_LONG
-/************************************************************
+/****************************************************************************
* Name: llutodec
- ************************************************************/
+ ****************************************************************************/
static void llutodec(struct lib_stream_s *obj, unsigned long long n)
{
@@ -767,9 +767,9 @@ static void llutodec(struct lib_stream_s *obj, unsigned long long n)
obj->put(obj, (remainder + (unsigned int)'0'));
}
-/************************************************************
+/****************************************************************************
* Name: llutohex
- ************************************************************/
+ ****************************************************************************/
static void llutohex(struct lib_stream_s *obj, unsigned long long n, ubyte a)
{
@@ -800,9 +800,9 @@ static void llutohex(struct lib_stream_s *obj, unsigned long long n, ubyte a)
}
}
-/************************************************************
+/****************************************************************************
* Name: llutooct
- ************************************************************/
+ ****************************************************************************/
static void llutooct(struct lib_stream_s *obj, unsigned long long n)
{
@@ -817,9 +817,9 @@ static void llutooct(struct lib_stream_s *obj, unsigned long long n)
obj->put(obj, (remainder + (unsigned int)'0'));
}
-/************************************************************
+/****************************************************************************
* Name: llutobin
- ************************************************************/
+ ****************************************************************************/
static void llutobin(struct lib_stream_s *obj, unsigned long long n)
{
@@ -834,9 +834,9 @@ static void llutobin(struct lib_stream_s *obj, unsigned long long n)
obj->put(obj, (remainder + (unsigned int)'0'));
}
-/************************************************************
+/****************************************************************************
* Name: llutoascii
- ************************************************************/
+ ****************************************************************************/
static void llutoascii(struct lib_stream_s *obj, ubyte fmt, ubyte flags, unsigned long long lln)
{
@@ -940,9 +940,9 @@ static void llutoascii(struct lib_stream_s *obj, ubyte fmt, ubyte flags, unsigne
}
}
-/************************************************************
+/****************************************************************************
* Name: llfixup
- ************************************************************/
+ ****************************************************************************/
#ifndef CONFIG_NOPRINTF_FIELDWIDTH
static void llfixup(ubyte fmt, ubyte *flags, long long *lln)
@@ -983,9 +983,9 @@ static void llfixup(ubyte fmt, ubyte *flags, long long *lln)
}
}
-/************************************************************
+/****************************************************************************
* Name: getllusize
- ************************************************************/
+ ****************************************************************************/
static int getllusize(ubyte fmt, ubyte flags, unsigned long long lln)
{
@@ -1000,9 +1000,9 @@ static int getllusize(ubyte fmt, ubyte flags, unsigned long long lln)
#endif /* CONFIG_NOPRINTF_FIELDWIDTH */
#endif /* CONFIG_HAVE_LONG_LONG */
-/************************************************************
+/****************************************************************************
* Name: prejustify
- ************************************************************/
+ ****************************************************************************/
static void prejustify(struct lib_stream_s *obj, ubyte fmt,
ubyte flags, int fieldwidth, int numwidth)
@@ -1064,9 +1064,9 @@ static void prejustify(struct lib_stream_s *obj, ubyte fmt,
}
}
-/************************************************************
+/****************************************************************************
* Name: postjustify
- ************************************************************/
+ ****************************************************************************/
static void postjustify(struct lib_stream_s *obj, ubyte fmt,
ubyte flags, int fieldwidth, int numwidth)
@@ -1095,13 +1095,13 @@ static void postjustify(struct lib_stream_s *obj, ubyte fmt,
break;
}
}
-/************************************************************
+/****************************************************************************
* Public Functions
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* lib_vsprintf
- ************************************************************/
+ ****************************************************************************/
int lib_vsprintf(struct lib_stream_s *obj, const char *src, va_list ap)
{
@@ -1465,7 +1465,9 @@ int lib_vsprintf(struct lib_stream_s *obj, const char *src, va_list ap)
else if (strchr("eEfgG", *src))
{
-#warning "No floating point support"
+#ifdef CONFIG_CPP_HAVE_WARNING
+# warning "No floating point support"
+#endif
}
}
diff --git a/nuttx/lib/lib_printf.c b/nuttx/lib/lib_printf.c
index b51365dfa..0660d22b3 100644
--- a/nuttx/lib/lib_printf.c
+++ b/nuttx/lib/lib_printf.c
@@ -1,7 +1,7 @@
-/************************************************************
+/****************************************************************************
* lib_printf.c
*
- * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
- * 3. Neither the name Gregory Nutt nor the names of its contributors may be
+ * 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -31,58 +31,58 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Compilation Switches
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Included Files
- ************************************************************/
+ ****************************************************************************/
#include <stdio.h>
#include "lib_internal.h"
-/************************************************************
+/****************************************************************************
* Definitions
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Type Declarations
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Function Prototypes
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Global Function Prototypes
- ************************************************************/
+ ****************************************************************************/
-/**********************************************************
+/**************************************************************************
* Global Constant Data
- **********************************************************/
+ **************************************************************************/
-/************************************************************
+/****************************************************************************
* Global Variables
- ************************************************************/
+ ****************************************************************************/
-/**********************************************************
+/**************************************************************************
* Private Constant Data
- **********************************************************/
+ **************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Variables
- **********************************************************/
+ **************************************************************************/
-/************************************************************
+/****************************************************************************
* Global Functions
- **********************************************************/
+ **************************************************************************/
-/************************************************************
+/****************************************************************************
* Name: printf
- **********************************************************/
+ **************************************************************************/
int printf(const char *fmt, ...)
{
@@ -97,7 +97,10 @@ int printf(const char *fmt, ...)
#elif defined(CONFIG_ARCH_LOWPUTC)
ret = lib_lowvprintf(fmt, ap);
#else
-# warning "printf has no data sink"
+# ifdef CONFIG_CPP_HAVE_WARNING
+# warning "printf has no data sink"
+# endif
+# ret = 0;
#endif
va_end(ap);
diff --git a/nuttx/lib/lib_sscanf.c b/nuttx/lib/lib_sscanf.c
index e06839f47..b02515da7 100644
--- a/nuttx/lib/lib_sscanf.c
+++ b/nuttx/lib/lib_sscanf.c
@@ -1,7 +1,7 @@
-/************************************************************
+/****************************************************************************
* lib_sscanf.c
*
- * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
- * 3. Neither the name Gregory Nutt nor the names of its contributors may be
+ * 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Included Files
- ************************************************************/
+ ****************************************************************************/
#include <nuttx/compiler.h>
#include <sys/types.h>
@@ -45,51 +45,51 @@
#include <ctype.h>
#include <debug.h>
-/************************************************************
+/****************************************************************************
* Definitions
- ************************************************************/
+ ****************************************************************************/
#define MAXLN 128
-/************************************************************
+/****************************************************************************
* Private Type Declarations
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Function Prototypes
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Global Function Prototypes
- ************************************************************/
+ ****************************************************************************/
int vsscanf(char *buf, const char *s, va_list ap);
-/**********************************************************
+/**************************************************************************
* Global Constant Data
- **********************************************************/
+ **************************************************************************/
-/************************************************************
+/****************************************************************************
* Global Variables
- ************************************************************/
+ ****************************************************************************/
-/**********************************************************
+/**************************************************************************
* Private Constant Data
- **********************************************************/
+ **************************************************************************/
static const char spaces[] = " \t\n\r\f\v";
-/************************************************************
+/****************************************************************************
* Private Variables
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Function: sscanf
*
* Description:
* ANSI standard sscanf implementation.
*
- ************************************************************/
+ ****************************************************************************/
int sscanf(const char *buf, const char *fmt, ...)
{
@@ -103,13 +103,13 @@ int sscanf(const char *buf, const char *fmt, ...)
} /* end sscanf */
-/************************************************************
+/****************************************************************************
* Function: vsscanf
*
* Description:
* ANSI standard vsscanf implementation.
*
- ************************************************************/
+ ****************************************************************************/
int vsscanf(char *buf, const char *s, va_list ap)
{
int count;
@@ -261,7 +261,9 @@ int vsscanf(char *buf, const char *s, va_list ap)
else if (*s == 'f')
{
#if 1
-# warning "No floating point conversions"
+# ifdef CONFIG_CPP_HAVE_WARNING
+# warning "No floating point conversions"
+# endif
void *pv = va_arg(ap, void*);
lvdbg("vsscanf: Return 0.0 to %p\n", pv);