pthread: Add len argument to pthread_getname_np

follow the spec:
https://man7.org/linux/man-pages/man3/pthread_setname_np.3.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2022-02-05 17:06:51 +08:00
committed by Petro Karashchenko
parent 202b8141a6
commit 4ee5ff81dd
4 changed files with 120 additions and 14 deletions
+5 -14
View File
@@ -29,8 +29,6 @@
#include <nuttx/compiler.h> /* Compiler settings, noreturn_function */
#include <sys/types.h> /* Needed for general types */
#include <sys/prctl.h> /* Needed by pthread_[set|get]name_np */
#include <stdint.h> /* C99 fixed width integer types */
#include <stdbool.h> /* C99 boolean types */
#include <unistd.h> /* For getpid */
@@ -188,18 +186,6 @@
#define _PTHREAD_MFLAGS_INCONSISTENT (1 << 1) /* Mutex is in an inconsistent state */
#define _PTHREAD_MFLAGS_NRECOVERABLE (1 << 2) /* Inconsistent mutex has been unlocked */
/* Definitions to map some non-standard, BSD thread management interfaces to
* the non-standard Linux-like prctl() interface. Since these are simple
* mappings to prctl, they will return 0 on success and -1 on failure with the
* error number in errno. This is an inconsistency with the pthread interfaces.
*/
#define pthread_setname_np(thread, name) \
prctl((int)PR_SET_NAME_EXT, (char*)name, (int)thread)
#define pthread_getname_np(thread, name) \
prctl((int)PR_GET_NAME_EXT, (char*)name, (int)thread)
/********************************************************************************
* Public Type Definitions
********************************************************************************/
@@ -484,6 +470,11 @@ int pthread_attr_setstack(FAR pthread_attr_t *attr,
int pthread_attr_getstack(FAR pthread_attr_t *attr,
FAR void **stackaddr, FAR long *stacksize);
/* Set or get the name of a thread */
int pthread_setname_np(pthread_t thread, FAR const char *name);
int pthread_getname_np(pthread_t thread, FAR char *name, size_t len);
/* Get run-time stack address and size */
FAR void *pthread_get_stackaddr_np(pthread_t thread);