Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys Remove the CIRCLEQ API from queue(3)



details:   https://anonhg.NetBSD.org/src/rev/5ed96a68442f
branches:  trunk
changeset: 941429:5ed96a68442f
user:      kamil <kamil%NetBSD.org@localhost>
date:      Tue Oct 20 23:27:57 2020 +0000

description:
Remove the CIRCLEQ API from queue(3)

It was marked deprecated in NetBSD 7 and already removed from
FreeBSD in 2000 and OpenBSD in 2015.

Proposed on tech-kern@.

diffstat:

 share/man/man3/queue.3 |   12 ++-
 sys/sys/queue.h        |  198 +------------------------------------------------
 2 files changed, 12 insertions(+), 198 deletions(-)

diffs (240 lines):

diff -r c6e7f3839b62 -r 5ed96a68442f share/man/man3/queue.3
--- a/share/man/man3/queue.3    Tue Oct 20 23:15:23 2020 +0000
+++ b/share/man/man3/queue.3    Tue Oct 20 23:27:57 2020 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: queue.3,v 1.60 2018/06/18 02:48:56 eadler Exp $
+.\"    $NetBSD: queue.3,v 1.61 2020/10/20 23:27:57 kamil Exp $
 .\"
 .\" Copyright (c) 2000, 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -1091,3 +1091,13 @@
 .Nm STAILQ
 functions first appeared in
 .Fx 2.1.5 .
+.Pp
+The
+.Nm CIRCLEQ
+functions first appeared in
+.Bx 4.4
+and were deprecated in
+.Nx 7
+and removed in
+.Nx 10
+due to the pointer aliasing violations.
diff -r c6e7f3839b62 -r 5ed96a68442f sys/sys/queue.h
--- a/sys/sys/queue.h   Tue Oct 20 23:15:23 2020 +0000
+++ b/sys/sys/queue.h   Tue Oct 20 23:27:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: queue.h,v 1.74 2019/03/23 12:01:18 maxv Exp $  */
+/*     $NetBSD: queue.h,v 1.75 2020/10/20 23:27:58 kamil Exp $ */
 
 /*
  * Copyright (c) 1991, 1993
@@ -69,14 +69,6 @@
  * after an existing element, at the head of the list, or at the end of
  * the list. A tail queue may be traversed in either direction.
  *
- * A circle queue is headed by a pair of pointers, one to the head of the
- * list and the other to the tail of the list. The elements are doubly
- * linked so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before or after
- * an existing element, at the head of the list, or at the end of the list.
- * A circle queue may be traversed in either direction, but has a more
- * complex end of list detection.
- *
  * For details on the use of these macros, see the queue(3) manual page.
  */
 
@@ -663,192 +655,4 @@
                ((struct type *)(void *)                                \
                ((char *)((head)->stqh_last) - offsetof(struct type, field))))
 
