mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-08 11:55:24 +00:00
libc: rename special-purpose pthread creation functions
The functions are used by our VirtualBox ports to hook into thread creation and, thus, are listed in the ABI symbols. Issue #4031
This commit is contained in:
parent
0f9cb72cfa
commit
0ac4d1d411
@ -975,8 +975,9 @@ _ZN4Libc19Select_handler_baseD2Ev T
|
||||
_ZN4Libc10resume_allEv T
|
||||
_ZN4Libc7PthreadC2ERN6Genode6ThreadEPv T
|
||||
_ZN4Libc7suspendERNS_15Suspend_functorEm T
|
||||
_ZN4Libc14pthread_createEPP7pthreadPFPvS3_ES3_mPKcPN6Genode11Cpu_sessionENS8_8Affinity8LocationE T
|
||||
_ZN4Libc14pthread_createEPP7pthreadRN6Genode6ThreadEPv T
|
||||
_ZN4Libc14pthread_createEPP7pthreadPKP12pthread_attrPFPvS7_ES7_PKc T
|
||||
_ZN4Libc26pthread_create_from_threadEPP7pthreadRN6Genode6ThreadEPv T
|
||||
_ZN4Libc27pthread_create_from_sessionEPP7pthreadPFPvS3_ES3_mPKcPN6Genode11Cpu_sessionENS8_8Affinity8LocationE T
|
||||
|
||||
#
|
||||
# Libc plugin interface
|
||||
|
@ -27,12 +27,19 @@
|
||||
|
||||
namespace Libc {
|
||||
|
||||
int pthread_create(pthread_t *thread,
|
||||
void *(*start_routine) (void *), void *arg,
|
||||
size_t stack_size, char const * name,
|
||||
Cpu_session * cpu, Affinity::Location location);
|
||||
int pthread_create_from_session(pthread_t *thread,
|
||||
void *(*start_routine) (void *),
|
||||
void *arg,
|
||||
size_t stack_size,
|
||||
char const * name,
|
||||
Cpu_session * cpu,
|
||||
Affinity::Location location);
|
||||
|
||||
int pthread_create(pthread_t *, Thread &, void *stack_address);
|
||||
int pthread_create_from_thread(pthread_t *, Thread &, void *stack_address);
|
||||
|
||||
int pthread_create(pthread_t *thread, pthread_attr_t const *attr,
|
||||
void *(*start_routine) (void *), void *arg,
|
||||
char const *name);
|
||||
}
|
||||
|
||||
#endif /* _LIBC__INTERNAL__THREAD_CREATE_H_ */
|
||||
|
@ -84,10 +84,13 @@ static unsigned pthread_id()
|
||||
}
|
||||
|
||||
|
||||
int Libc::pthread_create(pthread_t *thread,
|
||||
void *(*start_routine) (void *), void *arg,
|
||||
size_t stack_size, char const * name,
|
||||
Cpu_session * cpu, Affinity::Location location)
|
||||
int Libc::pthread_create_from_session(pthread_t *thread,
|
||||
void *(*start_routine) (void *),
|
||||
void *arg,
|
||||
size_t stack_size,
|
||||
char const *name,
|
||||
Cpu_session *cpu,
|
||||
Affinity::Location location)
|
||||
{
|
||||
Libc::Allocator alloc { };
|
||||
pthread_t thread_obj = new (alloc)
|
||||
@ -104,7 +107,7 @@ int Libc::pthread_create(pthread_t *thread,
|
||||
}
|
||||
|
||||
|
||||
int Libc::pthread_create(pthread_t *thread, Thread &t, void *stack_address)
|
||||
int Libc::pthread_create_from_thread(pthread_t *thread, Thread &t, void *stack_address)
|
||||
{
|
||||
Libc::Allocator alloc { };
|
||||
|
||||
@ -118,41 +121,48 @@ int Libc::pthread_create(pthread_t *thread, Thread &t, void *stack_address)
|
||||
}
|
||||
|
||||
|
||||
extern "C"
|
||||
int Libc::pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
void *(*start_routine) (void *), void *arg,
|
||||
char const *name)
|
||||
{
|
||||
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
void *(*start_routine) (void *), void *arg)
|
||||
{
|
||||
if (!_cpu_session || !start_routine || !thread)
|
||||
return EINVAL;
|
||||
if (!_cpu_session || !start_routine || !thread)
|
||||
return EINVAL;
|
||||
|
||||
size_t const stack_size = (attr && *attr && (*attr)->stack_size)
|
||||
? (*attr)->stack_size
|
||||
: Libc::Component::stack_size();
|
||||
size_t const stack_size = (attr && *attr && (*attr)->stack_size)
|
||||
? (*attr)->stack_size
|
||||
: Libc::Component::stack_size();
|
||||
|
||||
using Genode::Affinity;
|
||||
using Genode::Affinity;
|
||||
|
||||
unsigned const id { pthread_id() };
|
||||
unsigned const cpu = (id < sizeof(_id_cpu_map) / sizeof(_id_cpu_map[0])) ? _id_cpu_map[id] : 0;
|
||||
unsigned const id { pthread_id() };
|
||||
unsigned const cpu = (id < sizeof(_id_cpu_map) / sizeof(_id_cpu_map[0])) ? _id_cpu_map[id] : 0;
|
||||
|
||||
Genode::String<32> const pthread_name { "pthread.", id };
|
||||
Affinity::Space space { _cpu_session->affinity_space() };
|
||||
Affinity::Location location { space.location_of_index(cpu) };
|
||||
Genode::String<32> const pthread_name { "pthread.", id };
|
||||
Affinity::Space space { _cpu_session->affinity_space() };
|
||||
Affinity::Location location { space.location_of_index(cpu) };
|
||||
|
||||
if (_verbose)
|
||||
Genode::log("create ", pthread_name, " -> cpu ", cpu);
|
||||
if (_verbose)
|
||||
Genode::log("create ", pthread_name, " -> cpu ", cpu);
|
||||
|
||||
int result = Libc::pthread_create(thread, start_routine, arg, stack_size,
|
||||
pthread_name.string(), _cpu_session,
|
||||
location);
|
||||
int result =
|
||||
Libc::pthread_create_from_session(thread, start_routine, arg,
|
||||
stack_size,
|
||||
name ? : pthread_name.string(),
|
||||
_cpu_session, location);
|
||||
|
||||
if ((result == 0) && attr && *attr &&
|
||||
((*attr)->detach_state == PTHREAD_CREATE_DETACHED))
|
||||
pthread_detach(*thread);
|
||||
if ((result == 0) && attr && *attr &&
|
||||
((*attr)->detach_state == PTHREAD_CREATE_DETACHED))
|
||||
pthread_detach(*thread);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
typeof(pthread_create) _pthread_create
|
||||
__attribute__((alias("pthread_create")));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
void *(*start_routine) (void *), void *arg)
|
||||
{
|
||||
return Libc::pthread_create(thread, attr, start_routine, arg, nullptr);
|
||||
}
|
||||
|
||||
|
||||
extern "C" typeof(pthread_create) _pthread_create __attribute__((alias("pthread_create")));
|
||||
|
@ -456,7 +456,7 @@ struct Usb_ep : Genode::Entrypoint
|
||||
void _handle_pthread_registration()
|
||||
{
|
||||
Genode::Thread *myself = Genode::Thread::myself();
|
||||
if (!myself || Libc::pthread_create(&_pthread, *myself, &myself)) {
|
||||
if (!myself || Libc::pthread_create_from_thread(&_pthread, *myself, &myself)) {
|
||||
Genode::error("USB passthough will not work - thread for "
|
||||
"pthread registration invalid");
|
||||
}
|
||||
|
@ -793,8 +793,8 @@ bool create_emt_vcpu(pthread_t * thread, ::size_t stack_size,
|
||||
|
||||
vcpu_handler_list().insert(vcpu_handler);
|
||||
|
||||
Libc::pthread_create(thread, start_routine, arg,
|
||||
stack_size, name, cpu_connection, location);
|
||||
Libc::pthread_create_from_session(thread, start_routine, arg,
|
||||
stack_size, name, cpu_connection, location);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ class Nic_client
|
||||
void _handle_pthread_registration()
|
||||
{
|
||||
Genode::Thread *myself = Genode::Thread::myself();
|
||||
if (!myself || Libc::pthread_create(&_pthread, *myself, &myself)) {
|
||||
if (!myself || Libc::pthread_create_from_thread(&_pthread, *myself, &myself)) {
|
||||
Genode::error("network will not work - thread for pthread "
|
||||
"registration invalid");
|
||||
return;
|
||||
|
@ -127,9 +127,9 @@ static int create_thread(pthread_t *thread, const pthread_attr_t *attr,
|
||||
bool const rtthread_timer = rtthread->enmType == RTTHREADTYPE_TIMER;
|
||||
|
||||
if (rtthread_timer) {
|
||||
return Libc::pthread_create(thread, start_routine, arg,
|
||||
stack_size, rtthread->szName, nullptr,
|
||||
Genode::Affinity::Location());
|
||||
return Libc::pthread_create_from_session(thread, start_routine, arg,
|
||||
stack_size, rtthread->szName, nullptr,
|
||||
Genode::Affinity::Location());
|
||||
|
||||
} else {
|
||||
using namespace Genode;
|
||||
@ -137,9 +137,9 @@ static int create_thread(pthread_t *thread, const pthread_attr_t *attr,
|
||||
return cpu->retry_with_upgrade(Ram_quota{8*1024}, Cap_quota{2},
|
||||
[&] ()
|
||||
{
|
||||
return Libc::pthread_create(thread, start_routine, arg,
|
||||
stack_size, rtthread->szName, cpu,
|
||||
Genode::Affinity::Location());
|
||||
return Libc::pthread_create_from_session(thread, start_routine, arg,
|
||||
stack_size, rtthread->szName, cpu,
|
||||
Genode::Affinity::Location());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -438,7 +438,7 @@ struct Usb_ep : Genode::Entrypoint
|
||||
void _handle_pthread_registration()
|
||||
{
|
||||
Genode::Thread *myself = Genode::Thread::myself();
|
||||
if (!myself || Libc::pthread_create(&_pthread, *myself, &myself)) {
|
||||
if (!myself || Libc::pthread_create_from_thread(&_pthread, *myself, &myself)) {
|
||||
Genode::error("USB passthough will not work - thread for "
|
||||
"pthread registration invalid");
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ class Nic_client
|
||||
void _handle_pthread_registration()
|
||||
{
|
||||
Genode::Thread *myself = Genode::Thread::myself();
|
||||
if (!myself || Libc::pthread_create(&_pthread, *myself, &myself)) {
|
||||
if (!myself || Libc::pthread_create_from_thread(&_pthread, *myself, &myself)) {
|
||||
Genode::error("network will not work - thread for pthread "
|
||||
"registration invalid");
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user