rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] rust: helpers: Add list helpers for C linked list operations
@ 2025-11-11 17:13 Joel Fernandes
  2025-11-11 17:13 ` [PATCH v2 2/3] rust: clist: Add basic list infrastructure and head iterator Joel Fernandes
                   ` (3 more replies)
  0 siblings, 4 replies; 34+ messages in thread
From: Joel Fernandes @ 2025-11-11 17:13 UTC (permalink / raw)
  To: linux-kernel, rust-for-linux, dri-devel, dakr, airlied
  Cc: acourbot, apopple, ojeda, alex.gaynor, boqun.feng, gary,
	bjorn3_gh, lossin, a.hindborg, aliceryhl, tmgross, simona,
	maarten.lankhorst, mripard, tzimmermann, jhubbard, joelagnelf,
	ttabi, joel, elle, daniel.almeida, arighi, phasta, nouveau

Add Rust helper functions for common C linked list operations
that are implemented as macros or inline functions and thus not
directly accessible from Rust.

Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
---
 rust/helpers/helpers.c |  1 +
 rust/helpers/list.c    | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)
 create mode 100644 rust/helpers/list.c

diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
index 79c72762ad9c..634fa2386bbb 100644
--- a/rust/helpers/helpers.c
+++ b/rust/helpers/helpers.c
@@ -32,6 +32,7 @@
 #include "io.c"
 #include "jump_label.c"
 #include "kunit.c"
+#include "list.c"
 #include "maple_tree.c"
 #include "mm.c"
 #include "mutex.c"
diff --git a/rust/helpers/list.c b/rust/helpers/list.c
new file mode 100644
index 000000000000..fea2a18621da
--- /dev/null
+++ b/rust/helpers/list.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Helpers for C Circular doubly linked list implementation.
+ */
+
+#include <linux/list.h>
+
+bool rust_helper_list_empty(const struct list_head *head)
+{
+	return list_empty(head);
+}
+
+void rust_helper_list_del(struct list_head *entry)
+{
+	list_del(entry);
+}
+
+void rust_helper_INIT_LIST_HEAD(struct list_head *list)
+{
+	INIT_LIST_HEAD(list);
+}
+
+void rust_helper_list_add(struct list_head *new, struct list_head *head)
+{
+	list_add(new, head);
+}
+
+void rust_helper_list_add_tail(struct list_head *new, struct list_head *head)
+{
+	list_add_tail(new, head);
+}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2025-12-03  3:30 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-11 17:13 [PATCH v2 1/3] rust: helpers: Add list helpers for C linked list operations Joel Fernandes
2025-11-11 17:13 ` [PATCH v2 2/3] rust: clist: Add basic list infrastructure and head iterator Joel Fernandes
2025-11-24  3:47   ` Alexandre Courbot
2025-11-25 23:03     ` Joel Fernandes
2025-11-25 23:06     ` Joel Fernandes
2025-11-28 18:39   ` Daniel Almeida
2025-11-11 17:13 ` [PATCH v2 3/3] rust: clist: Add typed iteration with FromListHead trait Joel Fernandes
2025-11-24  7:01   ` Alexandre Courbot
2025-11-25 23:29     ` Joel Fernandes
2025-11-26  1:03       ` Alexandre Courbot
2025-11-26 20:14         ` Joel Fernandes
2025-11-27  3:43           ` Alexandre Courbot
2025-11-27  5:08             ` Joel Fernandes
2025-11-11 17:13 ` [PATCH v2 0/3] rust: Introduce support for C linked list interfacing Joel Fernandes
2025-11-11 19:54   ` Miguel Ojeda
2025-11-11 21:52     ` Joel Fernandes
2025-11-25 14:52 ` [PATCH v2 1/3] rust: helpers: Add list helpers for C linked list operations Alexandre Courbot
2025-11-25 18:16   ` Joel Fernandes
2025-11-25 19:48     ` John Hubbard
2025-11-25 22:52       ` Joel Fernandes
2025-11-26  1:16     ` Alexandre Courbot
2025-11-26  1:39       ` John Hubbard
2025-11-26 10:06         ` Miguel Ojeda
2025-11-26 18:15           ` John Hubbard
2025-11-26 18:50       ` Joel Fernandes
2025-11-26 20:57         ` John Hubbard
2025-11-27  5:10           ` Joel Fernandes
2025-11-27 13:46             ` Alexandre Courbot
2025-11-28 21:49               ` Joel Fernandes
2025-11-29 22:44                 ` John Hubbard
2025-11-30  1:04                   ` Joel Fernandes
2025-11-28 18:20           ` Daniel Almeida
2025-11-28 18:17       ` Daniel Almeida
2025-12-03  3:30         ` Alexandre Courbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).