-
-#ifndef _KERNEL
-/*
- * Circular queue definitions. Do not use. We still keep the macros
- * for compatibility but because of pointer aliasing issues their use
- * is discouraged!
- */
-
-/*
- * __launder_type():  We use this ugly hack to work around the compiler
- * noticing that two types may not alias each other and elide tests in code.
- * We hit this in the CIRCLEQ macros when comparing 'struct name *' and
- * 'struct type *' (see CIRCLEQ_HEAD()).  Modern compilers (such as GCC
- * 4.8) declare these comparisons as always false, causing the code to
- * not run as designed.
- *
- * This hack is only to be used for comparisons and thus can be fully const.
- * Do not use for assignment.
- *
- * If we ever choose to change the ABI of the CIRCLEQ macros, we could fix
- * this by changing the head/tail sentinal values, but see the note above
- * this one.
- */
-static __inline const void * __launder_type(const void *);
-static __inline const void *
-__launder_type(const void *__x)
-{
-       __asm __volatile("" : "+r" (__x));
-       return __x;
-}
-
-#if defined(QUEUEDEBUG)
-#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field)                           \
-       if ((head)->cqh_first != CIRCLEQ_ENDC(head) &&                  \
-           (head)->cqh_first->field.cqe_prev != CIRCLEQ_ENDC(head))    \
-               QUEUEDEBUG_ABORT("CIRCLEQ head forw %p %s:%d", (head),  \
-                     __FILE__, __LINE__);                              \
-       if ((head)->cqh_last != CIRCLEQ_ENDC(head) &&                   \
-           (head)->cqh_last->field.cqe_next != CIRCLEQ_ENDC(head))     \
-               QUEUEDEBUG_ABORT("CIRCLEQ head back %p %s:%d", (head),  \
-                     __FILE__, __LINE__);
-#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field)                       \
-       if ((elm)->field.cqe_next == CIRCLEQ_ENDC(head)) {              \
-               if ((head)->cqh_last != (elm))                          \
-                       QUEUEDEBUG_ABORT("CIRCLEQ elm last %p %s:%d",   \
-                           (elm), __FILE__, __LINE__);                 \
-       } else {                                                        \
-               if ((elm)->field.cqe_next->field.cqe_prev != (elm))     \
-                       QUEUEDEBUG_ABORT("CIRCLEQ elm forw %p %s:%d",   \
-                           (elm), __FILE__, __LINE__);                 \
-       }                                                               \
-       if ((elm)->field.cqe_prev == CIRCLEQ_ENDC(head)) {              \
-               if ((head)->cqh_first != (elm))                         \
-                       QUEUEDEBUG_ABORT("CIRCLEQ elm first %p %s:%d",  \
-                           (elm), __FILE__, __LINE__);                 \
-       } else {                                                        \
-               if ((elm)->field.cqe_prev->field.cqe_next != (elm))     \
-                       QUEUEDEBUG_ABORT("CIRCLEQ elm prev %p %s:%d",   \
-                           (elm), __FILE__, __LINE__);                 \
-       }
-#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field)                      \
-       (elm)->field.cqe_next = (void *)1L;                             \
-       (elm)->field.cqe_prev = (void *)1L;
-#else
-#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field)
-#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field)
-#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field)
-#endif
-
-#define        CIRCLEQ_HEAD(name, type)                                        \
-struct name {                                                          \
-       struct type *cqh_first;         /* first element */             \
-       struct type *cqh_last;          /* last element */              \
-}
-
-#define        CIRCLEQ_HEAD_INITIALIZER(head)                                  \
-       { CIRCLEQ_END(&head), CIRCLEQ_END(&head) }
-
-#define        CIRCLEQ_ENTRY(type)                                             \
-struct {                                                               \
-       struct type *cqe_next;          /* next element */              \
-       struct type *cqe_prev;          /* previous element */          \
-}
-
-/*
- * Circular queue functions.
- */
-#define        CIRCLEQ_INIT(head) do {                                         \
-       (head)->cqh_first = CIRCLEQ_END(head);                          \
-       (head)->cqh_last = CIRCLEQ_END(head);                           \
-} while (/*CONSTCOND*/0)
-
-#define        CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {            \
-       QUEUEDEBUG_CIRCLEQ_HEAD((head), field)                          \
-       QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field)                \
-       (elm)->field.cqe_next = (listelm)->field.cqe_next;              \
-       (elm)->field.cqe_prev = (listelm);                              \
-       if ((listelm)->field.cqe_next == CIRCLEQ_ENDC(head))            \
-               (head)->cqh_last = (elm);                               \
-       else                                                            \
-               (listelm)->field.cqe_next->field.cqe_prev = (elm);      \
-       (listelm)->field.cqe_next = (elm);                              \
-} while (/*CONSTCOND*/0)
-
-#define        CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {           \
-       QUEUEDEBUG_CIRCLEQ_HEAD((head), field)                          \
-       QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field)                \
-       (elm)->field.cqe_next = (listelm);                              \
-       (elm)->field.cqe_prev = (listelm)->field.cqe_prev;              \
-       if ((listelm)->field.cqe_prev == CIRCLEQ_ENDC(head))            \
-               (head)->cqh_first = (elm);                              \
-       else                                                            \
-               (listelm)->field.cqe_prev->field.cqe_next = (elm);      \
-       (listelm)->field.cqe_prev = (elm);                              \
-} while (/*CONSTCOND*/0)
-
-#define        CIRCLEQ_INSERT_HEAD(head, elm, field) do {                      \
-       QUEUEDEBUG_CIRCLEQ_HEAD((head), field)                          \
-       (elm)->field.cqe_next = (head)->cqh_first;                      \
-       (elm)->field.cqe_prev = CIRCLEQ_END(head);                      \
-       if ((head)->cqh_last == CIRCLEQ_ENDC(head))                     \
-               (head)->cqh_last = (elm);                               \
-       else                                                            \
-               (head)->cqh_first->field.cqe_prev = (elm);              \
-       (head)->cqh_first = (elm);                                      \
-} while (/*CONSTCOND*/0)
-
-#define        CIRCLEQ_INSERT_TAIL(head, elm, field) do {                      \
-       QUEUEDEBUG_CIRCLEQ_HEAD((head), field)                          \
-       (elm)->field.cqe_next = CIRCLEQ_END(head);                      \
-       (elm)->field.cqe_prev = (head)->cqh_last;                       \
-       if ((head)->cqh_first == CIRCLEQ_ENDC(head))                    \
-               (head)->cqh_first = (elm);                              \
-       else                                                            \
-               (head)->cqh_last->field.cqe_next = (elm);               \
-       (head)->cqh_last = (elm);                                       \
-} while (/*CONSTCOND*/0)
-
-#define        CIRCLEQ_REMOVE(head, elm, field) do {                           \
-       QUEUEDEBUG_CIRCLEQ_HEAD((head), field)                          \
-       QUEUEDEBUG_CIRCLEQ_ELM((head), (elm), field)                    \
-       if ((elm)->field.cqe_next == CIRCLEQ_ENDC(head))                \
-               (head)->cqh_last = (elm)->field.cqe_prev;               \
-       else                                                            \
-               (elm)->field.cqe_next->field.cqe_prev =                 \
-                   (elm)->field.cqe_prev;                              \
-       if ((elm)->field.cqe_prev == CIRCLEQ_ENDC(head))                \
-               (head)->cqh_first = (elm)->field.cqe_next;              \
-       else                                                            \
-               (elm)->field.cqe_prev->field.cqe_next =                 \
-                   (elm)->field.cqe_next;                              \
-       QUEUEDEBUG_CIRCLEQ_POSTREMOVE((elm), field)                     \
-} while (/*CONSTCOND*/0)
-
-#define        CIRCLEQ_FOREACH(var, head, field)                               \
-       for ((var) = ((head)->cqh_first);                               \
-               (var) != CIRCLEQ_ENDC(head);                            \
-               (var) = ((var)->field.cqe_next))
-
-#define        CIRCLEQ_FOREACH_REVERSE(var, head, field)                       \
-       for ((var) = ((head)->cqh_last);                                \
-               (var) != CIRCLEQ_ENDC(head);                            \
-               (var) = ((var)->field.cqe_prev))
-
-/*
- * Circular queue access methods.
- */
-#define        CIRCLEQ_FIRST(head)             ((head)->cqh_first)
-#define        CIRCLEQ_LAST(head)              ((head)->cqh_last)
-/* For comparisons */
-#define        CIRCLEQ_ENDC(head)              (__launder_type(head))
-/* For assignments */
-#define        CIRCLEQ_END(head)               ((void *)(head))
-#define        CIRCLEQ_NEXT(elm, field)        ((elm)->field.cqe_next)
-#define        CIRCLEQ_PREV(elm, field)        ((elm)->field.cqe_prev)
-#define        CIRCLEQ_EMPTY(head)                                             \
-    (CIRCLEQ_FIRST(head) == CIRCLEQ_ENDC(head))
-
-#define CIRCLEQ_LOOP_NEXT(head, elm, field)                            \
-       (((elm)->field.cqe_next == CIRCLEQ_ENDC(head))                  \
-           ? ((head)->cqh_first)                                       \
-           : (elm->field.cqe_next))
-#define CIRCLEQ_LOOP_PREV(head, elm, field)                            \
-       (((elm)->field.cqe_prev == CIRCLEQ_ENDC(head))                  \
-           ? ((head)->cqh_last)                                        \
-           : (elm->field.cqe_prev))
-#endif /* !_KERNEL */
-
 #endif /* !_SYS_QUEUE_H_ */



Home | Main Index | Thread Index | Old Index