freebsd-dev/sys/netinet/ipfw/test/mylist.h
Luigi Rizzo 8018e843a3 MFC of a large number of ipfw and dummynet fixes and enhancements
done in CURRENT over the last 4 months.
HEAD and RELENG_8 are almost in sync now for ipfw, dummynet
the pfil hooks and related components.

Among the most noticeable changes:
- r200855 more efficient lookup of skipto rules, and remove O(N)
  blocks from critical sections in the kernel;
- r204591 large restructuring of the dummynet module, with support
  for multiple scheduling algorithms (4 available so far)
See the original commit logs for details.

Changes in the kernel/userland ABI should be harmless because the
kernel is able to understand previous requests from RELENG_8 and
RELENG_7. For this reason, this changeset would be applicable
to RELENG_7 as well, but i am not sure if it is worthwhile.
2010-03-23 09:58:59 +00:00

50 lines
1.0 KiB
C

/*
* $FreeBSD$
*
* linux-like bidirectional lists
*/
#ifndef _MYLIST_H
#define _MYLIST_H
struct list_head {
struct list_head *prev, *next;
};
#define INIT_LIST_HEAD(l) do { (l)->prev = (l)->next = (l); } while (0)
#define list_empty(l) ( (l)->next == l )
static inline void
__list_add(struct list_head *o, struct list_head *prev,
struct list_head *next)
{
next->prev = o;
o->next = next;
o->prev = prev;
prev->next = o;
}
static inline void
list_add_tail(struct list_head *o, struct list_head *head)
{
__list_add(o, head->prev, head);
}
#define list_first_entry(pL, ty, member) \
(ty *)((char *)((pL)->next) - offsetof(ty, member))
static inline void
__list_del(struct list_head *prev, struct list_head *next)
{
next->prev = prev;
prev->next = next;
}
static inline void
list_del(struct list_head *entry)
{
ND("called on %p", entry);
__list_del(entry->prev, entry->next);
entry->next = entry->prev = NULL;
}
#endif /* _MYLIST_H */