From f6dec901bbd6662be096d186afedc06f0572d383 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Mon, 9 May 2016 15:04:37 +0200 Subject: [PATCH] base: remove Component::name from API It turns out that the name function does not have much use in practice except for naming the thread of the component's initial entrypoint. For dynamically linked components, this thread is created by the dynamic linker. It is named "ep" in these cases. Considering that we will eventually turn all regular components into dynamically linked executables, the additional information provided by the Component::name() function remains unused. So it is better to not bother the component developers with adding boilerplate code. --- repos/base-linux/src/test/lx_hybrid_ctors/main.cc | 1 - repos/base-linux/src/test/lx_hybrid_errno/main.cc | 1 - repos/base-linux/src/test/lx_hybrid_exception/main.cc | 1 - .../base-linux/src/test/lx_hybrid_pthread_ipc/main.cc | 1 - repos/base/include/base/component.h | 5 ----- repos/base/src/lib/base/entrypoint.cc | 10 ++++++++-- repos/base/src/lib/ldso/main.cc | 3 ++- repos/base/src/lib/startup/component_construct.cc | 7 ------- repos/base/src/test/thread/main.cc | 3 --- repos/libports/src/lib/libc/task.cc | 6 ++++-- repos/os/src/drivers/framebuffer/spec/sdl/fb_sdl.cc | 1 - repos/os/src/lib/server/server.cc | 6 ------ 12 files changed, 14 insertions(+), 31 deletions(-) diff --git a/repos/base-linux/src/test/lx_hybrid_ctors/main.cc b/repos/base-linux/src/test/lx_hybrid_ctors/main.cc index 7976a21544..972c22d10e 100644 --- a/repos/base-linux/src/test/lx_hybrid_ctors/main.cc +++ b/repos/base-linux/src/test/lx_hybrid_ctors/main.cc @@ -45,7 +45,6 @@ static void exit_on_suspended() { exit(exit_status); } Genode::size_t Component::stack_size() { return 16*1024*sizeof(long); } -char const * Component::name() { return "lx_hybrid_ctors"; } /* diff --git a/repos/base-linux/src/test/lx_hybrid_errno/main.cc b/repos/base-linux/src/test/lx_hybrid_errno/main.cc index 11142915a9..9c55711a61 100644 --- a/repos/base-linux/src/test/lx_hybrid_errno/main.cc +++ b/repos/base-linux/src/test/lx_hybrid_errno/main.cc @@ -47,7 +47,6 @@ static void exit_on_suspended() { exit(exit_status); } Genode::size_t Component::stack_size() { return 16*1024*sizeof(long); } -char const * Component::name() { return "lx_hybrid_errno"; } struct Unexpected_errno_change { }; diff --git a/repos/base-linux/src/test/lx_hybrid_exception/main.cc b/repos/base-linux/src/test/lx_hybrid_exception/main.cc index 6271fb4c01..2b878cb227 100644 --- a/repos/base-linux/src/test/lx_hybrid_exception/main.cc +++ b/repos/base-linux/src/test/lx_hybrid_exception/main.cc @@ -28,7 +28,6 @@ static void exit_on_suspended() { exit(exit_status); } Genode::size_t Component::stack_size() { return 16*1024*sizeof(long); } -char const * Component::name() { return "lx_hybrid_exception"; } /* diff --git a/repos/base-linux/src/test/lx_hybrid_pthread_ipc/main.cc b/repos/base-linux/src/test/lx_hybrid_pthread_ipc/main.cc index f80c7781be..2186c75b22 100644 --- a/repos/base-linux/src/test/lx_hybrid_pthread_ipc/main.cc +++ b/repos/base-linux/src/test/lx_hybrid_pthread_ipc/main.cc @@ -54,7 +54,6 @@ static void exit_on_suspended() { exit(exit_status); } Genode::size_t Component::stack_size() { return 16*1024*sizeof(long); } -char const * Component::name() { return "lx_hybrid_pthread_ipc"; } /* diff --git a/repos/base/include/base/component.h b/repos/base/include/base/component.h index 66975a1634..6d01df5590 100644 --- a/repos/base/include/base/component.h +++ b/repos/base/include/base/component.h @@ -30,11 +30,6 @@ namespace Component */ Genode::size_t stack_size(); - /** - * Return component name - */ - char const *name(); - /** * Construct component * diff --git a/repos/base/src/lib/base/entrypoint.cc b/repos/base/src/lib/base/entrypoint.cc index b4e1c2ac6e..675be73618 100644 --- a/repos/base/src/lib/base/entrypoint.cc +++ b/repos/base/src/lib/base/entrypoint.cc @@ -36,6 +36,12 @@ namespace Genode { } +/** + * Return thread name used for the component's initial entrypoint + */ +static char const *initial_ep_name() { return "ep"; } + + void Entrypoint::_dispatch_signal(Signal &sig) { Signal_dispatcher_base *dispatcher = 0; @@ -79,7 +85,7 @@ void Entrypoint::_process_incoming_signals() _suspended_callback(); init_signal_thread(_env); - _rpc_ep.construct(&_env.pd(), Component::stack_size(), Component::name()); + _rpc_ep.construct(&_env.pd(), Component::stack_size(), initial_ep_name()); _signal_proxy_cap = manage(_signal_proxy); _sig_rec.construct(); @@ -154,7 +160,7 @@ namespace { Entrypoint::Entrypoint(Env &env) : _env(env), - _rpc_ep(&env.pd(), Component::stack_size(), Component::name()) + _rpc_ep(&env.pd(), Component::stack_size(), initial_ep_name()) { /* initialize signalling after initializing but before calling the entrypoint */ init_signal_thread(_env); diff --git a/repos/base/src/lib/ldso/main.cc b/repos/base/src/lib/ldso/main.cc index aca79df4bb..ff3c96c53c 100644 --- a/repos/base/src/lib/ldso/main.cc +++ b/repos/base/src/lib/ldso/main.cc @@ -539,10 +539,11 @@ extern "C" void init_rtld() Genode::size_t Component::stack_size() { return 16*1024*sizeof(long); } -char const * Component::name() { return "ep"; } + struct Failed_to_load_program { }; + void Component::construct(Genode::Env &env) { /* load program headers of linker now */ diff --git a/repos/base/src/lib/startup/component_construct.cc b/repos/base/src/lib/startup/component_construct.cc index f57cee89c2..dcf208cafb 100644 --- a/repos/base/src/lib/startup/component_construct.cc +++ b/repos/base/src/lib/startup/component_construct.cc @@ -89,10 +89,3 @@ Genode::size_t Component::stack_size() { return 16UL * 1024 * sizeof(Genode::addr_t); } - - -char const *Component::name() __attribute__((weak)); -char const *Component::name() -{ - return "ep"; -} diff --git a/repos/base/src/test/thread/main.cc b/repos/base/src/test/thread/main.cc index 98ab8e4489..9d5ef264bd 100644 --- a/repos/base/src/test/thread/main.cc +++ b/repos/base/src/test/thread/main.cc @@ -333,9 +333,6 @@ static void test_create_as_many_threads(Env &env) } -char const *Component::name() { return "test-thread"; } - - size_t Component::stack_size() { return 16*1024*sizeof(long); } diff --git a/repos/libports/src/lib/libc/task.cc b/repos/libports/src/lib/libc/task.cc index 7057092aa4..5a8e420e7a 100644 --- a/repos/libports/src/lib/libc/task.cc +++ b/repos/libports/src/lib/libc/task.cc @@ -72,9 +72,11 @@ class Libc::Task : public Genode::Rpc_object bool _app_runnable = true; jmp_buf _app_task; + Genode::Thread &_myself = *Genode::Thread::myself(); + void *_app_stack = { - Genode::Thread::myself()->alloc_secondary_stack(Component::name(), - Component::stack_size()) }; + _myself.alloc_secondary_stack(_myself.name().string(), + Component::stack_size()) }; /** * Libc context diff --git a/repos/os/src/drivers/framebuffer/spec/sdl/fb_sdl.cc b/repos/os/src/drivers/framebuffer/spec/sdl/fb_sdl.cc index 5c34f89d2d..664ae290d1 100644 --- a/repos/os/src/drivers/framebuffer/spec/sdl/fb_sdl.cc +++ b/repos/os/src/drivers/framebuffer/spec/sdl/fb_sdl.cc @@ -215,5 +215,4 @@ struct Main Genode::size_t Component::stack_size() { return 4*1024*sizeof(long); } -char const * Component::name() { return "fb_sdl"; } void Component::construct(Genode::Env &env) { static Main inst(env); } diff --git a/repos/os/src/lib/server/server.cc b/repos/os/src/lib/server/server.cc index 0b13f85071..3cb487c7bc 100644 --- a/repos/os/src/lib/server/server.cc +++ b/repos/os/src/lib/server/server.cc @@ -21,12 +21,6 @@ Genode::size_t Component::stack_size() } -char const *Component::name() -{ - return Server::name(); -} - - static Genode::Env *_env;