From: Corinna Vinschen <vinschen@redhat.com>
To: newlib@sourceware.org
Subject: Re: [PATCH 1/8] Add new FOREACH_FROM variants of the queue(3) FOREACH macros which can optionally start the traversal from a previously found element by passing the element in as "var". Passing a NULL "var" retains the same semantics as the regular FOREACH macros.
Date: Tue, 04 Apr 2017 09:53:00 -0000 [thread overview]
Message-ID: <20170404095333.GB2961@calimero.vinschen.de> (raw)
In-Reply-To: <1491294889-9721-1-git-send-email-sebastian.huber@embedded-brains.de>
[-- Attachment #1: Type: text/plain, Size: 5530 bytes --]
Hi Sebastian,
would you mind to resend the patches 1, 2, 4, 5, with subject length
restricted to +/- 72 chars? There was only one such patch in your
previous patchset, so I fixed that myself.
Thanks,
Corinna
On Apr 4 10:34, Sebastian Huber wrote:
> From: lstewart <lstewart@FreeBSD.org>
>
> Kudos to phk for suggesting the "FROM" suffix instead of my original proposal.
>
> Reviewed by: jhb (previous version), rpaulo
> MFC after: 1 week
> ---
> newlib/libc/include/sys/queue.h | 53 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 53 insertions(+)
>
> diff --git a/newlib/libc/include/sys/queue.h b/newlib/libc/include/sys/queue.h
> index 4bc7dac..7a5bc79 100644
> --- a/newlib/libc/include/sys/queue.h
> +++ b/newlib/libc/include/sys/queue.h
> @@ -88,9 +88,13 @@
> * _PREV - + - +
> * _LAST - - + +
> * _FOREACH + + + +
> + * _FOREACH_FROM + + + +
> * _FOREACH_SAFE + + + +
> + * _FOREACH_FROM_SAFE + + + +
> * _FOREACH_REVERSE - - - +
> + * _FOREACH_REVERSE_FROM - - - +
> * _FOREACH_REVERSE_SAFE - - - +
> + * _FOREACH_REVERSE_FROM_SAFE - - - +
> * _INSERT_HEAD + + + +
> * _INSERT_BEFORE - + - +
> * _INSERT_AFTER + + + +
> @@ -167,11 +171,21 @@ struct { \
> (var); \
> (var) = SLIST_NEXT((var), field))
>
> +#define SLIST_FOREACH_FROM(var, head, field) \
> + for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \
> + (var); \
> + (var) = SLIST_NEXT((var), field))
> +
> #define SLIST_FOREACH_SAFE(var, head, field, tvar) \
> for ((var) = SLIST_FIRST((head)); \
> (var) && ((tvar) = SLIST_NEXT((var), field), 1); \
> (var) = (tvar))
>
> +#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
> + for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \
> + (var) && ((tvar) = SLIST_NEXT((var), field), 1); \
> + (var) = (tvar))
> +
> #define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
> for ((varp) = &SLIST_FIRST((head)); \
> ((var) = *(varp)) != NULL; \
> @@ -259,12 +273,21 @@ struct { \
> (var); \
> (var) = STAILQ_NEXT((var), field))
>
> +#define STAILQ_FOREACH_FROM(var, head, field) \
> + for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \
> + (var); \
> + (var) = STAILQ_NEXT((var), field))
>
> #define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
> for ((var) = STAILQ_FIRST((head)); \
> (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
> (var) = (tvar))
>
> +#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
> + for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \
> + (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
> + (var) = (tvar))
> +
> #define STAILQ_INIT(head) do { \
> STAILQ_FIRST((head)) = NULL; \
> (head)->stqh_last = &STAILQ_FIRST((head)); \
> @@ -394,11 +417,21 @@ struct { \
> (var); \
> (var) = LIST_NEXT((var), field))
>
> +#define LIST_FOREACH_FROM(var, head, field) \
> + for ((var) = ((var) ? (var) : LIST_FIRST((head))); \
> + (var); \
> + (var) = LIST_NEXT((var), field))
> +
> #define LIST_FOREACH_SAFE(var, head, field, tvar) \
> for ((var) = LIST_FIRST((head)); \
> (var) && ((tvar) = LIST_NEXT((var), field), 1); \
> (var) = (tvar))
>
> +#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
> + for ((var) = ((var) ? (var) : LIST_FIRST((head))); \
> + (var) && ((tvar) = LIST_NEXT((var), field), 1); \
> + (var) = (tvar))
> +
> #define LIST_INIT(head) do { \
> LIST_FIRST((head)) = NULL; \
> } while (0)
> @@ -531,21 +564,41 @@ struct { \
> (var); \
> (var) = TAILQ_NEXT((var), field))
>
> +#define TAILQ_FOREACH_FROM(var, head, field) \
> + for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \
> + (var); \
> + (var) = TAILQ_NEXT((var), field))
> +
> #define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
> for ((var) = TAILQ_FIRST((head)); \
> (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
> (var) = (tvar))
>
> +#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
> + for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \
> + (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
> + (var) = (tvar))
> +
> #define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
> for ((var) = TAILQ_LAST((head), headname); \
> (var); \
> (var) = TAILQ_PREV((var), headname, field))
>
> +#define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \
> + for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
> + (var); \
> + (var) = TAILQ_PREV((var), headname, field))
> +
> #define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
> for ((var) = TAILQ_LAST((head), headname); \
> (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
> (var) = (tvar))
>
> +#define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar) \
> + for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
> + (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
> + (var) = (tvar))
> +
> #define TAILQ_INIT(head) do { \
> TAILQ_FIRST((head)) = NULL; \
> (head)->tqh_last = &TAILQ_FIRST((head)); \
> --
> 1.8.4.5
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2017-04-04 9:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-04 8:35 Sebastian Huber
2017-04-04 8:35 ` [PATCH 8/8] Renumber copyright clause 4 Sebastian Huber
2017-04-04 8:35 ` [PATCH 6/8] queue(3): Enhance queue debugging macros Sebastian Huber
2017-04-04 8:35 ` [PATCH 4/8] Make the system queue header file fully usable within C++ programs by adding macros to define class lists Sebastian Huber
2017-04-04 8:35 ` [PATCH 7/8] queue.3: Document existing QMD_* macros Sebastian Huber
2017-04-04 8:35 ` [PATCH 5/8] Add two new macros, SLIST_CONCAT and LIST_CONCAT. Note in both the queue.h header file and in the queue.3 manual page that they are O(n) so should be used only in low-usage paths with short lists (otherwise an STAILQ or TAILQ should be used) Sebastian Huber
2017-04-04 8:35 ` [PATCH 2/8] Fix order of arguments in the TRACEBUF_INITIALIZER macro so that we can define QUEUE_MACRO_DEBUG to debug list problems Sebastian Huber
2017-04-04 8:35 ` [PATCH 3/8] Pass macro arguments properly Sebastian Huber
2017-04-04 9:53 ` Corinna Vinschen [this message]
2017-04-04 9:56 ` [PATCH 1/8] Add new FOREACH_FROM variants of the queue(3) FOREACH macros which can optionally start the traversal from a previously found element by passing the element in as "var". Passing a NULL "var" retains the same semantics as the regular FOREACH macros Sebastian Huber
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=20170404095333.GB2961@calimero.vinschen.de \
--to=vinschen@redhat.com \
--cc=newlib@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).