diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-11-19 11:27:18 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-11-19 11:27:18 +0100 |
commit | 50e48dc5d50f8a7542174fa826b6ef8505c37855 (patch) | |
tree | 2c331042d5920f61720b96aaf20849434bda9e4e | |
parent | 9c516218eeb742c3417f7fb268a475305c7d5266 (diff) | |
parent | 7cff168b2c57f957603be5d7992a2ba207dca914 (diff) |
Merge commit 'refs/top-bases/t/ONSTACK' into t/ONSTACK
-rw-r--r-- | hurd/hurd/threadvar.h | 17 | ||||
-rw-r--r-- | sysdeps/mach/hurd/fork.c | 18 | ||||
-rw-r--r-- | sysdeps/mach/hurd/i386/makecontext-helper.c | 71 |
3 files changed, 4 insertions, 102 deletions
diff --git a/hurd/hurd/threadvar.h b/hurd/hurd/threadvar.h index 1c40af6cfc..ff43598d2c 100644 --- a/hurd/hurd/threadvar.h +++ b/hurd/hurd/threadvar.h @@ -22,21 +22,6 @@ #include <features.h> #include <tls.h> -/* The per-thread variables are found by ANDing this mask - with the value of the stack pointer and then adding this offset. - - In the multi-threaded case, cthreads initialization sets - __hurd_threadvar_stack_mask to ~(cthread_stack_size - 1), a mask which - finds the base of the fixed-size cthreads stack; and - __hurd_threadvar_stack_offset to a small offset that skips the data - cthreads itself maintains at the base of each thread's stack. - - In the single-threaded or libpthread case, __hurd_threadvar_stack_mask is - zero, so the stack pointer is ignored. */ - -extern unsigned long int __hurd_threadvar_stack_mask; -extern unsigned long int __hurd_threadvar_stack_offset; - /* The variables __hurd_sigthread_stack_base and __hurd_sigthread_stack_end define the bounds of the stack used by the signal thread, so that thread can always be specifically identified. */ @@ -46,6 +31,8 @@ extern unsigned long int __hurd_sigthread_stack_end; /* We do not use threadvars any more, this is kept as zero for compatibility with cthreads */ +extern unsigned long int __hurd_threadvar_stack_mask; +extern unsigned long int __hurd_threadvar_stack_offset; extern unsigned int __hurd_threadvar_max; extern mach_port_t __hurd_reply_port0; diff --git a/sysdeps/mach/hurd/fork.c b/sysdeps/mach/hurd/fork.c index 82059d6097..e5a7ce280f 100644 --- a/sysdeps/mach/hurd/fork.c +++ b/sysdeps/mach/hurd/fork.c @@ -506,24 +506,10 @@ __fork (void) (natural_t *) &state, &statecount)) LOSE; #ifdef STACK_GROWTH_UP - if (__hurd_sigthread_stack_base == 0) - { - state.SP &= __hurd_threadvar_stack_mask; - state.SP += __hurd_threadvar_stack_offset; - } - else + if (__hurd_sigthread_stack_base != 0) state.SP = __hurd_sigthread_stack_base; #else - if (__hurd_sigthread_stack_end == 0) - { - /* The signal thread has a stack assigned by cthreads. - The threadvar_stack variables conveniently tell us how - to get to the highest address in the stack, just below - the per-thread variables. */ - state.SP &= __hurd_threadvar_stack_mask; - state.SP += __hurd_threadvar_stack_offset; - } - else + if (__hurd_sigthread_stack_end != 0) state.SP = __hurd_sigthread_stack_end; #endif MACHINE_THREAD_STATE_SET_PC (&state, diff --git a/sysdeps/mach/hurd/i386/makecontext-helper.c b/sysdeps/mach/hurd/i386/makecontext-helper.c deleted file mode 100644 index e604488264..0000000000 --- a/sysdeps/mach/hurd/i386/makecontext-helper.c +++ /dev/null @@ -1,71 +0,0 @@ -/* Helper for makecontext: handle threadvars. - Copyright (C) 2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <hurd/threadvar.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ucontext.h> - -#if 0 - -void -__makecontext_helper (ucontext_t *ucp) -{ - if (__hurd_threadvar_stack_mask == 0) - { - /* We are not using threads, so per init-first.c:init, the threadvars - live in a malloced space, addressed relative to the base of the - virtual address space. Just keep using that one. */ - } - else - { - /* The following is only prepared to work with libpthread, which only - keeps the threadvars at the bottom of the stack -- contrary to - libthreads, which also puts additional data there. */ - - void *s = ucp->uc_stack.ss_sp; - size_t s_size = ucp->uc_stack.ss_size; - - /* Is the new stack suitable? Check that that the last threadvar - occupies the last storage unit within the bounds of the new stack. - Alignment according to (sp & __hurd_threadvar_stack_mask) == sp is not - actually a requirement (though, in practice it often will be). */ - if (__hurd_threadvar_location_from_sp (_HURD_THREADVAR_MAX, s) - != s + s_size) - { - /* Instead of having makecontext return an error, we bail out the - hard way, as we can't expect its caller to be able to properly - react to this situation. */ - fprintf (stderr, - "*** makecontext: a stack at %p with size %#x is not " - "usable with threadvars\n", - s, s_size); - abort (); - } - - /* Copy the threadvars to the new stack. */ - void *t_old = __hurd_threadvar_location (0); - void *t_new = __hurd_threadvar_location_from_sp (0, s); - size_t t_size = __hurd_threadvar_max * sizeof (unsigned long int); - memcpy (t_new, t_old, t_size); - /* Account for the space taken by the threadvars. */ - ucp->uc_stack.ss_size -= t_size; - } -} -#endif |