On 08/21/2016 03:15 PM, Nadav Har'El wrote:
Hi Justin,
On Tue, Aug 16, 2016 at 9:50 AM, Justin Cinkelj
<justin.cink...@xlab.si <mailto:justin.cink...@xlab.si>> wrote:
pthread_getid is only a convience function to convert pthread_t to
corresponding thread ID. It is added here to avoid manually casting
pthread_t to osv::pthread at other places.
Signed-off-by: Justin Cinkelj <justin.cink...@xlab.si
<mailto:justin.cink...@xlab.si>>
---
include/api/pthread.h | 2 ++
libc/pthread.cc | 4 ++++
2 files changed, 6 insertions(+)
diff --git a/include/api/pthread.h b/include/api/pthread.h
index 85743f7..ac5e203 100644
--- a/include/api/pthread.h
+++ b/include/api/pthread.h
@@ -95,6 +95,8 @@ int pthread_getschedparam(pthread_t, int
*__restrict, struct sched_param *__rest
int pthread_setschedparam(pthread_t, int, const struct
sched_param *);
int pthread_setschedprio(pthread_t, int);
+pid_t pthread_getid(pthread_t);
The "include/api/pthread.h" is supposed to be compatible with Linux's
/usr/include/pthread.h - not to add new OSv-specific stuff. (all of
the "api/" header files are supposed to be like that).
We also have a private libc/pthread.hh (which we already include in
pthread.cc) - so maybe we should define the new function there?
Also the name "pthread_getid" might suggest to a reader that this is
an official POSIX threads function. Perhaps we should choose a name
like pthread_gettid_np() (similar to gettid() just for a specific
pthread) - to emphasize that this is a non-posix function?
_np for non-portable - just asked google about that :). I fully agree
that name looks as std posix function, while it is not); I just wasn't
sure how to name the function, or where to put it.
+
int pthread_once(pthread_once_t *, void (*)(void));
int pthread_mutex_init(pthread_mutex_t *__restrict, const
pthread_mutexattr_t *__restrict);
diff --git a/libc/pthread.cc b/libc/pthread.cc
index ac7b3f0..dce6375 100644
--- a/libc/pthread.cc
+++ b/libc/pthread.cc
@@ -258,6 +258,10 @@ extern "C" {
__attribute__((alias("pthread_key_create")));
}
+pid_t pthread_getid(pthread_t thread)
+{
+ return pthread::from_libc(thread)->_thread.id
<http://thread.id>();
+}
int pthread_key_delete(pthread_key_t key)
{
--
2.5.5
--
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
<mailto:osv-dev%2bunsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout
<https://groups.google.com/d/optout>.
--
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.