public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tobias DiPasquale <codeslinger@gmail.com>
To: linux-kernel@vger.kernel.org, akpm@digeo.com
Subject: [PATCH] add list_del_head function
Date: Sat, 20 Nov 2004 10:56:32 -0500	[thread overview]
Message-ID: <876ef97a04112007562d6797e@mail.gmail.com> (raw)

[-- 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.
  *

             reply	other threads:[~2004-11-20 15:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-20 15:56 Tobias DiPasquale [this message]
2004-11-22  9:20 ` [PATCH] add list_del_head function Jens Axboe
2004-11-22 16:18   ` Tobias DiPasquale

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=876ef97a04112007562d6797e@mail.gmail.com \
    --to=codeslinger@gmail.com \
    --cc=akpm@digeo.com \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox