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

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

commit 0f29ca849aed093711c68dd90458a1a4c358d044
Author: Marco Casaroli <[email protected]>
AuthorDate: Fri Oct 23 10:21:11 2026 +0200

    Documentation: Describe the destructors of pthread keys.
    
    The pthread_key_create() page said that the destructor argument is
    ignored.  The destructors run when a thread exits, and now again while a
    destructor sets a value, up to PTHREAD_DESTRUCTOR_ITERATIONS times.  Say
    so, and that PTHREAD_KEYS_MAX is CONFIG_TLS_NELEM, with the POSIX
    minimum of 128.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 Documentation/reference/user/08_pthread.rst | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/Documentation/reference/user/08_pthread.rst 
b/Documentation/reference/user/08_pthread.rst
index b359cf24ae5..c0924271096 100644
--- a/Documentation/reference/user/08_pthread.rst
+++ b/Documentation/reference/user/08_pthread.rst
@@ -795,7 +795,6 @@ No support for the following pthread interfaces is provided 
by NuttX:
   -  ``key`` is a pointer to the key to create.
   -  ``destructor`` is an optional destructor function that may be
      associated with each key that is invoked when a thread exits.
-     However, this argument is ignored in the current implementation.
 
   **Returned Value:**
 
@@ -813,7 +812,12 @@ No support for the following pthread interfaces is 
provided by NuttX:
   **POSIX Compatibility:** Comparable to the POSIX interface of the same
   name.
 
-  -  The present implementation ignores the ``destructor`` argument.
+  -  When a thread exits, the destructor of each key with a value that is
+     not ``NULL`` is called with that value; the value is set to ``NULL``
+     first.  If a destructor sets a value again, the destructors are
+     called again, up to ``PTHREAD_DESTRUCTOR_ITERATIONS`` (4) times.
+  -  ``PTHREAD_KEYS_MAX`` is ``CONFIG_TLS_NELEM``.  POSIX requires at
+     least ``_POSIX_THREAD_KEYS_MAX`` (128) keys.
 
 .. c:function:: int pthread_setspecific(pthread_key_t key, void *value)
 

Reply via email to