From patchwork Wed Jan 14 22:48:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 43136 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 81734240B9 for ; Wed, 14 Jan 2015 22:49:51 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id s18sf466054lam.2 for ; Wed, 14 Jan 2015 14:49:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=V6R2mZXu4f/drogEHQ9x5igD4Qk0Td0Bqp47PFEGewI=; b=flBkxXFdQ1di+QkR/AmmIpBnNMgEIqUPPIzbq1SaS3t/hI9ILz7xPn8KN1drMru+sl 6dkI48OvjswpXmq8daTgW9bnUbmphzeUfrZdvUrAFDXypNybh3HpLo/IVjYlvabdHhwC R0qM+K0ORq4jY1iAgZ3uj5f0JkfS7DY/DBXTDhHefw+tMz099q4OSnJmAGgoVF3FXNMY lK6UQIYXROGTPHn0qUsAcpN2r/lNzSKhCnXlpkcyH20Xz1n2Rq16WxULY0CmH6m9e79G d0M8Csz4/6l1n/fR/fw1ulYFhj9o0cfsi7GBb//FZGjw1rxMI1kxJHY6/Eo6+Uj6ckA0 4o8A== X-Gm-Message-State: ALoCoQkeaTUdgAitkBdHiV9fFE7tM3twNEwp55Q7XmYruCi6qppms5ws/vbBQgWHrlm/PEKIvByl X-Received: by 10.112.148.198 with SMTP id tu6mr816241lbb.3.1421275790473; Wed, 14 Jan 2015 14:49:50 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.7 with SMTP id f7ls175775laa.100.gmail; Wed, 14 Jan 2015 14:49:50 -0800 (PST) X-Received: by 10.112.55.199 with SMTP id u7mr6388588lbp.74.1421275790333; Wed, 14 Jan 2015 14:49:50 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id lb3si7272045lab.20.2015.01.14.14.49.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 Jan 2015 14:49:50 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id gd6so10815278lab.3 for ; Wed, 14 Jan 2015 14:49:50 -0800 (PST) X-Received: by 10.112.41.234 with SMTP id i10mr6624273lbl.25.1421275790243; Wed, 14 Jan 2015 14:49:50 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp1845655lbb; Wed, 14 Jan 2015 14:49:49 -0800 (PST) X-Received: by 10.140.86.99 with SMTP id o90mr10546409qgd.21.1421275789048; Wed, 14 Jan 2015 14:49:49 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id bh8si33032863qcb.45.2015.01.14.14.49.48 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 14 Jan 2015 14:49:49 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YBWl0-0000Jf-IK; Wed, 14 Jan 2015 22:49:46 +0000 Received: from mail-la0-f50.google.com ([209.85.215.50]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YBWkd-0000BP-HC for lng-odp@lists.linaro.org; Wed, 14 Jan 2015 22:49:23 +0000 Received: by mail-la0-f50.google.com with SMTP id pn19so10717943lab.9 for ; Wed, 14 Jan 2015 14:49:18 -0800 (PST) X-Received: by 10.112.162.4 with SMTP id xw4mr6355441lbb.89.1421275757985; Wed, 14 Jan 2015 14:49:17 -0800 (PST) Received: from localhost (c-853670d5.07-21-73746f28.cust.bredbandsbolaget.se. [213.112.54.133]) by mx.google.com with ESMTPSA id zs7sm6308954lbb.18.2015.01.14.14.49.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Jan 2015 14:49:17 -0800 (PST) From: Anders Roxell To: lng-odp@lists.linaro.org Date: Wed, 14 Jan 2015 23:48:24 +0100 Message-Id: <1421275706-11176-8-git-send-email-anders.roxell@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1421275706-11176-1-git-send-email-anders.roxell@linaro.org> References: <1421275706-11176-1-git-send-email-anders.roxell@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv3 7/9] api: cpumask: add odp_cpumask_next X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: anders.roxell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Robbie King Finding the next element to traverse a mask. Signed-off-by: Robbie King Signed-off-by: Anders Roxell --- platform/linux-generic/include/api/odp_cpumask.h | 21 +++++++++++++++++++++ platform/linux-generic/odp_cpumask.c | 8 ++++++++ 2 files changed, 29 insertions(+) diff --git a/platform/linux-generic/include/api/odp_cpumask.h b/platform/linux-generic/include/api/odp_cpumask.h index a81bca7..ebff9b0 100644 --- a/platform/linux-generic/include/api/odp_cpumask.h +++ b/platform/linux-generic/include/api/odp_cpumask.h @@ -146,6 +146,27 @@ int odp_cpumask_first(const odp_cpumask_t *mask); int odp_cpumask_last(const odp_cpumask_t *mask); /** + * Find next cpu in mask + * + * Finds the next cpu in the CPU mask, starting at the cpu passed. + * Use with odp_cpumask_first to traverse a CPU mask, i.e. + * + * int cpu = odp_cpumask_first(&mask); + * while (0 <= cpu) { + * ... + * ... + * cpu = odp_cpumask_next(&mask, cpu); + * } + * + * @param mask CPU mask to find next cpu in + * @param cpu CPU to start from + * @return cpu found else -1 + * + * @see odp_cpumask_first() + */ +int odp_cpumask_next(const odp_cpumask_t *mask, int cpu); + +/** * @} */ diff --git a/platform/linux-generic/odp_cpumask.c b/platform/linux-generic/odp_cpumask.c index 3930264..d9931b4 100644 --- a/platform/linux-generic/odp_cpumask.c +++ b/platform/linux-generic/odp_cpumask.c @@ -185,3 +185,11 @@ int odp_cpumask_last(const odp_cpumask_t *mask) return cpu; return -1; } + +int odp_cpumask_next(const odp_cpumask_t *mask, int cpu) +{ + for (cpu += 1; cpu < CPU_SETSIZE; cpu++) + if (odp_cpumask_isset(mask, cpu)) + return cpu; + return -1; +}