Re: [PATCH 2/2] Remove the CIRCLEQ API

2020-10-11 Thread Paul Goyette

On Sun, 11 Oct 2020, Kamil Rytarowski wrote:


It was marked deprecated in NetBSD 7 and already removed from
FreeBSD in 2000 and OpenBSD in 2015.
---
share/man/man3/queue.3 |  10 +++
sys/sys/queue.h| 196 -
2 files changed, 10 insertions(+), 196 deletions(-)

diff --git a/share/man/man3/queue.3 b/share/man/man3/queue.3
index 4293090986d4..359c772e5439 100644
--- a/share/man/man3/queue.3
+++ b/share/man/man3/queue.3
@@ -1091,3 +1091,13 @@ and
.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.


Please reword this slightly.  Instead of

 and  and 

use

, , and .



diff --git a/sys/sys/queue.h b/sys/sys/queue.h
index 5764c7a98a53..ec686364126b 100644
--- a/sys/sys/queue.h
+++ b/sys/sys/queue.h
@@ -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 {  
\
((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__); \
-   }

[PATCH 2/2] Remove the CIRCLEQ API

2020-10-11 Thread Kamil Rytarowski
It was marked deprecated in NetBSD 7 and already removed from
FreeBSD in 2000 and OpenBSD in 2015.
---
 share/man/man3/queue.3 |  10 +++
 sys/sys/queue.h| 196 -
 2 files changed, 10 insertions(+), 196 deletions(-)

diff --git a/share/man/man3/queue.3 b/share/man/man3/queue.3
index 4293090986d4..359c772e5439 100644
--- a/share/man/man3/queue.3
+++ b/share/man/man3/queue.3
@@ -1091,3 +1091,13 @@ and
 .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 --git a/sys/sys/queue.h b/sys/sys/queue.h
index 5764c7a98a53..ec686364126b 100644
--- a/sys/sys/queue.h
+++ b/sys/sys/queue.h
@@ -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 {  
\
((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; \
-