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: 69643 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2504413qgf; Wed, 8 Jun 2016 06:46:04 -0700 (PDT) X-Received: by 10.55.164.20 with SMTP id n20mr4632276qke.73.1465393564572; Wed, 08 Jun 2016 06:46:04 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x63si694306qkd.159.2016.06.08.06.46.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 08 Jun 2016 06:46:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57081 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdo4-0000oG-0k for patch@linaro.org; Wed, 08 Jun 2016 09:46:04 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.1.4 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;