From patchwork Fri May 27 14:51:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9138613 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6D05A6075A for ; Fri, 27 May 2016 14:57:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 601B127B90 for ; Fri, 27 May 2016 14:57:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54FAC28096; Fri, 27 May 2016 14:57:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CDEE727B90 for ; Fri, 27 May 2016 14:57:20 +0000 (UTC) Received: from localhost ([::1]:46456 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6JCR-0004cp-WD for patchwork-qemu-devel@patchwork.kernel.org; Fri, 27 May 2016 10:57:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6JAu-0003fK-M9 for qemu-devel@nongnu.org; Fri, 27 May 2016 10:55:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6JAs-0006LN-CJ for qemu-devel@nongnu.org; Fri, 27 May 2016 10:55:43 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:57395) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6JAs-0006Im-4O for qemu-devel@nongnu.org; Fri, 27 May 2016 10:55:42 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1b6J7K-0004iK-DK; Fri, 27 May 2016 15:52:02 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 27 May 2016 15:51:43 +0100 Message-Id: <1464360721-14359-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464360721-14359-1-git-send-email-peter.maydell@linaro.org> References: <1464360721-14359-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH v2 01/19] linux-user: Factor out handle_signal code from process_pending_signals() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Timothy Edward Baldwin , patches@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Factor out the code to handle a single signal from the process_pending_signals() function. The use of goto for flow control is OK currently, but would get significantly uglier if extended to allow running the handle_signal code multiple times. Signed-off-by: Peter Maydell Reviewed-by: Laurent Vivier --- linux-user/signal.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index 8090b4d..a9ac491 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -5765,33 +5765,40 @@ long do_rt_sigreturn(CPUArchState *env) #endif +static void handle_pending_signal(CPUArchState *cpu_env, int sig); + void process_pending_signals(CPUArchState *cpu_env) { CPUState *cpu = ENV_GET_CPU(cpu_env); int sig; - abi_ulong handler; - sigset_t set, old_set; - target_sigset_t target_old_set; - struct emulated_sigtable *k; - struct target_sigaction *sa; - struct sigqueue *q; TaskState *ts = cpu->opaque; if (!ts->signal_pending) return; /* FIXME: This is not threadsafe. */ - k = ts->sigtab; for(sig = 1; sig <= TARGET_NSIG; sig++) { - if (k->pending) - goto handle_signal; - k++; + if (ts->sigtab[sig - 1].pending) { + handle_pending_signal(cpu_env, sig); + return; + } } /* if no signal is pending, just return */ ts->signal_pending = 0; return; +} + +static void handle_pending_signal(CPUArchState *cpu_env, int sig) +{ + CPUState *cpu = ENV_GET_CPU(cpu_env); + abi_ulong handler; + sigset_t set, old_set; + target_sigset_t target_old_set; + struct target_sigaction *sa; + struct sigqueue *q; + TaskState *ts = cpu->opaque; + struct emulated_sigtable *k = &ts->sigtab[sig - 1]; - handle_signal: trace_user_handle_signal(cpu_env, sig); /* dequeue signal */ q = k->first;