This also removes build warnings of redefined macros
since it uses the embracing "#ifndef _DLINKLIST_H ... #endif".
Michael
/* To use these macros you must have a structure containing a next and
prev pointer */
/* To use these macros you must have a structure containing a next and
prev pointer */
+#ifndef _DLINKLIST_H
+#define _DLINKLIST_H
+
/* hook into the front of the list */
#define DLIST_ADD(list, p) \
/* hook into the front of the list */
#define DLIST_ADD(list, p) \
} while (0)
/* remove an element from a list - element doesn't have to be in list. */
} while (0)
/* remove an element from a list - element doesn't have to be in list. */
#define DLIST_REMOVE(list, p) \
do { \
if ((p) == (list)) { \
#define DLIST_REMOVE(list, p) \
do { \
if ((p) == (list)) { \
} \
if ((p) && ((p) != (list))) (p)->next = (p)->prev = NULL; \
} while (0)
} \
if ((p) && ((p) != (list))) (p)->next = (p)->prev = NULL; \
} while (0)
/* promote an element to the top of the list */
#define DLIST_PROMOTE(list, p) \
/* promote an element to the top of the list */
#define DLIST_PROMOTE(list, p) \
DLIST_ADD(list, p); \
} while (0)
DLIST_ADD(list, p); \
} while (0)
-/* hook into the end of the list - needs a tmp pointer */
+/* hook into the end of the list - needs the entry type */
#define DLIST_ADD_END(list, p, type) \
do { \
if (!(list)) { \
#define DLIST_ADD_END(list, p, type) \
do { \
if (!(list)) { \
-/* demote an element to the end of the list, needs a tmp pointer */
-#define DLIST_DEMOTE(list, p, tmp) \
+/* demote an element to the end of the list, needs the entry type */
+#define DLIST_DEMOTE(list, p, type) \
do { \
DLIST_REMOVE(list, p); \
do { \
DLIST_REMOVE(list, p); \
- DLIST_ADD_END(list, p, tmp); \
+ DLIST_ADD_END(list, p, type); \
} while (0)
/* concatenate two lists - putting all elements of the 2nd list at the
} while (0)
/* concatenate two lists - putting all elements of the 2nd list at the
+
+#endif /* _DLINKLIST_H */