From patchwork Wed Jan 14 22:48:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 43134 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7F2C4240B9 for ; Wed, 14 Jan 2015 22:49:43 +0000 (UTC) Received: by mail-we0-f197.google.com with SMTP id w61sf6204467wes.0 for ; Wed, 14 Jan 2015 14:49:42 -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=YDhwCaRPJBULetaqq31hxN7yW8B4gSxtCcLBaq2w3FI=; b=DeloPUDIlmxt4UK51BhA4mf62OoE3YJ0cRGuAEvfvekuh2Ni8GC4vl3RxpHB+GEE0d PHcq9m9u3q7n5K+RFZ8YQj+Ff0tEJmCJ7kl49yAYxLaVK/f30EXDSD2RUknA0pTRvD9r O6/tYTf6kv/YkBIsgMVWP1U4p91H/nYkJurKf3MRYJExRGJgp29CLm0T8K7/I2tsLWYc YDdNu11X6BWwyeewl3vIs0XrgAM+A9aF3x70/41hGXspuFwKFQsfHRrZy5cEHjv8DutV X3Nrhs0BTDEe58AFkKqSStwfWqoOmV0l7t0/0ulDlHJGV5/02zTNoNY5t2oGN2aHW11U WjIQ== X-Gm-Message-State: ALoCoQm1ywFE+BhJeyters30tvTQPtBG2uNYGX0XxV9sHvTMr5AwqRCgkzjaC6NNcvsueX50oMj2 X-Received: by 10.112.148.198 with SMTP id tu6mr816169lbb.3.1421275782830; Wed, 14 Jan 2015 14:49:42 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.39 with SMTP id x7ls182025lax.92.gmail; Wed, 14 Jan 2015 14:49:42 -0800 (PST) X-Received: by 10.112.30.71 with SMTP id q7mr6520719lbh.41.1421275782691; Wed, 14 Jan 2015 14:49:42 -0800 (PST) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id uh4si28613291lbb.15.2015.01.14.14.49.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 Jan 2015 14:49:42 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by mail-lb0-f172.google.com with SMTP id z12so10535987lbi.3 for ; Wed, 14 Jan 2015 14:49:42 -0800 (PST) X-Received: by 10.112.52.229 with SMTP id w5mr6589551lbo.52.1421275782599; Wed, 14 Jan 2015 14:49:42 -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 c8csp1845625lbb; Wed, 14 Jan 2015 14:49:41 -0800 (PST) X-Received: by 10.224.135.193 with SMTP id o1mr11051994qat.97.1421275781351; Wed, 14 Jan 2015 14:49:41 -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 c4si2524990qch.25.2015.01.14.14.49.40 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 14 Jan 2015 14:49:41 -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 1YBWkr-0000Fu-S9; Wed, 14 Jan 2015 22:49:37 +0000 Received: from mail-lb0-f170.google.com ([209.85.217.170]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YBWkb-0000BC-EN for lng-odp@lists.linaro.org; Wed, 14 Jan 2015 22:49:21 +0000 Received: by mail-lb0-f170.google.com with SMTP id 10so10504991lbg.1 for ; Wed, 14 Jan 2015 14:49:15 -0800 (PST) X-Received: by 10.152.37.168 with SMTP id z8mr6493554laj.63.1421275755917; Wed, 14 Jan 2015 14:49:15 -0800 (PST) Received: from localhost (c-853670d5.07-21-73746f28.cust.bredbandsbolaget.se. [213.112.54.133]) by mx.google.com with ESMTPSA id bs3sm6305751lbd.37.2015.01.14.14.49.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Jan 2015 14:49:15 -0800 (PST) From: Anders Roxell To: lng-odp@lists.linaro.org Date: Wed, 14 Jan 2015 23:48:22 +0100 Message-Id: <1421275706-11176-6-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 5/9] api: cpumask: add odp_cpumask_first 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.217.172 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 To get the first element in order to be able to traverse a mask. Signed-off-by: Robbie King Signed-off-by: Anders Roxell --- platform/linux-generic/include/api/odp_cpumask.h | 7 +++++++ platform/linux-generic/odp_cpumask.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/platform/linux-generic/include/api/odp_cpumask.h b/platform/linux-generic/include/api/odp_cpumask.h index 0090f9a..cccbb62 100644 --- a/platform/linux-generic/include/api/odp_cpumask.h +++ b/platform/linux-generic/include/api/odp_cpumask.h @@ -132,6 +132,13 @@ int odp_cpumask_equal(const odp_cpumask_t *mask1, void odp_cpumask_copy(odp_cpumask_t *dest, const odp_cpumask_t *src); /** + * Find first bit set in mask + * + * @return cpu else -1 if no bits set in cpumask + */ +int odp_cpumask_first(const odp_cpumask_t *mask); + +/** * @} */ diff --git a/platform/linux-generic/odp_cpumask.c b/platform/linux-generic/odp_cpumask.c index 6be7f1e..a3bb176 100644 --- a/platform/linux-generic/odp_cpumask.c +++ b/platform/linux-generic/odp_cpumask.c @@ -175,3 +175,13 @@ void odp_cpumask_copy(odp_cpumask_t *dest, const odp_cpumask_t *src) { memcpy(&dest->set, &src->set, sizeof(src->set)); } + +int odp_cpumask_first(const odp_cpumask_t *mask) +{ + int cpu; + + for (cpu = 0; cpu < CPU_SETSIZE; cpu++) + if (odp_cpumask_isset(mask, cpu)) + return cpu; + return -1; +}