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

(nuttx) branch master updated (5c2fae25338 -> df2baff1b85)

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

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


    from 5c2fae25338 syscall: Add pause() to the system call table.
     new 4fe3305f143 libs/libc/stdio: Add ctermid().
     new df2baff1b85 Documentation: Mark ctermid() as supported.

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:
 Documentation/reference/user/10_filesystem.rst     |  4 ++
 Documentation/standards/posix.rst                  |  2 +-
 include/cxx/cstdio                                 |  4 ++
 include/stdio.h                                    |  8 ++++
 libs/libc/libc.csv                                 |  1 +
 libs/libc/stdio/CMakeLists.txt                     |  3 +-
 libs/libc/stdio/Make.defs                          |  2 +-
 .../libc/stdio/lib_ctermid.c                       | 56 +++++++++++-----------
 8 files changed, 48 insertions(+), 32 deletions(-)
 copy boards/risc-v/esp32p4/common/include/esp_board_mmcsd.h => libs/libc/stdio/lib_ctermid.c (68%)


(nuttx) 01/02: libs/libc/stdio: Add ctermid().

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

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

commit 4fe3305f14390dd38ad701ae5a7a1384a311b428
Author: Marco Casaroli <ma...@gmail.com>
AuthorDate: Sat Oct 17 19:51:50 2026 +0200

    libs/libc/stdio: Add ctermid().
    
    POSIX declares ctermid() and L_ctermid in <stdio.h>, but NuttX did
    not have them.  Programs that open the controlling terminal with
    ctermid() did not link.
    
    This commit adds ctermid().  It returns "/dev/console", the terminal
    of every task on NuttX.  The function copies the path into the buffer
    of the caller, or into a static buffer when the argument is NULL.
    L_ctermid gives the size of the buffer.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <ma...@gmail.com>
---
 include/cxx/cstdio             |  4 +++
 include/stdio.h                |  8 +++++
 libs/libc/libc.csv             |  1 +
 libs/libc/stdio/CMakeLists.txt |  3 +-
 libs/libc/stdio/Make.defs      |  2 +-
 libs/libc/stdio/lib_ctermid.c  | 74 ++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 90 insertions(+), 2 deletions(-)

diff --git a/include/cxx/cstdio b/include/cxx/cstdio
index 93d06254b0e..459a4f20463 100644
--- a/include/cxx/cstdio
+++ b/include/cxx/cstdio
@@ -95,6 +95,10 @@ namespace std
   using ::tmpnam;
   using ::tempnam;
   using ::remove;
+
+  // Controlling terminal
+
+  using ::ctermid;
 }
 
 #endif // __INCLUDE_CXX_CSTDIO
diff --git a/include/stdio.h b/include/stdio.h
index 0311f96bffb..00487311ee9 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -101,6 +101,10 @@
 
 #define L_tmpnam   CONFIG_LIBC_MAX_TMPFILE
 
+/* Size of character array to hold ctermid() output: "/dev/console" */
+
+#define L_ctermid  13
+
 /* The maximum number of unique temporary file names that can be generated */
 
 #define TMP_MAX 308915776
@@ -367,6 +371,10 @@ FAR char *tmpnam(FAR char *s);
 FAR char *tempnam(FAR const char *dir, FAR const char *pfx) malloc_like;
 int       remove(FAR const char *path);
 
+/* Controlling terminal */
+
+FAR char *ctermid(FAR char *s);
+
 /* Shell operations.  These are not actually implemented in the OS.  See
  * apps/system/popen for implementation.
  */
diff --git a/libs/libc/libc.csv b/libs/libc/libc.csv
index da894be284f..1cceb425198 100644
--- a/libs/libc/libc.csv
+++ b/libs/libc/libc.csv
@@ -37,6 +37,7 @@
 "closedir","dirent.h","","int","DIR *"
 "crc32","nuttx/crc32.h","","uint32_t","FAR const uint8_t *","size_t"
 "crc32part","nuttx/crc32.h","","uint32_t","FAR const uint8_t *","size_t","uint32_t"
+"ctermid","stdio.h","","FAR char *","FAR char *"
 "ctime","time.h","","char *","const time_t *"
 "crypt","unistd.h","defined(CONFIG_CRYPTO)","FAR const char *","FAR const char *"
 "crypt_r","unistd.h","defined(CONFIG_CRYPTO)","FAR const char *","FAR const char *","FAR char *"
