printf("done\n\n");
}
-#define TAILQ_SWAP(first, second, head, field) do { \
- *((first)->field.tqe_prev) = (second); \
- (second)->field.tqe_prev = (first)->field.tqe_prev; \
- (first)->field.tqe_prev = &((second)->field.tqe_next); \
- (first)->field.tqe_next = (second)->field.tqe_next; \
- if ((second)->field.tqe_next) \
- (second)->field.tqe_next->field.tqe_prev = &((first)->field.tqe_next); \
- (second)->field.tqe_next = first; \
- if ((head)->tqh_last == &((second)->field.tqe_next)) \
- (head)->tqh_last = &((first)->field.tqe_next); \
-} while (0)
+#define TAILQ_SWAP(first, second, head, field) \
+ do { \
+ *((first)->field.tqe_prev) = (second); \
+ (second)->field.tqe_prev = (first)->field.tqe_prev; \
+ (first)->field.tqe_prev = &((second)->field.tqe_next); \
+ (first)->field.tqe_next = (second)->field.tqe_next; \
+ if ((second)->field.tqe_next) \
+ (second)->field.tqe_next->field.tqe_prev = &((first)->field.tqe_next); \
+ (second)->field.tqe_next = first; \
+ if ((head)->tqh_last == &((second)->field.tqe_next)) \
+ (head)->tqh_last = &((first)->field.tqe_next); \
+ } while (0)
void _TAILQ_SWAP(struct obj *first, struct obj *second, struct objhead *head) {
struct obj **tqe_prev = first->entry.tqe_prev;
if (head->tqh_last == &(second->entry.tqe_next))
head->tqh_last = &(first->entry.tqe_next);
-
}
int main() {
struct obj fourth;
fourth.abc = 999;
-
struct obj fifth;
fifth.abc = 5555;
dump();
-
/*
* ************************************************
*/
dump();
-
/*
* ************************************************
*/
dump();
-
/*
* ************************************************
*/
TAILQ_REMOVE(&head, &second, entry);
dump();
-
}