L4Re/departure

Changeset

517:3f427c2a2faf
2023-03-16 Paul Boddie raw files shortlog changelog graph On MIPS32, at least, in a payload started by libexec, the main thread is not necessarily returned correctly by pthread_l4_cap(pthread_self()). So a workaround is used when a server is initialised for the main thread.
libfsserver/lib/generic/resource_server.cc (file)
     1.1 --- a/libfsserver/lib/generic/resource_server.cc	Wed Mar 15 15:20:18 2023 +0100
     1.2 +++ b/libfsserver/lib/generic/resource_server.cc	Thu Mar 16 15:24:33 2023 +0100
     1.3 @@ -19,6 +19,7 @@
     1.4   * Boston, MA  02110-1301, USA
     1.5   */
     1.6  
     1.7 +#include <l4/re/env.h>
     1.8  #include <l4/sys/types.h>
     1.9  
    1.10  #include <pthread-l4.h>
    1.11 @@ -45,6 +46,12 @@
    1.12    resource_init_config(_config, _resource);
    1.13    _config->thread = pthread_l4_cap(pthread_self());
    1.14  
    1.15 +  /* NOTE: On MIPS32, at least, in a payload started by libexec, the main thread
    1.16 +           is not necessarily returned correctly. */
    1.17 +
    1.18 +  if (l4_is_invalid_cap(_config->thread))
    1.19 +    _config->thread = l4re_env()->main_thread;
    1.20 +
    1.21    if (finalisation)
    1.22    {
    1.23      _config->finaliser = resource_same_thread_finaliser;