You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by je...@apache.org on 2021/11/02 08:00:18 UTC

[incubator-nuttx] branch master updated (391ccdc -> aa9c17e)

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

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


    from 391ccdc  local_socket: recv should return 0 NOT -ECONNRESET if remote closed
     new ad2f828  libc/misc: Add lib_ prefix to stream_semtake and tream_semgive
     new aa9c17e  libc: Move lib_filesem.c and lib_stream.c to libc/stdio

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:
 libs/libc/libc.h                                   |  4 +-
 libs/libc/misc/Make.defs                           | 12 +----
 libs/libc/misc/lib_streamsem.c                     | 61 ----------------------
 libs/libc/stdio/Make.defs                          |  9 +---
 libs/libc/stdio/lib_fclose.c                       |  4 +-
 .../{misc/lib_filesem.c => stdio/lib_libfilesem.c} |  2 +-
 libs/libc/stdio/lib_libflushall.c                  |  4 +-
 .../{misc/lib_stream.c => stdio/lib_libstream.c}   | 28 ++++++++--
 8 files changed, 33 insertions(+), 91 deletions(-)
 delete mode 100644 libs/libc/misc/lib_streamsem.c
 rename libs/libc/{misc/lib_filesem.c => stdio/lib_libfilesem.c} (99%)
 rename libs/libc/{misc/lib_stream.c => stdio/lib_libstream.c} (90%)

[incubator-nuttx] 02/02: libc: Move lib_filesem.c and lib_stream.c to libc/stdio

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

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

commit aa9c17e93de50272cf89f2cfa90e834955064cbe
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Oct 31 23:46:31 2021 +0800

    libc: Move lib_filesem.c and lib_stream.c to libc/stdio
    
    since it make more sense to put all FILE functions in one place
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 libs/libc/misc/Make.defs                                 | 10 ----------
 libs/libc/stdio/Make.defs                                |  9 ++-------
 libs/libc/{misc/lib_filesem.c => stdio/lib_libfilesem.c} |  2 +-
 libs/libc/{misc/lib_stream.c => stdio/lib_libstream.c}   |  2 +-
 4 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/libs/libc/misc/Make.defs b/libs/libc/misc/Make.defs
index 8d26b67..e1331fc 100644
--- a/libs/libc/misc/Make.defs
+++ b/libs/libc/misc/Make.defs
@@ -23,21 +23,11 @@
 CSRCS += lib_umask.c lib_utsname.c
 CSRCS += lib_xorshift128.c lib_tea_encrypt.c lib_tea_decrypt.c
 
-ifneq ($(CONFIG_STDIO_DISABLE_BUFFERING),y)
-CSRCS += lib_filesem.c
-endif
-
 # Support for platforms that do not have long long types
 
 CSRCS += lib_umul32.c lib_umul64.c lib_umul32x64.c
 CSRCS += lib_uadd32x64.c lib_uadd64.c lib_usub64x32.c lib_usub64.c
 
-# Add C files that depend on file OR socket descriptors
-
-ifeq ($(CONFIG_FILE_STREAM),y)
-CSRCS += lib_stream.c
-endif
-
 ifeq ($(CONFIG_PIPES),y)
 CSRCS += lib_mkfifo.c
 endif
diff --git a/libs/libc/stdio/Make.defs b/libs/libc/stdio/Make.defs
index c260544..a1ba9ec 100644
--- a/libs/libc/stdio/Make.defs
+++ b/libs/libc/stdio/Make.defs
@@ -32,11 +32,11 @@ CSRCS += lib_libsnoflush.c lib_libvsprintf.c lib_ultoa_invert.c
 ifeq ($(CONFIG_LIBC_FLOATINGPOINT),y)
 CSRCS += lib_dtoa_engine.c lib_dtoa_data.c
 endif
+CSRCS += lib_tempnam.c lib_tmpnam.c
 
 # The remaining sources files depend upon C streams
 
 ifeq ($(CONFIG_FILE_STREAM),y)
-
 CSRCS += lib_fopen.c lib_freopen.c lib_fclose.c lib_fread.c lib_libfread.c
 CSRCS += lib_fseek.c lib_fseeko.c lib_ftell.c lib_ftello.c lib_fsetpos.c
 CSRCS += lib_getdelim.c lib_fgetpos.c lib_getc.c lib_getchar.c lib_fgetc.c
@@ -49,14 +49,9 @@ 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_rewind.c lib_clearerr.c
 CSRCS += lib_scanf.c lib_vscanf.c lib_fscanf.c lib_vfscanf.c lib_tmpfile.c
