You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/06/03 13:36:20 UTC

[incubator-nuttx] branch master updated (d05cca0 -> 29f9d97)

This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from d05cca0  boards/mips: restore OUTPUT_FORMAT and OUTPUT_ARCH for mips link scripts
     new a55f8d2  libc: Implement vscanf() function
     new 29f9d97  libc: Call vdprintf in printf/vprintf for CONFIG_NFILE_STREAMS == 0

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 include/stdio.h                                    |  3 ++-
 libs/libc/libc.csv                                 | 29 +++++++++++-----------
 libs/libc/stdio/Make.defs                          |  2 +-
 libs/libc/stdio/lib_printf.c                       | 12 ++-------
 libs/libc/stdio/lib_vprintf.c                      |  5 ++--
 .../libc/stdio/lib_vscanf.c                        | 15 ++++++-----
 libs/libc/stdio/lib_vsscanf.c                      |  3 +--
 7 files changed, 30 insertions(+), 39 deletions(-)
 copy arch/risc-v/src/litex/litex_allocateheap.c => libs/libc/stdio/lib_vscanf.c (89%)


[incubator-nuttx] 02/02: libc: Call vdprintf in printf/vprintf for CONFIG_NFILE_STREAMS == 0

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 29f9d9742029cc11c87e1d84782c8beef0ad0445
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Wed Jun 3 02:46:05 2020 +0800

    libc: Call vdprintf in printf/vprintf for CONFIG_NFILE_STREAMS == 0
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Change-Id: I3c49ec02a9444f039ac7aac7b8ea6de5d1090340
---
 libs/libc/libc.csv            |  2 +-
 libs/libc/stdio/lib_printf.c  | 12 ++----------
 libs/libc/stdio/lib_vprintf.c |  5 ++---
 3 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/libs/libc/libc.csv b/libs/libc/libc.csv
index 3700207..d10d3c2 100644
--- a/libs/libc/libc.csv
+++ b/libs/libc/libc.csv
@@ -214,7 +214,7 @@
 "usleep","unistd.h","","int","useconds_t"
 "vasprintf","stdio.h","","int","FAR char **","FAR const IPTR char *","va_list"
 "vfprintf","stdio.h","CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","FAR const IPTR char *","va_list"
-"vprintf","stdio.h","CONFIG_NFILE_STREAMS > 0","int","FAR const IPTR char *","va_list"
+"vprintf","stdio.h","","int","FAR const IPTR char *","va_list"
 "vscanf","stdio.h","CONFIG_NFILE_STREAMS > 0","int","FAR const IPTR char *","va_list"
 "vsnprintf","stdio.h","","int","FAR char *","size_t","FAR const IPTR char *","va_list"
 "vsprintf","stdio.h","","int","FAR char *","FAR const IPTR char *","va_list"
diff --git a/libs/libc/stdio/lib_printf.c b/libs/libc/stdio/lib_printf.c
index 9bb7ac4..6dd02df 100644
--- a/libs/libc/stdio/lib_printf.c
+++ b/libs/libc/stdio/lib_printf.c
@@ -39,11 +39,7 @@
  ****************************************************************************/
 
 #include <stdio.h>
-#include <syslog.h>
-
-#include <nuttx/syslog/syslog.h>
-
-#include "libc.h"
+#include <unistd.h>
 
 /****************************************************************************
  * Public Functions
@@ -59,11 +55,7 @@ int printf(FAR const IPTR char *fmt, ...)
   int     ret;
 
   va_start(ap, fmt);
-#if CONFIG_NFILE_STREAMS > 0
-  ret = vfprintf(stdout, fmt, ap);
-#else
-  ret = nx_vsyslog(LOG_INFO, fmt, &ap);
-#endif
+  ret = vdprintf(STDOUT_FILENO, fmt, ap);
   va_end(ap);
 
   return ret;
diff --git a/libs/libc/stdio/lib_vprintf.c b/libs/libc/stdio/lib_vprintf.c
index 218b359..52a6761 100644
--- a/libs/libc/stdio/lib_vprintf.c
+++ b/libs/libc/stdio/lib_vprintf.c
@@ -38,6 +38,7 @@
  ****************************************************************************/
 
 #include <stdio.h>
