From 5bab5f4cca3ff7179b406ce80ab6db4dc0a2b73f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Mon, 18 Feb 2019 15:56:07 +0100 Subject: [PATCH] libc: extent vbox specific pthread_create API Make it possible to adopt normal Genode::Threads for use within in a pthread environment. Issue #3164. --- repos/libports/lib/symbols/libc | 1 + repos/libports/src/lib/libc/thread_create.cc | 12 ++++++++++++ repos/libports/src/lib/libc/thread_create.h | 2 ++ 3 files changed, 15 insertions(+) diff --git a/repos/libports/lib/symbols/libc b/repos/libports/lib/symbols/libc index b75d1d695..2df5d8ac2 100644 --- a/repos/libports/lib/symbols/libc +++ b/repos/libports/lib/symbols/libc @@ -948,6 +948,7 @@ _ZN16Pthread_registry6insertEP7pthread T _ZN16Pthread_registry6removeEP7pthread T _ZN16Pthread_registry8containsEP7pthread T _ZN4Libc14pthread_createEPP7pthreadPFPvS3_ES3_mPKcPN6Genode11Cpu_sessionENS8_8Affinity8LocationE T +_ZN4Libc14pthread_createEPP7pthreadRN6Genode6ThreadE T # # Libc plugin interface diff --git a/repos/libports/src/lib/libc/thread_create.cc b/repos/libports/src/lib/libc/thread_create.cc index 305f9896f..f0f891670 100644 --- a/repos/libports/src/lib/libc/thread_create.cc +++ b/repos/libports/src/lib/libc/thread_create.cc @@ -37,6 +37,18 @@ int Libc::pthread_create(pthread_t *thread, } +int Libc::pthread_create(pthread_t *thread, Genode::Thread &t) +{ + pthread_t thread_obj = new pthread(t); + + if (!thread_obj) + return EAGAIN; + + *thread = thread_obj; + return 0; +} + + extern "C" { int pthread_create(pthread_t *thread, const pthread_attr_t *attr, diff --git a/repos/libports/src/lib/libc/thread_create.h b/repos/libports/src/lib/libc/thread_create.h index 94027687c..3f7493d78 100644 --- a/repos/libports/src/lib/libc/thread_create.h +++ b/repos/libports/src/lib/libc/thread_create.h @@ -21,4 +21,6 @@ namespace Libc { void *(*start_routine) (void *), void *arg, size_t stack_size, char const * name, Genode::Cpu_session * cpu, Genode::Affinity::Location location); + + int pthread_create(pthread_t *, Genode::Thread &); }