From patchwork Wed Jun 8 13:29:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9164681 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 A27D960467 for ; Wed, 8 Jun 2016 13:44:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9550820410 for ; Wed, 8 Jun 2016 13:44:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A664282DC; Wed, 8 Jun 2016 13:44:20 +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=-5.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FSL_HELO_HOME, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 65DA020410 for ; Wed, 8 Jun 2016 13:44:18 +0000 (UTC) Received: from localhost ([::1]:57076 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdmL-00081o-7T for patchwork-qemu-devel@patchwork.kernel.org; Wed, 08 Jun 2016 09:44:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36806) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZB-00045O-87 for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:30:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAdZ6-0005dJ-5I for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:30:40 -0400 Received: from mail-lf0-x22f.google.com ([2a00:1450:4010:c07::22f]:33815) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZ5-0005d4-Ra for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:30:36 -0400 Received: by mail-lf0-x22f.google.com with SMTP id s186so5867106lfs.1 for ; Wed, 08 Jun 2016 06:30:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VE5CuL42xjed1CyrY8MukJKghBQ0twpI7bD5XqlRKMo=; b=NLvOwZMHg6WpriakFCO1G/m2fr3g7oI9zdLkXbtAh+abSdK8N4we2ziuVB2JabZx8C KM+PM4bh/Ti3EAi4pdryBO9pqorPWV106caTx+L+Rv7mLPLgQ6HvR6oM7fPW5xPAu+er Ov0l3ggfbMhzssFeJqWyms3OHKsAdczwU4/0k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VE5CuL42xjed1CyrY8MukJKghBQ0twpI7bD5XqlRKMo=; b=WBnVw4IiKmF2o5T9X0ZB8vOVIOAOibpZ9T93y4PG1YS6cgb07O2o8mkCymxVsLmTtw Gkn0otUgWu4Ay3USFFxj6sWrMr+S68AWSC+/If2qFs53P8daMb7lQhUnUtRvBIc2mijn hgjwHC9MnjL68vUVNgAdUzEAOqCrpaTou2BqV4P4xef0RmoA6q/OL6YATd0x2uYMd80l j1rW6npPBQXkTSfu/JnFfwcv6H5QmbYYLi2TKoyA0tSP2Aj6wRTo8GLrMUj3q96/o7Au F6xv5p7Uje9zL6Enha9mzY29MDyMYDJvk5n8a7DCm6byCyBcTu5NLfxFD8/UmhWCdAer KT2w== X-Gm-Message-State: ALyK8tKY/dEIlLwI+TvpV3adzyXBVkJcUWLBhhd9xE5bcLuANY0mM37i56Wg4NCmRRTOKWZn X-Received: by 10.25.145.140 with SMTP id t134mr3677441lfd.231.1465392635125; Wed, 08 Jun 2016 06:30:35 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id 2sm139854lja.37.2016.06.08.06.30.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jun 2016 06:30:34 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 8 Jun 2016 16:29:47 +0300 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::22f Subject: [Qemu-devel] [PULL 06/44] 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: Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Maydell 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 Signed-off-by: Riku Voipio --- 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;