+#include <unistd.h>
 
 /****************************************************************************
  * Public Functions
@@ -49,7 +50,5 @@
 
 int vprintf(FAR const IPTR char *fmt, va_list ap)
 {
-  /* vfprintf into stdout */
-
-  return vfprintf(stdout, fmt, ap);
+  return vdprintf(STDOUT_FILENO, fmt, ap);
 }


[incubator-nuttx] 01/02: libc: Implement vscanf() function

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit a55f8d24a20e4684c68ce6f65b69d47e28b0ec18
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue Jun 2 23:28:28 2020 +0800

    libc: Implement vscanf() function
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Change-Id: I2421e57b2c848c43afb749b8ebfa79ec457cde26
---
 include/stdio.h               |  3 ++-
 libs/libc/libc.csv            | 29 +++++++++++++++--------------
 libs/libc/stdio/Make.defs     |  2 +-
 libs/libc/stdio/lib_vscanf.c  | 40 ++++++++++++++++++++++++++++++++++++++++
 libs/libc/stdio/lib_vsscanf.c |  3 +--
 5 files changed, 59 insertions(+), 18 deletions(-)

diff --git a/include/stdio.h b/include/stdio.h
index b228fcd..5931ac9 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -192,10 +192,11 @@ int    vfprintf(FAR FILE *stream, FAR const IPTR char *fmt,
          va_list ap);
 int    vfscanf(FAR FILE *stream, FAR const IPTR char *fmt, va_list ap);
 int    vprintf(FAR const IPTR char *fmt, va_list ap);
+int    vscanf(FAR const IPTR char *fmt, va_list ap);
 int    vsnprintf(FAR char *buf, size_t size, FAR const IPTR char *fmt,
          va_list ap);
 int    vsprintf(FAR char *buf, FAR const IPTR char *fmt, va_list ap);
