aboutsummaryrefslogtreecommitdiff
path: root/lib.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-12-02 17:59:20 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:05:26 -0700
commit5aad28f0caa770be2b69717dba765763c6c3f7b2 (patch)
treeb87975ccb27ed97f2a60e64e96fdd60a81f2762f /lib.h
parentAllow anybody to declare their own allocator by making the (diff)
downloadsparse-5aad28f0caa770be2b69717dba765763c6c3f7b2.tar.gz
sparse-5aad28f0caa770be2b69717dba765763c6c3f7b2.tar.bz2
sparse-5aad28f0caa770be2b69717dba765763c6c3f7b2.zip
Add INSERT_CURRENT() macro to insert a new entry at the
point we are now when traversing a list. NOTE! If you traverse it forwards, the next entry you'll see is the current entry, since we do not change where in the list we are!
Diffstat (limited to 'lib.h')
-rw-r--r--lib.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib.h b/lib.h
index b6fe35e..5493980 100644
--- a/lib.h
+++ b/lib.h
@@ -358,6 +358,33 @@ static inline void add_expression(struct expression_list **list, struct expressi
#define THIS_ADDRESS(ptr) \
DO_THIS_ADDRESS(ptr, __head##ptr, __list##ptr, __nr##ptr)
+extern void split_ptr_list_head(struct ptr_list *);
+
+#define DO_SPLIT(ptr, __head, __list, __nr) do { \
+ split_ptr_list_head(__list); \
+ if (__nr >= __list->nr) { \
+ __nr -= __list->nr; \
+ __list = __list->next; \
+ }; \
+} while (0)
+
+#define DO_INSERT_CURRENT(new, ptr, __head, __list, __nr) do { \
+ void **__this, **__last; \
+ if (__list->nr == LIST_NODE_NR) \
+ DO_SPLIT(ptr, __head, __list, __nr); \
+ __this = __list->list + __nr; \
+ __last = __list->list + __list->nr - 1; \
+ while (__last >= __this) { \
+ __last[1] = __last[0]; \
+ __last--; \
+ } \
+ *__this = (new); \
+ __list->nr++; \
+} while (0)
+
+#define INSERT_CURRENT(new, ptr) \
+ DO_INSERT_CURRENT(new, ptr, __head##ptr, __list##ptr, __nr##ptr)
+
#define DO_DELETE_CURRENT(ptr, __head, __list, __nr) do { \
void **__this = __list->list + __nr; \
void **__last = __list->list + __list->nr - 1; \