public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] add list_del_head function
@ 2004-11-20 15:56 Tobias DiPasquale
  2004-11-22  9:20 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias DiPasquale @ 2004-11-20 15:56 UTC (permalink / raw)
  To: linux-kernel, akpm

[-- Attachment #1: Type: text/plain, Size: 648 bytes --]

Hi all,

I was working with some queues the other day and I noticed that there
was a list_add_tail() function in list.h, but no list_del_head()
function. This struck me as a little odd, so I went ahead and
implemented one in order to complete full queue functionality. The
patch below was generated against pristine 2.6.9 kernel.org kernel
sources and is attached to this email.

Please CC me on any replies, as I'm not subscribed to LKML. Thanks :)

Name: Add list_del_head for full queue functionality
Status: Tested
Signed-off-by: Tobias DiPasquale <codeslinger@gmail.com>

-- 
[ Tobias DiPasquale ]
0x636f6465736c696e67657240676d61696c2e636f6d

[-- Attachment #2: list_del_head.patch --]
[-- Type: application/octet-stream, Size: 921 bytes --]

diff -Nrup linux-2.6.9/include/linux/list.h linux/include/linux/list.h
--- linux-2.6.9/include/linux/list.h	2004-10-18 21:54:31.000000000 +0000
+++ linux/include/linux/list.h	2004-11-20 18:55:12.373654048 +0000
@@ -166,6 +166,21 @@ static inline void list_del(struct list_
 }
 
 /**
+ * list_del_head - deletes first entry from list.
+ * @entry: return parameter; will contain former head of list on return.
+ * @head: head of list from which to delete.
+ *
+ * This function is useful for implementing queues. Caller must ensure
+ * the list is not empty before calling this function. On return, entry
+ * will point to the former head of the list.
+ */
+static inline void list_del_head(struct list_head **entry, struct list_head *head)
+{
+	*entry = head->next;
+	list_del(head->next);
+}
+
+/**
  * list_del_rcu - deletes entry from list without re-initialization
  * @entry: the element to delete from the list.
  *

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

end of thread, other threads:[~2004-11-22 16:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-20 15:56 [PATCH] add list_del_head function Tobias DiPasquale
2004-11-22  9:20 ` Jens Axboe
2004-11-22 16:18   ` Tobias DiPasquale

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox