From: Justin Cinkelj <justin.cink...@xlab.si>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master
libc: add pthread_gettid_np to get thread ID of arbitrary pthread_t
The added pthread_gettid_np is not portable, and differs even from
pthread_getthreadid_np (that one works for current thread only).
Signed-off-by: Justin Cinkelj <justin.cink...@xlab.si>
Message-Id: <20170131213644.23637-2-justin.cink...@xlab.si>
---
diff --git a/include/api/pthread.h b/include/api/pthread.h
--- a/include/api/pthread.h
+++ b/include/api/pthread.h
@@ -217,6 +217,7 @@ 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 *);
int pthread_getaffinity_np(pthread_t, size_t, cpu_set_t *);
+pid_t pthread_gettid_np(pthread_t);
#endif
#ifdef __cplusplus
diff --git a/libc/pthread.cc b/libc/pthread.cc
--- a/libc/pthread.cc
+++ b/libc/pthread.cc
@@ -975,6 +975,11 @@ int pthread_getname_np(pthread_t p, char* name, size_t
namelen)
return 0;
}
+pid_t pthread_gettid_np(pthread_t p)
+{
+ return pthread::from_libc(p)->_thread->id();
+}
+
int pthread_attr_setaffinity_np(pthread_attr_t *attr, size_t cpusetsize,
const cpu_set_t *cpuset)
{
--
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 osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.