linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Christopher Li <sparse@chrisli.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 14/34] ptrlist: CUR_ENTRY/CUR_ENTRY_NOTAG
Date: Fri,  7 Jul 2017 15:39:42 +0200	[thread overview]
Message-ID: <20170707134002.49500-15-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170707134002.49500-1-luc.vanoostenryck@gmail.com>

---
 ptrlist.h | 44 +++++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/ptrlist.h b/ptrlist.h
index 91019e7c5..7c8fefe42 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -87,6 +87,8 @@ static inline void *ptr_cur_entry(const struct ptr_cur *cur)
 #define __PTR_STRIP_TAG(ptr)	(void *)(~3UL & (unsigned long)(ptr))
 #define __PTR_KEEP_TAG(ptr)	(ptr)
 #define PTR_ENTRY(h,i)		__PTR_STRIP_TAG(PTR_ENTRY_NOTAG(h,i))
+#define CUR_ENTRY_NOTAG(cur)	ptr_cur_entry(cur)
+#define CUR_ENTRY(cur)		__PTR_STRIP_TAG(CUR_ENTRY_NOTAG(cur))
 
 
 static inline void *first_ptr_list(struct ptr_list *list)
@@ -121,18 +123,18 @@ static inline void ptr_cur_init(struct ptr_cur *cur, struct ptr_list *head)
 #define DO_INIT(cur, head)	\
 	ptr_cur_init(&cur, (struct ptr_list *) head)
 
-#define DO_PREPARE(head, ptr, __cur, PTR_ENTRY)						\
+#define DO_PREPARE(head, ptr, __cur, CUR_ENTRY)						\
 	do {										\
 		struct ptr_cur __cur;							\
 		CHECK_TYPE(head,ptr);							\
 		DO_INIT(__cur, head);							\
-		if (__cur.h) ptr = PTR_ENTRY(__cur.h, 0);				\
+		if (__cur.h) ptr = CUR_ENTRY(&__cur);					\
 		else ptr = NULL
 
-#define DO_NEXT(ptr, __cur, PTR_ENTRY)							\
+#define DO_NEXT(ptr, __cur, CUR_ENTRY)							\
 		if (ptr) {								\
 			if (++__cur.n < __cur.l->nr) {					\
-				ptr = PTR_ENTRY(__cur.l,__cur.n);			\
+				ptr = CUR_ENTRY(&__cur);				\
 			} else {							\
 				ptr = NULL;						\
 				do							\
@@ -140,16 +142,16 @@ static inline void ptr_cur_init(struct ptr_cur *cur, struct ptr_list *head)
 				while (__cur.l->nr == 0 && __cur.l != __cur.h);		\
 				if (__cur.l != __cur.h) {				\
 					__cur.n = 0;					\
-					ptr = PTR_ENTRY(__cur.l,0);			\
+					ptr = CUR_ENTRY(&__cur);				\
 				}							\
 			}								\
 		}
 
-#define DO_RESET(ptr, __cur, PTR_ENTRY)						\
+#define DO_RESET(ptr, __cur, CUR_ENTRY)						\
 	do {										\
 		__cur.n = 0;								\
 		__cur.l = __cur.h;							\
-		if (__cur.h) ptr = PTR_ENTRY(__cur.h, 0);				\
+		if (__cur.h) ptr = CUR_ENTRY(&__cur);					\
 	} while (0)
 
 #define DO_FINISH(ptr, __cur)								\
@@ -157,32 +159,32 @@ static inline void ptr_cur_init(struct ptr_cur *cur, struct ptr_list *head)
 	} while (0)
 
 #define PREPARE_PTR_LIST(head, ptr) \