-int    vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap);
+int    vsscanf(FAR const char *buf, FAR const IPTR char *fmt, va_list ap);
 
 /* Operations on file descriptors including:
  *
diff --git a/libs/libc/libc.csv b/libs/libc/libc.csv
index f1f6375..3700207 100644
--- a/libs/libc/libc.csv
+++ b/libs/libc/libc.csv
@@ -9,7 +9,7 @@
 "aio_return","aio.h","defined(CONFIG_FS_AIO)","ssize_t","FAR struct aiocb *"
 "aio_suspend","aio.h","defined(CONFIG_FS_AIO)","int","FAR const struct aiocb * const []|FAR const struct aiocb * const *","int","FAR const struct timespec *"
 "alarm","unistd.h","!defined(CONFIG_DISABLE_POSIX_TIMERS)","unsigned int","unsigned int"
-"asprintf","stdio.h","","int","FAR char **","FAR const char *","..."
+"asprintf","stdio.h","","int","FAR char **","FAR const IPTR char *","..."
 "b16atan2","fixedmath.h","!defined(CONFIG_HAVE_LONG_LONG)","b16_t","b16_t","b16_t"
 "b16cos","fixedmath.h","","b16_t","b16_t"
 "b16divb16","fixedmath.h","!defined(CONFIG_HAVE_LONG_LONG)","b16_t","b16_t","b16_t"
@@ -42,7 +42,7 @@
 "fgets","stdio.h","CONFIG_NFILE_STREAMS > 0","FAR char *","FAR char *","int","FAR FILE *"
 "fileno","stdio.h","","int","FAR FILE *"
 "fopen","stdio.h","CONFIG_NFILE_STREAMS > 0","FAR FILE *","FAR const char *","FAR const char *"
-"fprintf","stdio.h","CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","FAR const char *","..."
+"fprintf","stdio.h","CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","FAR const IPTR char *","..."
 "fputc","stdio.h","CONFIG_NFILE_STREAMS > 0","int","int","FAR FILE *"
 "fputs","stdio.h","CONFIG_NFILE_STREAMS > 0","int","FAR const char *","FAR FILE *"
 "fread","stdio.h","CONFIG_NFILE_STREAMS > 0","size_t","FAR void *","size_t","size_t","FAR FILE *"
@@ -105,7 +105,7 @@
 "ntohs","arpa/inet.h","","uint16_t","uint16_t"
 "perror","stdio.h","CONFIG_NFILE_STREAMS > 0","void","FAR const char *"
 "pipe","unistd.h","","int","int [2]|FAR int *"
-"printf","stdio.h","","int","FAR const char *","..."
+"printf","stdio.h","","int","FAR const IPTR char *","..."
 "pthread_attr_destroy","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_attr_t *"
 "pthread_attr_getinheritsched","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR const pthread_attr_t *","FAR int *"
 "pthread_attr_getschedparam","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR const pthread_attr_t *","FAR struct sched_param *"
@@ -155,8 +155,8 @@
 "sigfillset","signal.h","","int","FAR sigset_t *"
 "sigismember","signal.h","","int","FAR const sigset_t *","int"
 "sleep","unistd.h","","unsigned int","unsigned int"
-"snprintf","stdio.h","","int","FAR char *","size_t","FAR const char *","..."
-"sprintf","stdio.h","","int","FAR char *","FAR const char *","..."
+"snprintf","stdio.h","","int","FAR char *","size_t","FAR const IPTR char *","..."
+"sprintf","stdio.h","","int","FAR char *","FAR const IPTR char *","..."
 "sq_addafter","queue.h","","void","FAR sq_entry_t *","FAR sq_entry_t *","FAR sq_queue_t *"
 "sq_addfirst","queue.h","","void","FAR sq_entry_t *","FAR sq_queue_t *"
 "sq_addlast","queue.h","","void","FAR sq_entry_t *","FAR sq_queue_t *"
@@ -165,7 +165,7 @@
 "sq_remfirst","queue.h","","FAR sq_entry_t *","FAR sq_queue_t *"
 "sq_remlast","queue.h","","FAR sq_entry_t *","FAR sq_queue_t *"
 "srand","stdlib.h","","void","unsigned int"
-"sscanf","stdio.h","","int","FAR const char *","FAR const char *","..."
+"sscanf","stdio.h","","int","FAR const IPTR char *","FAR const char *","..."
 "strcasecmp","strings.h","","int","FAR const char *","FAR const char *"
 "strcasestr","string.h","","FAR char *","FAR const char *","FAR const char *"
 "strcat","string.h","","FAR char *","FAR char *","FAR const char *"
@@ -199,7 +199,7 @@
 "strxfrm","string.h","defined(CONFIG_LIBC_LOCALE)","size_t","FAR char *","FAR const char *","size_t"
 "swab","unistd.h","","void","FAR const void *","FAR void *","ssize_t"
 "swprintf","wchar.h","defined(CONFIG_LIBC_WCHAR)","int","FAR wchar_t *","size_t","FAR const wchar_t *","..."
-"syslog","syslog.h","","void","int","FAR const char *","..."
+"syslog","syslog.h","","void","int","FAR const IPTR char *","..."
 "tcflush","termios.h","defined(CONFIG_SERIAL_TERMIOS)","int","int","int"
 "tcgetattr","termios.h","defined(CONFIG_SERIAL_TERMIOS)","int","int","FAR struct termios *"
 "tcsetattr","termios.h","defined(CONFIG_SERIAL_TERMIOS)","int","int","int","FAR const struct termios *"
@@ -212,13 +212,14 @@
 "ub16sqr","fixedmath.h","!defined(CONFIG_HAVE_LONG_LONG)","ub16_t","ub16_t"
 "ungetc","stdio.h","CONFIG_NFILE_STREAMS > 0","int","int","FAR FILE *"
 "usleep","unistd.h","","int","useconds_t"
-"vasprintf","stdio.h","","int","FAR char **","FAR const char *","va_list"
-"vfprintf","stdio.h","CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","FAR const char *","va_list"
-"vprintf","stdio.h","CONFIG_NFILE_STREAMS > 0","int","FAR const char *","va_list"
-"vsnprintf","stdio.h","","int","FAR char *","size_t","FAR const char *","va_list"
-"vsprintf","stdio.h","","int","FAR char *","FAR const char *","va_list"
-"vsscanf","stdio.h","","int","FAR const char *","FAR const char *","va_list"
-"vsyslog","syslog.h","","void","int","FAR const char *","va_list"
+"vasprintf","stdio.h","","int","FAR char **","FAR const IPTR char *","va_list"
+"vfprintf","stdio.h","CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","FAR const IPTR char *","va_list"
+"vprintf","stdio.h","CONFIG_NFILE_STREAMS > 0","int","FAR const IPTR char *","va_list"
+"vscanf","stdio.h","CONFIG_NFILE_STREAMS > 0","int","FAR const IPTR char *","va_list"
+"vsnprintf","stdio.h","","int","FAR char *","size_t","FAR const IPTR char *","va_list"
+"vsprintf","stdio.h","","int","FAR char *","FAR const IPTR char *","va_list"
+"vsscanf","stdio.h","","int","FAR const char *","FAR const IPTR char *","va_list"
+"vsyslog","syslog.h","","void","int","FAR const IPTR char *","va_list"
 "wcrtomb","wchar.h","defined(CONFIG_LIBC_WCHAR)","size_t","FAR char *","wchar_t","FAR mbstate_t *"
 "wcscmp","wchar.h","defined(CONFIG_LIBC_WCHAR)","int","FAR const wchar_t *","FAR const wchar_t *"
 "wcscoll","wchar.h","defined(CONFIG_LIBC_WCHAR)","int","FAR const wchar_t *","FAR const wchar_t *"
diff --git a/libs/libc/stdio/Make.defs b/libs/libc/stdio/Make.defs
index e00af30..5af1ae7 100644
--- a/libs/libc/stdio/Make.defs
+++ b/libs/libc/stdio/Make.defs
@@ -60,7 +60,7 @@ CSRCS += lib_stdinstream.c lib_stdoutstream.c lib_stdsistream.c
 CSRCS += lib_stdsostream.c lib_perror.c lib_feof.c lib_ferror.c
 CSRCS += lib_rawinstream.c lib_rawoutstream.c lib_rawsistream.c
 CSRCS += lib_rawsostream.c lib_remove.c lib_clearerr.c lib_scanf.c
-CSRCS += lib_fscanf.c lib_vfscanf.c lib_tmpfile.c
+CSRCS += lib_vscanf.c lib_fscanf.c lib_vfscanf.c lib_tmpfile.c
 
 endif
 
diff --git a/libs/libc/stdio/lib_vscanf.c b/libs/libc/stdio/lib_vscanf.c
new file mode 100644
index 0000000..bd49105
--- /dev/null
+++ b/libs/libc/stdio/lib_vscanf.c
@@ -0,0 +1,40 @@
+/****************************************************************************
+ * libs/libc/stdio/lib_vscanf.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdio.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: vscanf
+ ****************************************************************************/
+
+int vscanf(FAR const IPTR char *fmt, va_list ap)
+{
+  /* vfscanf from stdin */
+
+  return vfscanf(stdin, fmt, ap);
+}
diff --git a/libs/libc/stdio/lib_vsscanf.c b/libs/libc/stdio/lib_vsscanf.c
index 979a019..80187ce 100644
--- a/libs/libc/stdio/lib_vsscanf.c
+++ b/libs/libc/stdio/lib_vsscanf.c
@@ -53,7 +53,7 @@
  * Name: vsscanf
  ****************************************************************************/
 
-int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
+int vsscanf(FAR const char *buf, FAR const IPTR char *fmt, va_list ap)
 {
   struct lib_meminstream_s meminstream;
   int n;
@@ -65,7 +65,6 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
 
   /* Then let lib_vscanf do the real work */
 
-
   n = lib_vscanf((FAR struct lib_instream_s *)&meminstream.public, NULL,
                   fmt, ap);
   return n;