This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH] Use latest FreeBSD version of <sys/queue.h>
- From: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- To: newlib at sourceware dot org
- Date: Thu, 11 Apr 2013 14:17:54 +0200
- Subject: Re: [PATCH] Use latest FreeBSD version of <sys/queue.h>
- References: <1365682360-27257-1-git-send-email-sebastian dot huber at embedded-brains dot de>
Here is the difference to of the latest FreeBSD <sys/queue.h> to the updated
one in Newlib. The insque() and remque() are used by the RTEMS network stack.
The STAILQ_REMOVE_HEAD_UNTIL() was removed from FreeBSD in 2006.
--- queue.h 2013-04-11 14:14:20.470697371 +0200
+++ newlib/libc/include/sys/queue.h 2013-04-11 11:44:22.339719647 +0200
@@ -320,6 +320,11 @@
(head)->stqh_last = &STAILQ_FIRST((head)); \
} while (0)
+#define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do { \
+ if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL) \
+ (head)->stqh_last = &STAILQ_FIRST((head)); \
+} while (0)
+
#define STAILQ_SWAP(head1, head2, type) do { \
struct type *swap_first = STAILQ_FIRST(head1); \
struct type **swap_last = (head1)->stqh_last; \
@@ -638,4 +643,49 @@
(head2)->tqh_last = &(head2)->tqh_first; \
} while (0)
+#ifdef _KERNEL
+
+/*
+ * XXX insque() and remque() are an old way of handling certain queues.
+ * They bogusly assumes that all queue heads look alike.
+ */
+
+struct quehead {
+ struct quehead *qh_link;
+ struct quehead *qh_rlink;
+};
+
+#ifdef __GNUC__
+
+static __inline void
+insque(void *a, void *b)
+{
+ struct quehead *element = (struct quehead *)a,
+ *head = (struct quehead *)b;
+
+ element->qh_link = head->qh_link;
+ element->qh_rlink = head;
+ head->qh_link = element;
+ element->qh_link->qh_rlink = element;
+}
+
+static __inline void
+remque(void *a)
+{
+ struct quehead *element = (struct quehead *)a;
+
+ element->qh_link->qh_rlink = element->qh_rlink;
+ element->qh_rlink->qh_link = element->qh_link;
+ element->qh_rlink = 0;
+}
+
+#else /* !__GNUC__ */
+
+void insque(void *a, void *b);
+void remque(void *a);
+
+#endif /* __GNUC__ */
+
+#endif /* _KERNEL */
+
#endif /* !_SYS_QUEUE_H_ */
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.