Signed-off-by: Rick Payne <[email protected]>
---
 include/api/pthread.h | 1 +
 libc/pthread.cc       | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/include/api/pthread.h b/include/api/pthread.h
index 85743f7..105e8d4 100644
--- a/include/api/pthread.h
+++ b/include/api/pthread.h
@@ -212,6 +212,7 @@ void _pthread_cleanup_pop(struct __ptcb *, int);
 #ifdef _GNU_SOURCE
 int pthread_getattr_np(pthread_t, pthread_attr_t *);
 int pthread_setname_np(pthread_t pthread, const char* name);
+int pthread_getname_np(pthread_t pthread, char* name, size_t namelen);
 int pthread_attr_setaffinity_np(pthread_attr_t *, size_t, const cpu_set_t *);
 int pthread_attr_getaffinity_np(const pthread_attr_t *, size_t, cpu_set_t *);
 int pthread_setaffinity_np(pthread_t, size_t, const cpu_set_t *);
diff --git a/libc/pthread.cc b/libc/pthread.cc
index 148b79e..a2b9292 100644
--- a/libc/pthread.cc
+++ b/libc/pthread.cc
@@ -968,6 +968,13 @@ int pthread_setname_np(pthread_t p, const char* name)
     return 0;
 }
 
+int pthread_getname_np(pthread_t p, char* name, size_t namelen)
+{
+  strncpy(name, pthread::from_libc(p)->_thread->name().c_str(), namelen);
+  name[namelen-1] = 0;
+  return 0;
+}
+
 int pthread_attr_setaffinity_np(pthread_attr_t *attr, size_t cpusetsize,
         const cpu_set_t *cpuset)
 {
-- 
2.9.3

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to