All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Vesely <jan.vesely-kgbqMDwikbSVc3sceRu5cw@public.gmane.org>
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.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	[thread overview]
Message-ID: <20180518170007.2847-2-jan.vesely@rutgers.edu> (raw)
In-Reply-To: <20180518170007.2847-1-jan.vesely-kgbqMDwikbSVc3sceRu5cw@public.gmane.org>

Analogous to the mesa commit of the same name.
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
---
 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_ */
-- 
2.17.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-05-18 17:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-18 17:00 [PATCH libdrm v2 1/3] amdgpu: Take lock before removing devices from fd_tab hash table Jan Vesely
     [not found] ` <20180518170007.2847-1-jan.vesely-kgbqMDwikbSVc3sceRu5cw@public.gmane.org>
2018-05-18 17:00   ` Jan Vesely [this message]
2018-05-18 17:00   ` [PATCH libdrm 3/3] amdgpu: Destroy fd_hash table when the last device is removed Jan Vesely
     [not found]     ` <20180518170007.2847-3-jan.vesely-kgbqMDwikbSVc3sceRu5cw@public.gmane.org>
2018-05-24 17:04       ` Jan Vesely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180518170007.2847-2-jan.vesely@rutgers.edu \
    --to=jan.vesely-kgbqmdwikbsvc3sceru5cw@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.