-	DO_PREPARE(head, ptr, __cur##ptr, PTR_ENTRY)
+	DO_PREPARE(head, ptr, __cur##ptr, CUR_ENTRY)
 
 #define NEXT_PTR_LIST(ptr) \
-	DO_NEXT(ptr, __cur##ptr, PTR_ENTRY)
+	DO_NEXT(ptr, __cur##ptr, CUR_ENTRY)
 
 #define RESET_PTR_LIST(ptr) \
-	DO_RESET(ptr, __cur##ptr, PTR_ENTRY)
+	DO_RESET(ptr, __cur##ptr, CUR_ENTRY)
 
 #define FINISH_PTR_LIST(ptr) \
 	DO_FINISH(ptr, __cur##ptr)
 
-#define DO_FOR_EACH(head, ptr, __cur, PTR_ENTRY) do {					\
+#define DO_FOR_EACH(head, ptr, __cur, CUR_ENTRY) do {					\
 	struct ptr_cur __cur;								\
 	CHECK_TYPE(head,ptr);								\
 	DO_INIT(__cur, head);								\
 	if (!__cur.h) break;								\
 	do {										\
 		for (__cur.n = 0; __cur.n < __cur.l->nr; __cur.n++) {			\
-			ptr = PTR_ENTRY(__cur.l,__cur.n);				\
+			ptr = CUR_ENTRY(&__cur);					\
 
 #define DO_END_FOR_EACH(ptr, __cur)							\
 		}									\
 	} while ((__cur.l = __cur.l->next) != __cur.h);					\
 } while (0)
 
-#define DO_FOR_EACH_REVERSE(head, ptr, __cur, PTR_ENTRY) do {				\
+#define DO_FOR_EACH_REVERSE(head, ptr, __cur, CUR_ENTRY) do {				\
 	struct ptr_cur __cur;								\
 	CHECK_TYPE(head,ptr);								\
 	DO_INIT(__cur, head);								\
@@ -191,7 +193,7 @@ static inline void ptr_cur_init(struct ptr_cur *cur, struct ptr_list *head)
 		__cur.l = __cur.l->prev;						\
 		__cur.n = __cur.l->nr;							\
 		while (--__cur.n >= 0) {						\
-			ptr = PTR_ENTRY(__cur.l,__cur.n);				\
+			ptr = CUR_ENTRY(&__cur);					\
 
 
 #define DO_END_FOR_EACH_REVERSE(ptr, __cur)						\
@@ -199,7 +201,7 @@ static inline void ptr_cur_init(struct ptr_cur *cur, struct ptr_list *head)
 	} while (__cur.l != __cur.h);							\
 } while (0)
 
-#define DO_REVERSE(ptr, __cur, new, __newcur, PTR_ENTRY) do {				\
+#define DO_REVERSE(ptr, __cur, new, __newcur, CUR_ENTRY) do {				\
 	struct ptr_cur __newcur = __cur;						\
 	new = ptr;									\
 	goto __inside##new;								\
@@ -208,34 +210,34 @@ static inline void ptr_cur_init(struct ptr_cur *cur, struct ptr_list *head)
 		__newcur.n = __newcur.l->nr;						\
 	__inside##new:									\
 		while (--__newcur.n >= 0) {						\
-			new = PTR_ENTRY(__newcur.l,__newcur.n);				\
+			new = CUR_ENTRY(&__newcur);					\
 
 #define RECURSE_PTR_REVERSE(ptr, new)							\
 	DO_REVERSE(ptr, __cur##ptr,							\
-		   new, __cur##new, PTR_ENTRY)
+		   new, __cur##new, CUR_ENTRY)
 
 #define DO_THIS_ADDRESS(ptr, __cur)							\
 	((__typeof__(&(ptr))) (__cur.l->list + __cur.n))
 
 #define FOR_EACH_PTR(head, ptr) \
-	DO_FOR_EACH(head, ptr, __cur##ptr, PTR_ENTRY)
+	DO_FOR_EACH(head, ptr, __cur##ptr, CUR_ENTRY)
 
 #define END_FOR_EACH_PTR(ptr) \
 	DO_END_FOR_EACH(ptr, __cur##ptr)
 
 #define FOR_EACH_PTR_NOTAG(head, ptr) \
-	DO_FOR_EACH(head, ptr, __cur##ptr, PTR_ENTRY_NOTAG)
+	DO_FOR_EACH(head, ptr, __cur##ptr, CUR_ENTRY_NOTAG)
 
 #define END_FOR_EACH_PTR_NOTAG(ptr) END_FOR_EACH_PTR(ptr)
 
 #define FOR_EACH_PTR_REVERSE(head, ptr) \
-	DO_FOR_EACH_REVERSE(head, ptr, __cur##ptr, PTR_ENTRY)
+	DO_FOR_EACH_REVERSE(head, ptr, __cur##ptr, CUR_ENTRY)
 
 #define END_FOR_EACH_PTR_REVERSE(ptr) \
 	DO_END_FOR_EACH_REVERSE(ptr, __cur##ptr)
 
 #define FOR_EACH_PTR_REVERSE_NOTAG(head, ptr) \
-	DO_FOR_EACH_REVERSE(head, ptr, __cur##ptr, PTR_ENTRY_NOTAG)
+	DO_FOR_EACH_REVERSE(head, ptr, __cur##ptr, CUR_ENTRY_NOTAG)
 
 #define END_FOR_EACH_PTR_REVERSE_NOTAG(ptr) END_FOR_EACH_PTR_REVERSE(ptr)
 
-- 
2.13.0


  parent reply	other threads:[~2017-07-07 13:40 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-07 13:39 [RFC 00/34] ptrlist rework with iterator Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 01/34] ptrlist: simplify DO_FOR_EACH/DO_END_FOR_EACH Luc Van Oostenryck
2017-07-08 15:31   ` Christopher Li
2017-07-07 13:39 ` [PATCH 02/34] ptrlist: simplify DO_FOR_EACH_REVERSE/ Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 03/34] ptrlist: simplify DO_NEXT link walking Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 04/34] ptrlist: add helper __PTR_STRIP_TAG() Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 05/34] ptrlist: introduce the ptr_list iterator structure Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 06/34] ptrlist: add ptr_cur_entry() to get iterator's current entry Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 07/34] ptrlist: add forward iterator Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 08/34] ptrlist: let first_ptr_list() use the iterator API Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 09/34] ptrlist: add backward iterator Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 10/34] ptrlist: let lastst_ptr_list() use the iterator API Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 11/34] ptrlist: mechanically replace head-list-nr triplets by an iterator struct Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 12/34] ptrlist: simplify initialization of DO_REVERSE()'s cursor Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 13/34] ptrlist: abstract away iterator initialization Luc Van Oostenryck
2017-07-07 13:39 ` Luc Van Oostenryck [this message]
2017-07-07 13:39 ` [PATCH 15/34] ptrlist: use iterator API for PREPARE/NEXT_PTR_LIST() Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 16/34] ptrlist: use iterator API for RESET_PTR_LIST() Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 17/34] ptrlist: use iterator for FOR_EACH_PTR() Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 18/34] ptrlist: use iterator for FOR_EACH_PTR_REVERSE() Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 19/34] ptrlist: remove unneeded DO_INIT() Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 20/34] ptrlist: use the iterator API for DO_INSERT_CURRENT() Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 21/34] ptrlist: extract ptr_cur_insert from ptrlist.h Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 22/34] ptrlist: simplify ptr_cur_insert() Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 23/34] ptrlist: use the iterator API for DO_DELETE_CURRENT() Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 24/34] ptrlist: extract prt_cur_delete() from ptrlist.h Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 25/34] ptrlist: let delete_ptr_list() use the iterator API Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 26/34] ptrlist: let replace_ptr_list_entry() " Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 27/34] ptrlist: let concat_ptr_list() " Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 28/34] ptrlist: let undo_ptr_list_last() " Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 29/34] ptrlist: let delete_ptr_list_last() " Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 30/34] ptrlist: simplify common case for __add_ptr_list() Luc Van Oostenryck
2017-07-07 13:39 ` [PATCH 31/34] ptrlist: explicitely tagged Luc Van Oostenryck
2017-07-07 13:40 ` [PATCH 32/34] ptrlist: tag/notag common case Luc Van Oostenryck
2017-07-07 13:40 ` [PATCH 33/34] ptrlist: drop the now unneeded _NOTAG versions Luc Van Oostenryck
2017-07-07 13:40 ` [PATCH 34/34] ptrlist: addr vs entry Luc Van Oostenryck
2017-07-07 13:51 ` [RFC 00/34] ptrlist rework with iterator Luc Van Oostenryck
2017-07-08 15:13 ` Christopher Li
2017-07-09  6:50   ` Luc Van Oostenryck
2017-07-09  8:25     ` Christopher Li
2017-07-09  9:52       ` Luc Van Oostenryck
2017-07-09 10:34         ` Dibyendu Majumdar

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=20170707134002.49500-15-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.org \
    --cc=torvalds@linux-foundation.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 NNTP newsgroup(s).