diff options
author | ed <ed@FreeBSD.org> | 2009-05-27 19:28:04 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-05-27 19:28:04 +0000 |
commit | 3779b68747cdae9d6e156307aae1ecb97b52d4ea (patch) | |
tree | 6d3ce9791e7680277093a1a296bcbea3aaeb6040 | |
parent | 9fc2aafa8283c2dc1af8bfbfd1d727b16c0837d2 (diff) | |
download | FreeBSD-src-3779b68747cdae9d6e156307aae1ecb97b52d4ea.zip FreeBSD-src-3779b68747cdae9d6e156307aae1ecb97b52d4ea.tar.gz |
Rename the queue macros I introduced last year.
Last year I added SLIST_REMOVE_NEXT and STAILQ_REMOVE_NEXT, to remove
entries behind an element in the list, using O(1) time. I recently
discovered NetBSD also has a similar macro, called SLIST_REMOVE_AFTER.
In my opinion this approach is a lot better:
- It doesn't have the unused first argument of the list pointer. I added
this, mainly because OpenBSD also had it.
- The _AFTER suffix makes a lot more sense, because it is related to
SLIST_INSERT_AFTER. _NEXT is only used to iterate through the list.
The reason why I want to rename this now, is to make sure we don't
release a major version with the badly named macros.
-rw-r--r-- | ObsoleteFiles.inc | 3 | ||||
-rw-r--r-- | lib/libc/gen/popen.c | 2 | ||||
-rw-r--r-- | share/man/man3/Makefile | 4 | ||||
-rw-r--r-- | share/man/man3/queue.3 | 40 | ||||
-rw-r--r-- | sys/sys/queue.h | 10 |
5 files changed, 31 insertions, 28 deletions
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index dfa8e79..197f4a0 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -14,6 +14,9 @@ # The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last. # +# 20090527: renaming of S{LIST,TAILQ}_REMOVE_NEXT() to _REMOVE_AFTER() +OLD_FILES+=usr/share/man/man3/SLIST_REMOVE_NEXT.3.gz +OLD_FILES+=usr/share/man/man3/STAILQ_REMOVE_NEXT.3.gz # 20090527: removal of legacy USB stack OLD_FILES+=usr/include/legacy/dev/usb/dsbr100io.h OLD_FILES+=usr/include/legacy/dev/usb/ehcireg.h diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c index f3450b5..b123234 100644 --- a/lib/libc/gen/popen.c +++ b/lib/libc/gen/popen.c @@ -191,7 +191,7 @@ pclose(iop) if (last == NULL) SLIST_REMOVE_HEAD(&pidlist, next); else - SLIST_REMOVE_NEXT(&pidlist, last, next); + SLIST_REMOVE_AFTER(last, next); THREAD_UNLOCK(); (void)fclose(iop); diff --git a/share/man/man3/Makefile b/share/man/man3/Makefile index 13c5e14..d93a689 100644 --- a/share/man/man3/Makefile +++ b/share/man/man3/Makefile @@ -65,8 +65,8 @@ MLINKS+= queue.3 LIST_EMPTY.3 \ queue.3 SLIST_INSERT_HEAD.3 \ queue.3 SLIST_NEXT.3 \ queue.3 SLIST_REMOVE.3 \ + queue.3 SLIST_REMOVE_AFTER.3 \ queue.3 SLIST_REMOVE_HEAD.3 \ - queue.3 SLIST_REMOVE_NEXT.3 \ queue.3 STAILQ_CONCAT.3 \ queue.3 STAILQ_EMPTY.3 \ queue.3 STAILQ_ENTRY.3 \ @@ -82,8 +82,8 @@ MLINKS+= queue.3 LIST_EMPTY.3 \ queue.3 STAILQ_LAST.3 \ queue.3 STAILQ_NEXT.3 \ queue.3 STAILQ_REMOVE.3 \ + queue.3 STAILQ_REMOVE_AFTER.3 \ queue.3 STAILQ_REMOVE_HEAD.3 \ - queue.3 STAILQ_REMOVE_NEXT.3 \ queue.3 TAILQ_CONCAT.3 \ queue.3 TAILQ_EMPTY.3 \ queue.3 TAILQ_ENTRY.3 \ diff --git a/share/man/man3/queue.3 b/share/man/man3/queue.3 index 372c4ad..763ae42 100644 --- a/share/man/man3/queue.3 +++ b/share/man/man3/queue.3 @@ -47,8 +47,8 @@ .Nm SLIST_INSERT_AFTER , .Nm SLIST_INSERT_HEAD , .Nm SLIST_NEXT , +.Nm SLIST_REMOVE_AFTER , .Nm SLIST_REMOVE_HEAD , -.Nm SLIST_REMOVE_NEXT , .Nm SLIST_REMOVE , .Nm STAILQ_CONCAT , .Nm STAILQ_EMPTY , @@ -64,8 +64,8 @@ .Nm STAILQ_INSERT_TAIL , .Nm STAILQ_LAST , .Nm STAILQ_NEXT , +.Nm STAILQ_REMOVE_AFTER , .Nm STAILQ_REMOVE_HEAD , -.Nm STAILQ_REMOVE_NEXT , .Nm STAILQ_REMOVE , .Nm LIST_EMPTY , .Nm LIST_ENTRY , @@ -115,8 +115,8 @@ lists and tail queues .Fn SLIST_INSERT_AFTER "TYPE *listelm" "TYPE *elm" "SLIST_ENTRY NAME" .Fn SLIST_INSERT_HEAD "SLIST_HEAD *head" "TYPE *elm" "SLIST_ENTRY NAME" .Fn SLIST_NEXT "TYPE *elm" "SLIST_ENTRY NAME" +.Fn SLIST_REMOVE_AFTER "TYPE *elm" "SLIST_ENTRY NAME" .Fn SLIST_REMOVE_HEAD "SLIST_HEAD *head" "SLIST_ENTRY NAME" -.Fn SLIST_REMOVE_NEXT "SLIST_HEAD *head" "TYPE *elm" "SLIST_ENTRY NAME" .Fn SLIST_REMOVE "SLIST_HEAD *head" "TYPE *elm" "TYPE" "SLIST_ENTRY NAME" .\" .Fn STAILQ_CONCAT "STAILQ_HEAD *head1" "STAILQ_HEAD *head2" @@ -133,8 +133,8 @@ lists and tail queues .Fn STAILQ_INSERT_TAIL "STAILQ_HEAD *head" "TYPE *elm" "STAILQ_ENTRY NAME" .Fn STAILQ_LAST "STAILQ_HEAD *head" "TYPE" "STAILQ_ENTRY NAME" .Fn STAILQ_NEXT "TYPE *elm" "STAILQ_ENTRY NAME" +.Fn STAILQ_REMOVE_AFTER "STAILQ_HEAD *head" "TYPE *elm" "STAILQ_ENTRY NAME" .Fn STAILQ_REMOVE_HEAD "STAILQ_HEAD *head" "STAILQ_ENTRY NAME" -.Fn STAILQ_REMOVE_NEXT "STAILQ_HEAD *head" "TYPE *elm" "STAILQ_ENTRY NAME" .Fn STAILQ_REMOVE "STAILQ_HEAD *head" "TYPE *elm" "TYPE" "STAILQ_ENTRY NAME" .\" .Fn LIST_EMPTY "LIST_HEAD *head" @@ -380,6 +380,14 @@ The macro returns the next element in the list. .Pp The macro +.Nm SLIST_REMOVE_AFTER +removes the element after +.Fa elm +from the list. Unlike +.Fa SLIST_REMOVE , +this macro does not traverse the entire list. +.Pp +The macro .Nm SLIST_REMOVE_HEAD removes the element .Fa elm @@ -391,14 +399,6 @@ this macro instead of the generic macro. .Pp The macro -.Nm SLIST_REMOVE_NEXT -removes the element after -.Fa elm -from the list. Unlike -.Fa SLIST_REMOVE , -this macro does not traverse the entire list. -.Pp -The macro .Nm SLIST_REMOVE removes the element .Fa elm @@ -564,6 +564,14 @@ The macro returns the next item on the tail queue, or NULL this item is the last. .Pp The macro +.Nm STAILQ_REMOVE_AFTER +removes the element after +.Fa elm +from the tail queue. Unlike +.Fa STAILQ_REMOVE , +this macro does not traverse the entire tail queue. +.Pp +The macro .Nm STAILQ_REMOVE_HEAD removes the element at the head of the tail queue. For optimum efficiency, @@ -573,14 +581,6 @@ use this macro explicitly rather than the generic macro. .Pp The macro -.Nm STAILQ_REMOVE_NEXT -removes the element after -.Fa elm -from the tail queue. Unlike -.Fa STAILQ_REMOVE , -this macro does not traverse the entire tail queue. -.Pp -The macro .Nm STAILQ_REMOVE removes the element .Fa elm diff --git a/sys/sys/queue.h b/sys/sys/queue.h index d9f339a..f1f35c8 100644 --- a/sys/sys/queue.h +++ b/sys/sys/queue.h @@ -96,8 +96,8 @@ * _INSERT_AFTER + + + + * _INSERT_TAIL - - + + * _CONCAT - - + + + * _REMOVE_AFTER + - + - * _REMOVE_HEAD + - + - - * _REMOVE_NEXT + - + - * _REMOVE + + + + * */ @@ -196,12 +196,12 @@ struct { \ struct type *curelm = SLIST_FIRST((head)); \ while (SLIST_NEXT(curelm, field) != (elm)) \ curelm = SLIST_NEXT(curelm, field); \ - SLIST_REMOVE_NEXT(head, curelm, field); \ + SLIST_REMOVE_AFTER(curelm, field); \ } \ TRASHIT((elm)->field.sle_next); \ } while (0) -#define SLIST_REMOVE_NEXT(head, elm, field) do { \ +#define SLIST_REMOVE_AFTER(elm, field) do { \ SLIST_NEXT(elm, field) = \ SLIST_NEXT(SLIST_NEXT(elm, field), field); \ } while (0) @@ -292,7 +292,7 @@ struct { \ struct type *curelm = STAILQ_FIRST((head)); \ while (STAILQ_NEXT(curelm, field) != (elm)) \ curelm = STAILQ_NEXT(curelm, field); \ - STAILQ_REMOVE_NEXT(head, curelm, field); \ + STAILQ_REMOVE_AFTER(head, curelm, field); \ } \ TRASHIT((elm)->field.stqe_next); \ } while (0) @@ -303,7 +303,7 @@ struct { \ (head)->stqh_last = &STAILQ_FIRST((head)); \ } while (0) -#define STAILQ_REMOVE_NEXT(head, elm, field) do { \ +#define STAILQ_REMOVE_AFTER(head, elm, field) do { \ if ((STAILQ_NEXT(elm, field) = \ STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \ (head)->stqh_last = &STAILQ_NEXT((elm), field); \ |