diff --git a/libs/libc/stdio/CMakeLists.txt b/libs/libc/stdio/CMakeLists.txt
index 8d2982192aa..47acb2cde28 100644
--- a/libs/libc/stdio/CMakeLists.txt
+++ b/libs/libc/stdio/CMakeLists.txt
@@ -47,7 +47,8 @@ set(SRCS
     lib_tempnam.c
     lib_tmpnam.c
     lib_renameat.c
-    lib_putwchar.c)
+    lib_putwchar.c
+    lib_ctermid.c)
 
 # The remaining sources files depend upon C streams
 
diff --git a/libs/libc/stdio/Make.defs b/libs/libc/stdio/Make.defs
index af412a2c915..99bdca23818 100644
--- a/libs/libc/stdio/Make.defs
+++ b/libs/libc/stdio/Make.defs
@@ -29,7 +29,7 @@ CSRCS += lib_vsnprintf.c lib_dprintf.c lib_vdprintf.c lib_vprintf.c
 CSRCS += lib_perror.c lib_putchar.c lib_getchar.c lib_puts.c
 CSRCS += lib_gets_s.c lib_gets.c lib_libdgets.c lib_sscanf.c
 CSRCS += lib_vsscanf.c lib_remove.c lib_tempnam.c lib_tmpnam.c
-CSRCS += lib_renameat.c lib_putwchar.c
+CSRCS += lib_renameat.c lib_putwchar.c lib_ctermid.c
 
 # The remaining sources files depend upon C streams
 
diff --git a/libs/libc/stdio/lib_ctermid.c b/libs/libc/stdio/lib_ctermid.c
new file mode 100644
index 00000000000..d4aafe631e2
--- /dev/null
+++ b/libs/libc/stdio/lib_ctermid.c
@@ -0,0 +1,74 @@
+/****************************************************************************
+ * libs/libc/stdio/lib_ctermid.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * 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 <stdio.h>
+#include <string.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* The controlling terminal of every task.  L_ctermid in stdio.h is the
+ * size of this string.
+ */
+
+#define CTERMID_PATH "/dev/console"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: ctermid
+ *
+ * Description:
+ *   The ctermid() function generates a string that is the pathname of the
+ *   controlling terminal of the current process.  On NuttX this is always
+ *   the system console.
+ *
+ *   If s is a null pointer, ctermid() writes the string into an internal
+ *   static object and returns a pointer to it.  Otherwise s must point to
+ *   an array of at least L_ctermid bytes; ctermid() writes the string into
+ *   that array and returns s.
+ *
+ * Returned Value:
+ *   A pointer to the pathname of the controlling terminal.
+ *
+ ****************************************************************************/
+
+FAR char *ctermid(FAR char *s)
+{
+  static char path[sizeof(CTERMID_PATH)];
+
+  if (s == NULL)
+    {
+      s = path;
+    }
+
+  return strcpy(s, CTERMID_PATH);
+}


(nuttx) 02/02: Documentation: Mark ctermid() as supported.

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

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

commit df2baff1b855fb8335a8cd913c18c374e26bb61e
Author: Marco Casaroli <ma...@gmail.com>
AuthorDate: Sat Oct 17 19:51:51 2026 +0200

    Documentation: Mark ctermid() as supported.
    
    ctermid() is now in libc.  Mark it as supported in the POSIX table
    and add it to the list of stdio interfaces.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <ma...@gmail.com>
---
 Documentation/reference/user/10_filesystem.rst | 4 ++++
 Documentation/standards/posix.rst              | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/reference/user/10_filesystem.rst b/Documentation/reference/user/10_filesystem.rst
index 4cc5627d433..1cf5439b198 100644
--- a/Documentation/reference/user/10_filesystem.rst
+++ b/Documentation/reference/user/10_filesystem.rst
@@ -326,6 +326,10 @@ Standard I/O
   FAR char *tempnam(FAR const char *dir, FAR const char *pfx);
   int       remove(FAR const char *path);
 
+  /* Controlling terminal */
+
+  FAR char *ctermid(FAR char *s);
+
   #include <sys/stat.h>
 
   int mkdir(FAR const char *pathname, mode_t mode);
diff --git a/Documentation/standards/posix.rst b/Documentation/standards/posix.rst
index 580c999b1ec..4e3d3ac034c 100644
--- a/Documentation/standards/posix.rst
+++ b/Documentation/standards/posix.rst
@@ -1783,7 +1783,7 @@ General Terminal:
 +--------------------------------+---------+
 | :c:func:`cfsetospeed`          | Yes     |
 +--------------------------------+---------+
-| ctermid()                      | No      |
+| ctermid()                      | Yes     |
 +--------------------------------+---------+
 | :c:func:`isatty`               | Yes     |
 +--------------------------------+---------+