From patchwork Wed Jan 14 22:48:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 43135 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9E048240B9 for ; Wed, 14 Jan 2015 22:49:47 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id u14sf6247983lbd.3 for ; Wed, 14 Jan 2015 14:49:46 -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=cs0BQEqiJt3Yv1cOwhHtv5yRp0dL0pa3JFooNtkM5do=; b=fpTG/z3XhgnJJl43IU3zODGU/yYS90z6sKx5KgSocta153ycyFGldGlhIc7afrwlVZ zy7hMVETPnM4S0Mg9EFwIMESP40JugL26YaOiGV/HoEoMGa6kuOo20sux5iMmW4bMsB3 AcQ4GgtqGAh8efcXeD0lEYIFjIZ7Ge1kiPGPTVLAy75Of1XxA4XAsDKVQueacTF0Whvi Y5o2T/L1ZOalA+gaVBcZ5hwbbACP24jdX9hFzav0vypxckY2JfXVIZhbSolLBiiBTYBC OJluH0ItPyjWrCAczG6wZrhaZCzlywfhGtWyaz+ets7vPxy3T2VNUJbNEPaR0eC9vaJ8 Tirw== X-Gm-Message-State: ALoCoQnxzcAH9DsajbW2GXP0J1aOjZMJyvqTnvT5UYE7ICbp//8TLjgJneUgEAZ09Hn1fkElxzgi X-Received: by 10.112.64.197 with SMTP id q5mr837246lbs.4.1421275786583; Wed, 14 Jan 2015 14:49:46 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.207.33 with SMTP id lt1ls174284lac.64.gmail; Wed, 14 Jan 2015 14:49:46 -0800 (PST) X-Received: by 10.152.197.5 with SMTP id iq5mr6607595lac.6.1421275786438; Wed, 14 Jan 2015 14:49:46 -0800 (PST) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id ld9si28558916lbc.77.2015.01.14.14.49.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 Jan 2015 14:49:46 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id w7so10520572lbi.2 for ; Wed, 14 Jan 2015 14:49:46 -0800 (PST) X-Received: by 10.152.234.35 with SMTP id ub3mr6597119lac.70.1421275786357; Wed, 14 Jan 2015 14:49:46 -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 c8csp1845642lbb; Wed, 14 Jan 2015 14:49:45 -0800 (PST) X-Received: by 10.224.137.65 with SMTP id v1mr11096570qat.95.1421275785047; Wed, 14 Jan 2015 14:49:45 -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 g10si3056559qab.25.2015.01.14.14.49.44 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 14 Jan 2015 14:49:45 -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 1YBWkw-0000Ir-8H; Wed, 14 Jan 2015 22:49:42 +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 1YBWkc-0000BJ-IH for lng-odp@lists.linaro.org; Wed, 14 Jan 2015 22:49:22 +0000 Received: by mail-la0-f50.google.com with SMTP id pn19so10717886lab.9 for ; Wed, 14 Jan 2015 14:49:17 -0800 (PST) X-Received: by 10.112.235.67 with SMTP id uk3mr6565101lbc.48.1421275756946; Wed, 14 Jan 2015 14:49:16 -0800 (PST) Received: from localhost (c-853670d5.07-21-73746f28.cust.bredbandsbolaget.se. [213.112.54.133]) by mx.google.com with ESMTPSA id lh6sm2157348lab.49.2015.01.14.14.49.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Jan 2015 14:49:16 -0800 (PST) From: Anders Roxell To: lng-odp@lists.linaro.org Date: Wed, 14 Jan 2015 23:48:23 +0100 Message-Id: <1421275706-11176-7-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 6/9] api: cpumask: add odp_cpumask_last 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.171 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 last element in order to find the highest CPU in the 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 | 22 +++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/platform/linux-generic/include/api/odp_cpumask.h b/platform/linux-generic/include/api/odp_cpumask.h index cccbb62..a81bca7 100644 --- a/platform/linux-generic/include/api/odp_cpumask.h +++ b/platform/linux-generic/include/api/odp_cpumask.h @@ -139,6 +139,13 @@ void odp_cpumask_copy(odp_cpumask_t *dest, const odp_cpumask_t *src); int odp_cpumask_first(const odp_cpumask_t *mask); /** + * Find last bit set in mask + * + * @return cpu else -1 if no bits set in cpumask + */ +int odp_cpumask_last(const odp_cpumask_t *mask); + +/** * @} */ diff --git a/platform/linux-generic/odp_cpumask.c b/platform/linux-generic/odp_cpumask.c index a3bb176..3930264 100644 --- a/platform/linux-generic/odp_cpumask.c +++ b/platform/linux-generic/odp_cpumask.c @@ -60,20 +60,10 @@ void odp_cpumask_from_str(odp_cpumask_t *mask, const char *str_in) memcpy(&mask->set, &cpuset, sizeof(cpuset)); } -static int _odp_cpumask_last(const odp_cpumask_t *mask) -{ - int cpu; - - for (cpu = CPU_SETSIZE - 1; cpu >= 0; cpu--) - if (odp_cpumask_isset(mask, cpu)) - return cpu; - return -1; -} - void odp_cpumask_to_str(const odp_cpumask_t *mask, char *str, int len) { char *p = str; - int cpu = _odp_cpumask_last(mask); + int cpu = odp_cpumask_last(mask); int nibbles; int value; @@ -185,3 +175,13 @@ int odp_cpumask_first(const odp_cpumask_t *mask) return cpu; return -1; } + +int odp_cpumask_last(const odp_cpumask_t *mask) +{ + int cpu; + + for (cpu = CPU_SETSIZE - 1; cpu >= 0; cpu--) + if (odp_cpumask_isset(mask, cpu)) + return cpu; + return -1; +}