-CSRCS += lib_setbuf.c lib_setvbuf.c
-
+CSRCS += lib_setbuf.c lib_setvbuf.c lib_libstream.c lib_libfilesem.c
 endif
 
-CSRCS += lib_tempnam.c lib_tmpnam.c
-
-# Other support that depends on specific, configured features.
-
 # Add the stdio directory to the build
 
 DEPPATH += --dep-path stdio
diff --git a/libs/libc/misc/lib_filesem.c b/libs/libc/stdio/lib_libfilesem.c
similarity index 99%
rename from libs/libc/misc/lib_filesem.c
rename to libs/libc/stdio/lib_libfilesem.c
index bbe63b3..a67a89d 100644
--- a/libs/libc/misc/lib_filesem.c
+++ b/libs/libc/stdio/lib_libfilesem.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * libs/libc/misc/lib_filesem.c
+ * libs/libc/stdio/lib_libfilesem.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
diff --git a/libs/libc/misc/lib_stream.c b/libs/libc/stdio/lib_libstream.c
similarity index 99%
rename from libs/libc/misc/lib_stream.c
rename to libs/libc/stdio/lib_libstream.c
index a749af0..b59bf3d 100644
--- a/libs/libc/misc/lib_stream.c
+++ b/libs/libc/stdio/lib_libstream.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * libs/libc/misc/lib_stream.c
+ * libs/libc/stdio/lib_libstream.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with

[incubator-nuttx] 01/02: libc/misc: Add lib_ prefix to stream_semtake and tream_semgive

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

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

commit ad2f82898a40c0092b65cd13453e271d3055355c
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Nov 1 12:00:39 2021 +0800

    libc/misc: Add lib_ prefix to stream_semtake and tream_semgive
    
    and merge lib_streamsem.c to lib_stream.c
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 libs/libc/libc.h                  |  4 +--
 libs/libc/misc/Make.defs          |  4 +--
 libs/libc/misc/lib_stream.c       | 26 ++++++++++++++---
 libs/libc/misc/lib_streamsem.c    | 61 ---------------------------------------
 libs/libc/stdio/lib_fclose.c      |  4 +--
 libs/libc/stdio/lib_libflushall.c |  4 +--
 6 files changed, 30 insertions(+), 73 deletions(-)

diff --git a/libs/libc/libc.h b/libs/libc/libc.h
index c80d993..28726cc 100644
--- a/libs/libc/libc.h
+++ b/libs/libc/libc.h
@@ -77,8 +77,8 @@ extern "C"
 /* Defined in lib_streamsem.c */
 
 #ifdef CONFIG_FILE_STREAM
-void  stream_semtake(FAR struct streamlist *list);
-void  stream_semgive(FAR struct streamlist *list);
+void  lib_stream_semtake(FAR struct streamlist *list);
+void  lib_stream_semgive(FAR struct streamlist *list);
 #endif
 
 /* Defined in lib_dtoa.c */
diff --git a/libs/libc/misc/Make.defs b/libs/libc/misc/Make.defs
index 859dafa..8d26b67 100644
--- a/libs/libc/misc/Make.defs
+++ b/libs/libc/misc/Make.defs
@@ -20,7 +20,7 @@
 
 # Add the internal C files to the build
 
-CSRCS += lib_stream.c lib_umask.c lib_utsname.c
+CSRCS += lib_umask.c lib_utsname.c
 CSRCS += lib_xorshift128.c lib_tea_encrypt.c lib_tea_decrypt.c
 
 ifneq ($(CONFIG_STDIO_DISABLE_BUFFERING),y)
@@ -35,7 +35,7 @@ CSRCS += lib_uadd32x64.c lib_uadd64.c lib_usub64x32.c lib_usub64.c
 # Add C files that depend on file OR socket descriptors
 
 ifeq ($(CONFIG_FILE_STREAM),y)
-CSRCS += lib_streamsem.c
+CSRCS += lib_stream.c
 endif
 
 ifeq ($(CONFIG_PIPES),y)
diff --git a/libs/libc/misc/lib_stream.c b/libs/libc/misc/lib_stream.c
index 1ba5d23..a749af0 100644
--- a/libs/libc/misc/lib_stream.c
+++ b/libs/libc/misc/lib_stream.c
@@ -52,7 +52,6 @@
  *
  ****************************************************************************/
 
