Received: from eggs.gnu.org ([140.186.70.92]:58251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJ60g-0001M3-Vd for qemu-devel@nongnu.org; Wed, 26 Oct 2011 12:07:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJ60f-0005t6-LY for qemu-devel@nongnu.org; Wed, 26 Oct 2011 12:07:22 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:52409) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJ60f-0005rj-9s for qemu-devel@nongnu.org; Wed, 26 Oct 2011 12:07:21 -0400 From: Peter Maydell Date: Wed, 26 Oct 2011 17:07:11 +0100 Message-Id: <1319645231-14151-3-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1319645231-14151-1-git-send-email-peter.maydell@linaro.org> References: <1319645231-14151-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH 2/2] Make cpu_single_env thread-local List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Dr. David Alan Gilbert" , Jan Kiszka From: Paolo Bonzini Make cpu_single_env thread-local. This fixes a regression in handling of multi-threaded programs in linux-user mode (bug 823902). Signed-off-by: Paolo Bonzini --- cpu-all.h | 4 +++- darwin-user/main.c | 2 -- exec.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cpu-all.h b/cpu-all.h index 42a5fa0..e37ebfc 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -20,6 +20,7 @@ #define CPU_ALL_H #include "qemu-common.h" +#include "qemu-tls.h" #include "cpu-common.h" /* some important defines: @@ -334,7 +335,8 @@ void cpu_dump_statistics(CPUState *env, FILE *f, fprintf_function cpu_fprintf, void QEMU_NORETURN cpu_abort(CPUState *env, const char *fmt, ...) GCC_FMT_ATTR(2, 3); extern CPUState *first_cpu; -extern CPUState *cpu_single_env; +DECLARE_TLS(CPUState *,tls_cpu_single_env); +#define cpu_single_env get_tls(tls_cpu_single_env) /* Flags for use in ENV->INTERRUPT_PENDING. diff --git a/darwin-user/main.c b/darwin-user/main.c index 1a881a0..c0f14f8 100644 --- a/darwin-user/main.c +++ b/darwin-user/main.c @@ -729,8 +729,6 @@ static void usage(void) /* XXX: currently only used for async signals (see signal.c) */ CPUState *global_env; -/* used only if single thread */ -CPUState *cpu_single_env = NULL; /* used to free thread contexts */ TaskState *first_task_state; diff --git a/exec.c b/exec.c index 9dc4edb..ea4e8de 100644 --- a/exec.c +++ b/exec.c @@ -120,7 +120,7 @@ static MemoryRegion *system_io; CPUState *first_cpu; /* current CPU in the current thread. It is only valid inside cpu_exec() */ -CPUState *cpu_single_env; +DEFINE_TLS(CPUState *,tls_cpu_single_env); /* 0 = Do not count executed instructions. 1 = Precise instruction counting. 2 = Adaptive rate instruction counting. */ -- 1.7.1