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 73213750d1bb0235b96d3509dcdd85793a8ff6fc
Author: Marco Casaroli <[email protected]>
AuthorDate: Wed Oct 28 00:34:03 2026 +0100

    include/unistd.h: Hide crypt_r() with NUTTX_NO_EXTENSIONS.
    
    The crypt_r() of NuttX writes the hash to a buffer of the caller, its
    third argument.  glibc and libxcrypt have crypt_r(key, salt, FAR struct
    crypt_data *) in <crypt.h>.  A program that includes <crypt.h> of
    libxcrypt and <unistd.h> did not compile: the two declarations conflict
    (for example perl, with libxcrypt for crypt()).
    
    With NUTTX_NO_EXTENSIONS, unistd.h does not declare the NuttX crypt_r(),
    as for the other NuttX names that this macro hides.  crypt() does not
    change.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 include/nuttx/compiler.h | 10 +++++-----
 include/unistd.h         |  9 +++++++++
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h
index 495973df3bc..dfc63bd4fd9 100644
--- a/include/nuttx/compiler.h
+++ b/include/nuttx/compiler.h
@@ -1622,11 +1622,11 @@
  * (errno.h), zalloc() (stdlib.h), O_TEXT and O_BINARY (fcntl.h), utimens()
  * and lutimens() (sys/stat.h), the file system types *_MAGIC
  * (sys/statfs.h), PANIC(), PANIC_WITH_REGS(), ASSERT(), VERIFY(),
- * COMPILE_TIME_ASSERT() and BUILD_BUG_ON_ZERO() (assert.h) and the helper
- * macros of this file below, such as memory_barrier() and UNUSED().  The
- * headers that a program includes do not use these names.  A definition
- * that the program made before is restored (saved at the start of this
- * file).
+ * COMPILE_TIME_ASSERT() and BUILD_BUG_ON_ZERO() (assert.h), crypt_r()
+ * (unistd.h) and the helper macros of this file below, such as
+ * memory_barrier() and UNUSED().  The headers that a program includes do
+ * not use these names.  A definition that the program made before is
+ * restored (saved at the start of this file).
  */
 
 #ifdef NUTTX_NO_EXTENSIONS
diff --git a/include/unistd.h b/include/unistd.h
index 37f9cbb5cb1..c9bd9b37699 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -548,9 +548,18 @@ int     profil(FAR unsigned short *buf, size_t bufsiz,
 FAR char *getpass(FAR const char *prompt);
 #ifdef CONFIG_CRYPTO
 FAR char *crypt(FAR const char *key, FAR const char *salt);
+
+/* NuttX's crypt_r() writes to a buffer of the caller.  glibc and
+ * libxcrypt have crypt_r(key, salt, FAR struct crypt_data *) in
+ * <crypt.h>: with NUTTX_NO_EXTENSIONS this declaration is left out, so
+ * that theirs can be used.
+ */
+
+#ifndef NUTTX_NO_EXTENSIONS /* See nuttx/compiler.h */
 FAR char *crypt_r(FAR const char *key, FAR const char *salt,
                   FAR char *output);
 #endif
+#endif
 
 #if CONFIG_FORTIFY_SOURCE > 0
 fortify_function(getcwd) FAR char *getcwd(FAR char *buf,

Reply via email to