-#ifdef CONFIG_FILE_STREAM
 void lib_stream_initialize(FAR struct task_group_s *group)
 {
   FAR struct streamlist *list;
@@ -80,7 +79,6 @@ void lib_stream_initialize(FAR struct task_group_s *group)
   list->sl_std[2].fs_fd = -1;
   lib_sem_initialize(&list->sl_std[2]);
 }
-#endif /* CONFIG_FILE_STREAM */
 
 /****************************************************************************
  * Name: lib_stream_release
@@ -92,7 +90,6 @@ void lib_stream_initialize(FAR struct task_group_s *group)
  *
  ****************************************************************************/
 
-#ifdef CONFIG_FILE_STREAM
 void lib_stream_release(FAR struct task_group_s *group)
 {
   FAR struct streamlist *list;
@@ -151,5 +148,26 @@ void lib_stream_release(FAR struct task_group_s *group)
 #endif
 }
 
-#endif /* CONFIG_FILE_STREAM */
 #endif /* CONFIG_BUILD_FLAT || __KERNEL__ */
+
+void lib_stream_semtake(FAR struct streamlist *list)
+{
+  int ret;
+
+  /* Take the semaphore (perhaps waiting) */
+
+  while ((ret = _SEM_WAIT(&list->sl_sem)) < 0)
+    {
+      /* The only case that an error should occr here is if
+       * the wait was awakened by a signal.
+       */
+
+      DEBUGASSERT(_SEM_ERRNO(ret) == EINTR || _SEM_ERRNO(ret) == ECANCELED);
+      UNUSED(ret);
+    }
+}
+
+void lib_stream_semgive(FAR struct streamlist *list)
+{
+  _SEM_POST(&list->sl_sem);
+}
diff --git a/libs/libc/misc/lib_streamsem.c b/libs/libc/misc/lib_streamsem.c
deleted file mode 100644
index b733353..0000000
--- a/libs/libc/misc/lib_streamsem.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
- * libs/libc/misc/lib_streamsem.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 <nuttx/config.h>
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <errno.h>
-
-#include <nuttx/semaphore.h>
-#include <nuttx/fs/fs.h>
-
-#include "libc.h"
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-void stream_semtake(FAR struct streamlist *list)
-{
-  int ret;
-
-  /* Take the semaphore (perhaps waiting) */
-
-  while ((ret = _SEM_WAIT(&list->sl_sem)) < 0)
-    {
-      /* The only case that an error should occr here is if
-       * the wait was awakened by a signal.
-       */
-
-      DEBUGASSERT(_SEM_ERRNO(ret) == EINTR || _SEM_ERRNO(ret) == ECANCELED);
-      UNUSED(ret);
-    }
-}
-
-void stream_semgive(FAR struct streamlist *list)
-{
-  _SEM_POST(&list->sl_sem);
-}
diff --git a/libs/libc/stdio/lib_fclose.c b/libs/libc/stdio/lib_fclose.c
index 0d0fad9..ac9c1d7 100644
--- a/libs/libc/stdio/lib_fclose.c
+++ b/libs/libc/stdio/lib_fclose.c
@@ -85,7 +85,7 @@ int fclose(FAR FILE *stream)
       /* Remove FILE structure from the stream list */
 
       slist = nxsched_get_streams();
-      stream_semtake(slist);
+      lib_stream_semtake(slist);
 
       for (next = slist->sl_head; next; prev = next, next = next->fs_next)
         {
@@ -109,7 +109,7 @@ int fclose(FAR FILE *stream)
             }
         }
 
-      stream_semgive(slist);
+      lib_stream_semgive(slist);
 
       /* Check that the underlying file descriptor corresponds to an an open
        * file.
diff --git a/libs/libc/stdio/lib_libflushall.c b/libs/libc/stdio/lib_libflushall.c
index 0a6b707..4dffbff 100644
--- a/libs/libc/stdio/lib_libflushall.c
+++ b/libs/libc/stdio/lib_libflushall.c
@@ -58,7 +58,7 @@ int lib_flushall(FAR struct streamlist *list)
 
       /* Process each stream in the thread's stream list */
 
-      stream_semtake(list);
+      lib_stream_semtake(list);
       stream = list->sl_head;
       for (; stream != NULL; stream = stream->fs_next)
         {
@@ -83,7 +83,7 @@ int lib_flushall(FAR struct streamlist *list)
             }
         }
 
-      stream_semgive(list);
+      lib_stream_semgive(list);
     }
 
   /* If any flush failed, return the errorcode of the last failed flush */