From patchwork Fri May 18 17:00:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Vesely X-Patchwork-Id: 10411561 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 6303A601F9 for ; Fri, 18 May 2018 17:00:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5360528A00 for ; Fri, 18 May 2018 17:00:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4875F28A10; Fri, 18 May 2018 17:00:19 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0688928A00 for ; Fri, 18 May 2018 17:00:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 16DF96EE81; Fri, 18 May 2018 17:00:17 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x22b.google.com (mail-qk0-x22b.google.com [IPv6:2607:f8b0:400d:c09::22b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 367B26EE7A for ; Fri, 18 May 2018 17:00:12 +0000 (UTC) Received: by mail-qk0-x22b.google.com with SMTP id b22-v6so6957265qkj.9 for ; Fri, 18 May 2018 10:00:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scarletmail-rutgers-edu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=n4RT7wFoKT3oSZ8N4Q0h45Z7aL3XIuT5yGzDjkmj3Tg=; b=13a0hcuEUYK3ugg+CiQO3nTsjURB2HikEP3/kxXwYOZD6HYHfqPvjaCc81pOLikRtX AnSuWV9EHzFSuvMyAiysMvHFKPbukWxQUDeSEN3ZT8zjs63tHD7/k2aXuXI52JEW0afa 2pGTb4gS7og/40IUKvexxkRSBFqzCDMUWKrTT0YQx2IIMzRQ4pnXmvsnRzaa13Ky94v1 tE2tdSEh9Q/MafMxMJFmynt/B9uFSv67zeCtv/QXnet3W1RGe1HS6ZuvBXdrK4XBikrp axndHonXNiGQDfTKoxJWa1mgw5SDkvs/XQ6nCfBrb0Dl2UEL2gnqf7YrEhsaUWmkCl61 4uPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=n4RT7wFoKT3oSZ8N4Q0h45Z7aL3XIuT5yGzDjkmj3Tg=; b=BDOGkEAtcClrjCrEU2hjiBIXZY7nLMuzbvG400XFWvYv2YAJpCUJ+s1FsxmxCuyATD Sar87oA8M/N3cyAZxEJDd6OfYYYLnSTwk995ScTe5LaZScm7xhLNLbJUHr4JAHeAW+am Ff5GfK2Dah6e9yF4I0R58iRKfR5GepRpTfUHzJv1Bh4/rZQcAJCAyS0C3i4r1gbstAjh I9yNxqsBGfmbdsz8q7Gm3yGxPSr67Tjpb2lPEfwdxnxFqNxd+YTo864joTWXV4ocQ1r2 zi3is+BAA/BgxAMY9y2oVHgxslzgINE2r250PaE/M2O7/TqsE3rJb70Rne7DwsTTlnu/ M/TQ== X-Gm-Message-State: ALKqPwf6bf/k0L0GTS6Bf0NYpzHEtA/caUh99MU/6UuOjtMgSX76B/Vw UUGqvmbMdjn7o2dlDUCHryy6bplQ5lQ= X-Google-Smtp-Source: AB8JxZqE7U2lFhwDCKAUIzUmVwphuI0euDoHVT/mzRzdJ+pZDIcgQA0OxrAwVmp+m12c5kYvgr2Ckg== X-Received: by 2002:a37:9f84:: with SMTP id i126-v6mr6360826qke.171.1526662811186; Fri, 18 May 2018 10:00:11 -0700 (PDT) Received: from adriatix.rutgers.edu (pool-128-6-37-254.nat.rutgers.edu. [128.6.37.254]) by smtp.gmail.com with ESMTPSA id b27-v6sm5969152qtc.66.2018.05.18.10.00.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 May 2018 10:00:10 -0700 (PDT) From: Jan Vesely To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH libdrm 2/3] amdgpu/util_hash_table: Add helper function to count the number of entries in hash table Date: Fri, 18 May 2018 13:00:06 -0400 Message-Id: <20180518170007.2847-2-jan.vesely@rutgers.edu> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180518170007.2847-1-jan.vesely@rutgers.edu> References: <20180518170007.2847-1-jan.vesely@rutgers.edu> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Analogous to the mesa commit of the same name. Signed-off-by: Jan Vesely --- amdgpu/util_hash_table.c | 12 ++++++++++++ amdgpu/util_hash_table.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/amdgpu/util_hash_table.c b/amdgpu/util_hash_table.c index 89a8bf9b..e06d4415 100644 --- a/amdgpu/util_hash_table.c +++ b/amdgpu/util_hash_table.c @@ -237,6 +237,18 @@ drm_private void util_hash_table_foreach(struct util_hash_table *ht, } } +static void util_hash_table_inc(void *k, void *v, void *d) +{ + ++*(size_t *)d; +} + +drm_private size_t util_hash_table_count(struct util_hash_table *ht) +{ + size_t count = 0; + util_hash_table_foreach(ht, util_hash_table_inc, &count); + return count; +} + drm_private void util_hash_table_destroy(struct util_hash_table *ht) { struct util_hash_iter iter; diff --git a/amdgpu/util_hash_table.h b/amdgpu/util_hash_table.h index 5e295a81..3ab81a12 100644 --- a/amdgpu/util_hash_table.h +++ b/amdgpu/util_hash_table.h @@ -64,6 +64,8 @@ drm_private void util_hash_table_foreach(struct util_hash_table *ht, void (*callback)(void *key, void *value, void *data), void *data); +drm_private size_t util_hash_table_count(struct util_hash_table *ht); + drm_private void util_hash_table_destroy(struct util_hash_table *ht); #endif /* U_HASH_TABLE_H_ */